Add post labelling.
This commit is contained in:
parent
d052bfc186
commit
ce2b9ee170
@ -1,6 +1,6 @@
|
||||
- Post hiding rewrite:
|
||||
- `Thread Hiding` and `Reply Hiding` settings are merged into one: `Post Hiding`.
|
||||
- `Thread Hiding Link` and `Reply Hiding Link` settings are merged into one: `Post Hiding Link`.
|
||||
- The posts' menu now has a label entry listing the reasons why a post got hidden or highlighted.
|
||||
- `Thread Hiding` and `Reply Hiding` settings are merged into one: `Post Hiding`.
|
||||
- `Thread Hiding Link` and `Reply Hiding Link` settings are merged into one: `Post Hiding Link`.
|
||||
|
||||
### 3.18.1 - *2014-02-20*
|
||||
|
||||
|
||||
@ -57,7 +57,18 @@ Filter =
|
||||
top = filter.match(/top:(yes|no)/)?[1] or 'yes'
|
||||
top = top is 'yes' # Turn it into a boolean
|
||||
|
||||
@filters[key].push @createFilter regexp, op, stub, hl, top
|
||||
@filters[key].push {
|
||||
hide: !hl
|
||||
op: op
|
||||
stub: stub
|
||||
class: hl
|
||||
top: top
|
||||
match: regexp
|
||||
test: if typeof regexp is 'string'
|
||||
Filter.stringTest # MD5 checking
|
||||
else
|
||||
Filter.regexpTest
|
||||
}
|
||||
|
||||
# Only execute filter types that contain valid filters.
|
||||
unless @filters[key].length
|
||||
@ -68,25 +79,6 @@ Filter =
|
||||
name: 'Filter'
|
||||
cb: @node
|
||||
|
||||
createFilter: (regexp, op, stub, hl, top) ->
|
||||
test =
|
||||
if typeof regexp is 'string'
|
||||
# MD5 checking
|
||||
(value) -> regexp is value
|
||||
else
|
||||
(value) -> regexp.test value
|
||||
settings =
|
||||
hide: !hl
|
||||
stub: stub
|
||||
class: hl
|
||||
top: top
|
||||
(value, isReply) ->
|
||||
if isReply and op is 'only' or !isReply and op is 'no'
|
||||
return false
|
||||
unless test value
|
||||
return false
|
||||
settings
|
||||
|
||||
node: ->
|
||||
return if @isClone
|
||||
for key of Filter.filters
|
||||
@ -94,23 +86,29 @@ Filter =
|
||||
# Continue if there's nothing to filter (no tripcode for example).
|
||||
continue if value is false
|
||||
|
||||
for filter in Filter.filters[key]
|
||||
unless result = filter value, @isReply
|
||||
for obj in Filter.filters[key]
|
||||
unless Filter.test obj, value, @isReply
|
||||
continue
|
||||
|
||||
# Hide
|
||||
if result.hide
|
||||
if obj.hide
|
||||
continue unless @isReply or g.VIEW is 'index'
|
||||
@hide result.stub
|
||||
@hide "Hidden by filtering the #{key}: #{obj.match}", obj.stub
|
||||
return
|
||||
|
||||
# Highlight
|
||||
$.addClass @nodes.root, result.class
|
||||
unless @highlights and result.class in @highlights
|
||||
(@highlights or= []).push result.class
|
||||
if !@isReply and result.top
|
||||
@thread.isOnTop = true
|
||||
@highlight "Highlighted by filtering the #{key}: #{obj.match}", obj.class, obj.top
|
||||
|
||||
stringTest: (string, value) ->
|
||||
regexp is value
|
||||
regexpTest: (regexp, value) ->
|
||||
regexp.test value
|
||||
test: ({test, match, op}, value, isReply) ->
|
||||
if isReply and op is 'only' or !isReply and op is 'no'
|
||||
return false
|
||||
unless test match, value
|
||||
return false
|
||||
true
|
||||
name: (post) ->
|
||||
if 'name' of post.info
|
||||
return post.info.name
|
||||
|
||||
@ -28,10 +28,11 @@ PostHiding =
|
||||
|
||||
if data = PostHiding.db.get {boardID: @board.ID, threadID: @thread.ID, postID: @ID}
|
||||
if data.thisPost is false
|
||||
Recursive.apply 'hide', @, data.makeStub, true
|
||||
Recursive.add 'hide', @, data.makeStub, true
|
||||
label = "Recursively hidden for quoting No.#{@}"
|
||||
Recursive.apply 'hide', @, label, data.makeStub, true
|
||||
Recursive.add 'hide', @, label, data.makeStub, true
|
||||
else
|
||||
@hide data.makeStub, data.hideRecursively
|
||||
@hide 'Manually hidden', data.makeStub, data.hideRecursively
|
||||
|
||||
return unless Conf['Post Hiding']
|
||||
a = PostHiding.makeButton true
|
||||
@ -54,7 +55,7 @@ PostHiding =
|
||||
if post.isHidden
|
||||
post.show()
|
||||
else
|
||||
post.hide()
|
||||
post.hide 'Manually hidden'
|
||||
PostHiding.saveHiddenState post
|
||||
|
||||
saveHiddenState: (post, val) ->
|
||||
@ -137,13 +138,14 @@ PostHiding =
|
||||
thisPost = $('input[name=thisPost]', parent).checked if post.isReply
|
||||
replies = $('input[name=replies]', parent).checked if post.isReply
|
||||
makeStub = $('input[name=makeStub]', parent).checked
|
||||
label = 'Manually hidden'
|
||||
if !post.isReply
|
||||
post.hide makeStub
|
||||
post.hide label, makeStub
|
||||
else if thisPost
|
||||
post.hide makeStub, replies
|
||||
post.hide label, makeStub, replies
|
||||
else if replies
|
||||
Recursive.apply 'hide', post, makeStub, true
|
||||
Recursive.add 'hide', post, makeStub, true
|
||||
Recursive.apply 'hide', post, label, makeStub, true
|
||||
Recursive.add 'hide', post, label, makeStub, true
|
||||
else
|
||||
return
|
||||
val = if post.isReply
|
||||
|
||||
@ -281,7 +281,7 @@ Build =
|
||||
|
||||
root.dataset.fullID = thread.fullID
|
||||
$.addClass root, 'pinned' if thread.isPinned
|
||||
$.addClass root, thread.OP.highlights... if thread.OP.highlights
|
||||
$.addClass root, thread.OP.highlights... if thread.OP.highlights.length
|
||||
|
||||
thumb = root.firstElementChild
|
||||
if data.spoiler and !Conf['Reveal Spoilers']
|
||||
|
||||
@ -90,6 +90,7 @@ Main =
|
||||
initFeature 'Delete Link', DeleteLink
|
||||
initFeature 'Filter (Menu)', Filter.menu
|
||||
initFeature 'Download Link', DownloadLink
|
||||
initFeature 'Labels list', Labels
|
||||
initFeature 'Archive Link', ArchiveLink
|
||||
initFeature 'Quote Inlining', QuoteInline
|
||||
initFeature 'Quote Previewing', QuotePreview
|
||||
|
||||
@ -52,6 +52,8 @@ class Post
|
||||
@parseQuotes()
|
||||
@parseFile that
|
||||
|
||||
@labels = []
|
||||
@highlights = []
|
||||
@isDead = false
|
||||
@isHidden = false
|
||||
|
||||
@ -106,7 +108,7 @@ class Post
|
||||
|
||||
# ES6 Set when?
|
||||
fullID = "#{match[1]}.#{match[2]}"
|
||||
@quotes.push fullID if @quotes.indexOf(fullID) is -1
|
||||
@quotes.push fullID unless fullID in @quotes
|
||||
|
||||
parseFile: (that) ->
|
||||
return unless (fileEl = $ '.file', @nodes.post) and thumb = $ 'img[data-md5]', fileEl
|
||||
@ -151,7 +153,8 @@ class Post
|
||||
$.rmClass node, 'desktop'
|
||||
return
|
||||
|
||||
hide: (makeStub=Conf['Stubs'], hideRecursively=Conf['Recursive Hiding']) ->
|
||||
hide: (label, makeStub=Conf['Stubs'], hideRecursively=Conf['Recursive Hiding']) ->
|
||||
@labels.push label unless label in @labels
|
||||
return if @isHidden
|
||||
@isHidden = true
|
||||
if !@isReply
|
||||
@ -159,8 +162,9 @@ class Post
|
||||
return
|
||||
|
||||
if hideRecursively
|
||||
Recursive.apply 'hide', @, makeStub, true
|
||||
Recursive.add 'hide', @, makeStub, true
|
||||
label = "Recursively hidden for quoting No.#{@}"
|
||||
Recursive.apply 'hide', @, label, makeStub, true
|
||||
Recursive.add 'hide', @, label, makeStub, true
|
||||
|
||||
for quotelink in Get.allQuotelinksLinkingTo @
|
||||
$.addClass quotelink, 'filtered'
|
||||
@ -183,6 +187,9 @@ class Post
|
||||
show: (showRecursively=Conf['Recursive Hiding']) ->
|
||||
return if !@isHidden
|
||||
@isHidden = false
|
||||
@labels = @labels.filter (label) ->
|
||||
# This is lame.
|
||||
!/^(Manually hidden|Recursively hidden|Hidden by)/.test label
|
||||
if !@isReply
|
||||
@thread.show()
|
||||
return
|
||||
@ -199,6 +206,13 @@ class Post
|
||||
delete @nodes.stub
|
||||
else
|
||||
@nodes.root.hidden = false
|
||||
highlight: (label, highlight, top) ->
|
||||
@labels.push label
|
||||
unless highlight in @highlights
|
||||
@highlights.push highlight
|
||||
$.addClass @nodes.root, highlight
|
||||
if !@isReply and top
|
||||
@thread.isOnTop = true
|
||||
|
||||
kill: (file) ->
|
||||
if file
|
||||
|
||||
@ -84,7 +84,9 @@ UI = do ->
|
||||
|
||||
insertEntry: (entry, parent, data) ->
|
||||
if typeof entry.open is 'function'
|
||||
return unless entry.open data
|
||||
return unless entry.open data, (subEntry) =>
|
||||
@parseEntry subEntry
|
||||
entry.subEntries.push subEntry
|
||||
$.add parent, entry.el
|
||||
|
||||
return unless entry.subEntries
|
||||
|
||||
15
src/Menu/Labels.coffee
Normal file
15
src/Menu/Labels.coffee
Normal file
@ -0,0 +1,15 @@
|
||||
Labels =
|
||||
init: ->
|
||||
return if !Conf['Menu']
|
||||
|
||||
$.event 'AddMenuEntry',
|
||||
type: 'post'
|
||||
el: $.el 'div', textContent: 'Labels'
|
||||
order: 60
|
||||
open: ({labels}, addSubEntry) ->
|
||||
return false unless labels.length
|
||||
@subEntries.length = 0
|
||||
for label in labels
|
||||
addSubEntry el: $.el 'div', textContent: label
|
||||
true
|
||||
subEntries: []
|
||||
Loading…
x
Reference in New Issue
Block a user