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