Add mode and sort options for custom board links.

This commit is contained in:
ccd0 2016-03-12 17:58:40 -08:00
parent 274419b639
commit 1e528eabe2
2 changed files with 11 additions and 1 deletions

View File

@ -186,7 +186,7 @@ Header =
return unless boardnav
boardnav = boardnav.replace /(\r\n|\n|\r)/g, ' '
as = $$ '#full-board-list a[title]', Header.boardList
re = /[\w@]+(-(all|title|replace|full|index|catalog|archive|expired|text:"[^"]+"(,"[^"]+")?))*|[^\w@]+/g
re = /[\w@]+(-(all|title|replace|full|index|catalog|archive|expired|(mode|sort|text):"[^"]+"(,"[^"]+")?))*|[^\w@]+/g
nodes = (Header.mapCustomNavigation t, as for t in boardnav.match re)
$.add list, nodes
@ -202,6 +202,11 @@ Header =
url = m2
''
indexOptions = []
t = t.replace /-(?:mode|sort):"([^"]+)"/g, (m0, m1) ->
indexOptions.push m1.toLowerCase().replace(/\ /g, '-')
''
if /^toggle-all/.test t
a = $.el 'a',
className: 'show-board-list-button'
@ -252,6 +257,9 @@ Header =
else
return a.firstChild # Its text node.
if Conf['JSON Index'] and indexOptions.length and a.host is location.host and /\/$/.test(a.pathname)
a.href += (if a.hash then '/' else '#') + indexOptions.join('/')
if /-archive/.test t
if href = Redirect.to 'board', {boardID}
a.href = href

View File

@ -32,6 +32,8 @@
<div>Custom text link: <code>g-text:&quot;Install Gentoo&quot;</code></div>
<div>Index-only link: <code>g-index</code></div>
<div>Catalog-only link: <code>g-catalog</code></div>
<div>Index mode: <code>g-mode:&quot;infinite scrolling&quot;</code></div>
<div>Index sort: <code>g-sort:&quot;creation date&quot;</code></div>
<div>External link: <code>external-text:&quot;Google&quot;,&quot;http://www.google.com&quot;</code></div>
<div>Combinations are possible: <code>g-index-text:&quot;Technology Index&quot;</code></div>
<div>Full board list toggle: <code>toggle-all</code></div>