diff --git a/src/Filtering/Filter.coffee b/src/Filtering/Filter.coffee index bcbd0e3602..99a8b36308 100644 --- a/src/Filtering/Filter.coffee +++ b/src/Filtering/Filter.coffee @@ -124,6 +124,8 @@ Filter = hl = undefined top = false noti = false + matcher = undefined + fielder = undefined if QuoteYou.isYou(post) hideable = false mask = (if post.isReply then 2 else 1) @@ -139,6 +141,8 @@ Filter = (filter.mask & mask) or (if filter.isstring then (filter.regexp isnt value) else !filter.regexp.test(value)) ) + matcher = key + fielder = filter.regexp if filter.hide if hideable hide = true @@ -150,21 +154,24 @@ Filter = if filter.noti noti = true if hide - {hide, stub} + {hide, stub, matcher, fielder} else - {hl, top, noti} + {hl, top, noti, matcher, fielder} node: -> return if @isClone - {hide, stub, hl, top, noti} = Filter.test @, (!@isFetchedQuote and (@isReply or g.VIEW is 'index')) + {hide, stub, hl, top, noti, matcher, fielder} = Filter.test @, (!@isFetchedQuote and (@isReply or g.VIEW is 'index')) if hide if @isReply PostHiding.hide @, stub + @labels.push "Hidden by the #{fielder} in #{matcher}" else ThreadHiding.hide @thread, stub + @labels.push "Hidden by the #{fielder} in #{matcher}" else if hl @highlights = hl + @labels.push "Highlighting with #{hl} by the #{fielder} in #{matcher}" $.addClass @nodes.root, hl... if noti and Unread.posts and (@ID > Unread.lastReadPost) and not QuoteYou.isYou(@) Unread.openNotification @, ' triggered a notification filter' diff --git a/src/Filtering/PostHiding.coffee b/src/Filtering/PostHiding.coffee index fd132f499e..201094bc92 100644 --- a/src/Filtering/PostHiding.coffee +++ b/src/Filtering/PostHiding.coffee @@ -18,10 +18,11 @@ PostHiding = if data = PostHiding.db.get {boardID: @board.ID, threadID: @thread.ID, postID: @ID} if data.thisPost - PostHiding.hide @, data.makeStub, data.hideRecursively + PostHiding.hide @, 'Manually hidden', data.makeStub, data.hideRecursively else - Recursive.apply PostHiding.hide, @, data.makeStub, true - Recursive.add PostHiding.hide, @, data.makeStub, true + label = "Recursively hidden for quoting No.#{@postID}" + Recursive.apply PostHiding.hide, @, label, data.makeStub, true + Recursive.add PostHiding.hide, @, label, data.makeStub, true return unless Conf['Reply Hiding Buttons'] @@ -121,15 +122,16 @@ PostHiding = thisPost = $('input[name=thisPost]', parent).checked replies = $('input[name=replies]', parent).checked makeStub = $('input[name=makeStub]', parent).checked + label = 'Manually hidden' {post} = PostHiding.menu if thisPost - PostHiding.hide post, makeStub, replies + PostHiding.hide post, label, makeStub, replies else if replies - Recursive.apply PostHiding.hide, post, makeStub, true - Recursive.add PostHiding.hide, post, makeStub, true + Recursive.apply PostHiding.hide, post, label, makeStub, true + Recursive.add PostHiding.hide, post, label, makeStub, true else return - PostHiding.saveHiddenState post, true, thisPost, makeStub, replies + PostHiding.saveHiddenState post, true, thisPost, label, makeStub, replies $.event 'CloseMenu' show: -> @@ -186,13 +188,15 @@ PostHiding = PostHiding[(if post.isHidden then 'show' else 'hide')] post PostHiding.saveHiddenState post, post.isHidden - hide: (post, makeStub=Conf['Stubs'], hideRecursively=Conf['Recursive Hiding']) -> + hide: (post, label, makeStub=Conf['Stubs'], hideRecursively=Conf['Recursive Hiding']) -> + post.labels.push label unless label in post.labels return if post.isHidden post.isHidden = true if hideRecursively - Recursive.apply PostHiding.hide, post, makeStub, true - Recursive.add PostHiding.hide, post, makeStub, true + label = "Recursively hidden for quoting No.#{post.postID}" + Recursive.apply PostHiding.hide, post, label, makeStub, true + Recursive.add PostHiding.hide, post, label, makeStub, true for quotelink in Get.allQuotelinksLinkingTo post $.addClass quotelink, 'filtered' @@ -217,6 +221,9 @@ PostHiding = else post.nodes.root.hidden = false post.isHidden = false + post.labels = post.labels.filter (label) -> + # Mayhem says this is lame + !/^(Manually hidden|Recurisvely hidden|Hidden by)/.test label if showRecursively Recursive.apply PostHiding.show, post, true Recursive.rm PostHiding.hide, post diff --git a/src/Menu/FilterLabels.coffee b/src/Menu/FilterLabels.coffee new file mode 100644 index 0000000000..ae25b809ed --- /dev/null +++ b/src/Menu/FilterLabels.coffee @@ -0,0 +1,18 @@ +FilterLabels = + init: -> + return unless g.VIEW in ['index', 'thread'] and Conf['Menu'] and Conf['Filter Labels'] + + div = $.el 'div', + textContent: 'Labels' + + Menu.menu.addEntry + el: div + order: 117 + open: (post) -> + {labels} = post.origin or post + return false unless labels.length + @subEntries.length = 0 + for label in labels + @subEntries.push el: $.el 'div', textContent: label + true + subEntries: [] \ No newline at end of file diff --git a/src/classes/Post.coffee b/src/classes/Post.coffee index 8551aa718a..1636aa9810 100644 --- a/src/classes/Post.coffee +++ b/src/classes/Post.coffee @@ -53,6 +53,7 @@ class Post @parseQuotes() @parseFiles() + @labels = [] @isDead = false @isHidden = false diff --git a/src/config/Config.coffee b/src/config/Config.coffee index a3443c8807..f9bf951429 100644 --- a/src/config/Config.coffee +++ b/src/config/Config.coffee @@ -364,6 +364,11 @@ Config = 'Add a download with original filename link to the menu.' 1 ] + 'Filter Labels': [ + true + 'Add a menu entry that lists reasons for a post matching a filter.' + 1 + ] 'Monitoring': 'Thread Updater': [ diff --git a/src/main/Main.coffee b/src/main/Main.coffee index 3d740c4691..3905e50858 100644 --- a/src/main/Main.coffee +++ b/src/main/Main.coffee @@ -664,6 +664,7 @@ Main = ['Edit Link', QR.oekaki.menu] ['Download Link', DownloadLink] ['Archive Link', ArchiveLink] + ['Filter Labels', FilterLabels] ['Quote Inlining', QuoteInline] ['Quote Previewing', QuotePreview] ['Quote Backlinks', QuoteBacklink]