%% in format string = literal %
This commit is contained in:
parent
e40fe775f1
commit
3fa001636d
@ -408,7 +408,7 @@ Settings =
|
||||
time: ->
|
||||
@nextElementSibling.textContent = Time.format @value, new Date()
|
||||
backlink: ->
|
||||
@nextElementSibling.textContent = @value.replace /%id/, '123456789'
|
||||
@nextElementSibling.textContent = @value.replace /%(?:id|%)/g, (x) -> {'%id': '123456789', '%%': '%'}[x]
|
||||
fileInfo: ->
|
||||
data =
|
||||
isReply: true
|
||||
|
||||
@ -47,6 +47,7 @@
|
||||
<div>Hour: <code>%k</code>, <code>%H</code>, <code>%l</code>, <code>%I</code>, <code>%p</code>, <code>%P</code></div>
|
||||
<div>Minute: <code>%M</code></div>
|
||||
<div>Second: <code>%S</code></div>
|
||||
<div>Literal <code>%</code>: <code>%%</code></div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
@ -62,6 +63,7 @@
|
||||
<div>Spoiler indicator: <code>%p</code></div>
|
||||
<div>Size: <code>%B</code> (Bytes), <code>%K</code> (KB), <code>%M</code> (MB), <code>%s</code> (4chan default)</div>
|
||||
<div>Resolution: <code>%r</code> (Displays 'PDF' for PDF files)</div>
|
||||
<div>Literal <code>%</code>: <code>%%</code></div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
|
||||
@ -7,5 +7,6 @@
|
||||
<li><code>%MD5</code>: MD5 hash.</li>
|
||||
<li><code>%name</code>: Original file name.</li>
|
||||
<li><code>%board</code>: Current board.</li>
|
||||
<li><code>%%</code>: Literal <code>%</code>.</li>
|
||||
</ul>
|
||||
<textarea name=sauces class=field spellcheck=false></textarea>
|
||||
|
||||
@ -19,17 +19,19 @@ Sauce =
|
||||
link = link.replace /;text:.+$/, ''
|
||||
parts = [link, text]
|
||||
for i in [0..1]
|
||||
parts[i] = parts[i].replace /%(T?URL|MD5|board|name)/g, (parameter) ->
|
||||
if type = {
|
||||
parts[i] = parts[i].replace /%(T?URL|MD5|board|name|%)/g, (parameter) ->
|
||||
type = {
|
||||
'%TURL': post.file.thumbURL
|
||||
'%URL': post.file.URL
|
||||
'%MD5': post.file.MD5
|
||||
'%board': post.board
|
||||
'%name': post.file.name
|
||||
'%%': '%'
|
||||
}[parameter]
|
||||
if i is 0 then encodeURIComponent(type) else type
|
||||
if i is 0 and parameter isnt '%%'
|
||||
encodeURIComponent type
|
||||
else
|
||||
parameter
|
||||
type
|
||||
a.href = parts[0]
|
||||
a.textContent = parts[1]
|
||||
a
|
||||
|
||||
@ -11,7 +11,7 @@ FileInfo =
|
||||
FileInfo.format Conf['fileInfo'], @, @file.text.firstElementChild
|
||||
format: (formatString, post, outputNode) ->
|
||||
output = innerHTML: ''
|
||||
formatString.replace /%([A-Za-z])|[^%]+/g, (s, c) ->
|
||||
formatString.replace /%(.)|[^%]+/g, (s, c) ->
|
||||
if c of FileInfo.formatters
|
||||
FileInfo.formatters[c].call post, output
|
||||
else
|
||||
@ -60,3 +60,5 @@ FileInfo =
|
||||
r: (x) ->
|
||||
dim = @file.dimensions or 'PDF'
|
||||
x.innerHTML += E dim
|
||||
'%': (x) ->
|
||||
x.innerHTML += '%'
|
||||
|
||||
@ -9,7 +9,7 @@ Time =
|
||||
return if @isClone
|
||||
@nodes.date.textContent = Time.format Conf['time'], @info.date
|
||||
format: (formatString, date) ->
|
||||
formatString.replace /%([A-Za-z])/g, (s, c) ->
|
||||
formatString.replace /%(.)/g, (s, c) ->
|
||||
if c of Time.formatters
|
||||
Time.formatters[c].call(date)
|
||||
else
|
||||
@ -56,3 +56,4 @@ Time =
|
||||
S: -> Time.zeroPad @getSeconds()
|
||||
y: -> @getFullYear().toString()[2..]
|
||||
Y: -> @getFullYear()
|
||||
'%': -> '%'
|
||||
|
||||
@ -26,7 +26,7 @@ QuoteBacklink =
|
||||
a = $.el 'a',
|
||||
href: Build.postURL @board.ID, @thread.ID, @ID
|
||||
className: if @isHidden then 'filtered backlink' else 'backlink'
|
||||
textContent: (Conf['backlink'].replace /%id/, @ID) + (if markYours then '\u00A0(You)' else '')
|
||||
textContent: Conf['backlink'].replace(/%(?:id|%)/g, (x) => {'%id': @ID, '%%': '%'}[x]) + (if markYours then '\u00A0(You)' else '')
|
||||
for quote in @quotes
|
||||
containers = [QuoteBacklink.getContainer quote]
|
||||
if (post = g.posts[quote]) and post.nodes.backlinkContainer
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user