Skip to content

Commit

Permalink
Refactor default public site theme.
Browse files Browse the repository at this point in the history
- Better styles and responsiveness.
- Remove hardcoded languages and make them config based/dynamic.
- Add support for multi-dict selection above the search box.
- Make all hardcoded language i18n-ized (lang.json)
  • Loading branch information
knadh committed Jun 4, 2023
1 parent 059e4b7 commit aab9be6
Show file tree
Hide file tree
Showing 11 changed files with 297 additions and 219 deletions.
37 changes: 22 additions & 15 deletions site/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<head>
<meta charset="utf-8" />
<title>
{{- if eq .Data.PageName "/" }}Welcome to the dictionary.
{{- else if eq .Data.PageName "glossary" }}Glossary of words
{{- else if eq .Data.PageName "search" }}"{{ .Data.Query.Query }}" meaning
{{- if eq .Data.PageName "/" }} {{- .L.T "global.siteName" -}}
{{- else if eq .Data.PageName "glossary" }}{{- .L.T "public.glossaryTitle" -}}
{{- else if eq .Data.PageName "search" }}{{- .L.Ts "public.searchTitle" "query" .Data.Query.Query -}}
{{- else if ne .Data.Title "" }}{{ .Data.Title }}
{{- else }}{{ block "title" . }}{{end}}
{{- end -}}
Expand All @@ -21,7 +21,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />

<link rel="shortcut icon" href="static/favicon.png" type="image/x-icon" />
<link rel="shortcut icon" href="/static/favicon.png" type="image/x-icon" />
<link href="/static/flexit.css" rel="stylesheet" type="text/css" />
<link href="/static/style.css" rel="stylesheet" type="text/css" />
</head>
Expand All @@ -31,17 +31,26 @@
<div class="row">
<div class="logo four columns">
<a href="/"><img src="/static/logo.svg" alt="Dictionary logo" /></a>
<div class="intro">
<p>Welcome to the dictionary website</p>
</div>
<h3 class="intro">
{{- .L.T "public.subTitle" -}}
</h3>
</div><!-- logo col -->

<div class="search eight columns">
<div class="tabs">
{{ range $d := .Dicts }}
{{ $from := index $d 0}}
{{ $to := index $d 1}}
<a href="#" class="tab" data-dict="{{ $from.ID }}-{{ $to.ID }}">
{{ $from.Name }} - {{ $to.Name }}
</a>
{{ end }}
</div>
<form class="search-form" method="get" action="/dictionary/english/malayalam">
<div>
<input autofocus autocomplete="off" required placeholder=""
type="text" id="q" name="q" value="{{ if .Data.Query }}{{ .Data.Query.Query }}{{ end }}" />
<button type="submit"><img src="/static/search.svg" alt="Search" /></button>
<button type="submit"><img src="/static/search.svg" alt="{{- .L.T "public.btnSearch" -}}" /></button>
</div>
</form>
</div>
Expand All @@ -51,25 +60,23 @@

{{ define "footer" }}
<nav class="nav">
<a href="/glossary/english/malayalam/a">Glossary</a>
{{ if .EnableSubmissions }}
<a href="/submit">Submit new</a>
<a href="/submit">{{- .L.T "public.submitEntry" -}}</a>
{{ end }}
<a href="/pages/about">About</a>
</nav>
</div>
<footer class="footer">
<a href="https://dict.press">Powered by dictpress</a>
</footer>
<script src="/static/main.js"></script>

<form class="box form-comments">
<form class="box form-comments" data-success="{{ .L.T "public.suggestSubmitted" }}">
<div>
<h3>Comments and suggestions</h3>
<h3>{{ .L.T "public.submitTitle" }}</h3>
<textarea name="comments" autofocus maxlength="500"></textarea>
<p>
<button type="submit">Submit for review</button>
<button type="submit" class="button-outline close">Close</button>
<button type="submit">{{ .L.T "public.suggestSubmitBtn" }}</button>
<button class="button-outline close">{{ .L.T "global.btnClose" }}</button>
</p>
</div>
</form>
Expand Down
4 changes: 2 additions & 2 deletions site/glossary-words.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ define "glossary-words" }}
{{ if not .Words }}
<h2>No words</h2>
<p>No words were found in this glossary.</p>
<h2>{{ .L.T "public.noResultsTitle" }}</h2>
<p>{{ .L.T "public.noGlossary" }}</p>
{{ else }}
<ul class="noul words">
{{ range $i, $w := .Words }}
Expand Down
4 changes: 2 additions & 2 deletions site/glossary.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

<section class="content glossary">
{{ if not .Data.Initials }}
<h2>Glossary not found</h2>
<p>No glossary was found for that language.</p>
<h2>{{ .L.T "public.glossaryTitle" }}</h2>
<p>{{ .L.T "public.noGlossary" }}</p>
{{ else }}
<nav class="index">
{{ range $k, $a := .Data.Initials }}
Expand Down
33 changes: 33 additions & 0 deletions site/lang.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"_.code": "en",
"_.name": "English",
"global.btnClose": "Close",
"global.btnDelete": "Delete",
"global.btnSearch": "Search",
"global.siteName": "Dictionary",
"public.errorMessage": "An error occurred. Please try later.",
"public.errorTitle": "Error",
"public.glossary": "{name} glossary",
"public.glossaryTitle": "Glossary of words",
"public.mainTitle": "Dictionary website",
"public.noGlossary": "No glossary results were found for that language",
"public.noResults": "No results where found for the query.",
"public.noResultsTitle": "No results",
"public.searchTitle": "\"{query}\" meaning",
"public.similarTitle": "Similar words",
"public.subTitle": "English-Malayalam dictionary",
"public.submitEntry": "Suggest new entry",
"public.submitEntryTitle": "Suggest new entry",
"public.submitTitle": "Comments and suggestions",
"public.suggestAddDefBtn": "Add another definition",
"public.suggestContent": "Content",
"public.suggestDefLang": "Definition language",
"public.suggestDefsTitle": "Definitions",
"public.suggestEdit": "Suggest edit for \"{word}\"",
"public.suggestEntryLang": "Entry language",
"public.suggestPhones": "Phonetic notations (pronunciation)",
"public.suggestPhonesPlaceholder": "eg: pɛts, pɛt (commma separated)",
"public.suggestSubmitBtn": "Submit for review",
"public.suggestSubmitted": "Submitted for review successfully",
"public.suggestTitle": "Suggest a new entry"
}
91 changes: 59 additions & 32 deletions site/results.html
Original file line number Diff line number Diff line change
@@ -1,37 +1,64 @@
{{ define "results" }}
<ol class="entries">
{{ range $k, $r := .Data.Results.Entries }}
<li class="entry" data-guid="{{ $r.GUID }}">
<header class="head">
{{ if $.EnableSubmissions }}
<a href="" data-from="{{ $r.GUID }}" class="edit" title="Suggest edit">✏️</a>
{{ end }}
<h3 class="title">{{ $r.Content }}</h3>
<span class="pronun">♪ {{ join $r.Phones "," }}</span>
</header>
{{ $numResults := (min (len .Data.Results.Entries) 10) }}
<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 }}">
<header class="head">
{{ if $.EnableSubmissions }}
<a href="" data-from="{{ $r.GUID }}" class="edit" title="{{ $.L.Ts "public.suggestEdit" "word" $r.Content }}">✏️</a>
{{ end }}
<h3 class="title">{{ $r.Content }}</h3>

<ol class="defs">
{{ $prevTypes := "" }}
{{ range $k, $d := $r.Relations }}
{{ $types := (join $d.RelationTypes ", ") }}
{{ if ne $prevTypes $types }}
<div class="types">
<span>{{ $types }}</span>
</div>
{{ end }}
<li>
<div data-guid="{{ $d.GUID }}" class="def">
{{ $d.Content }}
{{ if $r.Phones }}
<span class="pronun">♪ {{ $r.Phones | join "," }}</span>
{{ end }}
</header>

{{ if $.EnableSubmissions }}
<a href="" data-from="{{ $r.GUID }}" data-to="{{ $d.GUID }}" class="edit" title="Suggest edit">✏️</a>
{{ if $r.Relations }}
{{ $lastType := "" }}
{{ range $k, $d := $r.Relations }}
{{ $types := ($d.RelationTypes | join ", ") }}
{{ if ne $lastType $types }}
{{- if $lastType -}}</ol>{{- end }}
<ol class="defs">
<div class="types">
:{{- range $t := $d.RelationTypes -}}
{{ index (index $.Langs $d.Lang).Types $t }} -
{{ index (index $.Langs $r.Lang).Types $t }}
{{- end -}}
</div>
{{ end }}
</div>
</li>
{{ $prevTypes = $types }}
{{ end }}
</ol>
</li>
{{ end }}
</ol>

<li>
<div data-guid="{{ $d.GUID }}" class="def">
{{ $d.Content }}

{{ if $.EnableSubmissions }}
<a href="" data-from="{{ $r.GUID }}" data-to="{{ $d.GUID }}"
class="edit" title="{{ $.L.Ts "public.suggestEdit" "word" $d.Content }}">✏️</a>
{{ end }}
</div>
</li>
{{ $lastType = $types }}
{{ end }}
</ol>
{{ end }}

</li>
{{ end }}
</ol>
</div>
<div class="four columns related">
{{ if gt (len .Data.Results.Entries) $numResults }}
<h4>{{ .L.T "public.similarTitle" }}</h4>
<ul>
{{ range $k, $r := (mustSlice .Data.Results.Entries $numResults) }}
<li><a href="{{ UnicodeURL $r.Content }}">{{ $r.Content }}</a></li>
{{ end }}
</ul>
{{ end }}
</div>
</div>
{{ end }}
9 changes: 2 additions & 7 deletions site/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@

<section class="content results">
{{ if not .Data.Results.Entries }}
<h2>ದೊರೆತಿಲ್ಲ</h2>
<h2>{{ .L.T "public.noResultsTitle" }}</h2>
<p>
&ldquo;{{ .Data.Query.Query }}&rdquo; ಪದಕ್ಕೆ ವಿವರಣೆ ದೊರಕುತ್ತಿಲ್ಲ.
ಹುಡುಕಿದ ಪದ ಕನ್ನಡದಲ್ಲಿದೆ ಎಂದು ಖಚಿತಪಡಿಸಿಕೊಳ್ಳಿ.
</p>
<p>
No results found for &ldquo;{{ .Data.Query.Query }}&rdquo;.
Make sure the search query is in Kannada.
{{ .L.T "public.noResults" }}
</p>
{{ else }}
{{ template "results" . }}
Expand Down
Binary file modified site/static/favicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 1 addition & 55 deletions site/static/logo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit aab9be6

Please sign in to comment.