Allow users to specify text for sauce links.

This commit is contained in:
Brian McSweeney 2012-06-14 23:13:37 -04:00
parent 4f8cfa82d8
commit 6c26e7dd53
3 changed files with 18 additions and 12 deletions

View File

@ -151,7 +151,7 @@
filesize: [''].join('\n'), filesize: [''].join('\n'),
md5: [''].join('\n') md5: [''].join('\n')
}, },
sauces: ['http://iqdb.org/?url=$1', 'http://www.google.com/searchbyimage?image_url=$1', '#http://tineye.com/search?url=$1', '#http://saucenao.com/search.php?db=999&url=$1', '#http://3d.iqdb.org/?url=$1', '#http://regex.info/exif.cgi?imgurl=$2', '# uploaders:', '#http://imgur.com/upload?url=$2', '#http://omploader.org/upload?url1=$2', '# "View Same" in archives:', '#http://archive.foolz.us/search/image/$3/', '#http://archive.foolz.us/$4/search/image/$3/', '#https://archive.installgentoo.net/$4/image/$3'].join('\n'), sauces: ['http://iqdb.org/?url=$1', 'http://www.google.com/searchbyimage?image_url=$1', '#http://tineye.com/search?url=$1', '#http://saucenao.com/search.php?db=999&url=$1', '#http://3d.iqdb.org/?url=$1', '#http://regex.info/exif.cgi?imgurl=$2', '# uploaders:', '#http://imgur.com/upload?url=$2;show:Upload to imgur', '#http://omploader.org/upload?url1=$2;show:Upload to omploader', '# "View Same" in archives:', '#http://archive.foolz.us/search/image/$3/;show:View same on foolz', '#http://archive.foolz.us/$4/search/image/$3/;show:View same on foolz /$4/', '#https://archive.installgentoo.net/$4/image/$3;show:View same on installgentoo /$4/'].join('\n'),
time: '%m/%d/%y(%a)%H:%M', time: '%m/%d/%y(%a)%H:%M',
backlink: '>>%id', backlink: '>>%id',
fileInfo: '%l (%p%s, %r)', fileInfo: '%l (%p%s, %r)',
@ -2238,7 +2238,8 @@
<input type=radio name=tab hidden id=sauces_tab>\ <input type=radio name=tab hidden id=sauces_tab>\
<div>\ <div>\
<div class=warning><code>Sauce</code> is disabled.</div>\ <div class=warning><code>Sauce</code> is disabled.</div>\
Lines starting with a <code>#</code> will be ignored.\ Lines starting with a <code>#</code> will be ignored.<br>\
You can specify a certain display text by appending ";show:[text]" to the url.\
<ul>These parameters will be replaced by their corresponding values:\ <ul>These parameters will be replaced by their corresponding values:\
<li>$1: Thumbnail url.</li>\ <li>$1: Thumbnail url.</li>\
<li>$2: Full image url.</li>\ <li>$2: Full image url.</li>\
@ -2768,8 +2769,7 @@
}, },
createSauceLink: function(link) { createSauceLink: function(link) {
var domain, el, href; var domain, el, href;
domain = link.match(/(\w+)\.\w+\//)[1]; link = link.replace(/(\$\d)/g, function(parameter) {
href = link.replace(/(\$\d)/g, function(parameter) {
switch (parameter) { switch (parameter) {
case '$1': case '$1':
return "http://thumbs.4chan.org' + img.pathname.replace(/src(\\/\\d+).+$/, 'thumb$1s.jpg') + '"; return "http://thumbs.4chan.org' + img.pathname.replace(/src(\\/\\d+).+$/, 'thumb$1s.jpg') + '";
@ -2781,6 +2781,8 @@
return g.BOARD; return g.BOARD;
} }
}); });
domain = link.match(/;show:(.+)$/) ? link.match(/;show:(.+)$/)[1] : link.match(/(\w+)\.\w+\//)[1];
href = link.match(/;show:(.+)$/) ? link.match(/^(.+);show:.+$/)[1] : link;
href = Function('img', "return '" + href + "'"); href = Function('img', "return '" + href + "'");
el = $.el('a', { el = $.el('a', {
target: '_blank', target: '_blank',

View File

@ -1,4 +1,6 @@
master master
- btmcsweeney
Allow users to specify text for sauce links.
- Mayhem - Mayhem
Opera fixes. Opera fixes.
/f/ fixes. /f/ fixes.

View File

@ -107,12 +107,12 @@ Config =
'#http://3d.iqdb.org/?url=$1' '#http://3d.iqdb.org/?url=$1'
'#http://regex.info/exif.cgi?imgurl=$2' '#http://regex.info/exif.cgi?imgurl=$2'
'# uploaders:' '# uploaders:'
'#http://imgur.com/upload?url=$2' '#http://imgur.com/upload?url=$2;show:Upload to imgur'
'#http://omploader.org/upload?url1=$2' '#http://omploader.org/upload?url1=$2;show:Upload to omploader'
'# "View Same" in archives:' '# "View Same" in archives:'
'#http://archive.foolz.us/search/image/$3/' '#http://archive.foolz.us/search/image/$3/;show:View same on foolz'
'#http://archive.foolz.us/$4/search/image/$3/' '#http://archive.foolz.us/$4/search/image/$3/;show:View same on foolz /$4/'
'#https://archive.installgentoo.net/$4/image/$3' '#https://archive.installgentoo.net/$4/image/$3;show:View same on installgentoo /$4/'
].join '\n' ].join '\n'
time: '%m/%d/%y(%a)%H:%M' time: '%m/%d/%y(%a)%H:%M'
backlink: '>>%id' backlink: '>>%id'
@ -1707,7 +1707,8 @@ Options =
<input type=radio name=tab hidden id=sauces_tab> <input type=radio name=tab hidden id=sauces_tab>
<div> <div>
<div class=warning><code>Sauce</code> is disabled.</div> <div class=warning><code>Sauce</code> is disabled.</div>
Lines starting with a <code>#</code> will be ignored. Lines starting with a <code>#</code> will be ignored.<br>
You can specify a certain display text by appending ";show:[text]" to the url.
<ul>These parameters will be replaced by their corresponding values: <ul>These parameters will be replaced by their corresponding values:
<li>$1: Thumbnail url.</li> <li>$1: Thumbnail url.</li>
<li>$2: Full image url.</li> <li>$2: Full image url.</li>
@ -2155,8 +2156,7 @@ Sauce =
Main.callbacks.push @node Main.callbacks.push @node
createSauceLink: (link) -> createSauceLink: (link) ->
domain = link.match(/(\w+)\.\w+\//)[1] link = link.replace /(\$\d)/g, (parameter) ->
href = link.replace /(\$\d)/g, (parameter) ->
switch parameter switch parameter
when '$1' when '$1'
"http://thumbs.4chan.org' + img.pathname.replace(/src(\\/\\d+).+$/, 'thumb$1s.jpg') + '" "http://thumbs.4chan.org' + img.pathname.replace(/src(\\/\\d+).+$/, 'thumb$1s.jpg') + '"
@ -2166,6 +2166,8 @@ Sauce =
"' + encodeURIComponent(img.firstChild.dataset.md5) + '" "' + encodeURIComponent(img.firstChild.dataset.md5) + '"
when '$4' when '$4'
g.BOARD g.BOARD
domain = if link.match(/;show:(.+)$/) then link.match(/;show:(.+)$/)[1] else link.match(/(\w+)\.\w+\//)[1]
href = if link.match(/;show:(.+)$/) then link.match(/^(.+);show:.+$/)[1] else link
href = Function 'img', "return '#{href}'" href = Function 'img', "return '#{href}'"
el = $.el 'a', el = $.el 'a',
target: '_blank' target: '_blank'