Begin work on supporting other imageboards.

This commit is contained in:
ccd0 2016-10-08 22:59:13 -07:00
parent 39792ad2ca
commit 2fb01f85b6
7 changed files with 24 additions and 1 deletions

View File

@ -32,7 +32,7 @@ $(eval $(shell node tools/pkgvars.js))
version = $(shell node -p "JSON.parse(require('fs').readFileSync('version.json')).version")
source_directories := \
globals config css platform classes \
globals config css platform classes site \
Archive Filtering General Images Linkification \
Menu Miscellaneous Monitoring Posting Quotelinks \
main

View File

@ -1049,3 +1049,7 @@ Config =
'Max Replies': 1000
'Autohiding Scrollbar': false
siteSoftware: """
4chan.org yotsuba
"""

View File

@ -100,6 +100,9 @@ Main =
new Notice 'info', el, 15
initFeatures: ->
Site.init()
return unless Site.software
{hostname, search} = location
pathname = location.pathname.split /\/+/
g.BOARD = new Board pathname[1] unless hostname is 'www.4chan.org'

1
src/site/SW.js Normal file
View File

@ -0,0 +1 @@
SW = {};

View File

@ -0,0 +1 @@
SW.tinyboard = {}

View File

@ -0,0 +1 @@
SW.yotsuba = {}

13
src/site/Site.coffee Normal file
View File

@ -0,0 +1,13 @@
Site =
init: ->
swDict = {}
for line in Conf['siteSoftware'].split('\n') when line[0] isnt '#'
[hostname, software] = line.split(' ')
swDict[hostname] = software if software of SW
{hostname} = location
while hostname and hostname not of swDict
hostname = hostname.replace(/^[^.]*\.?/, '')
return unless hostname
@hostname = hostname
@software = swDict[hostname]
$.extend @, SW[@software]