Skip to content

Commit

Permalink
Merge pull request #741 from moisseev/sidebar
Browse files Browse the repository at this point in the history
Autogenerate some sidebar menu sections
  • Loading branch information
moisseev authored Apr 23, 2024
2 parents 5454c60 + 1a5ae2f commit 5d2902c
Show file tree
Hide file tree
Showing 30 changed files with 164 additions and 124 deletions.
134 changes: 115 additions & 19 deletions _includes/directory-tree.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,82 @@
<ul>
{%- assign sorted_pages = include.pages | sort: "dir" -%}
{%- for page in sorted_pages -%}
{%- if page.layout == nil or page.layout == 'none' or page.dir contains '/blog/page' -%}
{%- comment -%}
Build a directory tree (e.g. sitemap)

Page Front Matter directory-tree hash parameters:

emphasize Emphasize the page in the tree.
Default: false.

de-emphasize De-emphasize the page in the tree.
Default: false.

Tree include parameters:

dir The top-level directory of the tree.
If the path ends with a slash, the directory itself will be excluded from the tree.
Default: The root directory.

Tree parameters that can be passed as include hash, Front Matter directory-tree hash or Liquid variables with directory-tree- prefix:

li The generated tree is a list item. Do not wrap an <ul> tag around it.

dir_class Add a class attribute with the specified classes to <li> tags of all directories.
If not set, wrap a <strong> tag around titles of all directories.

strong Wrap a <strong> tag around titles of the pages that have set `emphasize: true` in the Front Matter.
Default: false.

del Wrap a <del> tag around titles of the pages that have set `de-emphasize: true` in the Front Matter.
Default: false.
{%- endcomment -%}
{%- unless include.li or page.directory-tree.li or directory-tree-li %}<ul>{%- endunless %}
{%- assign dir_class = include.dir_class | default: directory-tree-dir_class | default: page.directory-tree.dir_class -%}
{%- if dir_class -%}
{%- assign dir_li = '<li class="' | append: dir_class | append: '">' -%}
{%- else -%}
{%- assign dir_li = "<li>" -%}
{%- assign dir_strong = "<strong>" -%}
{%- assign dir_strong_closing = "</strong>" -%}
{%- endif -%}
{%- assign filtered_pages = "" | split: "," -%}
{%- for pg in site.pages -%}
{%- comment -%}
# Skip page unless its directory starts with include.dir.
{%- endcomment -%}
{%- if include.dir -%}
{%- assign check_str = pg.dir | split: include.dir | first -%}
{%- if check_str.size > 0 -%}
{%- continue -%}
{%- endif -%}
{%- endif -%}
{%- if pg.layout == nil or pg.layout == 'none' or pg.dir contains '/blog/page' -%}
{%- continue -%}
{%- endif -%}
{% unless page.dir == prev_page_dir -%}
{%- assign path = page.dir | split: "/" -%}
{%- assign filtered_pages = filtered_pages | push: pg -%}
{%- endfor -%}
{%- assign sorted_by_dir = filtered_pages | sort_natural: "dir" -%}
{%- assign subdir_pages = "" | split: "," -%}
{%- assign sorted_pages = "" | split: "," -%}
{%- for pg in sorted_by_dir -%}
{%- unless pg.dir == prev_page_dir -%}
{%- if subdir_pages.size > 0 -%}
{%- assign sorted_subdir_pages = subdir_pages | sort_natural: "title" -%}
{%- assign sorted_pages = sorted_pages | concat: sorted_subdir_pages -%}
{%- endif -%}
{%- assign subdir_pages = "" | split: "," -%}
{%- assign prev_page_dir = pg.dir -%}
{%- endunless -%}
{%- assign subdir_pages = subdir_pages | push: pg -%}
{%- endfor -%}
{%- if subdir_pages.size > 0 -%}
{%- assign sorted_subdir_pages = subdir_pages | sort_natural: "title" -%}
{%- assign sorted_pages = sorted_pages | concat: sorted_subdir_pages -%}
{%- endif -%}
{%- assign prev_page_dir = include.dir -%}
{%- for pg in sorted_pages -%}
{% unless pg.dir == prev_page_dir -%}
{%- assign path = pg.dir | split: "/" -%}
{%- comment -%}
# Split returns [] for "/" but ["", "doc"] "/doc/" as removes empty strings.
# Split returns [] for "/" but ["", "doc"] "/doc/" as removes trailing empty strings.
{%- endcomment -%}
{%- unless path.size > 0 -%}
{%- assign path = path | push: "" -%}
Expand All @@ -30,28 +99,55 @@
{%- assign levels_match = index0 -%}
{%- break -%}
{%- endunless -%}
{%- if forloop.last -%}
{%- assign levels_match = forloop.index0 -%}
{%- endif -%}
{%- endfor -%}
{%- for num in (1..levels_back) %}
</ul>
</li>
{%- endfor -%}
{% for dir in path offset:levels_match -%}
{%- assign dir_index_page = include.pages | where: "dir", page.dir | where: "name", "index.md" | first -%}
{%- unless dir_index_page -%}
{%- assign dir_index_page = include.pages | where: "dir", page.dir | where: "name", "index.html" | first -%}
{%- endunless %}
<li>
<a href="{{ site.baseurl }}{{ page.dir }}"><strong>{{ dir_index_page.title }}</strong></a>
{% for dir in path offset:levels_match %}
{{ dir_li }}
{%- if forloop.last -%}
{%- assign dir_pages = site.pages | where: "dir", pg.dir -%}
{%- assign dir_index_page = dir_pages | where: "name", "index.md" | first -%}
{%- unless dir_index_page -%}
{%- assign dir_index_page = dir_pages | where: "name", "index.html" | first -%}
{%- endunless %}
<a href="{{ site.baseurl }}{{ pg.dir }}">{{ dir_strong }}{{ dir_index_page.title }}{{ dir_strong_closing }}</a>
{%- else %}
{{ dir_strong }}{{ dir }}{{ dir_strong_closing }}
{%- endif %}
<ul>
{%- endfor %}
{%- assign prev_page_dir = page.dir -%}
{%- assign prev_page_dir = pg.dir -%}
{%- endunless %}
{%- unless page.name == "index.md" or page.name == "index.html" %}
<li><a href="{{ site.baseurl }}{{ page.url }}">{{ page.title }}</a></li>
{%- unless pg.name == "index.md" or pg.name == "index.html" -%}
{%- if pg.directory-tree.emphasize and include.strong or page.directory-tree.strong or directory-tree-strong -%}
{%- assign strong = "<strong>" -%}
{%- assign strong_closing = "</strong>" -%}
{%- else -%}
{%- assign strong = "" -%}
{%- assign strong_closing = "" -%}
{%- endif -%}
{%- if pg.directory-tree.de-emphasize and include.del or page.directory-tree.del or directory-tree-del -%}
{%- assign del = "<del>" -%}
{%- assign del_closing = "</del>" -%}
{%- else -%}
{%- assign del = "" -%}
{%- assign del_closing = "" -%}
{%- endif %}
<li><a href="{{ site.baseurl }}{{ pg.url }}">{{ strong }}{{ del }}{{ pg.title }}{{ del_closing }}{{ strong_closing }}</a></li>
{%- endunless -%}
{% endfor -%}
{%- for dir in path %}
{%- assign offset = include.dir | split: "/" | size -%}
{%- assign last_char = include.dir | slice: -1 -%}
{%- unless last_char == "/" -%}
{%- assign offset = offset | minus: 1 -%}
{%- endunless -%}
{%- for dir in path offset: offset %}
</ul>
</li>
{%- endfor %}
</ul>
{% unless include.li or page.directory-tree.li or directory-tree-li -%}</ul>{%- endunless -%}
83 changes: 9 additions & 74 deletions _layouts/doc.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<!-- remove the white space after footer-->
{% include top.html %}

{%- assign directory-tree-li = true -%}
{%- assign directory-tree-strong = true -%}
{%- assign directory-tree-del = true -%}
{%- assign directory-tree-dir_class = "r-docs-subnav list-group-item" %}

<style>
.r-docs-nav {
width: 300px;
Expand All @@ -18,6 +23,7 @@
font-weight: bold;
color: #de4700;
}
.r-docs-nav a:not(.active-link) > del { opacity: 0.4; }

.r-docs-subnav ul {
list-style: none;
Expand Down Expand Up @@ -91,80 +97,9 @@
<a href="{{ site.baseurl }}/doc/faq.html">FAQ</a>
</li>

<li class="r-docs-subnav list-group-item">
<a href="{{ site.baseurl }}/doc/configuration/index.html">Rspamd configuration</a>
<ul>
<li><a href="{{ site.baseurl }}/doc/configuration/ucl.html">Universal configuration language (UCL)</a></li>
<li><a href="{{ site.baseurl }}/doc/configuration/composites.html">Composite symbols</a></li>
<li><a href="{{ site.baseurl }}/doc/configuration/logging.html">Logging setup</a></li>
<li><a href="{{ site.baseurl }}/doc/configuration/metrics.html">Symbols scores and metrics setup</a></li>
<li><a href="{{ site.baseurl }}/doc/configuration/options.html">Common options</a></li>
<li><a href="{{ site.baseurl }}/doc/configuration/redis.html">Redis server setup</a></li>
<li><a href="{{ site.baseurl }}/doc/configuration/statistic.html">Statistical module setup</a></li>
<li><a href="{{ site.baseurl }}/doc/configuration/settings.html">Users settings</a></li>
<li><a href="{{ site.baseurl }}/doc/configuration/upstream.html">Upstreams setup</a></li>
<li><a href="{{ site.baseurl }}/doc/configuration/selectors.html">Selectors</a></li>
</ul>
</li>

<li class="r-docs-subnav list-group-item">
<a href="{{ site.baseurl }}/doc/modules/">Modules documentation</a>
<ul>
<li><a href="{{ site.baseurl }}/doc/modules/antivirus.html"><strong>Antivirus</strong></a></li>
<li><a href="{{ site.baseurl }}/doc/modules/arc.html">ARC module</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/asn.html">ASN module</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/bayes_expiry.html">Bayes expiry module</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/clickhouse.html"><strong>Clickhouse module</strong></a></li>
<li><a href="{{ site.baseurl }}/doc/modules/chartable.html">Chartable</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/dcc.html">DCC module</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/dkim.html">DKIM</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/dkim_signing.html">DKIM signing</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/dmarc.html">DMARC</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/elastic.html">Elasticsearch exporter</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/emails.html">Emails scan</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/external_relay.html">External relay</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/external_services.html"><strong>External services</strong></a></li>
<li><a href="{{ site.baseurl }}/doc/modules/force_actions.html"><strong>Force Actions</strong></a></li>
<li><a href="{{ site.baseurl }}/doc/modules/fuzzy_check.html">Fuzzy check</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/greylisting.html">Greylisting module</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/hfilter.html">Hfilter</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/history_redis.html">History redis module</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/known_senders.html">Known senders module</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/maillist.html">Mailing list</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/metadata_exporter.html">Metadata exporter</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/metric_exporter.html">Metric exporter</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/mid.html">MID module</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/milter_headers.html"><strong>Milter headers</strong></a></li>
<li><a href="{{ site.baseurl }}/doc/modules/mime_types.html">Mime types</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/multimap.html"><strong>Multimap</strong></a></li>
<li><a href="{{ site.baseurl }}/doc/modules/mx_check.html">MX Check</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/neural.html">Neural network module</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/phishing.html">Phishing check</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/ratelimit.html"><strong>Ratelimit</strong></a></li>
<li><a href="{{ site.baseurl }}/doc/modules/rbl.html"><strong>RBL</strong></a></li>
<li><a href="{{ site.baseurl }}/doc/modules/regexp.html"><strong>Regexp</strong></a></li>
<li><a href="{{ site.baseurl }}/doc/modules/reputation.html">Reputation</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/once_received.html">Received policy</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/replies.html">Replies module</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/rspamd_update.html">Rspamd update</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/spamassassin.html">Spamassassin rules</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/spamtrap.html">Spamtrap</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/spf.html">SPF</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/trie.html">Trie matcher</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/url_redirector.html">URL redirector</a></li>
<li><a href="{{ site.baseurl }}/doc/modules/whitelist.html">Whitelist</a></li>
</ul>
</li>

<li class="r-docs-subnav list-group-item">
<a href="{{ site.baseurl }}/doc/workers/">Workers documentation</a>
<ul>
<li><a href="{{ site.baseurl }}/doc/workers/normal.html">Normal worker (scanner)</a></li>
<li><a href="{{ site.baseurl }}/doc/workers/rspamd_proxy.html">Proxy worker</a></li>
<li><a href="{{ site.baseurl }}/doc/workers/controller.html">Controller worker</a></li>
<li><a href="{{ site.baseurl }}/doc/workers/fuzzy_storage.html">Fuzzy hashes storage</a></li>
</ul>
</li>
{% include directory-tree.html dir="/doc/configuration" %}
{% include directory-tree.html dir="/doc/modules" %}
{% include directory-tree.html dir="/doc/workers" %}

<li class="r-docs-subnav list-group-item">
<a href="#">Developers documentation</a>
Expand Down
2 changes: 1 addition & 1 deletion doc/configuration/composites.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: doc
title: Rspamd Composites
title: Composite symbols
---

# Rspamd composite symbols
Expand Down
2 changes: 1 addition & 1 deletion doc/configuration/logging.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: doc
title: Rspamd Logging
title: Logging settings
---

# Rspamd logging settings
Expand Down
2 changes: 1 addition & 1 deletion doc/configuration/metrics.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: doc
title: Rspamd Metrics
title: Actions and scores
---
# Rspamd actions and scores

Expand Down
2 changes: 1 addition & 1 deletion doc/configuration/options.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: doc
title: Rspamd Options
title: Common options
---
# Rspamd options settings

Expand Down
2 changes: 1 addition & 1 deletion doc/configuration/selectors.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: doc
title: Rspamd Selectors
title: Selectors
---

# Rspamd selectors settings
Expand Down
2 changes: 1 addition & 1 deletion doc/configuration/settings.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: doc
title: Users settings description
title: User settings
---
# Rspamd user settings

Expand Down
2 changes: 1 addition & 1 deletion doc/configuration/statistic.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: doc
title: Rspamd Statistics
title: Statistics settings
---
# Rspamd statistic settings

Expand Down
2 changes: 1 addition & 1 deletion doc/configuration/ucl.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: doc
title: UCL language
title: Universal configuration language (UCL)
---
# UCL configuration language

Expand Down
2 changes: 2 additions & 0 deletions doc/modules/antivirus.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
layout: doc
title: Antivirus module
directory-tree:
emphasize: true
---

# Antivirus module
Expand Down
2 changes: 2 additions & 0 deletions doc/modules/clickhouse.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
layout: doc
title: Clickhouse module
directory-tree:
emphasize: true
---

# Clickhouse module
Expand Down
2 changes: 2 additions & 0 deletions doc/modules/emails.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
layout: doc
title: Emails module
directory-tree:
de-emphasize: true
---

# Emails module
Expand Down
2 changes: 2 additions & 0 deletions doc/modules/external_services.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
layout: doc
title: External Services module
directory-tree:
emphasize: true
---

# External Services module
Expand Down
2 changes: 2 additions & 0 deletions doc/modules/force_actions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
layout: doc
title: Force Actions module
directory-tree:
emphasize: true
---

# Force Actions module
Expand Down
6 changes: 0 additions & 6 deletions doc/modules/forged_recipients.md

This file was deleted.

2 changes: 2 additions & 0 deletions doc/modules/ip_score.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
layout: doc
title: IP Score module
directory-tree:
de-emphasize: true
---

# IP Score
Expand Down
2 changes: 2 additions & 0 deletions doc/modules/milter_headers.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
layout: doc
title: Milter headers module
directory-tree:
emphasize: true
---

# Milter headers module
Expand Down
Loading

0 comments on commit 5d2902c

Please sign in to comment.