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 true
'Replace the board index with a dynamically generated one supporting searching, sorting, and infinite scrolling.' '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': [ 'Catalog Links': [
true true
'Add toggle link in header menu to turn Navigation links into links to each board\'s catalog.' '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'] if Conf['External Catalog']
a.href = CatalogLinks.external board a.href = CatalogLinks.external board
else 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, 'catalog'
$.addClass a, 'navSmall' if board is '@' $.addClass a, 'navSmall' if board is '@'

View File

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

View File

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

View File

@ -24,7 +24,10 @@ CatalogLinks =
CatalogLinks.set @checked CatalogLinks.set @checked
set: (useCatalog) -> 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'] generateURL = if useCatalog and Conf['External Catalog']
CatalogLinks.external CatalogLinks.external

View File

@ -103,6 +103,9 @@ Keybinds =
# Board Navigation # Board Navigation
when Conf['Front page'] when Conf['Front page']
if Conf['JSON Navigation'] and g.VIEW is 'index' 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'] return unless Conf['Index Mode'] in ['paged', 'infinite']
Index.userPageNav 1 Index.userPageNav 1
else else
@ -134,7 +137,7 @@ Keybinds =
if Conf['External Catalog'] if Conf['External Catalog']
window.location = CatalogLinks.external(g.BOARD.ID) window.location = CatalogLinks.external(g.BOARD.ID)
else 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 # Thread Navigation
when Conf['Next thread'] when Conf['Next thread']
return if g.VIEW isnt 'index' or !threadRoot return if g.VIEW isnt 'index' or !threadRoot