client/help: split search help into sections

This commit is contained in:
rr- 2016-04-17 00:03:45 +02:00
parent 9247e11596
commit 925bfcecc5
10 changed files with 521 additions and 483 deletions

View file

@ -15,3 +15,10 @@
font-size: 1.6em
&:first-child
margin-top: 0
nav
text-align: center
ul
margin: 0 auto
text-align: left
nav.secondary
font-size: 0.95em

View file

@ -0,0 +1,87 @@
<p>Search queries are built of tokens that are separated by spaces. Each token
can be of following form:</p>
<table>
<thead>
<tr>
<th>Syntax</th>
<th>Token type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>&lt;value&gt;</code></td>
<td>anonymous tokens</td>
<td>basic filters</td>
</tr>
<tr>
<td><code>&lt;key&gt;:&lt;value&gt;</code></td>
<td>named tokens</td>
<td>advanced filters</td>
</tr>
<tr>
<td><code>order:&lt;style&gt;</code></td>
<td>order tokens</td>
<td>sort results</td>
</tr>
<tr>
<td><code>special:&lt;value&gt;</code></td>
<td>special tokens</td>
<td>filters usually tied to the logged in user</td>
</tr>
</tbody>
</table>
<p>Most of anonymous and named tokens support ranged and composite values that
take following form:</p>
<table>
<tbody>
<tr>
<td><code>a,b,c</code></td>
<td>will show things that satisfy either <code>a</code>,
<code>b</code> or <code>c</code>.</td>
</tr>
<tr>
<td><code>1..</code></td>
<td>will show things that are equal to or greater than 1.</td>
</tr>
<tr>
<td><code>..4</code></td>
<td>will show things that are equal to at most 4.</td>
</tr>
<tr>
<td><code>1..4</code></td>
<td>will show things that are equal to 1, 2, 3 or 4.</td>
</tr>
</tbody>
</table>
<p>Date/time values can be of following form:</p>
<ul>
<li><code>today</code></li>
<li><code>yesterday</code></li>
<li><code>&lt;year&gt;</code></li>
<li><code>&lt;year&gt;-&lt;month&gt;</code></li>
<li><code>&lt;year&gt;-&lt;month&gt;-&lt;day&gt;</code></li>
</ul>
<p>Some fields, such as user names, can take wildcards (<code>*</code>).</p>
<p>All tokens can be negated by prepending them with <code>-</code>.</p>
<p>Order token values can be appended with <code>,asc</code> or
<code>,desc</code> to control the sort direction, which can be also controlled
by negating the whole token.</p>
<h1>Example</h1>
<p>Searching for posts with following query:</p>
<pre><code>sea -fav-count:8.. type:swf uploader:Pirate</code></pre>
<p>will show flash files tagged as sea, that were liked by seven people at
most, uploaded by user Pirate.</p>

View file

@ -0,0 +1,172 @@
<p><strong>Anonymous tokens</strong></p>
<p>Filter posts tagged with given <code>&lt;value&gt;</code>.</p>
<p><strong>Named tokens</strong></p>
<table>
<tbody>
<tr>
<td><code>id</code></td>
<td>having specific post ID</td>
</tr>
<tr>
<td><code>score</code></td>
<td>having given score</td>
</tr>
<tr>
<td><code>uploader</code></td>
<td>uploaded by given user</td>
</tr>
<tr>
<td><code>comment</code></td>
<td>commented by given user</td>
</tr>
<tr>
<td><code>fav</code></td>
<td>favorited by given user</td>
</tr>
<tr>
<td><code>fav-count</code></td>
<td>favorited by given number of users</td>
</tr>
<tr>
<td><code>comment-count</code></td>
<td>having given number of comments</td>
</tr>
<tr>
<td><code>tag-count</code></td>
<td>having given number of tags</td>
</tr>
<tr>
<td><code>note-count</code></td>
<td>having given number of annotations</td>
</tr>
<tr>
<td><code>feature-count</code></td>
<td>having been featured given number of times</td>
</tr>
<tr>
<td><code>date</code></td>
<td>posted at given date</td>
</tr>
<tr>
<td><code>file-size</code></td>
<td>having given file size (in bytes)</td>
</tr>
<tr>
<td><code>image-width</code></td>
<td>having given image width (where applicable)</td>
</tr>
<tr>
<td><code>image-height</code></td>
<td>having given image height (where applicable)</td>
</tr>
<tr>
<td><code>image-area</code></td>
<td>having given number of pixels (image width * image height)</td>
</tr>
<tr>
<td><code>type</code></td>
<td>given type of posts (<code>&lt;value&gt;</code> can be either <code>image</code>, <code>flash</code>/<code>swf</code>, <code>youtube</code>/<code>yt</code>, <code>video</code> or <code>animation</code>)</td>
</tr>
</tbody>
</table>
<p><strong>Order tokens</strong></p>
<table>
<tbody>
<tr>
<td><code>random</code></td>
<td>as random as it can get</td>
</tr>
<tr>
<td><code>id</code></td>
<td>highest to lowest post ID</td>
</tr>
<tr>
<td><code>score</code></td>
<td>highest scored</td>
</tr>
<tr>
<td><code>fav-count</code></td>
<td>loved by most</td>
</tr>
<tr>
<td><code>comment-count</code></td>
<td>most commented first</td>
</tr>
<tr>
<td><code>tag-count</code></td>
<td>with most tags</td>
</tr>
<tr>
<td><code>note-count</code></td>
<td>with most annotations</td>
</tr>
<tr>
<td><code>file-size</code></td>
<td>largest files first</td>
</tr>
<tr>
<td><code>image-width</code></td>
<td>widest images first</td>
</tr>
<tr>
<td><code>image-height</code></td>
<td>tallest images first</td>
</tr>
<tr>
<td><code>image-area</code></td>
<td>largest images first</td>
</tr>
<tr>
<td><code>creation-date</code></td>
<td>newest to oldest (pretty much same as <code>id</code>)</td>
</tr>
<tr>
<td><code>edit-date</code></td>
<td>like <code>creation-date</code>, only looks at last edit time</td>
</tr>
<tr>
<td><code>fav-date</code></td>
<td>recently added to favorites by anyone</td>
</tr>
<tr>
<td><code>comment-date</code></td>
<td>recently commented by anyone</td>
</tr>
<tr>
<td><code>feature-date</code></td>
<td>recently featured</td>
</tr>
<tr>
<td><code>feature-count</code></td>
<td>most often featured</td>
</tr>
</tbody>
</table>
<p><strong>Special tokens</strong></p>
<table>
<tbody>
<tr>
<td><code>liked</code></td>
<td>posts liked by currently logged in user</td>
</tr>
<tr>
<td><code>disliked</code></td>
<td>posts disliked by currently logged in user</td>
</tr>
<tr>
<td><code>fav</code></td>
<td>posts added to favorites by currently logged in user</td>
</tr>
<tr>
<td><code>tumbleweed</code></td>
<td>posts with score of 0, without comments and without favorites</td>
</tr>
</tbody>
</table>

View file

@ -0,0 +1,129 @@
<p><strong>Anonymous tokens</strong></p>
<p>Same as <code>name</code> token.</p>
<p><strong>Named tokens</strong></p>
<table>
<tbody>
<tr>
<td><code>name</code></td>
<td>having given name (accepts wildcards)</td>
</tr>
<tr>
<td><code>category</code></td>
<td>having given category</td>
</tr>
<tr>
<td><code>creation-date</code></td>
<td>created at given date</td>
</tr>
<tr>
<td><code>creation-time</code></td>
<td>alias of <code>creation-date</code></td>
</tr>
<tr>
<td><code>last-edit-date</code></td>
<td>edited at given date</td>
</tr>
<tr>
<td><code>last-edit-time</code></td>
<td>alias of <code>last-edit-date</code></td>
</tr>
<tr>
<td><code>edit-date</code></td>
<td>alias of <code>last-edit-date</code></td>
</tr>
<tr>
<td><code>edit-time</code></td>
<td>alias of <code>last-edit-date</code></td>
</tr>
<tr>
<td><code>usages</code></td>
<td>used in given number of posts</td>
</tr>
<tr>
<td><code>usage-count</code></td>
<td>alias of <code>usages</code></td>
</tr>
<tr>
<td><code>post-count</code></td>
<td>alias of <code>usages</code></td>
</tr>
<tr>
<td><code>suggestion-count</code></td>
<td>with given number of suggestions</td>
</tr>
<tr>
<td><code>implication-count</code></td>
<td>with given number of implications</td>
</tr>
</tbody>
</table>
<p><strong>Order tokens</strong></p>
<table>
<tbody>
<tr>
<td><code>random</code></td>
<td>as random as it can get</td>
</tr>
<tr>
<td><code>name</code></td>
<td>A to Z</td>
</tr>
<tr>
<td><code>category</code></td>
<td>category (A to Z)</td>
</tr>
<tr>
<td><code>creation-date</code></td>
<td>recently created first</td>
</tr>
<tr>
<td><code>creation-time</code></td>
<td>alias of <code>creation-date</code></td>
</tr>
<tr>
<td><code>last-edit-date</code></td>
<td>recently edited first</td>
</tr>
<tr>
<td><code>last-edit-time</code></td>
<td>alias of <code>creation-time</code></td>
</tr>
<tr>
<td><code>edit-date</code></td>
<td>alias of <code>creation-time</code></td>
</tr>
<tr>
<td><code>edit-time</code></td>
<td>alias of <code>creation-time</code></td>
</tr>
<tr>
<td><code>usages</code></td>
<td>used in most posts first</td>
</tr>
<tr>
<td><code>usage-count</code></td>
<td>alias of <code>usages</code></td>
</tr>
<tr>
<td><code>post-count</code></td>
<td>alias of <code>usages</code></td>
</tr>
<tr>
<td><code>suggestion-count</code></td>
<td>with most suggestions first</td>
</tr>
<tr>
<td><code>implication-count</code></td>
<td>with most implications first</td>
</tr>
</tbody>
</table>
<p><strong>Special tokens</strong></p>
<p>None.</p>

View file

@ -0,0 +1,81 @@
<p><strong>Anonymous tokens</strong></p>
<p>Same as <code>name</code> token.</p>
<p><strong>Named tokens</strong></p>
<table>
<tbody>
<tr>
<td><code>name</code></td>
<td>having given name (doesn't accept wildcards yet)</td>
</tr>
<tr>
<td><code>creation-date</code></td>
<td>registered at given date</td>
</tr>
<tr>
<td><code>creation-time</code></td>
<td>alias of <code>creation-date</code></td>
</tr>
<tr>
<td><code>last-login-date</code>
<td>whose most recent login date matches given date</td>
</tr>
<tr>
<td><code>last-login-time</code>
<td>alias of <code>last-login-date</code>
</tr>
<tr>
<td><code>login-date</code>
<td>alias of <code>last-login-date</code>
</tr>
<tr>
<td><code>login-time</code></td>
<td>alias of <code>last-login-date</code>
</tr>
</tbody>
</table>
<p><strong>Order tokens</strong></p>
<table>
<tbody>
<tr>
<td><code>random</code></td>
<td>as random as it can get</td>
</tr>
<tr>
<td><code>name</code></td>
<td>A to Z</td>
</tr>
<tr>
<td><code>creation-date</code></td>
<td>newest to oldest</td>
</tr>
<tr>
<td><code>creation-time</code></td>
<td>alias of <code>creation-date</code></td>
</tr>
<tr>
<td><code>last-login-date</code></td>
<td>recently active first</td>
</tr>
<tr>
<td><code>last-login-time</code></td>
<td>alias of <code>last-login-date</code></td>
</tr>
<tr>
<td><code>login-date</code></td>
<td>alias of <code>last-login-date</code></td>
</tr>
<tr>
<td><code>login-time</code></td>
<td>alias of <code>last-login-date</code></td>
</tr>
</tbody>
</table>
<p><strong>Special tokens</strong></p>
<p>None.</p>

View file

@ -1,479 +1,10 @@
<h1>General search syntax</h1>
<nav class='text-nav secondary'><!--
--><ul><!--
--><li data-name='default'><a href='/help/search'>General</a></li><!--
--><li data-name='posts'><a href='/help/search/posts'>Posts</a></li><!--
--><li data-name='users'><a href='/help/search/users'>Users</a></li><!--
--><li data-name='tags'><a href='/help/search/tags'>Tags</a></li><!--
--></ul><!--
--></nav>
<p>Search queries are built of tokens that are separated by spaces. Each token
can be of following form:</p>
<table>
<thead>
<tr>
<th>Syntax</th>
<th>Token type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>&lt;value&gt;</code></td>
<td>anonymous tokens</td>
<td>basic filters</td>
</tr>
<tr>
<td><code>&lt;key&gt;:&lt;value&gt;</code></td>
<td>named tokens</td>
<td>advanced filters</td>
</tr>
<tr>
<td><code>order:&lt;style&gt;</code></td>
<td>order tokens</td>
<td>sort results</td>
</tr>
<tr>
<td><code>special:&lt;value&gt;</code></td>
<td>special tokens</td>
<td>filters usually tied to the logged in user</td>
</tr>
</tbody>
</table>
<p>Most of anonymous and named tokens support ranged and composite values that
take following form:</p>
<table>
<tbody>
<tr>
<td><code>a,b,c</code></td>
<td>will show things that satisfy either <code>a</code>,
<code>b</code> or <code>c</code>.</td>
</tr>
<tr>
<td><code>1..</code></td>
<td>will show things that are equal to or greater than 1.</td>
</tr>
<tr>
<td><code>..4</code></td>
<td>will show things that are equal to at most 4.</td>
</tr>
<tr>
<td><code>1..4</code></td>
<td>will show things that are equal to 1, 2, 3 or 4.</td>
</tr>
</tbody>
</table>
<p>Date/time values can be of following form:</p>
<ul>
<li><code>today</code></li>
<li><code>yesterday</code></li>
<li><code>&lt;year&gt;</code></li>
<li><code>&lt;year&gt;-&lt;month&gt;</code></li>
<li><code>&lt;year&gt;-&lt;month&gt;-&lt;day&gt;</code></li>
</ul>
<p>Some fields, such as user names, can take wildcards (<code>*</code>).</p>
<p>All tokens can be negated by prepending them with <code>-</code>.</p>
<p>Order token values can be appended with <code>,asc</code> or
<code>,desc</code> to control the sort direction, which can be also controlled
by negating the whole token.</p>
<h1>Example</h1>
<p>Searching for posts with following query:</p>
<pre><code>sea -fav-count:8.. type:swf uploader:Pirate</code></pre>
<p>will show flash files tagged as sea, that were liked by seven people at
most, uploaded by user Pirate.</p>
<h1 id='post-search-help'>Post search tokens</h1>
<p><strong>Anonymous tokens</strong></p>
<p>Filter posts tagged with given <code>&lt;value&gt;</code>.</p>
<p><strong>Named tokens</strong></p>
<table>
<tbody>
<tr>
<td><code>id</code></td>
<td>having specific post ID</td>
</tr>
<tr>
<td><code>score</code></td>
<td>having given score</td>
</tr>
<tr>
<td><code>uploader</code></td>
<td>uploaded by given user</td>
</tr>
<tr>
<td><code>comment</code></td>
<td>commented by given user</td>
</tr>
<tr>
<td><code>fav</code></td>
<td>favorited by given user</td>
</tr>
<tr>
<td><code>fav-count</code></td>
<td>favorited by given number of users</td>
</tr>
<tr>
<td><code>comment-count</code></td>
<td>having given number of comments</td>
</tr>
<tr>
<td><code>tag-count</code></td>
<td>having given number of tags</td>
</tr>
<tr>
<td><code>note-count</code></td>
<td>having given number of annotations</td>
</tr>
<tr>
<td><code>feature-count</code></td>
<td>having been featured given number of times</td>
</tr>
<tr>
<td><code>date</code></td>
<td>posted at given date</td>
</tr>
<tr>
<td><code>file-size</code></td>
<td>having given file size (in bytes)</td>
</tr>
<tr>
<td><code>image-width</code></td>
<td>having given image width (where applicable)</td>
</tr>
<tr>
<td><code>image-height</code></td>
<td>having given image height (where applicable)</td>
</tr>
<tr>
<td><code>image-area</code></td>
<td>having given number of pixels (image width * image height)</td>
</tr>
<tr>
<td><code>type</code></td>
<td>given type of posts (<code>&lt;value&gt;</code> can be either <code>image</code>, <code>flash</code>/<code>swf</code>, <code>youtube</code>/<code>yt</code>, <code>video</code> or <code>animation</code>)</td>
</tr>
</tbody>
</table>
<p><strong>Order tokens</strong></p>
<table>
<tbody>
<tr>
<td><code>random</code></td>
<td>as random as it can get</td>
</tr>
<tr>
<td><code>id</code></td>
<td>highest to lowest post ID</td>
</tr>
<tr>
<td><code>score</code></td>
<td>highest scored</td>
</tr>
<tr>
<td><code>fav-count</code></td>
<td>loved by most</td>
</tr>
<tr>
<td><code>comment-count</code></td>
<td>most commented first</td>
</tr>
<tr>
<td><code>tag-count</code></td>
<td>with most tags</td>
</tr>
<tr>
<td><code>note-count</code></td>
<td>with most annotations</td>
</tr>
<tr>
<td><code>file-size</code></td>
<td>largest files first</td>
</tr>
<tr>
<td><code>image-width</code></td>
<td>widest images first</td>
</tr>
<tr>
<td><code>image-height</code></td>
<td>tallest images first</td>
</tr>
<tr>
<td><code>image-area</code></td>
<td>largest images first</td>
</tr>
<tr>
<td><code>creation-date</code></td>
<td>newest to oldest (pretty much same as <code>id</code>)</td>
</tr>
<tr>
<td><code>edit-date</code></td>
<td>like <code>creation-date</code>, only looks at last edit time</td>
</tr>
<tr>
<td><code>fav-date</code></td>
<td>recently added to favorites by anyone</td>
</tr>
<tr>
<td><code>comment-date</code></td>
<td>recently commented by anyone</td>
</tr>
<tr>
<td><code>feature-date</code></td>
<td>recently featured</td>
</tr>
<tr>
<td><code>feature-count</code></td>
<td>most often featured</td>
</tr>
</tbody>
</table>
<p><strong>Special tokens</strong></p>
<table>
<tbody>
<tr>
<td><code>liked</code></td>
<td>posts liked by currently logged in user</td>
</tr>
<tr>
<td><code>disliked</code></td>
<td>posts disliked by currently logged in user</td>
</tr>
<tr>
<td><code>fav</code></td>
<td>posts added to favorites by currently logged in user</td>
</tr>
<tr>
<td><code>tumbleweed</code></td>
<td>posts with score of 0, without comments and without favorites</td>
</tr>
</tbody>
</table>
<h1 id='user-search-help'>User search tokens</h1>
<p><strong>Anonymous tokens</strong></p>
<p>Same as <code>name</code> token.</p>
<p><strong>Named tokens</strong></p>
<table>
<tbody>
<tr>
<td><code>name</code></td>
<td>having given name (doesn't accept wildcards yet)</td>
</tr>
<tr>
<td><code>creation-date</code></td>
<td>registered at given date</td>
</tr>
<tr>
<td><code>creation-time</code></td>
<td>alias of <code>creation-date</code></td>
</tr>
<tr>
<td><code>last-login-date</code>
<td>whose most recent login date matches given date</td>
</tr>
<tr>
<td><code>last-login-time</code>
<td>alias of <code>last-login-date</code>
</tr>
<tr>
<td><code>login-date</code>
<td>alias of <code>last-login-date</code>
</tr>
<tr>
<td><code>login-time</code></td>
<td>alias of <code>last-login-date</code>
</tr>
</tbody>
</table>
<p><strong>Order tokens</strong></p>
<table>
<tbody>
<tr>
<td><code>random</code></td>
<td>as random as it can get</td>
</tr>
<tr>
<td><code>name</code></td>
<td>A to Z</td>
</tr>
<tr>
<td><code>creation-date</code></td>
<td>newest to oldest</td>
</tr>
<tr>
<td><code>creation-time</code></td>
<td>alias of <code>creation-date</code></td>
</tr>
<tr>
<td><code>last-login-date</code></td>
<td>recently active first</td>
</tr>
<tr>
<td><code>last-login-time</code></td>
<td>alias of <code>last-login-date</code></td>
</tr>
<tr>
<td><code>login-date</code></td>
<td>alias of <code>last-login-date</code></td>
</tr>
<tr>
<td><code>login-time</code></td>
<td>alias of <code>last-login-date</code></td>
</tr>
</tbody>
</table>
<p><strong>Special tokens</strong></p>
<p>None.</p>
<h1 id='tag-search-help'>Tag search tokens</h1>
<p><strong>Anonymous tokens</strong></p>
<p>Same as <code>name</code> token.</p>
<p><strong>Named tokens</strong></p>
<table>
<tbody>
<tr>
<td><code>name</code></td>
<td>having given name (accepts wildcards)</td>
</tr>
<tr>
<td><code>category</code></td>
<td>having given category</td>
</tr>
<tr>
<td><code>creation-date</code></td>
<td>created at given date</td>
</tr>
<tr>
<td><code>creation-time</code></td>
<td>alias of <code>creation-date</code></td>
</tr>
<tr>
<td><code>last-edit-date</code></td>
<td>edited at given date</td>
</tr>
<tr>
<td><code>last-edit-time</code></td>
<td>alias of <code>last-edit-date</code></td>
</tr>
<tr>
<td><code>edit-date</code></td>
<td>alias of <code>last-edit-date</code></td>
</tr>
<tr>
<td><code>edit-time</code></td>
<td>alias of <code>last-edit-date</code></td>
</tr>
<tr>
<td><code>usages</code></td>
<td>used in given number of posts</td>
</tr>
<tr>
<td><code>usage-count</code></td>
<td>alias of <code>usages</code></td>
</tr>
<tr>
<td><code>post-count</code></td>
<td>alias of <code>usages</code></td>
</tr>
<tr>
<td><code>suggestion-count</code></td>
<td>with given number of suggestions</td>
</tr>
<tr>
<td><code>implication-count</code></td>
<td>with given number of implications</td>
</tr>
</tbody>
</table>
<p><strong>Order tokens</strong></p>
<table>
<tbody>
<tr>
<td><code>random</code></td>
<td>as random as it can get</td>
</tr>
<tr>
<td><code>name</code></td>
<td>A to Z</td>
</tr>
<tr>
<td><code>category</code></td>
<td>category (A to Z)</td>
</tr>
<tr>
<td><code>creation-date</code></td>
<td>recently created first</td>
</tr>
<tr>
<td><code>creation-time</code></td>
<td>alias of <code>creation-date</code></td>
</tr>
<tr>
<td><code>last-edit-date</code></td>
<td>recently edited first</td>
</tr>
<tr>
<td><code>last-edit-time</code></td>
<td>alias of <code>creation-time</code></td>
</tr>
<tr>
<td><code>edit-date</code></td>
<td>alias of <code>creation-time</code></td>
</tr>
<tr>
<td><code>edit-time</code></td>
<td>alias of <code>creation-time</code></td>
</tr>
<tr>
<td><code>usages</code></td>
<td>used in most posts first</td>
</tr>
<tr>
<td><code>usage-count</code></td>
<td>alias of <code>usages</code></td>
</tr>
<tr>
<td><code>post-count</code></td>
<td>alias of <code>usages</code></td>
</tr>
<tr>
<td><code>suggestion-count</code></td>
<td>with most suggestions first</td>
</tr>
<tr>
<td><code>implication-count</code></td>
<td>with most implications first</td>
</tr>
</tbody>
</table>
<p><strong>Special tokens</strong></p>
<p>None.</p>
<div class='subcontent'></div>

View file

@ -1,5 +1,5 @@
<div class='content-wrapper' id='help'>
<nav class='text-nav'><!--
<nav class='text-nav primary'><!--
--><ul><!--
--><li data-name='about'><a href='/help/about'>About</a></li><!--
--><li data-name='keyboard'><a href='/help/keyboard'>Keyboard</a></li><!--

View file

@ -9,7 +9,7 @@
</div>
<div class='buttons'>
<input type='submit' value='Search'/>
<a class='append icon' href='/help/search#user-search-help'><i class='fa fa-question-circle-o'></i></a>
<a class='append icon' href='/help/search/users'><i class='fa fa-question-circle-o'></i></a>
</div>
</form>
</div>

View file

@ -14,12 +14,18 @@ class HelpController {
page(
'/help/:section',
(ctx, next) => { this.showHelpRoute(ctx.params.section); });
page(
'/help/:section/:subsection',
(ctx, next) => {
this.showHelpRoute(ctx.params.section, ctx.params.subsection);
});
}
showHelpRoute(section) {
showHelpRoute(section, subsection) {
topNavController.activate('help');
this.helpView.render({
section: section,
subsection: subsection,
});
}
}

View file

@ -12,6 +12,14 @@ class HelpView {
const templateName = 'help-' + section;
this.sectionTemplates[section] = views.getTemplate(templateName);
}
this.subsectionTemplates = {
'search': {
'default': views.getTemplate('help-search-general'),
'posts': views.getTemplate('help-search-posts'),
'users': views.getTemplate('help-search-users'),
'tags': views.getTemplate('help-search-tags'),
}
}
}
render(ctx) {
@ -27,8 +35,17 @@ class HelpView {
}));
}
const allItemsSelector = '[data-name]';
for (let item of source.querySelectorAll(allItemsSelector)) {
ctx.subsection = ctx.subsection || 'default';
if (ctx.section in this.subsectionTemplates &&
ctx.subsection in this.subsectionTemplates[ctx.section]) {
views.showView(
source.querySelector('.subcontent'),
this.subsectionTemplates[ctx.section][ctx.subsection]({
name: config.name,
}));
}
for (let item of source.querySelectorAll('.primary [data-name]')) {
if (item.getAttribute('data-name') === ctx.section) {
item.className = 'active';
} else {
@ -36,6 +53,14 @@ class HelpView {
}
}
for (let item of source.querySelectorAll('.secondary [data-name]')) {
if (item.getAttribute('data-name') === ctx.subsection) {
item.className = 'active';
} else {
item.className = '';
}
}
views.listenToMessages(target);
views.showView(target, source);