diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index ccd23aeea..d6a76c91b 100755 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -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 diff --git a/src/General/html/Settings/Advanced.html b/src/General/html/Settings/Advanced.html index 32dc380ef..a4f7171c0 100755 --- a/src/General/html/Settings/Advanced.html +++ b/src/General/html/Settings/Advanced.html @@ -47,6 +47,7 @@
Hour: %k, %H, %l, %I, %p, %P
Minute: %M
Second: %S
+
Literal %: %%
@@ -62,6 +63,7 @@
Spoiler indicator: %p
Size: %B (Bytes), %K (KB), %M (MB), %s (4chan default)
Resolution: %r (Displays 'PDF' for PDF files)
+
Literal %: %%
diff --git a/src/General/html/Settings/Sauce.html b/src/General/html/Settings/Sauce.html index a9e5a1b25..7bdd83d7d 100755 --- a/src/General/html/Settings/Sauce.html +++ b/src/General/html/Settings/Sauce.html @@ -7,5 +7,6 @@
  • %MD5: MD5 hash.
  • %name: Original file name.
  • %board: Current board.
  • +
  • %%: Literal %.
  • diff --git a/src/Images/Sauce.coffee b/src/Images/Sauce.coffee index 7f464e612..2507ab53d 100755 --- a/src/Images/Sauce.coffee +++ b/src/Images/Sauce.coffee @@ -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 diff --git a/src/Miscellaneous/FileInfo.coffee b/src/Miscellaneous/FileInfo.coffee index 9af11e8e2..0ae2c20d0 100755 --- a/src/Miscellaneous/FileInfo.coffee +++ b/src/Miscellaneous/FileInfo.coffee @@ -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 += '%' diff --git a/src/Miscellaneous/Time.coffee b/src/Miscellaneous/Time.coffee index e16f93354..a79cb9e45 100755 --- a/src/Miscellaneous/Time.coffee +++ b/src/Miscellaneous/Time.coffee @@ -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() + '%': -> '%' diff --git a/src/Quotelinks/QuoteBacklink.coffee b/src/Quotelinks/QuoteBacklink.coffee index cb73c4876..17134870c 100755 --- a/src/Quotelinks/QuoteBacklink.coffee +++ b/src/Quotelinks/QuoteBacklink.coffee @@ -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