This commit is contained in:
parent
44feaf4eb7
commit
e43d91c9d3
@ -48,6 +48,11 @@ BoardConfig =
|
|||||||
domain: (board) ->
|
domain: (board) ->
|
||||||
"boards.#{if BoardConfig.isSFW(board) then '4channel' else '4chan'}.org"
|
"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) ->
|
noAudio: (boardID) ->
|
||||||
return false unless Site.software is 'yotsuba'
|
return false unless Site.software is 'yotsuba'
|
||||||
boards = @boards or Conf['boardConfig'].boards
|
boards = @boards or Conf['boardConfig'].boards
|
||||||
|
|||||||
@ -116,13 +116,9 @@ class DataBoard
|
|||||||
val or defaultValue
|
val or defaultValue
|
||||||
|
|
||||||
clean: ->
|
clean: ->
|
||||||
# XXX not yet multisite ready
|
|
||||||
return unless Site.software is 'yotsuba'
|
|
||||||
siteID = Site.hostname
|
siteID = Site.hostname
|
||||||
|
|
||||||
for boardID, val of @data[siteID].boards
|
for boardID, val of @data[siteID].boards
|
||||||
@deleteIfEmpty {siteID, boardID}
|
@deleteIfEmpty {siteID, boardID}
|
||||||
|
|
||||||
now = Date.now()
|
now = Date.now()
|
||||||
unless now - 2 * $.HOUR < (@data[siteID].lastChecked or 0) <= now
|
unless now - 2 * $.HOUR < (@data[siteID].lastChecked or 0) <= now
|
||||||
@data[siteID].lastChecked = now
|
@data[siteID].lastChecked = now
|
||||||
@ -131,12 +127,18 @@ class DataBoard
|
|||||||
return
|
return
|
||||||
|
|
||||||
ajaxClean: (boardID) ->
|
ajaxClean: (boardID) ->
|
||||||
$.cache "#{location.protocol}//a.4cdn.org/#{boardID}/threads.json", (e1) =>
|
that = @
|
||||||
return unless e1.target.status is 200
|
siteID = Site.hostname
|
||||||
response1 = e1.target.response
|
threadsList = Site.urls.threadsListJSON?({siteID, boardID})
|
||||||
$.cache "#{location.protocol}//a.4cdn.org/#{boardID}/archive.json", (e2) =>
|
return unless threadsList
|
||||||
return unless e2.target.status is 200 or boardID in ['b', 'f', 'trash', 'bant']
|
$.cache threadsList, ->
|
||||||
@ajaxCleanParse boardID, response1, e2.target.response
|
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) ->
|
ajaxCleanParse: (boardID, response1, response2) ->
|
||||||
siteID = Site.hostname
|
siteID = Site.hostname
|
||||||
|
|||||||
@ -60,6 +60,9 @@ SW.tinyboard =
|
|||||||
threadJSON: ({siteID, boardID, threadID}) ->
|
threadJSON: ({siteID, boardID, threadID}) ->
|
||||||
root = Conf['siteProperties'][siteID]?.root
|
root = Conf['siteProperties'][siteID]?.root
|
||||||
if root then "#{root}#{boardID}/res/#{threadID}.json" else ''
|
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:
|
selectors:
|
||||||
board: 'form[name="postcontrols"]'
|
board: 'form[name="postcontrols"]'
|
||||||
|
|||||||
@ -4,6 +4,8 @@ SW.yotsuba =
|
|||||||
urls:
|
urls:
|
||||||
thread: ({boardID, threadID}) -> "#{location.protocol}//#{BoardConfig.domain(boardID)}/#{boardID}/thread/#{threadID}"
|
thread: ({boardID, threadID}) -> "#{location.protocol}//#{BoardConfig.domain(boardID)}/#{boardID}/thread/#{threadID}"
|
||||||
threadJSON: ({boardID, threadID}) -> "#{location.protocol}//a.4cdn.org/#{boardID}/thread/#{threadID}.json"
|
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:
|
selectors:
|
||||||
board: '.board'
|
board: '.board'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user