Merge remote-tracking branch 'dzamie/iss944'

This commit is contained in:
ccd0 2016-10-03 16:33:03 -07:00
commit 9f6cc38e76
2 changed files with 11 additions and 7 deletions

View File

@ -7,6 +7,9 @@ Filter =
unless Conf['Filtered Backlinks']
$.addClass doc, 'hide-backlinks'
nsfwBoards = 'aco,b,d,e,f,gif,h,hc,hm,hr,i,ic,pol,r,r9k,s,s4s,soc,t,trash,u,wg,y'
sfwBoards = '3,a,adv,an,asp,biz,c,cgl,ck,cm,co,diy,fa,fit,g,gd,his,int,jp,k,lgbt,lit,m,mlp,mu,n,news,o,out,p,po,qa,qst,sci,sp,tg,toy,trv,tv,v,vg,vp,vr,w,wsg,wsr,x'
for key of Config.filter
@filters[key] = []
for line in Conf[key].split '\n'
@ -21,13 +24,14 @@ Filter =
# Comma-separated list of the boards this filter applies to.
# Defaults to global.
boards = filter.match(/boards:([^;]+)/)?[1].toLowerCase() or 'global'
boards = boards.replace('nsfw', nsfwBoards).replace('sfw', sfwBoards)
boards = if boards is 'global' then null else boards.split(',')
# boards to exclude from an otherwise global rule
excludes = if boards is null
filter.match(/exclude:([^;]+)/)?[1].toLowerCase().split(',') or null
else
null
# due to the sfw and nsfw keywords, also works on all filters
# replaces 'nsfw' and 'sfw' for consistency
excludes = filter.match(/exclude:([^;]+)/)?[1].toLowerCase() or null
excludes = if excludes is null then null else excludes.replace('nsfw', nsfwBoards).replace('sfw', sfwBoards).split(',')
if key in ['uniqueID', 'MD5']
# MD5 filter will use strings instead of regular expressions.

View File

@ -7,11 +7,11 @@
</p>
<ul>You can use these settings with each regular expression, separate them with semicolons:
<li>
Per boards, separate them with commas. It is global if not specified.<br>
For example: <code>boards:a,jp;</code>.
Per boards, separate them with commas. It is global if not specified. Use <code>sfw</code> and <code>nsfw</code> to reference all worksafe or not-worksafe boards.<br>
For example: <code>boards:a,jp;</code>.<br>
</li>
<li>
In case of a global rule, select boards to be excluded from the filter.<br>
In case of a global rule or one that uses <code>sfw</code>/<code>nsfw</code>, select boards to be excluded from the filter.<br>
For example: <code>exclude:vg,v;</code>.
</li>
<li>