use archive when 4chan unreachable, but don't mark post deleted

This commit is contained in:
ccd0 2014-08-01 22:21:32 -07:00
parent e9ac861ad9
commit 546f734ce0
2 changed files with 19 additions and 11 deletions

View File

@ -183,6 +183,7 @@ Gallery =
error: (file, thumb) -> error: (file, thumb) ->
if file.error?.code is MediaError.MEDIA_ERR_DECODE if file.error?.code is MediaError.MEDIA_ERR_DECODE
return new Notice 'error', 'Corrupt or unplayable video', 30 return new Notice 'error', 'Corrupt or unplayable video', 30
return unless file.src.split('/')[2] is 'i.4cdn.org'
ImageCommon.error file, g.posts[file.dataset.post], null, (URL) -> ImageCommon.error file, g.posts[file.dataset.post], null, (URL) ->
return unless URL return unless URL
thumb.href = URL thumb.href = URL

View File

@ -17,31 +17,38 @@ ImageCommon =
return cb URL if (post.isDead or post.file.isDead) and file.src.split('/')[2] is 'i.4cdn.org' return cb URL if (post.isDead or post.file.isDead) and file.src.split('/')[2] is 'i.4cdn.org'
timeoutID = setTimeout cb, delay, post.file.URL if delay? timeoutID = setTimeout (-> cb URL), delay if delay?
return if post.isDead or post.file.isDead return if post.isDead or post.file.isDead
kill = (fileOnly) -> redirect = ->
clearTimeout timeoutID if delay? if file.src.split('/')[2] is 'i.4cdn.org'
post.kill fileOnly clearTimeout timeoutID if delay?
cb URL cb URL
<% if (type === 'crx') { %> <% if (type === 'crx') { %>
$.ajax post.file.URL, $.ajax post.file.URL,
onloadend: -> onloadend: ->
return if @status isnt 404 if @status is 200
kill true URL = post.file.URL
else
post.kill true if @status is 404
redirect()
, ,
type: 'head' type: 'head'
<% } else { %> <% } else { %>
# XXX CORS for i.4cdn.org WHEN? # XXX CORS for i.4cdn.org WHEN?
$.ajax "//a.4cdn.org/#{post.board}/thread/#{post.thread}.json", onload: -> $.ajax "//a.4cdn.org/#{post.board}/thread/#{post.thread}.json", onload: ->
return kill() if @status is 404 post.kill() if @status is 404
return if @status isnt 200 return redirect() if @status isnt 200
for postObj in @response.posts for postObj in @response.posts
break if postObj.no is post.ID break if postObj.no is post.ID
if postObj.no isnt post.ID if postObj.no isnt post.ID
kill() post.kill()
redirect()
else if postObj.filedeleted else if postObj.filedeleted
kill true post.kill true
redirect()
else
URL = post.file.URL
<% } %> <% } %>
# Add controls, but not until the mouse is moved over the video. # Add controls, but not until the mouse is moved over the video.