From 0786f023f345a44c20934e3606170d5c4261c212 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Tue, 17 Jun 2014 02:25:09 -0700 Subject: [PATCH] make all quote links stub-tolerant --- src/General/Build.coffee | 14 +++++++++----- src/Quotelinks/QuoteBacklink.coffee | 2 +- src/Quotelinks/Quotify.coffee | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/General/Build.coffee b/src/General/Build.coffee index 7445eea0d..03c76100d 100755 --- a/src/General/Build.coffee +++ b/src/General/Build.coffee @@ -23,6 +23,11 @@ Build = -> n = (n + 1) % 3 sameThread: (boardID, threadID) -> g.VIEW is 'thread' and g.BOARD.ID is boardID and g.THREADID is +threadID + postURL: (boardID, threadID, postID) -> + if Build.sameThread boardID, threadID + "\#p#{postID}" + else + "/#{boardID}/thread/#{threadID}\#p#{postID}" postFromObject: (data, boardID) -> o = # id @@ -192,12 +197,11 @@ Build = else h_file = '' - if Build.sameThread boardID, threadID - postLink = "\#p#{postID}" - quoteLink = "javascript:quote('#{postID}');" + postLink = Build.postURL boardID, threadID, postID + quoteLink = if Build.sameThread boardID, threadID + "javascript:quote('#{postID}');" else - postLink = "/#{boardID}/thread/#{threadID}\#p#{postID}" - quoteLink = "/#{boardID}/thread/#{threadID}\#q#{postID}" + "/#{boardID}/thread/#{threadID}\#q#{postID}" if isSticky h_sticky = " Sticky" diff --git a/src/Quotelinks/QuoteBacklink.coffee b/src/Quotelinks/QuoteBacklink.coffee index 5dd6c301f..cb73c4876 100755 --- a/src/Quotelinks/QuoteBacklink.coffee +++ b/src/Quotelinks/QuoteBacklink.coffee @@ -24,7 +24,7 @@ QuoteBacklink = return if @isClone or !@quotes.length markYours = Conf['Quick Reply'] and Conf['Mark Quotes of You'] and QR.db.get {boardID: @board.ID, threadID: @thread.ID, postID: @ID} a = $.el 'a', - href: "/#{@board}/thread/#{@thread}#p#{@}" + 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 '') for quote in @quotes diff --git a/src/Quotelinks/Quotify.coffee b/src/Quotelinks/Quotify.coffee index 1acfe0378..f2a4ab0b1 100755 --- a/src/Quotelinks/Quotify.coffee +++ b/src/Quotelinks/Quotify.coffee @@ -45,13 +45,13 @@ Quotify = # Don't (Dead) when quotifying in an archived post, # and we know the post still exists. a = $.el 'a', - href: "/#{boardID}/thread/#{post.thread}#p#{postID}" + href: Build.postURL boardID, post.thread.ID, postID className: 'quotelink' textContent: quote else # Replace the .deadlink span if we can redirect. a = $.el 'a', - href: "/#{boardID}/thread/#{post.thread}#p#{postID}" + href: Build.postURL boardID, post.thread.ID, postID className: 'quotelink deadlink' target: '_blank' textContent: "#{quote}\u00A0(Dead)"