Refactor all templates to dictpress v5 (Rust/Tera templates).
This commit is contained in:
+79
-76
@@ -1,97 +1,100 @@
|
||||
{{ define "results" }}
|
||||
{{ $maxContentItems := .Consts.SiteMaxEntryContentItems }}
|
||||
{{ $numResults := (min (len .Data.Results.Entries) 10) }}
|
||||
{% set max_content_items = consts.site_max_content_items %}
|
||||
{% set num_results = results.entries | length %}
|
||||
{% if num_results > 10 %}{% set num_results = 10 %}{% endif %}
|
||||
|
||||
<div class="row">
|
||||
<div class="eight columns">
|
||||
<ol class="entries">
|
||||
{{- range $k, $r := (mustSlice .Data.Results.Entries 0 $numResults) -}}
|
||||
<li class="entry" data-guid="{{ $r.GUID }}" data-head="{{ $r.Content | join ", " }}">
|
||||
<header class="head">
|
||||
<div class="col-8">
|
||||
<ol class="entries unstyled">
|
||||
{% for r in results.entries | slice(end=num_results) %}
|
||||
{% set shareGuid = "s" ~ r.guid | split(pat="-") | first %}
|
||||
<li class="entry card" id="{{ shareGuid }}" data-head="{{ r.content | join(sep=", ") }}" data-lang="{{ r.lang }}">
|
||||
<header class="head hstack justify-between">
|
||||
<div>
|
||||
<div class="title-wrap">
|
||||
<h3 class="title">{{ $r.Content | join ", " }}</h3>
|
||||
|
||||
{{- if $r.Meta.audio -}}
|
||||
<a href="{{ $r.Meta.audio }}" class="audio" data-audio><img src="/static/audio.svg?v={{ $.AssetVer }}" alt="{{ $.L.T "public.playAudio" }}"></a>
|
||||
{{- end -}}
|
||||
|
||||
{{- if $.Consts.EnableSubmissions -}}
|
||||
<a href="#" data-from="{{ $r.GUID }}" class="edit" title="{{ $.L.Ts "public.suggestEdit" "word" (index $r.Content 0) }}">✏️</a>
|
||||
{{- end -}}
|
||||
<div class="title-wrap hstack items-center gap-2">
|
||||
<h3 class="title">{{ r.content | join(sep=", ") }}</h3>
|
||||
{% if r.meta.audio %}
|
||||
<button type="button" class="audio" data-audio data-src="{{ r.meta.audio }}">
|
||||
<img src="/static/audio.svg?v={{ asset_ver }}" alt="{{ t(key="public.playAudio") }}">
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{{- if $r.Phones -}}
|
||||
<span class="pronun">♪ {{ $r.Phones | join "," }}</span>
|
||||
{{- end -}}
|
||||
|
||||
{% if r.phones and r.phones | length > 0 %}
|
||||
<span class="pronun text-light">♪ {{ r.phones | join(sep=",") }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="meta">
|
||||
{{- if $r.Tags -}}
|
||||
<div class="meta hstack items-center">
|
||||
{% if r.tags and r.tags | length > 0 %}
|
||||
<span class="tags">
|
||||
{{- range $tag := $r.Tags -}}
|
||||
<span class="tag" {{- if hasPrefix "src:" $tag }} title="{{ $.L.T "public.sourceTag" }}"{{- end }}>{{ $tag }}</span>
|
||||
{{- end -}}
|
||||
{% for tag in r.tags %}
|
||||
<span class="badge outline" {% if tag is starting_with("src:") %} title="{{ t(key="public.sourceTag") }}"{% endif %}>{{ tag }}</span>
|
||||
{% endfor %}
|
||||
</span>
|
||||
{{- end -}}
|
||||
<a href="#" title="Share screenshot" class="export" data-guid="{{ $r.GUID }}"><img src="/static/export.svg?v={{ $.AssetVer }}" alt="Share screenshot"></a>
|
||||
{% endif %}
|
||||
|
||||
<div class="toolbar">
|
||||
{% if consts.enable_submissions %}
|
||||
<button class="ghost edit item" data-edit-from="{{ r.guid }}" title="{{ t(key="public.suggestEdit") }}"><img src="/static/edit.svg?v={{ asset_ver }}" alt="{{ t(key="public.suggestEdit") }}"></button>
|
||||
{% endif %}
|
||||
<button class="ghost share item" data-share-entry="{{ shareGuid }}" title="{{ t(key="public.shareSnapshot") }}"><img src="/static/export.svg?v={{ asset_ver }}" alt="{{ t(key="public.shareSnapshot") }}"></button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{{- if $r.Relations -}}
|
||||
{{- $lastType := "" -}}
|
||||
{{- range $k, $d := $r.Relations -}}
|
||||
{{- $types := ($d.RelationTypes | join ", ") -}}
|
||||
{% if r.relations and r.relations | length > 0 %}
|
||||
{%- set_global last_type = "" -%}
|
||||
{%- for d in r.relations -%}
|
||||
{%- set types = d.relation.types | default(value=[]) | join(sep=", ") -%}
|
||||
|
||||
{{- if ne $lastType $types -}}
|
||||
{{- if $lastType -}}</ol>{{- end }}
|
||||
<ol class="defs">
|
||||
{{ if $d.RelationTypes }}
|
||||
<li class="types">
|
||||
{{- range $t := $d.RelationTypes -}}
|
||||
<span>
|
||||
{{- $dType := index (index $.Langs $r.Lang).Types $t }}
|
||||
{{- if $dType }}{{ $dType }} {{ end -}}
|
||||
{{- $rType := index (index $.Langs $d.Lang).Types $t }}
|
||||
{{- if $rType }}({{ $rType }}){{ end -}}
|
||||
</span>
|
||||
{{- end -}}
|
||||
</li>
|
||||
{{ end }}
|
||||
{{- end -}}
|
||||
{%- if last_type != types or loop.first -%}
|
||||
{% if not loop.first %}</ol>{% endif %}
|
||||
<ol class="defs">
|
||||
<li class="types">
|
||||
{%- for t in d.relation.types | default(value=[]) -%}
|
||||
{%- if t != "" -%}
|
||||
<span>
|
||||
{%- set type_label = langs[d.lang].types | get(key=t, default="") -%}
|
||||
{%- if type_label %}{{ type_label }}
|
||||
{%- else %}({{ t }}){% endif -%}
|
||||
</span>
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
</li>
|
||||
{%- endif %}
|
||||
|
||||
<li><div data-guid="{{ $d.GUID }}" class="def">
|
||||
{{ $d.Content | join ", " }}
|
||||
{{ if or (gt $d.ContentLength $maxContentItems) $d.Meta.synonyms -}}
|
||||
<a href="#" class="more-toggle" data-id="{{ $r.GUID }}-{{ $d.GUID }}" title="{{ $.L.Ts "public.viewMore" "num" $d.ContentLength }}"
|
||||
data-entry-guid="{{ $d.GUID }}" data-from-lang="{{ $r.Lang }}" data-to-lang="{{ $d.Lang }}"
|
||||
role="button" aria-expanded="false" aria-controls="{{ $r.GUID }}-{{ $d.GUID }}">
|
||||
</a>
|
||||
{{- end -}}
|
||||
{{- if $.Consts.EnableSubmissions }}
|
||||
<a href="#" data-from="{{ $r.GUID }}" data-to="{{ $d.GUID }}" class="edit" title="{{ $.L.Ts "public.suggestEdit" "word" (index $d.Content 0) }}">✏️</a>
|
||||
{{ end -}}
|
||||
<li><div data-guid="{{ d.guid }}" class="def" data-lang="{{ d.lang }}">
|
||||
{{ d.content | join(sep=", ") }}
|
||||
{% if d.content_length > max_content_items or d.meta.synonyms %}
|
||||
<a href="#" class="more-toggle" data-id="{{ r.guid }}-{{ d.guid }}" title="{{ t(key="public.viewMore") }}"
|
||||
data-entry-guid="{{ d.guid }}" data-from-lang="{{ r.lang }}" data-to-lang="{{ d.lang }}"
|
||||
role="button" aria-expanded="false" aria-controls="{{ r.guid }}-{{ d.guid }}">
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if consts.enable_submissions %}
|
||||
<button type="button" data-edit-from="{{ r.guid }}" data-edit-to="{{ d.guid }}" class="edit" title="{{ t(key="public.suggestEdit") }}">
|
||||
<img src="/static/edit.svg?v={{ asset_ver }}" alt="{{ t(key="public.suggestEdit") }}">
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
<!-- This is dynamically populated by JS when the "more" link is clicked -->
|
||||
<div class="more" id="{{ $r.GUID }}-{{ $d.GUID }}" role="region" aria-hidden="true"></div>
|
||||
<div class="more" id="{{ r.guid }}-{{ d.guid }}" role="region" aria-hidden="true"></div>
|
||||
|
||||
</div></li>
|
||||
{{ $lastType = $types }}
|
||||
{{- end -}}
|
||||
</ol>
|
||||
{{ end }}
|
||||
</div></li>
|
||||
{%- set_global last_type = types -%}
|
||||
{%- endfor -%}
|
||||
</ol>
|
||||
{% endif %}
|
||||
|
||||
</li>
|
||||
{{- end -}}
|
||||
{% endfor %}
|
||||
</ol>
|
||||
</div>
|
||||
<nav class="three columns col-offset-1 related">
|
||||
{{ if gt (len .Data.Results.Entries) $numResults }}
|
||||
<h3>{{ .L.T "public.similarTitle" }}</h3>
|
||||
{{ range $k, $r := (mustSlice .Data.Results.Entries $numResults) }}
|
||||
<a href="{{ UnicodeURL (index $r.Content 0) }}" class="word">{{ index $r.Content 0 }}</a>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
<nav class="col-3 offset-1 related" aria-label="{{ t(key='public.similarTitle') }}">
|
||||
{% if results.entries | length > num_results %}
|
||||
<h3>{{ t(key="public.similarTitle") }}</h3>
|
||||
{% for r in results.entries | slice(start=num_results) %}
|
||||
<a href="{{ consts.root_url }}/dictionary/{{ from_lang }}/{{ to_lang }}/{{ r.content.0 | urlencode }}" class="word">{{ r.content.0 }}</a>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</nav>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
Reference in New Issue
Block a user