add boards and types options to sauce links; update example list

This commit is contained in:
ccd0 2014-06-29 04:41:52 -07:00
parent 3fa001636d
commit 7e7645bf1a
3 changed files with 32 additions and 18 deletions

View File

@ -520,16 +520,18 @@ Config =
https://www.google.com/searchbyimage?image_url=%TURL https://www.google.com/searchbyimage?image_url=%TURL
http://iqdb.org/?url=%TURL http://iqdb.org/?url=%TURL
#//tineye.com/search?url=%TURL #//tineye.com/search?url=%TURL
#http://saucenao.com/search.php?url=%TURL #//saucenao.com/search.php?url=%TURL
#http://3d.iqdb.org/?url=%TURL #http://3d.iqdb.org/?url=%TURL
#http://regex.info/exif.cgi?imgurl=%URL #http://regex.info/exif.cgi?imgurl=%URL
# uploaders: # uploaders:
#http://imgur.com/upload?url=%URL;text:Upload to imgur #//imgur.com/upload?url=%URL;text:Upload to imgur
#http://ompldr.org/upload?url1=%URL;text:Upload to ompldr
# "View Same" in archives: # "View Same" in archives:
#//archive.foolz.us/_/search/image/%MD5/;text:View same on foolz #//archive.foolz.us/_/search/image/%MD5/;text:View same on foolz
#//archive.foolz.us/%board/search/image/%MD5/;text:View same on foolz /%board/ #//archive.foolz.us/%board/search/image/%MD5/;text:View same on foolz /%board/;boards:a,biz,c,co,diy,gd,int,jp,m,out,po,sci,sp,tg,tv,vg,vp,vr,wsg
#//archive.installgentoo.net/%board/image/%MD5;text:View same on installgentoo /%board/ #https://rbt.asia/%board/image/%MD5;text:View same on rebeccablacktech /%board/;boards:cgl,con,g,mu,w
# Search with full image only for image file types:
#https://www.google.com/searchbyimage?image_url=%URL;types:gif,jpg,png
#https://www.google.com/searchbyimage?image_url=%TURL;types:webm,pdf
""" """
FappeT: FappeT:

View File

@ -1,12 +1,14 @@
<div class=warning><code>Sauce</code> is disabled.</div> <div class=warning><code>Sauce</code> is disabled.</div>
<div>Lines starting with a <code>#</code> will be ignored.</div> <div>Lines starting with a <code>#</code> will be ignored.</div>
<div>You can specify a display text by appending <code>;text:[text]</code> to the URL.</div> <div>You can specify a display text by appending <code>;text:[text]</code> to the URL.</div>
<div>You can specify the applicable boards by appending <code>;boards:board1,board2</code>.</div>
<div>You can specify the applicable file types by appending <code>;types:extension1,extension2</code>.</div>
<ul>These parameters will be replaced by their corresponding values: <ul>These parameters will be replaced by their corresponding values:
<li><code>%TURL</code>: Thumbnail URL.</li> <li><code>%TURL</code>: Thumbnail URL.</li>
<li><code>%URL</code>: Full image URL.</li> <li><code>%URL</code>: Full image URL.</li>
<li><code>%MD5</code>: MD5 hash.</li> <li><code>%MD5</code>: MD5 hash.</li>
<li><code>%name</code>: Original file name.</li> <li><code>%name</code>: Original file name.</li>
<li><code>%board</code>: Current board.</li> <li><code>%board</code>: Current board.</li>
<li><code>%%</code>: Literal <code>%</code>.</li> <li><code>%%</code>, <code>%semi</code>: Literal <code>%</code> and <code>;</code>.</li>
</ul> </ul>
<textarea name=sauces class=field spellcheck=false></textarea> <textarea name=sauces class=field spellcheck=false></textarea>

View File

@ -14,12 +14,15 @@ Sauce =
Post.callbacks.push Post.callbacks.push
name: 'Sauce' name: 'Sauce'
cb: @node cb: @node
createSauceLink: (link, post, a) -> createSauceLink: (link, post) ->
text = if m = link.match(/;text:(.+)$/) then m[1] else link.match(/(\w+)\.\w+\//)?[1] or '?' parts = {}
link = link.replace /;text:.+$/, '' for part in link.split ';'
parts = [link, text] m = part.match /^(?:(url|text|boards|types):)?(.*)$/
for i in [0..1] parts[m[1] or 'url'] = m[2]
parts[i] = parts[i].replace /%(T?URL|MD5|board|name|%)/g, (parameter) -> parts['url'] or= 'javascript:;'
parts['text'] or= parts['url'].match(/(\w+)\.\w+\//)?[1] or '?'
for key of parts
parts[key] = parts[key].replace /%(T?URL|MD5|board|name|%|semi)/g, (parameter) ->
type = { type = {
'%TURL': post.file.thumbURL '%TURL': post.file.thumbURL
'%URL': post.file.URL '%URL': post.file.URL
@ -27,18 +30,25 @@ Sauce =
'%board': post.board '%board': post.board
'%name': post.file.name '%name': post.file.name
'%%': '%' '%%': '%'
'%semi': ';'
}[parameter] }[parameter]
if i is 0 and parameter isnt '%%' if key is 'url' and parameter isnt '%%' and parameter isnt '%semi'
encodeURIComponent type encodeURIComponent type
else else
type type
a.href = parts[0] ext = post.file.URL.match(/\.([^\.]*)$/)?[1] or ''
a.textContent = parts[1] if (!parts['boards'] or post.board.ID in parts['boards'].split ',') and (!parts['types'] or ext in parts['types'].split ',')
a a = Sauce.link.cloneNode true
a.href = parts['url']
a.textContent = parts['text']
a
else
null
node: -> node: ->
return if @isClone or !@file return if @isClone or !@file
nodes = [] nodes = []
for link in Sauce.links for link in Sauce.links
# \u00A0 is nbsp if node = Sauce.createSauceLink link, @
nodes.push $.tn('\u00A0'), (Sauce.createSauceLink link, @, Sauce.link.cloneNode true) # \u00A0 is nbsp
nodes.push $.tn('\u00A0'), node
$.add @file.text, nodes $.add @file.text, nodes