Merge commit 'f2bb9b00a343a305e04f4f29285084c758471c34' (BoardsJSON -> BoardConfig.)

This commit is contained in:
ccd0 2016-07-10 01:41:16 -07:00
commit 52e7749f72
4 changed files with 12 additions and 12 deletions

View File

@ -1,26 +1,26 @@
BoardsJSON = BoardConfig =
cbs: [] cbs: []
init: -> init: ->
if (Conf['boardsJSON'].lastChecked or 0) < Date.now() - 2 * $.HOUR if (Conf['boardConfig'].lastChecked or 0) < Date.now() - 2 * $.HOUR
$.ajax '//a.4cdn.org/boards.json', onloadend: @load $.ajax '//a.4cdn.org/boards.json', onloadend: @load
else else
@set Conf['boardsJSON'].boards @set Conf['boardConfig'].boards
load: -> load: ->
if @status is 200 if @status is 200
boards = {} boards = {}
for board in @response.boards for board in @response.boards
boards[board.board] = board boards[board.board] = board
$.set 'boardsJSON', {boards, lastChecked: Date.now()} $.set 'boardConfig', {boards, lastChecked: Date.now()}
else else
{boards} = Conf['boardsJSON'] {boards} = Conf['boardConfig']
new Notice 'warning', "Failed to load boards JSON. Error #{@statusText} (#{@status})", 20 new Notice 'warning', "Failed to load board configuration data. Error #{@statusText} (#{@status})", 20
BoardsJSON.set boards BoardConfig.set boards
set: (@boards) -> set: (@boards) ->
for ID, board of @boards for ID, board of @boards
g.boards[ID]?.json = board g.boards[ID]?.config = board
for cb in @cbs for cb in @cbs
$.queueTask cb $.queueTask cb
return return

View File

@ -190,7 +190,7 @@ Settings =
# Make sure to export the most recent data. # Make sure to export the most recent data.
$.get Conf, (Conf) -> $.get Conf, (Conf) ->
# Don't export cached JSON data. # Don't export cached JSON data.
delete Conf['boardsJSON'] delete Conf['boardConfig']
Settings.downloadExport {version: g.VERSION, date: Date.now(), Conf} Settings.downloadExport {version: g.VERSION, date: Date.now(), Conf}
downloadExport: (data) -> downloadExport: (data) ->

View File

@ -4,6 +4,6 @@ class Board
constructor: (@ID) -> constructor: (@ID) ->
@threads = new SimpleDict() @threads = new SimpleDict()
@posts = new SimpleDict() @posts = new SimpleDict()
@json = BoardsJSON.boards?[@ID] @config = BoardConfig.boards?[@ID]
g.boards[@] = @ g.boards[@] = @

View File

@ -43,7 +43,7 @@ Main =
for db in DataBoard.keys for db in DataBoard.keys
Conf[db] = boards: {} Conf[db] = boards: {}
Conf['boardsJSON'] = boards: {} Conf['boardConfig'] = boards: {}
Conf['archives'] = Redirect.archives Conf['archives'] = Redirect.archives
Conf['selectedArchives'] = {} Conf['selectedArchives'] = {}
Conf['cooldowns'] = {} Conf['cooldowns'] = {}
@ -431,7 +431,7 @@ Main =
features: [ features: [
['Polyfill', Polyfill] ['Polyfill', Polyfill]
['Boards JSON', BoardsJSON] ['Board Configuration', BoardConfig]
['Normalize URL', NormalizeURL] ['Normalize URL', NormalizeURL]
['Captcha Configuration', Captcha.replace] ['Captcha Configuration', Captcha.replace]
['Redirect', Redirect] ['Redirect', Redirect]