Merge remote-tracking branch '18763C27/master'

This commit is contained in:
ccd0 2015-12-11 22:13:49 -08:00
commit 0546e439ea
2 changed files with 12 additions and 2 deletions

View File

@ -22,6 +22,10 @@ Filter =
boards = filter.match(/boards:([^;]+)/)?[1].toLowerCase() or 'global' boards = filter.match(/boards:([^;]+)/)?[1].toLowerCase() or 'global'
boards = if boards is 'global' then null else boards.split(',') boards = if boards is 'global' then null else boards.split(',')
# boards to exclude from an otherwise global rule
if boards is null
excludes = filter.match(/exclude:([^;]+)/)?[1].toLowerCase().split(',') or null
if key in ['uniqueID', 'MD5'] if key in ['uniqueID', 'MD5']
# MD5 filter will use strings instead of regular expressions. # MD5 filter will use strings instead of regular expressions.
regexp = regexp[1] regexp = regexp[1]
@ -64,7 +68,7 @@ Filter =
top = filter.match(/top:(yes|no)/)?[1] or 'yes' top = filter.match(/top:(yes|no)/)?[1] or 'yes'
top = top is 'yes' # Turn it into a boolean top = top is 'yes' # Turn it into a boolean
@filters[key].push @createFilter regexp, boards, op, stub, hl, top @filters[key].push @createFilter regexp, boards, excludes, op, stub, hl, top
# Only execute filter types that contain valid filters. # Only execute filter types that contain valid filters.
unless @filters[key].length unless @filters[key].length
@ -75,7 +79,7 @@ Filter =
name: 'Filter' name: 'Filter'
cb: @node cb: @node
createFilter: (regexp, boards, op, stub, hl, top) -> createFilter: (regexp, boards, excludes, op, stub, hl, top) ->
test = test =
if typeof regexp is 'string' if typeof regexp is 'string'
# MD5 checking # MD5 checking
@ -92,6 +96,8 @@ Filter =
(value, boardID, isReply) -> (value, boardID, isReply) ->
if boards and boardID not in boards if boards and boardID not in boards
return false return false
if excludes and boardID in excludes
return false
if isReply and op is 'only' or !isReply and op is 'no' if isReply and op is 'only' or !isReply and op is 'no'
return false return false
unless test value unless test value

View File

@ -10,6 +10,10 @@
Per boards, separate them with commas. It is global if not specified.<br> Per boards, separate them with commas. It is global if not specified.<br>
For example: <code>boards:a,jp;</code>. For example: <code>boards:a,jp;</code>.
</li> </li>
<li>
In case of a global rule, select boards to be excluded from the filter.<br>
For example: <code>exclude:vg,v;</code>.
</li>
<li> <li>
Filter OPs only along with their threads (`only`), replies only (`no`), or both (`yes`, this is default).<br> Filter OPs only along with their threads (`only`), replies only (`no`), or both (`yes`, this is default).<br>
For example: <code>op:only;</code>, <code>op:no;</code> or <code>op:yes;</code>. For example: <code>op:only;</code>, <code>op:no;</code> or <code>op:yes;</code>.