Allow fetching posts for archives that require credentials.
This commit is contained in:
parent
2cbf3d909d
commit
0b55e34361
@ -103,6 +103,7 @@
|
|||||||
"domain": "beta.foolz.us",
|
"domain": "beta.foolz.us",
|
||||||
"http": true,
|
"http": true,
|
||||||
"https": true,
|
"https": true,
|
||||||
|
"withCredentials": true,
|
||||||
"software": "foolfuuka",
|
"software": "foolfuuka",
|
||||||
"boards": ["a", "co", "gd", "h", "jp", "m", "mlp", "q", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"],
|
"boards": ["a", "co", "gd", "h", "jp", "m", "mlp", "q", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"],
|
||||||
"files": ["a", "gd", "h", "jp", "m", "q", "tg", "u", "vg", "vp", "vr", "wsg"]
|
"files": ["a", "gd", "h", "jp", "m", "q", "tg", "u", "vg", "vp", "vr", "wsg"]
|
||||||
|
|||||||
16
lib/$.coffee
16
lib/$.coffee
@ -49,7 +49,7 @@ $.ajax = (url, options, extra={}) ->
|
|||||||
r
|
r
|
||||||
$.cache = do ->
|
$.cache = do ->
|
||||||
reqs = {}
|
reqs = {}
|
||||||
(url, cb) ->
|
(url, cb, options) ->
|
||||||
if req = reqs[url]
|
if req = reqs[url]
|
||||||
if req.readyState is 4
|
if req.readyState is 4
|
||||||
cb.call req, req.evt
|
cb.call req, req.evt
|
||||||
@ -57,13 +57,13 @@ $.cache = do ->
|
|||||||
req.callbacks.push cb
|
req.callbacks.push cb
|
||||||
return
|
return
|
||||||
rm = -> delete reqs[url]
|
rm = -> delete reqs[url]
|
||||||
req = $.ajax url,
|
req = $.ajax url, options
|
||||||
onload: (e) ->
|
$.on req, 'load', (e) ->
|
||||||
cb.call @, e for cb in @callbacks
|
cb.call @, e for cb in @callbacks
|
||||||
@evt = e
|
@evt = e
|
||||||
delete @callbacks
|
delete @callbacks
|
||||||
onabort: rm
|
$.on req, 'abort', rm
|
||||||
onerror: rm
|
$.on req, 'error', rm
|
||||||
req.callbacks = [cb]
|
req.callbacks = [cb]
|
||||||
reqs[url] = req
|
reqs[url] = req
|
||||||
$.cb =
|
$.cb =
|
||||||
|
|||||||
@ -74,7 +74,9 @@ Redirect =
|
|||||||
# Remove necessary HTTPS procotol in September 2013.
|
# Remove necessary HTTPS procotol in September 2013.
|
||||||
if archive.name in ['Foolz', 'NSFW Foolz']
|
if archive.name in ['Foolz', 'NSFW Foolz']
|
||||||
protocol = 'https://'
|
protocol = 'https://'
|
||||||
"#{protocol}#{archive.domain}/_/api/chan/post/?board=#{boardID}&num=#{postID}"
|
URL = new String "#{protocol}#{archive.domain}/_/api/chan/post/?board=#{boardID}&num=#{postID}"
|
||||||
|
URL.archive = archive
|
||||||
|
URL
|
||||||
|
|
||||||
file: (archive, {boardID, filename}) ->
|
file: (archive, {boardID, filename}) ->
|
||||||
"#{Redirect.protocol archive}#{archive.domain}/#{boardID}/full_image/#{filename}"
|
"#{Redirect.protocol archive}#{archive.domain}/#{boardID}/full_image/#{filename}"
|
||||||
|
|||||||
@ -71,8 +71,10 @@ Get =
|
|||||||
$.cache "//api.4chan.org/#{boardID}/res/#{threadID}.json", ->
|
$.cache "//api.4chan.org/#{boardID}/res/#{threadID}.json", ->
|
||||||
Get.fetchedPost @, boardID, threadID, postID, root, context
|
Get.fetchedPost @, boardID, threadID, postID, root, context
|
||||||
else if url = Redirect.to 'post', {boardID, postID}
|
else if url = Redirect.to 'post', {boardID, postID}
|
||||||
$.cache url, ->
|
$.cache url,
|
||||||
Get.archivedPost @, boardID, postID, root, context
|
-> Get.archivedPost @, boardID, postID, root, context
|
||||||
|
,
|
||||||
|
withCredentials: url.archive.withCredentials
|
||||||
insert: (post, root, context) ->
|
insert: (post, root, context) ->
|
||||||
# Stop here if the container has been removed while loading.
|
# Stop here if the container has been removed while loading.
|
||||||
return unless root.parentNode
|
return unless root.parentNode
|
||||||
@ -97,8 +99,10 @@ Get =
|
|||||||
if status not in [200, 304]
|
if status not in [200, 304]
|
||||||
# The thread can die by the time we check a quote.
|
# The thread can die by the time we check a quote.
|
||||||
if url = Redirect.to 'post', {boardID, postID}
|
if url = Redirect.to 'post', {boardID, postID}
|
||||||
$.cache url, ->
|
$.cache url,
|
||||||
Get.archivedPost @, boardID, postID, root, context
|
-> Get.archivedPost @, boardID, postID, root, context
|
||||||
|
,
|
||||||
|
withCredentials: url.archive.withCredentials
|
||||||
else
|
else
|
||||||
$.addClass root, 'warning'
|
$.addClass root, 'warning'
|
||||||
root.textContent =
|
root.textContent =
|
||||||
@ -115,8 +119,10 @@ Get =
|
|||||||
if post.no > postID
|
if post.no > postID
|
||||||
# The post can be deleted by the time we check a quote.
|
# The post can be deleted by the time we check a quote.
|
||||||
if url = Redirect.to 'post', {boardID, postID}
|
if url = Redirect.to 'post', {boardID, postID}
|
||||||
$.cache url, ->
|
$.cache url,
|
||||||
Get.archivedPost @, boardID, postID, root, context
|
-> Get.archivedPost @, boardID, postID, root, context
|
||||||
|
,
|
||||||
|
withCredentials: url.archive.withCredentials
|
||||||
else
|
else
|
||||||
$.addClass root, 'warning'
|
$.addClass root, 'warning'
|
||||||
root.textContent = "Post No.#{postID} was not found."
|
root.textContent = "Post No.#{postID} was not found."
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user