Refactor all templates to dictpress v5 (Rust/Tera templates).

This commit is contained in:
2026-03-26 14:59:30 +05:30
parent c07b8331c3
commit b13a23bbc4
22 changed files with 1032 additions and 1585 deletions
+72 -79
View File
@@ -1,111 +1,104 @@
{{- define "header" -}}
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
{{ block "meta" . -}}
{% block meta %}
<title>
{{- if eq .Data.PageType "/" }} {{- .L.T "global.siteName" -}}
{{- else if eq .Data.PageType "glossary" }}{{- .L.Ts "public.glossary" "lang" (title .Data.Glossary.FromLang) -}}
{{- else if eq .Data.PageType "search" }}{{- .L.Ts "public.searchTitle" "query" .Data.Query.Query "fromLang" .Data.Query.ToLang -}}
{{- else if ne .Data.Title "" }}{{ .Data.Title }}
{{- end -}}
{%- if page_type == "/" %} {{ t(key="global.siteTitle") }}
{%- elif page_type == "glossary" %}{{ ts(key="public.glossaryTitle", lang=from_lang_name) }} - {{ t(key="global.siteName") }}
{%- elif page_type == "search" %}{{ ts(key="public.searchTitle", query=query, to_lang=to_lang_name | lower) }} - {{ t(key="global.siteName") }}
{%- elif title %}{{ title }} - {{ t(key="global.siteName") }}
{%- endif -%}
</title>
<meta name="description" value="
{{- if eq .Data.PageType "/" }}{{- .L.T "global.siteName" -}}
{{- else if eq .Data.PageType "glossary" }}{{- .L.Ts "public.glossary" "lang" (title .Data.Glossary.FromLang) -}}
{{- else if eq .Data.PageType "search" }}{{- .L.Ts "public.searchDescription" "query" .Data.Query.Query "fromLang" .Data.Query.FromLang "toLang" .Data.Query.ToLang -}}
{{- else if ne .Data.Description "" }}{{ .Data.Description }}
{{- else }}{{ block "description" . }}{{end}}
{{- end -}}" />
{{- end }}
<meta property="og:image" content="{{ .Consts.RootURL }}/static/thumb.png">
{%- if page_type == "/" %}{{ t(key="public.mainTitle") }}
{%- elif page_type == "glossary" %}{{ ts(key="public.glossaryTitle", lang=from_lang_name) }}
{%- elif page_type == "search" %}{{ ts(key="public.searchDescription", from_lang=from_lang_name, query=query, to_lang=to_lang_name) }}
{%- elif description %}{{ description }}
{%- else %}{% block description %}{% endblock %}
{%- endif -%}" />
{% endblock %}
<meta property="og:image" content="{{ consts.root_url | safe }}/static/thumb.png">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<script>
window._ROOT_URL = "";
window._MAX_CONTENT_ITEMS = {{ .Consts.SiteMaxEntryContentItems }};
<script>
window._ROOT_URL = "{{ consts.root_url | safe }}";
window._MAX_CONTENT_ITEMS = {{ consts.site_max_content_items }};
</script>
<link rel="shortcut icon" href="/static/favicon.png?v={{ .AssetVer }}" type="image/x-icon" />
<link href="/static/flexit.css?v={{ .AssetVer }}" rel="stylesheet" type="text/css" />
<link href="/static/style.css?v={{ .AssetVer }}" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="/static/favicon.png?v={{ asset_ver }}" type="image/x-icon" />
<link href="/static/_bundle.css?f=oat.min.css&f=style.css&v={{ asset_ver }}" rel="stylesheet" type="text/css" />
<script defer src="/static/oat.min.js?v={{ asset_ver }}"></script>
</head>
<body class="{{ if eq .Data.PageType "/"}}home{{ end }}">
<body class="{% if page_type == "/" %}home{% endif %}">
<div class="container">
<section class="main">
<main class="main">
<header class="header">
<div class="row">
<div class="logo four columns">
<a href="/"><img src="/static/logo.svg?v={{ .AssetVer }}" alt="Alar" /></a>
<h3 class="intro">
<div class="logo col-4">
<a class="unstyled" href="/"><img src="/static/logo.svg?v={{ asset_ver }}" alt="{{ t(key="global.siteName") }}" /></a>
<div class="intro">
<p>ಶ್ರೀ. ವಿ. ಕೃಷ್ಣ ಅವರ ಕನ್ನಡ - ಇಂಗ್ಲಿಷ್ ನಿಘಂಟು</p>
Alar V. Krishna's Kannada → English dictionary
</h3>
"Alar" V. Krishna's Kannada → English dictionary
</div>
</div><!-- logo col -->
<div class="search eight columns">
<div class="search col-8">
<form class="search-form" method="get" action="">
<div>
<select name="lang" aria-label="Select dictionary">
{{ range $d := .Dicts }}
{{ $from := index $d 0}}
{{ $to := index $d 1}}
<option value="{{ $from.ID }}/{{ $to.ID }}">
{{ $from.Name }} - {{ $to.Name }}
</option>
{{ end }}
<fieldset class="group">
<select name="lang" aria-label="{{ t(key="public.selectDict") }}">
{% for d in dicts -%}
{%- set from = d.0 -%}
{%- set to = d.1 -%}
<option value="{{ from.id }}/{{ to.id }}">{{ from.name }} - {{ to.name }}</option>
{% endfor -%}
</select>
<div class="input-group">
<input autofocus autocomplete="off" required placeholder="" aria-label="Search word"
type="text" id="q" name="q" value="{{ if .Data.Query }}{{ .Data.Query.Query }}{{ end }}" data-autocomp-autoselect="false" />
<button type="submit" aria-label="Search"><img src="/static/search.svg?v={{ .AssetVer }}" alt="{{- .L.T "global.btnSearch" -}}" /></button>
</div>
</div>
<input autofocus autocomplete="off" required placeholder="" aria-label="{{ t(key="public.searchWord") }}"
type="text" id="q" name="q" value="{{ query | default(value="") }}" />
<button type="submit" aria-label="{{ t(key="global.btnSearch") }}"><img src="/static/search.svg?v={{ asset_ver }}" alt="{{ t(key="global.btnSearch") }}" /></button>
</fieldset>
</form>
</div>
</div>
</header>
{{ end}}
{{ define "footer" }}
<nav class="nav">
{{ if .Consts.EnableSubmissions }}
<a href="/submit">{{- .L.T "public.submitEntry" -}}</a>
{{ end }}
{{ if .Consts.EnableGlossary }}
{{ range $d := .Dicts }}
{{ $from := index $d 0}}
{{ $to := index $d 1}}
<a href="/glossary/{{ $from.ID }}/{{ $to.ID }}/*" class="tab">
{{ $.L.Ts "public.glossary" "lang" $from.Name }}
</a>
{{ end }}
{{ end }}
<a href="/p/about">{{ .L.T "public.about" }}</a>
{%- block content %}{% endblock -%}
<nav class="nav justify-center" aria-label="Site">
{% if consts.enable_submissions %}
<a href="{{ consts.root_url | safe }}/submit">{{ t(key="public.submitEntry") }}</a>
{% endif %}
{% if consts.enable_glossary %}
{%- for d in dicts %}
{%- set from = d.0 -%}
{%- set to = d.1 -%}
<a href="{{ consts.root_url | safe }}/glossary/{{ from.id }}/{{ to.id }}/*" class="tab">
{{ ts(key="public.glossary", lang=from.name) }}
</a>
{% endfor -%}
{% endif %}
<a href="{{ consts.root_url | safe }}/p/about">{{ t(key="public.about") }}</a>
</nav>
</section>
</main>
<footer class="footer">
<a href="https://indicarchive.org">IDAF</a>
<a href="https://zerodha.tech/blog/alar-the-making-of-an-open-source-dictionary/">Support by <img src="/static/zerodha-logo.svg" alt="Zerodha"></a>
<footer class="footer align-center text-light">
<span>Maintained by <a href="https://indicarchive.org">IDAF</a></span>
<span>Supported by <a href="https://zerodha.tech/blog/alar-the-making-of-an-open-source-dictionary/"><img src="/static/zerodha-logo.svg" alt="Zerodha"></a></span>
</footer>
</div><!-- container -->
<form class="box form-comments" data-success="{{ .L.T "public.suggestSubmitted" }}">
<div>
<h4>{{ .L.T "public.submitTitle" }}</h4>
<textarea name="comments" autofocus maxlength="500"></textarea>
<p>
<button type="submit">{{ .L.T "public.suggestSubmitBtn" }}</button>
<button class="button-outline close">{{ .L.T "global.btnClose" }}</button>
</p>
</div>
</form>
<template id="tpl-form-comments">
<article class="card form-comments" popover data-success="{{ t(key="public.suggestSubmitted") }}">
<h4>{{ t(key="public.submitTitle") }}</h4>
<textarea name="comments" aria-label="{{ t(key="public.submitTitle") }}" maxlength="500"></textarea>
<script type="module" src="/static/_bundle.js?f=autocomp.js&f=share.js&f=main.js&f=alar.js&v={{ .AssetVer }}"></script>
<footer class="hstack mt-2">
<button class="submit-comment">{{ t(key="public.suggestSubmitBtn") }}</button>
<button class="close" data-variant="secondary">{{ t(key="global.btnClose") }}</button>
</footer>
</article>
</template>
<script type="module" src="/static/_bundle.js?f=autocomp.js&f=share.js&f=main.js&f=alar.js&v={{ asset_ver }}"></script>
</body>
</html>
{{ end }}