added lang support to all html templates and cleaned up template rendering

This commit is contained in:
partisan 2024-10-08 22:11:06 +02:00
parent 5dd3114e2d
commit d9d0301548
18 changed files with 645 additions and 410 deletions

View file

@ -6,14 +6,14 @@
{{ if .IsThemeDark }}
<meta name="darkreader-lock">
{{ end }}
<title>{{.Query}} - Ocásek</title>
<title>{{ translate "page_title" .Query }}</title>
<link rel="stylesheet" href="/static/css/style.css">
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
<link rel="search" type="application/opensearchdescription+xml" title="Ocásek" href="/opensearch.xml">
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate "site_name" }}" href="/opensearch.xml">
</head>
<body>
<form action="/search" id="prev-next-form" class="results-search-container" method="GET" autocomplete="off">
<h1 class="logomobile"><a class="no-decoration" href="./">Ocásek</a></h1>
<h1 class="logomobile"><a class="no-decoration" href="./">{{ translate "site_name" }}</a></h1>
<div class="wrapper-results">
<input type="text" name="q" value="{{ .Query }}" id="search-input"/>
<button id="search-wrapper-ico" class="material-icons-round" name="t" value="file">search</button>
@ -26,70 +26,70 @@
<div class="sub-search-button-wrapper">
<div class="search-container-results-btn">
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="text">search</button>
<button name="t" value="text" class="clickable">Web</button>
<button name="t" value="text" class="clickable">{{ translate "web" }}</button>
</div>
<div class="search-container-results-btn">
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="image">image</button>
<button name="t" value="image" class="clickable">Images</button>
<button name="t" value="image" class="clickable">{{ translate "images" }}</button>
</div>
<div class="search-container-results-btn">
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="video">movie</button>
<button name="t" value="video" class="clickable">Videos</button>
<button name="t" value="video" class="clickable">{{ translate "videos" }}</button>
</div>
<div class="search-container-results-btn">
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="forum">forum</button>
<button name="t" value="forum" class="clickable">Forums</button>
<button name="t" value="forum" class="clickable">{{ translate "forums" }}</button>
</div>
<div id="content" class="js-enabled">
<div class="search-container-results-btn">
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="map">map</button>
<button name="t" value="map" class="clickable">Maps</button>
<button name="t" value="map" class="clickable">{{ translate "maps" }}</button>
</div>
</div>
<div class="search-container-results-btn">
<button id="sub-search-wrapper-ico" class="material-icons-round clickable search-active" name="t" value="file">share</button>
<button name="t" value="file" class="clickable search-active">Torrents</button>
<button name="t" value="file" class="clickable search-active">{{ translate "torrents" }}</button>
</div>
</div>
</form>
<p class="fetched fetched_dif fetched_tor">Fetched in {{ .Fetched }} seconds</p>
<p class="fetched fetched_dif fetched_tor">{{ translate "fetched_in" .Fetched }}</p>
{{ if .Results }}
<form action="/search" class="torrent-sort" method="GET">
<input type="hidden" name="q" value="{{ .Query }}">
<input type="hidden" name="t" value="file">
<select class="torrent-settings" name="sort">
<option value="seed" {{ if eq .Sort "seed" }} selected {{ end }}>Number of Seeders</option>
<option value="leech" {{ if eq .Sort "leech" }} selected {{ end }}>Number of Leechers</option>
<option value="lth" {{ if eq .Sort "lth" }} selected {{ end }}>Size (Low to High)</option>
<option value="htl" {{ if eq .Sort "htl" }} selected {{ end }}>Size (High to Low)</option>
<option value="seed" {{ if eq .Sort "seed" }} selected {{ end }}>{{ translate "sort_seeders" }}</option>
<option value="leech" {{ if eq .Sort "leech" }} selected {{ end }}>{{ translate "sort_leechers" }}</option>
<option value="lth" {{ if eq .Sort "lth" }} selected {{ end }}>{{ translate "sort_lth" }}</option>
<option value="htl" {{ if eq .Sort "htl" }} selected {{ end }}>{{ translate "sort_htl" }}</option>
</select>
<select class="torrent-cat" name="cat">
<option value="all" {{ if eq .Category "all" }} selected {{ end }}>All Categories</option>
<option value="movie" {{ if eq .Category "movie" }} selected {{ end }}>Movies</option>
<option value="audiobook" {{ if eq .Category "audiobook" }} selected {{ end }}>Audiobooks</option>
<option value="tv" {{ if eq .Category "tv" }} selected {{ end }}>TV Shows</option>
<option value="games" {{ if eq .Category "games" }} selected {{ end }}>Games</option>
<option value="software" {{ if eq .Category "software" }} selected {{ end }}>Software</option>
<option value="anime" {{ if eq .Category "anime" }} selected {{ end }}>Anime</option>
<option value="music" {{ if eq .Category "music" }} selected {{ end }}>Music</option>
<option value="all" {{ if eq .Category "all" }} selected {{ end }}>{{ translate "category_all" }}</option>
<option value="movie" {{ if eq .Category "movie" }} selected {{ end }}>{{ translate "category_movie" }}</option>
<option value="audiobook" {{ if eq .Category "audiobook" }} selected {{ end }}>{{ translate "category_audiobook" }}</option>
<option value="tv" {{ if eq .Category "tv" }} selected {{ end }}>{{ translate "category_tv" }}</option>
<option value="games" {{ if eq .Category "games" }} selected {{ end }}>{{ translate "category_games" }}</option>
<option value="software" {{ if eq .Category "software" }} selected {{ end }}>{{ translate "category_software" }}</option>
<option value="anime" {{ if eq .Category "anime" }} selected {{ end }}>{{ translate "category_anime" }}</option>
<option value="music" {{ if eq .Category "music" }} selected {{ end }}>{{ translate "category_music" }}</option>
{{ if eq .Safe "disabled" }}
<option value="xxx" {{ if eq .Category "xxx" }} selected {{ end }}>XXX (18+)</option>
<option value="xxx" {{ if eq .Category "xxx" }} selected {{ end }}>{{ translate "category_xxx" }}</option>
{{ end }}
</select>
<button type="submit" class="torrent-sort-save">Apply settings</button>
<button type="submit" class="torrent-sort-save">{{ translate "apply_settings" }}</button>
</form>
<div class="clean">
{{ range .Results }}
<div class="results" id="results">
{{ if .Error }}
<div class="error">{{ .Error }}</div>
<div class="error">{{ translate "error" }}: {{ .Error }}</div>
{{ else }}
<a id="link" href="{{ .URL }}">{{ .URL }}</a>
<a class="torrent" href="magnet:{{ .Magnet }}"><h3>{{ .Title }}</h3></a>
<p class="stats">{{ if .Views }}{{ .Views }} views • {{ end }}{{ .Size }}</p>
<p class="publish__info"> Seeders: <span class="seeders">{{ .Seeders }}</span> | Leechers: <span class="leechers">{{ .Leechers }}</span></p>
<p class="stats">{{ if .Views }}{{ .Views }} {{ translate "views" }} • {{ end }}{{ .Size }}</p>
<p class="publish__info">{{ translate "seeders" }}: <span class="seeders">{{ .Seeders }}</span> | {{ translate "leechers" }}: <span class="leechers">{{ .Leechers }}</span></p>
{{ end }}
</div>
{{ end }}
@ -99,17 +99,17 @@
<input type="hidden" name="q" value="{{ .Query }}">
<input type="hidden" name="t" value="file">
{{ if .HasPrevPage }}
<button type="submit" name="p" value="{{ sub .Page 1 }}">Previous</button>
<button type="submit" name="p" value="{{ sub .Page 1 }}">{{ translate "previous" }}</button>
{{ end }}
{{ if .HasNextPage }}
<button type="submit" name="p" value="{{ add .Page 1 }}">Next</button>
<button type="submit" name="p" value="{{ add .Page 1 }}">{{ translate "next" }}</button>
{{ end }}
</form>
</div>
{{ else }}
<div class="no-results-found">
Your search '{{ .Query }}' came back with no results.<br>
Try rephrasing your search term and/or recorrect any spelling mistakes.
{{ translate "no_results_found" .Query }}<br>
{{ translate "suggest_rephrase" }}
</div>
{{ end }}
<script defer src="/static/js/autocomplete.js"></script>