Merge branch 'master' into getarchivedquotes

This commit is contained in:
Nicolas Stepien 2012-06-17 18:46:51 +02:00
commit 72c219cc6f
2 changed files with 110 additions and 77 deletions

View File

@ -1971,7 +1971,9 @@
QR.mimeTypes.push(''); QR.mimeTypes.push('');
fileInput = $('input[type=file]', QR.el); fileInput = $('input[type=file]', QR.el);
fileInput.max = $('input[name=MAX_FILE_SIZE]').value; fileInput.max = $('input[name=MAX_FILE_SIZE]').value;
if ($.engine !== 'presto') {
fileInput.accept = mimeTypes; fileInput.accept = mimeTypes;
}
QR.spoiler = !!$('input[name=spoiler]'); QR.spoiler = !!$('input[name=spoiler]');
spoiler = $('#spoilerLabel', QR.el); spoiler = $('#spoilerLabel', QR.el);
spoiler.hidden = !QR.spoiler; spoiler.hidden = !QR.spoiler;
@ -3670,7 +3672,7 @@
a.className = 'quotelink'; a.className = 'quotelink';
a.setAttribute('onclick', "replyhl('" + id + "');"); a.setAttribute('onclick', "replyhl('" + id + "');");
} else { } else {
a.href = Redirect.thread(board, id, 'post'); a.href = Redirect.thread(board, 0, id);
a.className = 'deadlink'; a.className = 'deadlink';
a.target = '_blank'; a.target = '_blank';
if (Redirect.post(board, id)) { if (Redirect.post(board, id)) {
@ -3944,26 +3946,15 @@
}; };
Redirect = { Redirect = {
init: function() {
var path, url;
url = location.hostname === 'images.4chan.org' ? (path = location.pathname.split('/'), this.image(path[1], path[3])) : /^\d+$/.test(g.THREAD_ID) ? this.thread() : void 0;
if (url) {
return location.href = url;
}
},
image: function(board, filename) { image: function(board, filename) {
if (!Conf['404 Redirect']) {
return;
}
switch (board) { switch (board) {
case 'a': case 'a':
case 'co':
case 'jp': case 'jp':
case 'm': case 'm':
case 'tg': case 'tg':
case 'u': case 'u':
case 'vg': case 'vg':
return "http://archive.foolz.us/" + board + "/full_image/" + filename; return "//archive.foolz.us/" + board + "/full_image/" + filename;
} }
}, },
post: function(board, postID) { post: function(board, postID) {
@ -3977,22 +3968,18 @@
case 'u': case 'u':
case 'v': case 'v':
case 'vg': case 'vg':
case 'dev':
case 'foolz':
case 'kuku':
return "//archive.foolz.us/api/chan/post/board/" + board + "/num/" + postID + "/format/json"; return "//archive.foolz.us/api/chan/post/board/" + board + "/num/" + postID + "/format/json";
} }
}, },
thread: function(board, id, mode) { thread: function(board, threadID, postID) {
if (board == null) { var path, url;
board = g.BOARD; if (postID) {
} postID = postID.match(/\d+/)[0];
if (id == null) {
id = g.THREAD_ID;
}
if (mode == null) {
mode = 'thread';
}
if (!(Conf['404 Redirect'] || mode === 'post')) {
return;
} }
path = threadID ? "" + board + "/thread/" + threadID : "" + board + "/post/" + postID;
switch (board) { switch (board) {
case 'a': case 'a':
case 'co': case 'co':
@ -4003,31 +3990,57 @@
case 'u': case 'u':
case 'v': case 'v':
case 'vg': case 'vg':
return "http://archive.foolz.us/" + board + "/" + mode + "/" + id + "/"; case 'dev':
case 'foolz':
case 'kuku':
url = "//archive.foolz.us/" + path + "/";
if (threadID && postID) {
url += "#" + postID;
}
break;
case 'lit': case 'lit':
return "http://fuuka.warosu.org/" + board + "/" + mode + "/" + id; url = "//fuuka.warosu.org/" + path;
if (threadID && postID) {
url += "#p" + postID;
}
break;
case 'diy': case 'diy':
case 'g': case 'g':
case 'k': case 'k':
case 'sci': case 'sci':
return "https://archive.installgentoo.net/" + board + "/" + mode + "/" + id; url = "//archive.installgentoo.net/" + path;
if (threadID && postID) {
url += "#p" + postID;
}
break;
case 'cgl': case 'cgl':
case 'mu': case 'mu':
case 'w': case 'w':
return "http://archive.rebeccablacktech.com/" + board + "/" + mode + "/" + id; url = "//archive.rebeccablacktech.com/" + path;
if (threadID && postID) {
url += "#p" + postID;
}
break;
case 'an': case 'an':
case 'toy': case 'toy':
case 'x': case 'x':
return "http://archive.xfiles.to/" + board + "/" + mode + "/" + id; url = "http://archive.xfiles.to/" + path;
if (threadID && postID) {
url += "#p" + postID;
}
break;
case 'e': case 'e':
return "https://md401.homelinux.net/4chan/cgi-board.pl/" + board + "/" + mode + "/" + id; url = "https://md401.homelinux.net/4chan/cgi-board.pl/" + path;
if (threadID && postID) {
url += "#p" + postID;
}
break;
default: default:
if (mode === 'thread') { if (threadID) {
return "//boards.4chan.org/" + board + "/"; url = "//boards.4chan.org/" + board + "/";
} else {
return null;
} }
} }
return url || null;
} }
}; };
@ -4331,8 +4344,13 @@
return; return;
case 'images.4chan.org': case 'images.4chan.org':
$.ready(function() { $.ready(function() {
if (d.title === '4chan - 404') { var url;
return Redirect.init(); if (d.title === '4chan - 404' && Conf['404 Redirect']) {
path = location.pathname.split('/');
url = Redirect.image(path[1], path[3]);
if (url) {
return location.href = url;
}
} }
}); });
return; return;
@ -4432,7 +4450,9 @@
ready: function() { ready: function() {
var MutationObserver, a, board, nav, node, nodes, observer, _i, _j, _len, _len1, _ref, _ref1; var MutationObserver, a, board, nav, node, nodes, observer, _i, _j, _len, _len1, _ref, _ref1;
if (d.title === '4chan - 404') { if (d.title === '4chan - 404') {
Redirect.init(); if (Conf['404 Redirect'] && /^\d+$/.test(g.THREAD_ID)) {
location.href = Redirect.thread(g.BOARD, g.THREAD_ID, location.hash);
}
return; return;
} }
if (!$.id('navtopr')) { if (!$.id('navtopr')) {
@ -4838,7 +4858,7 @@ textarea.field {\
min-height: 120px;\ min-height: 120px;\
}\ }\
#qr .field:only-child {\ #qr .field:only-child {\
display: block;\ display: -webkit-box;\
min-width: 100%;\ min-width: 100%;\
}\ }\
.captcha {\ .captcha {\

View File

@ -1474,7 +1474,7 @@ QR =
QR.mimeTypes.push '' QR.mimeTypes.push ''
fileInput = $ 'input[type=file]', QR.el fileInput = $ 'input[type=file]', QR.el
fileInput.max = $('input[name=MAX_FILE_SIZE]').value fileInput.max = $('input[name=MAX_FILE_SIZE]').value
fileInput.accept = mimeTypes fileInput.accept = mimeTypes if $.engine isnt 'presto' # Opera's accept attribute is fucked up
QR.spoiler = !!$ 'input[name=spoiler]' QR.spoiler = !!$ 'input[name=spoiler]'
spoiler = $ '#spoilerLabel', QR.el spoiler = $ '#spoilerLabel', QR.el
@ -2864,7 +2864,7 @@ Quotify =
a.className = 'quotelink' a.className = 'quotelink'
a.setAttribute 'onclick', "replyhl('#{id}');" a.setAttribute 'onclick', "replyhl('#{id}');"
else else
a.href = Redirect.thread board, id, 'post' a.href = Redirect.thread board, 0, id
a.className = 'deadlink' a.className = 'deadlink'
a.target = '_blank' a.target = '_blank'
if Redirect.post board, id if Redirect.post board, id
@ -3089,51 +3089,59 @@ Favicon =
dead: 'data:image/gif;base64,R0lGODlhEAAQAKECAAAAAP8AAP///////yH5BAEKAAIALAAAAAAQABAAAAIvlI+pq+D9DAgUoFkPDlbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw==' dead: 'data:image/gif;base64,R0lGODlhEAAQAKECAAAAAP8AAP///////yH5BAEKAAIALAAAAAAQABAAAAIvlI+pq+D9DAgUoFkPDlbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw=='
Redirect = Redirect =
init: ->
url =
if location.hostname is 'images.4chan.org'
path = location.pathname.split '/'
@image path[1], path[3]
else if /^\d+$/.test g.THREAD_ID
@thread()
location.href = url if url
image: (board, filename) -> image: (board, filename) ->
# Do not use g.BOARD, the image url can originate from a cross-quote. # Do not use g.BOARD, the image url can originate from a cross-quote.
return unless Conf['404 Redirect']
switch board switch board
when 'a', 'co', 'jp', 'm', 'tg', 'u', 'vg' when 'a', 'jp', 'm', 'tg', 'u', 'vg'
"http://archive.foolz.us/#{board}/full_image/#{filename}" "//archive.foolz.us/#{board}/full_image/#{filename}"
# these will work whenever https://github.com/eksopl/fuuka/issues/23 is done # these will work whenever https://github.com/eksopl/fuuka/issues/23 is done
# when 'cgl', 'g', 'w' # when 'cgl', 'g', 'w'
# "http://archive.rebeccablacktech.com/#{board}/full_image/#{filename}" # "//archive.rebeccablacktech.com/#{board}/full_image/#{filename}"
# when 'an', 'toy', 'x' # when 'an', 'toy', 'x'
# "http://archive.xfiles.to/#{board}/full_image/#{filename}" # "http://archive.xfiles.to/#{board}/full_image/#{filename}"
# when 'e' # when 'e'
# "https://md401.homelinux.net/4chan/cgi-board.pl/#{board}/full_image/#{filename}" # "https://md401.homelinux.net/4chan/cgi-board.pl/#{board}/full_image/#{filename}"
post: (board, postID) -> post: (board, postID) ->
switch board switch board
when 'a', 'co', 'jp', 'm', 'tg', 'tv', 'u', 'v', 'vg' when 'a', 'co', 'jp', 'm', 'tg', 'tv', 'u', 'v', 'vg', 'dev', 'foolz', 'kuku'
"//archive.foolz.us/api/chan/post/board/#{board}/num/#{postID}/format/json" "//archive.foolz.us/api/chan/post/board/#{board}/num/#{postID}/format/json"
thread: (board=g.BOARD, id=g.THREAD_ID, mode='thread') -> thread: (board, threadID, postID) ->
return unless Conf['404 Redirect'] or mode is 'post' # 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', 'tg', 'tv', 'u', 'v', 'vg' when 'a', 'co', 'jp', 'm', 'tg', 'tv', 'u', 'v', 'vg', 'dev', 'foolz', 'kuku'
"http://archive.foolz.us/#{board}/#{mode}/#{id}/" url = "//archive.foolz.us/#{path}/"
if threadID and postID
url += "##{postID}"
when 'lit' when 'lit'
"http://fuuka.warosu.org/#{board}/#{mode}/#{id}" url = "//fuuka.warosu.org/#{path}"
if threadID and postID
url += "#p#{postID}"
when 'diy', 'g', 'k', 'sci' when 'diy', 'g', 'k', 'sci'
"https://archive.installgentoo.net/#{board}/#{mode}/#{id}" url = "//archive.installgentoo.net/#{path}"
if threadID and postID
url += "#p#{postID}"
when 'cgl', 'mu', 'w' when 'cgl', 'mu', 'w'
"http://archive.rebeccablacktech.com/#{board}/#{mode}/#{id}" url = "//archive.rebeccablacktech.com/#{path}"
if threadID and postID
url += "#p#{postID}"
when 'an', 'toy', 'x' when 'an', 'toy', 'x'
"http://archive.xfiles.to/#{board}/#{mode}/#{id}" url = "http://archive.xfiles.to/#{path}"
if threadID and postID
url += "#p#{postID}"
when 'e' when 'e'
"https://md401.homelinux.net/4chan/cgi-board.pl/#{board}/#{mode}/#{id}" url = "https://md401.homelinux.net/4chan/cgi-board.pl/#{path}"
if threadID and postID
url += "#p#{postID}"
else else
if mode is 'thread' if threadID
"//boards.4chan.org/#{board}/" url = "//boards.4chan.org/#{board}/"
else url or null
null
ImageHover = ImageHover =
init: -> init: ->
@ -3344,7 +3352,11 @@ Main =
window.location = 'javascript:Recaptcha.reload()' if e.keyCode is 8 and not e.target.value window.location = 'javascript:Recaptcha.reload()' if e.keyCode is 8 and not e.target.value
return return
when 'images.4chan.org' when 'images.4chan.org'
$.ready -> Redirect.init() if d.title is '4chan - 404' $.ready ->
if d.title is '4chan - 404' and Conf['404 Redirect']
path = location.pathname.split '/'
url = Redirect.image path[1], path[3]
location.href = url if url
return return
$.ready Options.init $.ready Options.init
@ -3438,7 +3450,8 @@ Main =
ready: -> ready: ->
if d.title is '4chan - 404' if d.title is '4chan - 404'
Redirect.init() if Conf['404 Redirect'] and /^\d+$/.test g.THREAD_ID
location.href = Redirect.thread g.BOARD, g.THREAD_ID, location.hash
return return
unless $.id 'navtopr' unless $.id 'navtopr'
return return
@ -3788,7 +3801,7 @@ textarea.field {
min-height: 120px; min-height: 120px;
} }
#qr .field:only-child { #qr .field:only-child {
display: block; display: -webkit-box;
min-width: 100%; min-width: 100%;
} }
.captcha { .captcha {