Add Archivers submenu.

This commit is contained in:
noface 2012-10-20 00:59:54 +02:00
parent d9bd1ad402
commit dfc703fdfc
3 changed files with 177 additions and 59 deletions

View File

@ -4499,25 +4499,65 @@
}; };
ArchiveLink = { ArchiveLink = {
init: function() { init: function(post) {
var a; var div, entry, type, _i, _len, _ref;
a = $.el('a', { div = $.el('div', {
className: 'archive_link', textContent: 'Archive'
target: '_blank',
textContent: 'Archived post'
}); });
return Menu.addEntry({ entry = {
el: a, el: div,
open: function(post) { open: function(post) {
var href, path; var path;
path = $('a[title="Highlight this post"]', post.el).pathname.split('/'); path = $('a[title="Highlight this post"]', post.el).pathname.split('/');
if ((href = Redirect.thread(path[1], path[3], post.ID)) === ("//boards.4chan.org/" + path[1] + "/")) { if ((Redirect.thread(path[1], path[3], post.ID)) === ("//boards.4chan.org/" + path[1] + "/")) {
return false; return false;
} }
a.href = href;
return true; return true;
} },
children: []
};
_ref = [['Post', 'apost'], ['Name', 'name'], ['Tripcode', 'tripcode'], ['E-mail', 'email'], ['Subject', 'subject'], ['Filename', 'filename'], ['Image MD5', 'md5']];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
type = _ref[_i];
entry.children.push(this.createSubEntry(type[0], type[1]));
}
return Menu.addEntry(entry);
},
createSubEntry: function(text, type) {
var el, open;
el = $.el('a', {
textContent: text,
target: '_blank'
}); });
open = function(post) {
var path, value;
path = $('a[title="Highlight this post"]', post.el).pathname.split('/');
if (type !== 'apost') {
value = Filter[type](post);
}
if (value === false) {
return false;
}
switch (type) {
case 'name':
if (value === 'Anonymous' || value.length === 0) {
return false;
}
break;
case 'email':
if (value === 'sage' || value.length === 0) {
return false;
}
break;
case 'apost':
return el.href = Redirect.thread(path[1], path[3], post.ID);
}
return el.href = Redirect.thread(path[1], value, type, true);
};
return {
el: el,
open: open
};
} }
}; };
@ -4737,12 +4777,33 @@
return "//nsfw.foolz.us/_/api/chan/post/?board=" + board + "&num=" + postID; return "//nsfw.foolz.us/_/api/chan/post/?board=" + board + "&num=" + postID;
} }
}, },
thread: function(board, threadID, postID) { thread: function(board, threadID, postID, AL) {
var path, url; var ar, path, url;
if (postID) { ar = function(a) {
postID = postID.match(/\d+/)[0]; var path;
} if (AL) {
path = threadID ? "" + board + "/thread/" + threadID : "" + board + "/post/" + postID; if (postID === 'name') {
postID = 'username';
}
if (postID === 'md5') {
postID = 'image';
}
if (a === 'fuuka') {
return "" + board + "/search/" + postID + "/" + (encodeURIComponent(threadID));
} else if (a === 'gentoo') {
if (postID === 'image') {
return "" + board + "/image/" + (encodeURIComponent(threadID));
} else {
return "" + board + "/?task=search2&search_" + postID + "=" + (encodeURIComponent(threadID));
}
}
} else {
if (postID) {
postID = postID.match(/\d+/)[0];
}
return path = threadID ? "" + board + "/thread/" + threadID : "" + board + "/post/" + postID;
}
};
switch (board) { switch (board) {
case 'a': case 'a':
case 'co': case 'co':
@ -4757,30 +4818,34 @@
case 'wsg': case 'wsg':
case 'dev': case 'dev':
case 'foolz': case 'foolz':
path = ar('fuuka');
url = "//archive.foolz.us/" + path + "/"; url = "//archive.foolz.us/" + path + "/";
if (threadID && postID) { if (threadID && postID && !AL) {
url += "#" + postID; url += "#" + postID;
} }
break; break;
case 'u': case 'u':
case 'kuku': case 'kuku':
path = ar('fuuka');
url = "//nsfw.foolz.us/" + path + "/"; url = "//nsfw.foolz.us/" + path + "/";
if (threadID && postID) { if (threadID && postID && !AL) {
url += "#" + postID; url += "#" + postID;
} }
break; break;
case 'ck': case 'ck':
case 'lit': case 'lit':
path = ar('fuuka');
url = "//fuuka.warosu.org/" + path; url = "//fuuka.warosu.org/" + path;
if (threadID && postID) { if (threadID && postID && !AL) {
url += "#p" + postID; url += "#" + postID;
} }
break; break;
case 'diy': case 'diy':
case 'g': case 'g':
case 'sci': case 'sci':
path = ar('gentoo');
url = "//archive.installgentoo.net/" + path; url = "//archive.installgentoo.net/" + path;
if (threadID && postID) { if (threadID && postID && !AL) {
url += "#p" + postID; url += "#p" + postID;
} }
break; break;
@ -4788,8 +4853,9 @@
case 'mu': case 'mu':
case 'soc': case 'soc':
case 'w': case 'w':
path = ar('gentoo');
url = "//archive.rebeccablacktech.com/" + path; url = "//archive.rebeccablacktech.com/" + path;
if (threadID && postID) { if (threadID && postID && !AL) {
url += "#p" + postID; url += "#p" + postID;
} }
break; break;
@ -4800,14 +4866,9 @@
case 'r9k': case 'r9k':
case 'toy': case 'toy':
case 'x': case 'x':
path = ar('gentoo');
url = "http://archive.heinessen.com/" + path; url = "http://archive.heinessen.com/" + path;
if (threadID && postID) { if (threadID && postID && !AL) {
url += "#p" + postID;
}
break;
case 'e':
url = "https://www.cliché.net/4chan/cgi-board.pl/" + path;
if (threadID && postID) {
url += "#p" + postID; url += "#p" + postID;
} }
break; break;

View File

@ -1,4 +1,6 @@
master master
- noface
Archives now populate a submenu just like the quicklinks for the Filter.
2.36.0 2.36.0
- Mayhem - Mayhem

View File

@ -3695,19 +3695,56 @@ DownloadLink =
true true
ArchiveLink = ArchiveLink =
init: -> init: (post) ->
a = $.el 'a', div = $.el 'div',
className: 'archive_link' textContent: 'Archive'
target: '_blank'
textContent: 'Archived post' entry =
Menu.addEntry el: div
el: a open: (post) ->
open: (post) ->
path = $('a[title="Highlight this post"]', post.el).pathname.split '/' path = $('a[title="Highlight this post"]', post.el).pathname.split '/'
if (href = Redirect.thread path[1], path[3], post.ID) is "//boards.4chan.org/#{path[1]}/" if (Redirect.thread path[1], path[3], post.ID) is "//boards.4chan.org/#{path[1]}/"
return false return false
a.href = href
true true
children: []
for type in [
['Post', 'apost']
['Name', 'name']
['Tripcode', 'tripcode']
['E-mail', 'email']
['Subject', 'subject']
['Filename', 'filename']
['Image MD5', 'md5']
]
# Add a sub entry for each filter type.
entry.children.push @createSubEntry type[0], type[1]
Menu.addEntry entry
createSubEntry: (text, type) ->
el = $.el 'a',
textContent: text
target: '_blank'
open = (post) ->
path = $('a[title="Highlight this post"]', post.el).pathname.split '/'
unless type is 'apost'
value = Filter[type] post
# We want to parse the exact same stuff as Filter does already + maybe a few extras.
return false if value is false
switch type
when 'name'
if value is 'Anonymous' or value.length is 0
return false
when 'email'
if value is 'sage' or value.length is 0
return false
when 'apost'
return el.href = Redirect.thread path[1], path[3], post.ID
el.href = Redirect.thread path[1], value, type, true
return el: el, open: open
ThreadStats = ThreadStats =
init: -> init: ->
@ -3873,43 +3910,61 @@ Redirect =
"//archive.foolz.us/_/api/chan/post/?board=#{board}&num=#{postID}" "//archive.foolz.us/_/api/chan/post/?board=#{board}&num=#{postID}"
when 'u', 'kuku' when 'u', 'kuku'
"//nsfw.foolz.us/_/api/chan/post/?board=#{board}&num=#{postID}" "//nsfw.foolz.us/_/api/chan/post/?board=#{board}&num=#{postID}"
thread: (board, threadID, postID) -> thread: (board, threadID, postID, AL) ->
# keep the number only if the location.hash was sent f.e. ar = (a) ->
postID = postID.match(/\d+/)[0] if postID if AL
path = postID = 'username' if postID is 'name'
if threadID postID = 'image' if postID is 'md5'
"#{board}/thread/#{threadID}" if a is 'fuuka'
return "#{board}/search/#{postID}/#{encodeURIComponent threadID}"
else if a is 'gentoo'
if postID is 'image'
"#{board}/image/#{encodeURIComponent threadID}"
else
"#{board}/?task=search2&search_#{postID}=#{encodeURIComponent threadID}"
else else
"#{board}/post/#{postID}" # keep the number only if the location.hash was sent f.e.
postID = postID.match(/\d+/)[0] if postID
path =
if threadID
"#{board}/thread/#{threadID}"
else
"#{board}/post/#{postID}"
switch board switch board
when 'a', 'co', 'jp', 'm', 'q', 'sp', 'tg', 'tv', 'v', 'vg', 'wsg', 'dev', 'foolz' when 'a', 'co', 'jp', 'm', 'q', 'sp', 'tg', 'tv', 'v', 'vg', 'wsg', 'dev', 'foolz'
path = ar 'fuuka'
url = "//archive.foolz.us/#{path}/" url = "//archive.foolz.us/#{path}/"
if threadID and postID if threadID and postID and !AL
url += "##{postID}" url += "##{postID}"
when 'u', 'kuku' when 'u', 'kuku'
path = ar 'fuuka'
url = "//nsfw.foolz.us/#{path}/" url = "//nsfw.foolz.us/#{path}/"
if threadID and postID if threadID and postID and !AL
url += "##{postID}" url += "##{postID}"
when 'ck', 'lit' when 'ck', 'lit'
path = ar 'fuuka'
url = "//fuuka.warosu.org/#{path}" url = "//fuuka.warosu.org/#{path}"
if threadID and postID if threadID and postID and !AL
url += "#p#{postID}" url += "##{postID}"
when 'diy', 'g', 'sci' when 'diy', 'g', 'sci'
path = ar 'gentoo'
url = "//archive.installgentoo.net/#{path}" url = "//archive.installgentoo.net/#{path}"
if threadID and postID if threadID and postID and !AL
url += "#p#{postID}" url += "#p#{postID}"
when 'cgl', 'mu', 'soc', 'w' when 'cgl', 'mu', 'soc', 'w'
path = ar 'gentoo'
url = "//archive.rebeccablacktech.com/#{path}" url = "//archive.rebeccablacktech.com/#{path}"
if threadID and postID if threadID and postID and !AL
url += "#p#{postID}" url += "#p#{postID}"
when 'an', 'fit', 'k', 'mlp', 'r9k', 'toy', 'x' when 'an', 'fit', 'k', 'mlp', 'r9k', 'toy', 'x'
path = ar 'gentoo'
url = "http://archive.heinessen.com/#{path}" url = "http://archive.heinessen.com/#{path}"
if threadID and postID if threadID and postID and !AL
url += "#p#{postID}"
when 'e'
url = "https://www.cliché.net/4chan/cgi-board.pl/#{path}"
if threadID and postID
url += "#p#{postID}" url += "#p#{postID}"
#when 'e'
# url = "https://www.cliché.net/4chan/cgi-board.pl/#{path}"
# if threadID and postID
# url += "#p#{postID}"
else else
if threadID if threadID
url = "//boards.4chan.org/#{board}/" url = "//boards.4chan.org/#{board}/"