Support archived threads on kissu.moe in Thread Watcher.

This commit is contained in:
ccd0 2019-12-13 03:09:12 -08:00
parent 24526105b0
commit 2bc7b175dc
2 changed files with 15 additions and 8 deletions

View File

@ -332,12 +332,13 @@ ThreadWatcher =
return if data.last is -1 # 404 or no JSON API return if data.last is -1 # 404 or no JSON API
ThreadWatcher.fetch url, {siteID, force}, [thread], ThreadWatcher.parseStatus ThreadWatcher.fetch url, {siteID, force}, [thread], ThreadWatcher.parseStatus
parseStatus: ({siteID, boardID, threadID, data, newData}) -> parseStatus: (thread, isArchiveURL) ->
{siteID, boardID, threadID, data, newData, force} = thread
site = g.sites[siteID] site = g.sites[siteID]
if @status is 200 and @response if @status is 200 and @response
last = @response.posts[@response.posts.length-1].no last = @response.posts[@response.posts.length-1].no
replies = @response.posts.length-1 replies = @response.posts.length-1
isDead = isArchived = !!@response.posts[0].archived isDead = isArchived = !!(@response.posts[0].archived or isArchiveURL)
if isDead and Conf['Auto Prune'] if isDead and Conf['Auto Prune']
ThreadWatcher.rm siteID, boardID, threadID ThreadWatcher.rm siteID, boardID, threadID
return return
@ -380,7 +381,10 @@ ThreadWatcher =
ThreadWatcher.update siteID, boardID, threadID, newData ThreadWatcher.update siteID, boardID, threadID, newData
else if @status is 404 else if @status is 404
if site.mayLackJSON and !data.last? archiveURL = g.sites[siteID]?.urls.archivedThreadJSON?({siteID, boardID, threadID})
if !isArchiveURL and archiveURL
ThreadWatcher.fetch archiveURL, {siteID, force}, [thread, true], ThreadWatcher.parseStatus
else if site.mayLackJSON and !data.last?
ThreadWatcher.update siteID, boardID, threadID, {last: -1} ThreadWatcher.update siteID, boardID, threadID, {last: -1}
else else
ThreadWatcher.update siteID, boardID, threadID, {isDead: true} ThreadWatcher.update siteID, boardID, threadID, {isDead: true}
@ -403,12 +407,12 @@ ThreadWatcher =
href: 'javascript:;' href: 'javascript:;'
$.on x, 'click', ThreadWatcher.cb.rm $.on x, 'click', ThreadWatcher.cb.rm
{excerpt} = data {excerpt, isArchived} = data
excerpt or= "/#{boardID}/ - No.#{threadID}" excerpt or= "/#{boardID}/ - No.#{threadID}"
excerpt = ThreadWatcher.prefixes[siteID] + excerpt if Conf['Show Site Prefix'] excerpt = ThreadWatcher.prefixes[siteID] + excerpt if Conf['Show Site Prefix']
link = $.el 'a', link = $.el 'a',
href: g.sites[siteID]?.urls.thread({siteID, boardID, threadID}) or '' href: g.sites[siteID]?.urls.thread({siteID, boardID, threadID}, isArchived) or ''
title: excerpt title: excerpt
className: 'watcher-link' className: 'watcher-link'

View File

@ -41,14 +41,17 @@ SW.tinyboard =
false false
urls: urls:
thread: ({siteID, boardID, threadID}) -> "#{Conf['siteProperties'][siteID]?.root or "http://#{siteID}/"}#{boardID}/res/#{threadID}.html" thread: ({siteID, boardID, threadID}, isArchived) ->
"#{Conf['siteProperties'][siteID]?.root or "http://#{siteID}/"}#{boardID}/#{if isArchived then 'archive/' else ''}res/#{threadID}.html"
post: ({postID}) -> "##{postID}" post: ({postID}) -> "##{postID}"
index: ({siteID, boardID}) -> "#{Conf['siteProperties'][siteID]?.root or "http://#{siteID}/"}#{boardID}/" index: ({siteID, boardID}) -> "#{Conf['siteProperties'][siteID]?.root or "http://#{siteID}/"}#{boardID}/"
catalog: ({siteID, boardID}) -> "#{Conf['siteProperties'][siteID]?.root or "http://#{siteID}/"}#{boardID}/catalog.html" catalog: ({siteID, boardID}) -> "#{Conf['siteProperties'][siteID]?.root or "http://#{siteID}/"}#{boardID}/catalog.html"
archive: ({siteID, boardID}) -> "#{Conf['siteProperties'][siteID]?.root or "http://#{siteID}/"}#{boardID}/archive/" archive: ({siteID, boardID}) -> "#{Conf['siteProperties'][siteID]?.root or "http://#{siteID}/"}#{boardID}/archive/"
threadJSON: ({siteID, boardID, threadID}) -> threadJSON: ({siteID, boardID, threadID}, isArchived) ->
root = Conf['siteProperties'][siteID]?.root root = Conf['siteProperties'][siteID]?.root
if root then "#{root}#{boardID}/res/#{threadID}.json" else '' if root then "#{root}#{boardID}/#{if isArchived then 'archive/' else ''}res/#{threadID}.json" else ''
archivedThreadJSON: (thread) ->
SW.tinyboard.urls.threadJSON thread, true
threadsListJSON: ({siteID, boardID}) -> threadsListJSON: ({siteID, boardID}) ->
root = Conf['siteProperties'][siteID]?.root root = Conf['siteProperties'][siteID]?.root
if root then "#{root}#{boardID}/threads.json" else '' if root then "#{root}#{boardID}/threads.json" else ''