diff --git a/config.toml b/config.toml index bcb02b31f8617e5d1f0fc96ca9edbc531e95d0fe..560b3023565e89e8c5da0769315f8c8dbbb4b2a5 100755 --- a/config.toml +++ b/config.toml @@ -64,11 +64,9 @@ favicon = "assets/favicon.ico" languages = ["en","ru"] -# header title -header.name = "Karzok" +header_file = "content/header.toml" # github -#version = "https://api.github.com/repos/kogeletey/karzok/releases/latest" #localcdn = true devmode = true @@ -82,19 +80,17 @@ repo_branch = "develop" alert_file = "content/alert.toml" -[[extra.header_left]] -text = "Reference" -link = "$base_url/reference" +[[extra.footer]] +lang = "en" +text = "powered by <a href=\"https://karzok.re128.org\"> karzok</a>" -[[extra.header_right]] -link = "https://github.com/kogeletey/karzok" -svg = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" viewBox="0 0 24 24"><path d="M12 2A10 10 0 0 0 2 12c0 4.42 2.87 8.17 6.84 9.5c.5.08.66-.23.66-.5v-1.69c-2.77.6-3.36-1.34-3.36-1.34c-.46-1.16-1.11-1.47-1.11-1.47c-.91-.62.07-.6.07-.6c1 .07 1.53 1.03 1.53 1.03c.87 1.52 2.34 1.07 2.91.83c.09-.65.35-1.09.63-1.34c-2.22-.25-4.55-1.11-4.55-4.92c0-1.11.38-2 1.03-2.71c-.1-.25-.45-1.29.1-2.64c0 0 .84-.27 2.75 1.02c.79-.22 1.65-.33 2.5-.33c.85 0 1.71.11 2.5.33c1.91-1.29 2.75-1.02 2.75-1.02c.55 1.35.2 2.39.1 2.64c.65.71 1.03 1.6 1.03 2.71c0 3.82-2.34 4.66-4.57 4.91c.36.31.69.92.69 1.85V21c0 .27.16.59.67.5C19.14 20.16 22 16.42 22 12A10 10 0 0 0 12 2z" fill="currentColor"></path></svg>' +[[extra.footer]] +lang = "ru" +text = "запущен Ñ Ð¿Ð¾Ð¼Ð¾Ñ‰ÑŒÑŽ <a href=\"https://karzok.re128.org\"> karzok</a>" -[[extra.header_right]] -link = "https://sr.ht/~kogeletey/karzok" -svg = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path d="M11.5 3a9.5 9.5 0 1 1 0 19a9.5 9.5 0 0 1 0-19zm0 1a8.5 8.5 0 1 0 0 17a8.5 8.5 0 0 0 0-17z" fill="currentColor"></path></svg>' +[[extra.footer]] +version = "https://api.github.com/repos/kogeletey/karzok/releases/latest" + +[[extra.footer]] +text = "license: MIT" -[[extra.header_right]] -text = "External Link" -link = "https://karzok.re128.org" -target = "_blank" diff --git a/content/alert.toml b/content/alert.toml index 3f606233e11e239610a5aa8fc97711c8356a9a2a..08f6cefe0ce6aecd66751aa0f0f432a6d72eae80 100644 --- a/content/alert.toml +++ b/content/alert.toml @@ -2,3 +2,11 @@ text = "This a staging site, use production <a href=\"https://karzok.re128.org\" bg_color = "#ffdc00" text_color = "#111" #dismissable = true + +[[translations]] +lang = "en" +text = "This a staging site, use production <a href=\"https://karzok.re128.org\"> here </a>" + +[[translations]] +lang = "ru" +text = "Ðто промежуточный Ñайт, лучше иÑпользуйте <a href=\"https://karzok.re128.org\"> Ñтот </a>" diff --git a/content/header.toml b/content/header.toml new file mode 100644 index 0000000000000000000000000000000000000000..34f46102ed54cf6823f70644823aafc728f53c9e --- /dev/null +++ b/content/header.toml @@ -0,0 +1,32 @@ +name = "Karzok" + +[[left]] +lang = "en" +text = "Reference" +link = "@/reference" + +[[left]] +lang = "ru" +text = "СпецификациÑ" +link = "@/reference" + +[[right]] +link = "https://github.com/kogeletey/karzok" +svg = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" viewBox="0 0 24 24"><path d="M12 2A10 10 0 0 0 2 12c0 4.42 2.87 8.17 6.84 9.5c.5.08.66-.23.66-.5v-1.69c-2.77.6-3.36-1.34-3.36-1.34c-.46-1.16-1.11-1.47-1.11-1.47c-.91-.62.07-.6.07-.6c1 .07 1.53 1.03 1.53 1.03c.87 1.52 2.34 1.07 2.91.83c.09-.65.35-1.09.63-1.34c-2.22-.25-4.55-1.11-4.55-4.92c0-1.11.38-2 1.03-2.71c-.1-.25-.45-1.29.1-2.64c0 0 .84-.27 2.75 1.02c.79-.22 1.65-.33 2.5-.33c.85 0 1.71.11 2.5.33c1.91-1.29 2.75-1.02 2.75-1.02c.55 1.35.2 2.39.1 2.64c.65.71 1.03 1.6 1.03 2.71c0 3.82-2.34 4.66-4.57 4.91c.36.31.69.92.69 1.85V21c0 .27.16.59.67.5C19.14 20.16 22 16.42 22 12A10 10 0 0 0 12 2z" fill="currentColor"></path></svg>' + +[[right]] +link = "https://sr.ht/~kogeletey/karzok" +svg = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path d="M11.5 3a9.5 9.5 0 1 1 0 19a9.5 9.5 0 0 1 0-19zm0 1a8.5 8.5 0 1 0 0 17a8.5 8.5 0 0 0 0-17z" fill="currentColor"></path></svg>' + +[[right]] +lang = "ru" +text = "ВнешнÑÑ ÑÑылка" +link = "https://karzok.re128.org" +target = "_blank" + +[[right]] +lang = "en" +text = "External Link" +link = "https://karzok.re128.org" +target = "_blank" + diff --git a/templates/macros/common.html b/templates/macros/common.html index a71bde9a03c38ff413a86845dd612832df4910a4..07af9ef5f67db6104cf92686d64dd8ae4d2363e6 100644 --- a/templates/macros/common.html +++ b/templates/macros/common.html @@ -3,28 +3,30 @@ {# footer in the page #} {% macro footer() %} +{% if config.extra.footer%} <footer> <ul> - {% if config.extra.footer %} - {% for item in config.extra.footer%} + {% for item in config.extra.footer %} + {% if item.lang and item.lang == lang and item.text %} + <li> + <span> {{ item.text | safe }} </span> + </li> + {% elif not item.lang and item.text %} + <li> + <span> {{ item.text | safe }} </span> + </li> + {% elif item.version and not item.text %} + {% set path = load_data(url=item.version, format="json") %} <li> - <span {% if item.url %}<a href="{{ item.url }}"/> {% endif %}{{ item.text }} </a></span> - </li> - {% endfor %} - {% else %} - <li> - <span> powered by <a href="https://karzok.re128.org"> karzok </a></span> - </li> - <li> - {% if config.extra.version and not config.extra.footer %} - {% set path = load_data(url=config.extra.version, format="json") %} <a href="{{ path.html_url }}"> <span> {{ path.tag_name }} </span> </a> - {%endif%} </li> - {% endif %} + {% endif %} + {% endfor %} </ul> </footer> +{% endif %} {% endmacro %} + {% macro title_or_last(component, offset=2) %} {% set length = component.components | length %} {% set last = component.components | last %} diff --git a/templates/macros/header.html b/templates/macros/header.html index 0797e134362bdb28d84862c9c786debaf48e01d8..e5f9d56cd57dad5a8fc50e4ab7cdf9607b8a8019 100644 --- a/templates/macros/header.html +++ b/templates/macros/header.html @@ -4,6 +4,9 @@ {{ top_nav::alert(file=config.extra.alert_file) }} {% endif %} {% set current_link = current_url | safe | trim_end_matches(pat="/") %} +{% if config.extra.header_file %} +{% set h = load_data(path=config.extra.header_file | safe) %} +{% endif %} <header> <nav aria-label="section navigation" itemscope itemtype="http://shema.org/SiteNavigationElement"> <ul> @@ -13,14 +16,20 @@ <div class="logotype"> <img width="31" height="31" alt="favicon" src="{{ get_url(path=config.extra.logotype)}}" /> </div> - {% else %} + {% elif config.extra.header.name %} <span> {{ config.extra.header.name | default(value="Home") }}</span> + {% elif h %} + <span> {{ h.name | default(value="Home") }}</span> {% endif %} </a> </li> {% if config.extra.header_left %} {% for item in config.extra.header_left %} - {{ top_nav::links(item=item,current_url=current_url) }} + {{ top_nav::links(item=item,current_url=current_url) }} + {% endfor %} + {% elif h %} + {% for item in h.left %} + {{ top_nav::links(item=item,current_url=current_url) }} {% endfor %} {% endif %} </ul> @@ -39,9 +48,12 @@ {% for item in config.extra.header_right %} {{ top_nav::links(item=item,current_url=current_url) }} {% endfor %} - {% endif %} - <li class="separator"> - {% if config.extra.devmode %} + {% elif h.right %} + {% for item in h.right %} + {{ top_nav::links(item=item,current_url=current_url) }} + {% endfor %} + {% endif %} + <li class="separator"> {% if config.languages and config.extra.languages %} <div class="dropdown"> <button class="vector" aria-expanded="false"> @@ -62,7 +74,6 @@ {% endfor %} </ul> </div> - {% endif %} {% endif %} <button class="toggle vector" type="button" aria-label="Toggle mode"> <span class="svg"> @@ -97,7 +108,15 @@ color: {{ alert.text_color }}; " {% endif %}> - <span> {{ alert.text | safe }} </span> + {% if alert.translations %} + {% for trs in alert.translations %} + {% if trs.lang == lang %} + <span> {{ trs.text | safe }} </span> + {% endif %} + {% endfor %} + {% else %} + <span> {{ alert.text | safe }} </span> + {% endif %} {% if alert.dismissable %} <button aria-label="close alert"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" width="22" height="22" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M24 9.4L22.6 8L16 14.6L9.4 8L8 9.4l6.6 6.6L8 22.6L9.4 24l6.6-6.6l6.6 6.6l1.4-1.4l-6.6-6.6L24 9.4z" fill="currentColor"></path></svg> @@ -110,7 +129,10 @@ {% endmacro %} {% macro links(item,current_url) %} -{% set item_link = item.link | replace(from = "$base_url", to=config.base_url) %} +{% set item_link = item.link | replace(from = "@", to=config.base_url) %} +{% if item.lang and lang != config.default_language %} + {% set item_link = item.link | replace(from="@", to=config.base_url ~ "/" ~ lang) %} +{% endif %} {% set item_target = item.target | default(value="_self") %} <li> {% if item.svg %} @@ -122,17 +144,22 @@ {% endif %} </a> {% endif %} - {% if item.text %} - <a aria-label="{% if item.alt %} {{ item.alt }} {% else %} {{ item.text }} {%endif%}" itemprop="url" href=" {{ item_link | safe }}" + <a aria-label="{% if item.alt %} {{ item.alt }} {% elif item.text %} {{ item.text }} {% elif item.lang and item.lang == lang %} {{ item.text }} {% endif %}" itemprop="url" href=" {{ item_link | safe }}" {% if item_target != "_blank" %} class="{% if current_url is starting_with(item_link) %} active {% endif %}" {% endif %} target="{{ item_target }}"> - <span> {{ item.text }} + {% if item.lang and item.lang == lang %} + <span> {{ item.text }} + {% if item_target == "_blank" %} + <svg width="16" height="16" viewBox="0 0 32 32"><path fill="currentColor" d="M10 6v2h12.59L6 24.59L7.41 26L24 9.41V22h2V6H10z"/></svg> + {% endif %}</span> + {% elif not item.lang and item.text %} + <span> {{ item.text }} {% if item_target == "_blank" %} <svg width="16" height="16" viewBox="0 0 32 32"><path fill="currentColor" d="M10 6v2h12.59L6 24.59L7.41 26L24 9.41V22h2V6H10z"/></svg> {% endif %}</span> + {% endif %} </a> - {% endif %} </li> {% endmacro %}