Support filters that apply to multiple post fields joined by newline characters.

This commit is contained in:
ccd0 2019-03-31 00:54:43 -07:00
parent e784844333
commit abb43b3314
2 changed files with 8 additions and 4 deletions

View File

@ -92,8 +92,7 @@ Filter =
# Fields that this filter applies to (for 'general' filters)
if key is 'general'
if (types = filter.match /(?:^|;)\s*type:([^;]*)/)
types = types[1].split(',').filter (x) ->
x of Config.filter and x isnt 'general'
types = types[1].split(',')
else
types = ['subject', 'name', 'filename', 'comment']
@ -181,7 +180,10 @@ Filter =
MD5: (post) -> post.file?.MD5
value: (key, post) ->
Filter.valueF[key](post)
if key of Filter.valueF
Filter.valueF[key](post)
else
key.split('+').map((k) -> Filter.valueF[k]?(post) or '').join('\n')
addFilter: (type, re, cb) ->
$.get type, Conf[type], (item) ->

View File

@ -41,7 +41,9 @@
<li>
Filters in the "General" section apply to multiple fields, by default <code>subject,name,filename,comment</code>.<br>
The fields can be specified with the <code>type</code> option, separated by commas.<br>
For example: <code>type:@{filterTypes};</code>.
For example: <code>type:@{filterTypes};</code>.<br>
Types can also be combined with a <code>+</code> sign; this indicates the filter applies to the given fields joined by newlines.<br>
For example: <code>type:filename+filesize+dimensions;</code>.<br>
</li>
</ul>
<p>