add setting to link to 4chan X catalog

This commit is contained in:
ccd0 2014-09-20 18:02:46 -07:00
parent 7a3e3acee8
commit 3dd0ed6026
6 changed files with 30 additions and 11 deletions

View File

@ -5,6 +5,10 @@ Config =
true
'Replace the board index with a dynamically generated one supporting searching, sorting, and infinite scrolling.'
]
'Use 4chan X Catalog': [
false
'Link to 4chan X\'s catalog instead of the native 4chan one.'
]
'Catalog Links': [
true
'Add toggle link in header menu to turn Navigation links into links to each board\'s catalog.'

View File

@ -197,7 +197,7 @@ Header =
if Conf['External Catalog']
a.href = CatalogLinks.external board
else
a.href += 'catalog'
a.href += if Conf['JSON Navigation'] and Conf['Use 4chan X Catalog'] then '#catalog' else 'catalog'
$.addClass a, 'catalog'
$.addClass a, 'navSmall' if board is '@'

View File

@ -1,8 +1,12 @@
Index =
showHiddenThreads: false
init: ->
return if g.BOARD.ID is 'f' or g.VIEW isnt 'index' or !Conf['JSON Navigation']
@cb.popstate()
return if g.BOARD.ID is 'f' or !Conf['JSON Navigation']
if g.VIEW is 'thread' and Conf['Use 4chan X Catalog']
$.ready ->
for link in $$ '.navLinks.desktop a' when link.pathname is "/#{g.BOARD}/catalog"
link.href = "/#{g.BOARD}/#catalog"
return if g.VIEW isnt 'index'
@board = "#{g.BOARD}"
@ -14,6 +18,10 @@ Index =
name: 'Catalog Features'
cb: @catalogNode
if Conf['Use 4chan X Catalog'] and Conf['Index Mode'] is 'catalog'
Index.setMode Conf['Previous Index Mode']
@cb.popstate()
@button = $.el 'a',
className: 'index-refresh-shortcut fa fa-refresh'
title: 'Refresh'
@ -79,10 +87,11 @@ Index =
@root = $.el 'div', className: 'board'
@pagelist = $.el 'div', className: 'pagelist'
$.extend @pagelist, <%= importHTML('Features/Index-pagelist') %>
$('.cataloglink a', @pagelist).href = if Conf['Use 4chan X Catalog'] then '#catalog' else "/#{g.BOARD}/catalog"
@navLinks = $.el 'div', className: 'navLinks'
$.extend @navLinks, <%= importHTML('Features/Index-navlinks') %>
$('.returnlink a', @navLinks).href = "//boards.4chan.org/#{g.BOARD}/"
$('.cataloglink a', @navLinks).href = "//boards.4chan.org/#{g.BOARD}/catalog"
$('.returnlink a', @navLinks).href = if Conf['Use 4chan X Catalog'] then '#index' else "/#{g.BOARD}/"
$('.cataloglink a', @navLinks).href = if Conf['Use 4chan X Catalog'] then '#catalog' else "/#{g.BOARD}/catalog"
@searchInput = $ '#index-search', @navLinks
@hideLabel = $ '#hidden-label', @navLinks
@currentPage = @getCurrentPage()
@ -238,8 +247,8 @@ Index =
Index.buildIndex()
hashchange: (e) ->
switch command = location.hash[1..]
when 'paged', 'infinite', 'all pages', 'catalog'
mode = command
when 'paged', 'infinite', 'all-pages', 'catalog'
mode = command.replace /-/g, ' '
when 'index'
mode = Conf['Previous Index Mode']
if mode

View File

@ -1,5 +1,5 @@
<span class="brackets-wrap returnlink"><a href="javascript:;">Return</a></span>
<span class="brackets-wrap cataloglink"><a href="javascript:;">Catalog</a></span>
<span class="brackets-wrap returnlink"><a href="./">Return</a></span>
<span class="brackets-wrap cataloglink"><a href="./catalog">Catalog</a></span>
<span class="brackets-wrap bottomlink"><a href="#bottom">Bottom</a></span>
<span class="brackets-wrap" id="index-last-refresh"><time title="Last index refresh">...</time></span>
<input type="search" id="index-search" class="field" placeholder="Search">

View File

@ -24,7 +24,10 @@ CatalogLinks =
CatalogLinks.set @checked
set: (useCatalog) ->
path = if useCatalog then 'catalog' else ''
path = if useCatalog
if Conf['JSON Navigation'] and Conf['Use 4chan X Catalog'] then '#catalog' else 'catalog'
else
''
generateURL = if useCatalog and Conf['External Catalog']
CatalogLinks.external

View File

@ -103,6 +103,9 @@ Keybinds =
# Board Navigation
when Conf['Front page']
if Conf['JSON Navigation'] and g.VIEW is 'index'
if Conf['Use 4chan X Catalog'] and Conf['Index Mode'] is 'catalog'
window.location = '#index'
return
return unless Conf['Index Mode'] in ['paged', 'infinite']
Index.userPageNav 1
else
@ -134,7 +137,7 @@ Keybinds =
if Conf['External Catalog']
window.location = CatalogLinks.external(g.BOARD.ID)
else
window.location = "/#{g.BOARD}/catalog"
window.location = "/#{g.BOARD}/" + if Conf['JSON Navigation'] and Conf['Use 4chan X Catalog'] then '#catalog' else 'catalog'
# Thread Navigation
when Conf['Next thread']
return if g.VIEW isnt 'index' or !threadRoot