diff --git a/src/core/utils.py b/src/core/utils.py index 677799d851af2edfaa936e0e541041c73bfbf76e..7337722731bbd1af49fedef2f508f1d37941fee0 100644 --- a/src/core/utils.py +++ b/src/core/utils.py @@ -8,15 +8,22 @@ from django.conf import settings from django.utils import timezone from django.utils.html import strip_tags from django.utils.safestring import mark_safe +from django.utils.text import slugify import markdown from markdown.extensions import Extension as MarkdownExtension +from markdown.extensions.toc import TocExtension from markdown.inlinepatterns import LinkInlineProcessor, LINK_RE, ReferenceInlineProcessor, REFERENCE_RE +def markdown_header_slugify(value: str, separator: str) -> str: + return 'md-' + slugify(value) + + MARKDOWN_EXTENSIONS = [ 'markdown.extensions.codehilite', 'markdown.extensions.sane_lists', 'markdown.extensions.tables', + TocExtension(marker='', permalink=' 🔗', slugify=markdown_header_slugify), ] TOKEN_CHARSET = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' @@ -69,13 +76,12 @@ def render_markdown(markup: str): 'table', 'thead', 'tbody', 'th', 'td', 'tr', 'hr', 'p', 'pre' ] + bleach.sanitizer.ALLOWED_TAGS, attributes={ - '*': ['class'], + '*': ['class', 'id'], **bleach.sanitizer.ALLOWED_ATTRIBUTES, }, protocols=['http', 'https', 'mailto', 'ftp', 'ftps'] ) return mark_safe(cleaner.clean(rendered_markup)) - return mark_safe(rendered_markup) def gen_token(length: int = 50): diff --git a/src/plainui/jinja2/plainui/base.html b/src/plainui/jinja2/plainui/base.html index 0d54638b8a9802924fb7c57e5fce21150b12d7ec..713216290838672729e715ba133d99afe9b51ad2 100644 --- a/src/plainui/jinja2/plainui/base.html +++ b/src/plainui/jinja2/plainui/base.html @@ -81,6 +81,9 @@ <li> <a class="nav-link text-white" title="{{ _("Principles") }}" href="https://howto.rc3.world/rules.html">{{ _("Principles") }}</a> </li> + <li> + <a class="nav-link text-white" title="{{ _("helpful teams") }}" href="{{ url( 'plainui:static_page', page_slug='start') }}#md-helpful-teams">{{ _("helpful teams") }}</a> + </li> <li> <a class="nav-link text-white external" title="{{ _("merch") }}" target="_blank" href="https://merch.rc3.world/">{{ _("merch") }}</a> </li> diff --git a/src/plainui/jinja2/plainui/components/header_buttons.html b/src/plainui/jinja2/plainui/components/header_buttons.html index 121a19a530a6eaac72e2491a38c8f5d4acfffe29..3b41e56a45b8756f10885335d71912b2b39a9074 100644 --- a/src/plainui/jinja2/plainui/components/header_buttons.html +++ b/src/plainui/jinja2/plainui/components/header_buttons.html @@ -122,6 +122,16 @@ </a> {% endmacro %} +{% macro help(title=_("helpful teams"), color="transparent" ) %} + <a + href="{{ url( 'plainui:static_page', page_slug='start') }}" + class="btn-icon-big btn btn-{{ color }} p-2" + title="{{ title }}" + > + <svg width="1.25rem" height="1.25rem" fill="currentColor" version="1.1" x="0" y="0" viewBox="0 0 500 500" style="enable-background:new 0 0 500 500" xml:space="preserve" id="svg62" xmlns="http://www.w3.org/2000/svg"><style type="text/css" id="style2">.st0{display:none}.st1{display:inline}.st2{fill:none;stroke:#000;stroke-width:18;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10}</style><g aria-label="?" transform="scale(.9727 1.02807)" id="text1060" style="font-weight:700;font-size:300.21px;font-family:'Open Sans';-inkscape-font-specification:'Open Sans Bold';stroke-width:7.50525"><g id="g2188"><g id="report" style="enable-background:new 0 0 500 500" transform="scale(1.02807 .9727)"><g id="g59"><path d="M448.65 237.65 262.3 51.3a16.992 16.992 0 0 0-24.04 0L51.9 237.65c-6.64 6.64-6.64 17.4 0 24.04l186.35 186.35a16.992 16.992 0 0 0 24.04 0l186.35-186.35c6.65-6.64 6.65-17.4.01-24.04zM250.27 411.98 87.96 249.67 250.28 87.36l162.31 162.31-162.32 162.31z" id="path57"/></g></g><path d="m226.697 274.396-3.903-45.332q-.3-5.104 3.602-7.806 4.203-3.002 15.912-6.904l27.92-9.007v-23.716q-5.105-.9-11.109-1.201-5.704-.6-11.708-.6-10.207 0-22.516 1.8-12.308 1.802-22.816 4.204l-6.004-30.622q29.721-9.006 56.44-9.006 24.016 0 38.126 4.503 14.41 4.203 20.715 13.81 6.604 9.606 6.604 25.818 0 10.207-2.701 17.712-2.402 7.505-9.007 13.21-6.304 5.703-18.313 11.107-12.008 5.104-30.921 10.808l-1.801 31.222zm-9.607 42.029q0-12.609 4.503-18.013 4.503-5.704 19.213-5.704 14.11 0 18.613 5.704 4.804 5.404 4.804 18.013 0 12.91-4.804 18.313-4.503 5.404-18.613 5.404-14.71 0-19.213-5.404t-4.503-18.313z" style="font-family:Changa;-inkscape-font-specification:'Changa Bold'" id="path2061"/></g></g></svg> + </a> +{% endmacro %} + {% macro share(share_url, title=_("share this "), color="transparent" ) -%} <a href="{{ share_url }}" diff --git a/src/plainui/jinja2/plainui/header.html b/src/plainui/jinja2/plainui/header.html index 5e516836f4c768f94e814977a5fa18e1e50036c4..4186c3791b88a1e20a720a2c8acf28308c473563 100644 --- a/src/plainui/jinja2/plainui/header.html +++ b/src/plainui/jinja2/plainui/header.html @@ -79,6 +79,7 @@ {% if report_info %} {{ hbtns.report(report_info.url, kind=report_info.get('kind', 'url'), color="transparent") }} {% endif %} + {{ hbtns.help() }} {{ hbtns.globe() }} {{ hbtns.logout() }} </div>