From 52dfc296cf7f8e39ae047fb1464e5dc63c3d4126 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Tue, 14 Apr 2015 23:19:13 -0700 Subject: [PATCH] Support reporting posts to fgts archive. --- src/Archive/Redirect.coffee | 14 ++++++++++---- src/General/Config.coffee | 4 ++++ src/Menu/ReportLink.coffee | 13 ++++++++----- src/Miscellaneous/Report.coffee | 19 ++++++++++++++----- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/Archive/Redirect.coffee b/src/Archive/Redirect.coffee index 081a3c428..e43889109 100755 --- a/src/Archive/Redirect.coffee +++ b/src/Archive/Redirect.coffee @@ -4,15 +4,18 @@ Redirect = thread: {} post: {} file: {} + report: {} archives = {} for data in Redirect.archives {name, boards, files, software, withCredentials} = data archives[name] = data - for boardID in boards when !withCredentials - o.thread[boardID] = data unless boardID of o.thread - o.post[boardID] = data unless boardID of o.post or software isnt 'foolfuuka' - o.file[boardID] = data unless boardID of o.file or boardID not in files + for boardID in boards + unless withCredentials + o.thread[boardID] = data unless boardID of o.thread + o.post[boardID] = data unless boardID of o.post or software isnt 'foolfuuka' + o.file[boardID] = data unless boardID of o.file or boardID not in files + o.report[boardID] = data if name is 'fgts' for boardID, record of Conf['selectedArchives'] for type, id of record @@ -84,6 +87,9 @@ Redirect = "#{boardID}/?task=search2&search_#{if type is 'image' then 'media_hash' else type}=#{value}" "#{Redirect.protocol archive}#{archive.domain}/#{path}" + report: (archive, {boardID, postID}) -> + "https://so.fgts.jp/report/?board=#{boardID}&no=#{postID}" + securityCheck: (URL) -> /^https:\/\//.test(URL) or location.protocol is 'http:' or diff --git a/src/General/Config.coffee b/src/General/Config.coffee index 0851d933e..3ea4fe6e6 100755 --- a/src/General/Config.coffee +++ b/src/General/Config.coffee @@ -35,6 +35,10 @@ Config = true 'Redirect dead threads and images to the archives.' ] + 'Archive Report': [ + true + 'Enable reporting posts to supported archives.' + ] 'Except Archives from Encryption': [ false 'Permit loading content from, and warningless redirects to, HTTP-only archives from HTTPS pages.' diff --git a/src/Menu/ReportLink.coffee b/src/Menu/ReportLink.coffee index 73b60a661..c86c217b5 100755 --- a/src/Menu/ReportLink.coffee +++ b/src/Menu/ReportLink.coffee @@ -11,11 +11,14 @@ ReportLink = el: a order: 10 open: (post) -> - ReportLink.post = post - !post.isDead + ReportLink.url = unless post.isDead + "//sys.4chan.org/#{post.board}/imgboard.php?mode=report&no=#{post}" + else if Conf['Archive Report'] + Redirect.to 'report', {boardID: post.board.ID, postID: post.ID} + !!ReportLink.url + report: -> - {post} = ReportLink - url = "//sys.4chan.org/#{post.board}/imgboard.php?mode=report&no=#{post}" + {url} = ReportLink id = Date.now() - set = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1,width=685,height=285" + set = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1,width=685,height=320" window.open url, id, set diff --git a/src/Miscellaneous/Report.coffee b/src/Miscellaneous/Report.coffee index 0aaeb2c41..44ea4414e 100755 --- a/src/Miscellaneous/Report.coffee +++ b/src/Miscellaneous/Report.coffee @@ -1,8 +1,17 @@ Report = init: -> - return unless /report/.test(location.search) - $.asap (-> $.id 'recaptcha_response_field'), Report.ready + return unless Conf['Archive Report'] and /\bmode=report\b/.test(location.search) + return unless match = location.search.match /\bno=(\d+)/ + postID = +match[1] + Redirect.init() + if @archive = Redirect.to 'report', {boardID: g.BOARD.ID, postID} + $.ready @ready + ready: -> - field = $.id 'recaptcha_response_field' - $.on field, 'keydown', (e) -> - $.globalEval 'Recaptcha.reload()' if e.keyCode is 8 and not field.value + if (message = $ 'h3') and /Report submitted!/.test(message.textContent) + location.replace Report.archive + return + link = $.el 'a', + href: Report.archive + textContent: 'Report to fgts' + $.add d.body, [$.tn(' ['), link, $.tn(']')]