From adf1d4716bf7e4d1b7e83e27af40366a8dfc0fda Mon Sep 17 00:00:00 2001 From: ccd0 Date: Wed, 11 May 2016 23:39:22 -0700 Subject: [PATCH] Turn archive links into quotelinks. #512 --- src/Quotelinks/Quotify.coffee | 13 +++++++++++++ src/config/Config.coffee | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Quotelinks/Quotify.coffee b/src/Quotelinks/Quotify.coffee index 958597c33..0bd0e40d3 100644 --- a/src/Quotelinks/Quotify.coffee +++ b/src/Quotelinks/Quotify.coffee @@ -11,10 +11,23 @@ Quotify = node: -> return if @isClone + for link in $$ 'a.linkify', @nodes.comment + Quotify.parseArchiveLink.call @, link for deadlink in $$ '.deadlink', @nodes.comment Quotify.parseDeadlink.call @, deadlink return + parseArchiveLink: (link) -> + return unless Redirect.archives.some (o) -> link.host is o.domain + return unless (m = link.pathname.match /^\/([^/]+)\/thread\/S?(\d+)\/?/) + boardID = m[1] + threadID = m[2] + postID = link.hash.match(/^#p?(\d+)$|$/)[1] or threadID + if Redirect.to 'post', {boardID, postID} + $.addClass link, 'quotelink' + $.extend link.dataset, {boardID, threadID, postID} + @nodes.quotelinks.push link + parseDeadlink: (deadlink) -> if $.hasClass deadlink.parentNode, 'prettyprint' # Don't quotify deadlinks inside code tags, diff --git a/src/config/Config.coffee b/src/config/Config.coffee index aea391bdc..44c11e7e3 100644 --- a/src/config/Config.coffee +++ b/src/config/Config.coffee @@ -547,7 +547,7 @@ Config = ] 'Resurrect Quotes': [ true - 'Link dead quotes to the archives.' + 'Link dead quotes to the archives, and support inlining/previewing of archive links like quote links.' ] 'Remember Your Posts': [ true