diff --git a/src/General/BoardConfig.coffee b/src/General/BoardConfig.coffee index fb8ee4f06..842cd84da 100644 --- a/src/General/BoardConfig.coffee +++ b/src/General/BoardConfig.coffee @@ -48,6 +48,11 @@ BoardConfig = domain: (board) -> "boards.#{if BoardConfig.isSFW(board) then '4channel' else '4chan'}.org" + isArchived: (board) -> + # assume archive exists if no data available to prevent cleaning of archived threads + data = (@boards or Conf['boardConfig'].boards)[board] + !data or data.is_archived + noAudio: (boardID) -> return false unless Site.software is 'yotsuba' boards = @boards or Conf['boardConfig'].boards diff --git a/src/classes/DataBoard.coffee b/src/classes/DataBoard.coffee index 3a07e3d4c..811dabd81 100644 --- a/src/classes/DataBoard.coffee +++ b/src/classes/DataBoard.coffee @@ -116,13 +116,9 @@ class DataBoard val or defaultValue clean: -> - # XXX not yet multisite ready - return unless Site.software is 'yotsuba' siteID = Site.hostname - for boardID, val of @data[siteID].boards @deleteIfEmpty {siteID, boardID} - now = Date.now() unless now - 2 * $.HOUR < (@data[siteID].lastChecked or 0) <= now @data[siteID].lastChecked = now @@ -131,12 +127,18 @@ class DataBoard return ajaxClean: (boardID) -> - $.cache "#{location.protocol}//a.4cdn.org/#{boardID}/threads.json", (e1) => - return unless e1.target.status is 200 - response1 = e1.target.response - $.cache "#{location.protocol}//a.4cdn.org/#{boardID}/archive.json", (e2) => - return unless e2.target.status is 200 or boardID in ['b', 'f', 'trash', 'bant'] - @ajaxCleanParse boardID, response1, e2.target.response + that = @ + siteID = Site.hostname + threadsList = Site.urls.threadsListJSON?({siteID, boardID}) + return unless threadsList + $.cache threadsList, -> + return unless @status is 200 + archiveList = Site.urls.archiveListJSON?({siteID, boardID}) + return that.ajaxCleanParse(boardID, @response) unless archiveList + response1 = @response + $.cache archiveList, -> + return unless @status is 200 + that.ajaxCleanParse(boardID, response1, @response) ajaxCleanParse: (boardID, response1, response2) -> siteID = Site.hostname diff --git a/src/site/SW.tinyboard.coffee b/src/site/SW.tinyboard.coffee index 78f03b1ef..412724b39 100644 --- a/src/site/SW.tinyboard.coffee +++ b/src/site/SW.tinyboard.coffee @@ -60,6 +60,9 @@ SW.tinyboard = threadJSON: ({siteID, boardID, threadID}) -> root = Conf['siteProperties'][siteID]?.root if root then "#{root}#{boardID}/res/#{threadID}.json" else '' + threadsListJSON: ({siteID, boardID}) -> + root = Conf['siteProperties'][siteID]?.root + if root then "#{root}#{boardID}/threads.json" else '' selectors: board: 'form[name="postcontrols"]' diff --git a/src/site/SW.yotsuba.coffee b/src/site/SW.yotsuba.coffee index ba51fb569..b1c3a0d15 100644 --- a/src/site/SW.yotsuba.coffee +++ b/src/site/SW.yotsuba.coffee @@ -4,6 +4,8 @@ SW.yotsuba = urls: thread: ({boardID, threadID}) -> "#{location.protocol}//#{BoardConfig.domain(boardID)}/#{boardID}/thread/#{threadID}" threadJSON: ({boardID, threadID}) -> "#{location.protocol}//a.4cdn.org/#{boardID}/thread/#{threadID}.json" + threadsListJSON: ({boardID}) -> "#{location.protocol}//a.4cdn.org/#{boardID}/threads.json" + archiveListJSON: ({boardID}) -> if BoardConfig.isArchived(boardID) then "#{location.protocol}//a.4cdn.org/#{boardID}/archive.json" else '' selectors: board: '.board'