BoardsJSON -> BoardConfig.

This commit is contained in:
ccd0 2016-01-28 21:53:11 -08:00
parent a22ca7a3f3
commit f2bb9b00a3
5 changed files with 13 additions and 13 deletions

View File

@ -108,7 +108,7 @@ module.exports = (grunt) ->
'src/classes/Connection.coffee'
'src/classes/Fetcher.coffee'
'src/General/Polyfill.coffee'
'src/General/BoardsJSON.coffee'
'src/General/BoardConfig.coffee'
'src/General/Header.coffee'
'src/General/Index.coffee'
'src/General/Build.coffee'

View File

@ -1,26 +1,26 @@
BoardsJSON =
BoardConfig =
cbs: []
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
else
@set Conf['boardsJSON'].boards
@set Conf['boardConfig'].boards
load: ->
if @status is 200
boards = {}
for board in @response.boards
boards[board.board] = board
$.set 'boardsJSON', {boards, lastChecked: Date.now()}
$.set 'boardConfig', {boards, lastChecked: Date.now()}
else
{boards} = Conf['boardsJSON']
new Notice 'warning', "Failed to load boards JSON. Error #{@statusText} (#{@status})", 20
BoardsJSON.set boards
{boards} = Conf['boardConfig']
new Notice 'warning', "Failed to load board configuration data. Error #{@statusText} (#{@status})", 20
BoardConfig.set boards
set: (@boards) ->
for ID, board of @boards
g.boards[ID]?.json = board
g.boards[ID]?.config = board
for cb in @cbs
$.queueTask cb
return

View File

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

View File

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

View File

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