Use % for sauce parameters for consistency with other rice settings.

Create only one sauce element to clone, instead of one per closure.
Don't use a closure, just a simple Function.
This also fixes the parameters in the optional text.
This commit is contained in:
Nicolas Stepien 2012-09-17 01:31:10 +02:00
parent 0897fe5c5b
commit 92bece87ea
2 changed files with 35 additions and 44 deletions

View File

@ -165,7 +165,7 @@
filesize: [''].join('\n'),
md5: [''].join('\n')
},
sauces: ['http://iqdb.org/?url=$turl', 'http://www.google.com/searchbyimage?image_url=$turl', '#http://tineye.com/search?url=$turl', '#http://saucenao.com/search.php?db=999&url=$turl', '#http://3d.iqdb.org/?url=$turl', '#http://regex.info/exif.cgi?imgurl=$url', '# uploaders:', '#http://imgur.com/upload?url=$url;text:Upload to imgur', '#http://omploader.org/upload?url1=$url;text:Upload to omploader', '# "View Same" in archives:', '#http://archive.foolz.us/_/search/image/$md5/;text:View same on foolz', '#http://archive.foolz.us/$board/search/image/$md5/;text:View same on foolz /$board/', '#https://archive.installgentoo.net/$board/image/$md5;text:View same on installgentoo /$board/'].join('\n'),
sauces: ['http://iqdb.org/?url=%turl', 'http://www.google.com/searchbyimage?image_url=%turl', '#http://tineye.com/search?url=%turl', '#http://saucenao.com/search.php?db=999&url=%turl', '#http://3d.iqdb.org/?url=%turl', '#http://regex.info/exif.cgi?imgurl=%url', '# uploaders:', '#http://imgur.com/upload?url=%url;text:Upload to imgur', '#http://omploader.org/upload?url1=%url;text:Upload to omploader', '# "View Same" in archives:', '#//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.installgentoo.net/%board/image/%md5;text:View same on installgentoo /%board/'].join('\n'),
time: '%m/%d/%y(%a)%H:%M:%S',
backlink: '>>%id',
fileInfo: '%l (%p%s, %r)',
@ -2328,22 +2328,25 @@
return;
}
this.links = links;
this.link = $.el('a', {
target: '_blank'
});
return Post.prototype.callbacks.push({
name: 'Sauce',
cb: this.node
});
},
createSauceLink: function(link) {
var el, href, m, text;
link = link.replace(/\$(turl|url|md5|board)/g, function(parameter) {
var m, text;
link = link.replace(/%(t?url|md5|board)/g, function(parameter) {
switch (parameter) {
case '$turl':
case '%turl':
return "' + post.file.thumbURL + '";
case '$url':
case '%url':
return "' + post.file.URL + '";
case '$md5':
case '%md5':
return "' + encodeURIComponent(post.file.MD5) + '";
case '$board':
case '%board':
return "' + post.board + '";
default:
return parameter;
@ -2351,17 +2354,7 @@
});
text = (m = link.match(/;text:(.+)$/)) ? m[1] : link.match(/(\w+)\.\w+\//)[1];
link = link.replace(/;text:.+$/, '');
href = Function('post', "return '" + link + "'");
el = $.el('a', {
target: '_blank',
textContent: text
});
return function(post) {
var a;
a = el.cloneNode(true);
a.href = href(post);
return a;
};
return Function('post', 'a', "a.href = '" + link + "';\na.textContent = '" + text + "';\nreturn a;");
},
node: function() {
var link, nodes, _i, _len, _ref;
@ -2372,7 +2365,7 @@
_ref = Sauce.links;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
link = _ref[_i];
nodes.push($.tn('\u00A0'), link(this));
nodes.push($.tn('\u00A0'), link(this, Sauce.link.cloneNode(true)));
}
return $.add(this.file.info, nodes);
}

View File

@ -106,19 +106,19 @@ Config =
''
].join '\n'
sauces: [
'http://iqdb.org/?url=$turl'
'http://www.google.com/searchbyimage?image_url=$turl'
'#http://tineye.com/search?url=$turl'
'#http://saucenao.com/search.php?db=999&url=$turl'
'#http://3d.iqdb.org/?url=$turl'
'#http://regex.info/exif.cgi?imgurl=$url'
'http://iqdb.org/?url=%turl'
'http://www.google.com/searchbyimage?image_url=%turl'
'#http://tineye.com/search?url=%turl'
'#http://saucenao.com/search.php?db=999&url=%turl'
'#http://3d.iqdb.org/?url=%turl'
'#http://regex.info/exif.cgi?imgurl=%url'
'# uploaders:'
'#http://imgur.com/upload?url=$url;text:Upload to imgur'
'#http://omploader.org/upload?url1=$url;text:Upload to omploader'
'#http://imgur.com/upload?url=%url;text:Upload to imgur'
'#http://omploader.org/upload?url1=%url;text:Upload to omploader'
'# "View Same" in archives:'
'#http://archive.foolz.us/_/search/image/$md5/;text:View same on foolz'
'#http://archive.foolz.us/$board/search/image/$md5/;text:View same on foolz /$board/'
'#https://archive.installgentoo.net/$board/image/$md5;text:View same on installgentoo /$board/'
'#//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.installgentoo.net/%board/image/%md5;text:View same on installgentoo /%board/'
].join '\n'
time: '%m/%d/%y(%a)%H:%M:%S'
backlink: '>>%id'
@ -2119,38 +2119,36 @@ Sauce =
links.push @createSauceLink link.trim()
return unless links.length
@links = links
@link = $.el 'a', target: '_blank'
Post::callbacks.push
name: 'Sauce'
cb: @node
createSauceLink: (link) ->
link = link.replace /\$(turl|url|md5|board)/g, (parameter) ->
link = link.replace /%(t?url|md5|board)/g, (parameter) ->
switch parameter
when '$turl'
when '%turl'
"' + post.file.thumbURL + '"
when '$url'
when '%url'
"' + post.file.URL + '"
when '$md5'
when '%md5'
"' + encodeURIComponent(post.file.MD5) + '"
when '$board'
when '%board'
"' + post.board + '"
else
parameter
text = if m = link.match(/;text:(.+)$/) then m[1] else link.match(/(\w+)\.\w+\//)[1]
link = link.replace /;text:.+$/, ''
href = Function 'post', "return '#{link}'"
el = $.el 'a',
target: '_blank'
textContent: text
(post) ->
a = el.cloneNode true
a.href = href post
a
Function 'post', 'a', """
a.href = '#{link}';
a.textContent = '#{text}';
return a;
"""
node: ->
return if @isClone or !@file
nodes = []
for link in Sauce.links
# \u00A0 is nbsp
nodes.push $.tn('\u00A0'), link @
nodes.push $.tn('\u00A0'), link @, Sauce.link.cloneNode true
$.add @file.info, nodes
RevealSpoilers =