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>

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="forum">search</button>
@ -25,44 +25,44 @@
<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 search-active" name="t" value="forum">forum</button>
<button name="t" value="forum" class="clickable search-active">Forums</button>
<button name="t" value="forum" class="clickable search-active">{{ 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" name="t" value="file">share</button>
<button name="t" value="file" class="clickable">Torrents</button>
<button name="t" value="file" class="clickable">{{ translate "torrents" }}</button>
</div>
</div>
</form>
<form class="results_settings" action="/search" method="get">
<input type="hidden" name="q" value="{{ .Query }}">
<select class="results-settings" name="safe" id="safeSearchSelect">
<option value="disabled" {{if eq .Safe "disabled"}}selected{{end}}>Safe Search Off</option>
<option value="active" {{if eq .Safe "active"}}selected{{end}}>Safe Search On</option>
<option value="disabled" {{if eq .Safe "disabled"}}selected{{end}}>{{ translate "safe_search_off" }}</option>
<option value="active" {{if eq .Safe "active"}}selected{{end}}>{{ translate "safe_search_on" }}</option>
</select>
<select class="results-settings" name="lang" id="languageSelect">
{{range .LanguageOptions}}
<option value="{{.Code}}" {{if eq .Code $.CurrentLang}}selected{{end}}>{{.Name}}</option>
{{end}}
</select>
<button class="results-save" name="t" value="forum">Apply settings</button>
<button class="results-save" name="t" value="forum">{{ translate "save_settings" }}</button>
</form>
<div class="results" id="results">
{{if .Results}}
@ -75,13 +75,13 @@
<br>
{{end}}
{{else if .NoResults}}
<div class="no-results">No results found for '{{ .Query }}'. Try different keywords.</div>
<div class="no-results">{{ translate "no_results" .Query }}</div>
{{else}}
<div class="no-more-results">Looks like this is the end of results.</div>
<div class="no-more-results">{{ translate "no_more_results" }}</div>
{{end}}
</div>
<div class="message-bottom-left" id="message-bottom-left">
<span>Searching for new results...</span>
<span>{{ translate "searching_for_new_results" }}</span>
</div>
<div class="prev-next prev-img" id="prev-next">
<form action="/search" method="get">
@ -89,10 +89,10 @@
<input type="hidden" name="t" value="forum">
<div id="content" class="js-enabled">
{{ 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 }}
</div>
</form>

View file

@ -6,15 +6,15 @@
{{ 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/style-fixedwidth.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="image">search</button>
@ -27,44 +27,44 @@
<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 search-active" name="t" value="image">image</button>
<button name="t" value="image" class="clickable search-active">Images</button>
<button name="t" value="image" class="clickable search-active">{{ 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" name="t" value="file">share</button>
<button name="t" value="file" class="clickable">Torrents</button>
<button name="t" value="file" class="clickable">{{ translate "torrents" }}</button>
</div>
</div>
</form>
<form class="results_settings" action="/search" method="get">
<input type="hidden" name="q" value="{{ .Query }}">
<select class="results-settings" name="safe" id="safeSearchSelect">
<option value="disabled" {{if eq .Safe "disabled"}}selected{{end}}>Safe Search Off</option>
<option value="active" {{if eq .Safe "active"}}selected{{end}}>Safe Search On</option>
<option value="disabled" {{if eq .Safe "disabled"}}selected{{end}}>{{ translate "safe_search_off" }}</option>
<option value="active" {{if eq .Safe "active"}}selected{{end}}>{{ translate "safe_search_on" }}</option>
</select>
<select class="results-settings" name="lang" id="languageSelect">
{{range .LanguageOptions}}
<option value="{{.Code}}" {{if eq .Code $.CurrentLang}}selected{{end}}>{{.Name}}</option>
{{end}}
</select>
<button class="results-save" name="t" value="image">Apply settings</button>
<button class="results-save" name="t" value="image">{{ translate "save_settings" }}</button>
</form>
<div class="search-results" id="results">
@ -78,7 +78,7 @@
<div class="resolution">{{ .Width }} × {{ .Height }}</div>
<div class="details">
<span class="img_title clickable">{{ .Title }}</span>
<a href="{{ .Source }}" target="_blank" class="img_source">Source</a>
<a href="{{ .Source }}" target="_blank" class="img_source">{{ translate "source" }}</a>
</div>
</div>
{{ end }}
@ -90,24 +90,22 @@
<input type="hidden" name="q" value="{{ .Query }}">
<input type="hidden" name="t" value="image">
{{ if .HasPrevPage }}
<!-- Subtract 1 from the current page for the Previous button -->
<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 }}
<!-- Add 1 to the current page for the Next button -->
<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>
</noscript>
{{ else if .NoResults }}
<div class="no-results">No results found for '{{ .Query }}'. Try different keywords.</div>
<div class="no-results">{{ translate "no_results" .Query }}</div>
{{ else }}
<div class="no-more-results">Looks like this is the end of results.</div>
<div class="no-more-results">{{ translate "no_more_results" }}</div>
{{ end }}
</div>
<div class="message-bottom-left" id="message-bottom-left">
<span>Searching for new results...</span>
<span>{{ translate "searching_for_new_results" }}</span>
</div>
<div id="image-viewer-overlay" style="display: none;"></div>

View file

@ -6,10 +6,10 @@
{{ 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">
<script src="https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.css" />
<style>
@ -28,7 +28,7 @@
</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="map">search</button>
@ -41,27 +41,27 @@
<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 class="search-container-results-btn">
<button id="sub-search-wrapper-ico" class="material-icons-round clickable search-active" name="t" value="map">map</button>
<button name="t" value="map" class="clickable search-active">Maps</button>
<button name="t" value="map" class="clickable search-active">{{ translate "maps" }}</button>
</div>
<div class="search-container-results-btn">
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="file">share</button>
<button name="t" value="file" class="clickable">Torrents</button>
<button name="t" value="file" class="clickable">{{ translate "torrents" }}</button>
</div>
</div>
</form>
@ -69,87 +69,87 @@
<div id="map"></div>
{{ else }}
<div id="map"></div>
<div class="message">No results found for "{{ .Query }}". Please try another search.</div>
<div class="message">{{ translate "no_results" .Query }}</div>
{{ end }}
{{ if .Found }}
<script>
document.addEventListener('DOMContentLoaded', function () {
var map = L.map('map').setView([{{ .Latitude }}, {{ .Longitude }}], 13); // Set view to found coordinates
// Base layers
var streets = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© OpenStreetMap contributors'
});
var satellite = L.tileLayer('https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© OpenStreetMap contributors'
});
var esriSat = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{x}/{y}', {
maxZoom: 19,
attribution: 'Tiles © Esri'
});
var topo = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', {
maxZoom: 17,
attribution: '© OpenTopoMap contributors'
});
var baseMaps = {
"Streets": streets,
"Satellite": satellite,
"Esri Satellite": esriSat,
"Topographic": topo
};
streets.addTo(map); // Add default layer
// Layer control
L.control.layers(baseMaps).addTo(map);
// Marker with passed coordinates
L.marker([{{ .Latitude }}, {{ .Longitude }}]).addTo(map)
.bindPopup('{{ .Query }}');
// Add scale control
L.control.scale().addTo(map);
// Add custom control for geolocation
L.Control.geolocate = L.Control.extend({
onAdd: function(map) {
var div = L.DomUtil.create('div', 'leaflet-control-locate');
div.title = 'Locate Me';
L.DomEvent.on(div, 'click', function() {
map.locate({setView: true, maxZoom: 16});
});
return div;
}
});
L.control.geolocate = function(opts) {
return new L.Control.geolocate(opts);
}
L.control.geolocate({ position: 'topright' }).addTo(map);
// Geolocation function
function onLocationFound(e) {
var radius = e.accuracy / 2;
L.marker(e.latlng).addTo(map)
.bindPopup("You are within " + radius + " meters from this point").openPopup();
L.circle(e.latlng, radius).addTo(map);
}
function onLocationError(e) {
alert(e.message);
}
map.on('locationfound', onLocationFound);
map.on('locationerror', onLocationError);
<script>
document.addEventListener('DOMContentLoaded', function () {
var map = L.map('map').setView([{{ .Latitude }}, {{ .Longitude }}], 13); // Set view to found coordinates
// Base layers
var streets = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© OpenStreetMap contributors'
});
</script>
var satellite = L.tileLayer('https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© OpenStreetMap contributors'
});
var esriSat = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{x}/{y}', {
maxZoom: 19,
attribution: 'Tiles © Esri'
});
var topo = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', {
maxZoom: 17,
attribution: '© OpenTopoMap contributors'
});
var baseMaps = {
"{{ translate "streets" }}": streets,
"{{ translate "satellite" }}": satellite,
"{{ translate "esri_satellite" }}": esriSat,
"{{ translate "topographic" }}": topo
};
streets.addTo(map); // Add default layer
// Layer control
L.control.layers(baseMaps).addTo(map);
// Marker with passed coordinates
L.marker([{{ .Latitude }}, {{ .Longitude }}]).addTo(map)
.bindPopup('{{ .Query }}');
// Add scale control
L.control.scale().addTo(map);
// Add custom control for geolocation
L.Control.geolocate = L.Control.extend({
onAdd: function(map) {
var div = L.DomUtil.create('div', 'leaflet-control-locate');
div.title = '{{ translate "locate_me" }}';
L.DomEvent.on(div, 'click', function() {
map.locate({setView: true, maxZoom: 16});
});
return div;
}
});
L.control.geolocate = function(opts) {
return new L.Control.geolocate(opts);
}
L.control.geolocate({ position: 'topright' }).addTo(map);
// Geolocation function
function onLocationFound(e) {
var radius = e.accuracy / 2;
L.marker(e.latlng).addTo(map)
.bindPopup("{{ translate "you_are_within" }}" + radius + " {{ translate "meters_from_point" }}").openPopup();
L.circle(e.latlng, radius).addTo(map);
}
function onLocationError(e) {
alert(e.message);
}
map.on('locationfound', onLocationFound);
map.on('locationerror', onLocationError);
});
</script>
{{ end }}
</body>
</html>

View file

@ -6,11 +6,11 @@
{{ if .IsThemeDark }}
<meta name="darkreader-lock">
{{ end }}
<title>Search with Ocásek</title>
<title>{{ translate "search_page_title" }}</title>
<link rel="stylesheet" href="/static/css/style.css">
<link rel="stylesheet" href="/static/css/style-search.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>
<script defer src="/static/js/autocomplete.js"></script>
@ -70,19 +70,19 @@
<button class="material-icons-round clickable settings-icon-link settings-icon-link-search">menu</button>
</div>
<div class="search-menu settings-menu-hidden">
<h2>Settings</h2>
<h2>{{ translate "settings" }}</h2>
<div class="settings-content">
<button id="settingsButton" onclick="window.location.href='/settings'">All settings</button> <!-- Well its unessesary to use js here but this menu will not work without js anyway -->
<button id="settingsButton" onclick="window.location.href='/settings'">{{ translate "all_settings" }}</button> <!-- Well its unessesary to use js here but this menu will not work without js anyway -->
<div class="theme-settings theme-mini-settings">
<p><span class="highlight">Current theme: </span> <span id="theme_name">{{.Theme}}</span></p>
<p><span class="highlight">{{ translate "current_theme" }}: </span> <span id="theme_name">{{.Theme}}</span></p>
<div class="themes-settings-menu">
<div><img class="view-image-search clickable" id="dark_theme" alt="Dark Theme" src="/static/images/dark.webp"></div>
<div><img class="view-image-search clickable" id="light_theme" alt="Light Theme" src="/static/images/light.webp"></div>
<div><img class="view-image-search clickable" id="dark_theme" alt="{{ translate "dark_theme" }}" src="/static/images/dark.webp"></div>
<div><img class="view-image-search clickable" id="light_theme" alt="{{ translate "light_theme" }}" src="/static/images/light.webp"></div>
</div>
</div>
<select class="lang" name="safe" id="safeSearchSelect">
<option value="disabled" {{if eq .Safe "disabled"}}selected{{end}}>Safe Search Off</option>
<option value="active" {{if eq .Safe "active"}}selected{{end}}>Safe Search On</option>
<option value="disabled" {{if eq .Safe "disabled"}}selected{{end}}>{{ translate "safe_search_off" }}</option>
<option value="active" {{if eq .Safe "active"}}selected{{end}}>{{ translate "safe_search_on" }}</option>
</select>
<select class="lang" name="site_lang" id="siteLanguageSelect">
{{range .LanguageOptions}}
@ -93,9 +93,9 @@
</div>
<form action="/search" class="search-container" method="post" autocomplete="off">
<div class="search-page-content">
<h1>Ocásek</h1>
<h1>{{ translate "site_name" }}</h1>
<div class="wrapper">
<input type="text" name="q" autofocus id="search-input"/> <!-- placeholder="Type to search..." -->
<input type="text" name="q" autofocus id="search-input"/> <!-- placeholder="{{ translate "type_to_search" }}" -->
<button id="search-wrapper-ico" class="material-icons-round" name="t" value="web" type="submit">search</button>
<div class="autocomplete">
<ul></ul>
@ -106,32 +106,32 @@
<div class="icon-button">
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="text">search</button>
<p>Web</p>
<p>{{ translate "web" }}</p>
</div>
<div class="icon-button">
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="image">image</button>
<p>Images</p>
<p>{{ translate "images" }}</p>
</div>
<div class="icon-button">
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="video">movie</button>
<p>Videos</p>
<p>{{ translate "videos" }}</p>
</div>
<div class="icon-button">
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="forum">forum</button>
<p>Forums</p>
<p>{{ translate "forums" }}</p>
</div>
<div class="icon-button">
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="map">map</button>
<p>Maps</p>
<p>{{ translate "maps" }}</p>
</div>
<div class="icon-button">
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="file">share</button>
<p>Torrents</p>
<p>{{ translate "torrents" }}</p>
</div>
</div>
</div>

View file

@ -68,8 +68,8 @@
<div class="settings-row">
<p>{{ translate "safe_search" }}</p>
<select class="results-settings" name="safe" id="safeSearchSelect">
<option value="disabled" {{if eq .Safe "disabled"}}selected{{end}}>{{ translate "safe_search_off" }}</option>
<option value="active" {{if eq .Safe "active"}}selected{{end}}>{{ translate "safe_search_on" }}</option>
<option value="disabled" {{if eq .Safe "disabled"}}selected{{end}}>{{ translate "off" }}</option>
<option value="active" {{if eq .Safe "active"}}selected{{end}}>{{ translate "on" }}</option>
</select>
</div>

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="text">search</button>
@ -26,44 +26,44 @@
<div class="sub-search-button-wrapper">
<div class="search-container-results-btn">
<button id="sub-search-wrapper-ico" class="material-icons-round clickable search-active" name="t" value="text">search</button>
<button name="t" value="text" class="clickable search-active">Web</button>
<button name="t" value="text" class="clickable search-active">{{ 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 id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="forum">image</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" name="t" value="file">share</button>
<button name="t" value="file" class="clickable">Torrents</button>
<button name="t" value="file" class="clickable">{{ translate "torrents" }}</button>
</div>
</div>
</form>
<form class="results_settings" action="/search" method="get">
<input type="hidden" name="q" value="{{ .Query }}">
<select class="results-settings" name="safe" id="safeSearchSelect">
<option value="disabled" {{if eq .Safe "disabled"}}selected{{end}}>Safe Search Off</option>
<option value="active" {{if eq .Safe "active"}}selected{{end}}>Safe Search On</option>
<option value="disabled" {{if eq .Safe "disabled"}}selected{{end}}>{{ translate "safe_search_off" }}</option>
<option value="active" {{if eq .Safe "active"}}selected{{end}}>{{ translate "safe_search_on" }}</option>
</select>
<select class="results-settings" name="lang" id="languageSelect">
{{range .LanguageOptions}}
<option value="{{.Code}}" {{if eq .Code $.CurrentLang}}selected{{end}}>{{.Name}}</option>
{{end}}
</select>
<button class="results-save" name="t" value="text">Apply settings</button>
<button class="results-save" name="t" value="text">{{ translate "save_settings" }}</button>
</form>
<div class="results" id="results">
{{if .Results}}
@ -76,13 +76,13 @@
<br>
{{end}}
{{else if .NoResults}}
<div class="no-results">No results found for '{{ .Query }}'. Try different keywords.</div>
<div class="no-results">{{ translate "no_results" .Query }}</div>
{{else}}
<div class="no-more-results">Looks like this is the end of results.</div>
<div class="no-more-results">{{ translate "no_more_results" }}</div>
{{end}}
</div>
<div class="message-bottom-left" id="message-bottom-left">
<span>Searching for new results...</span>
<span>{{ translate "searching_for_new_results" }}</span>
</div>
<div class="prev-next prev-img" id="prev-next">
<form action="/search" method="get">
@ -90,10 +90,10 @@
<input type="hidden" name="t" value="text">
<div id="content" class="js-enabled">
{{ 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 }}
</div>
</form>

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="video">search</button>
@ -26,34 +26,34 @@
<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 search-active" name="t" value="video">movie</button>
<button name="t" value="video" class="clickable search-active">Videos</button>
<button name="t" value="video" class="clickable search-active">{{ 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" name="t" value="file">share</button>
<button name="t" value="file" class="clickable">Torrents</button>
<button name="t" value="file" class="clickable">{{ translate "torrents" }}</button>
</div>
</div>
</form>
<!-- Results go here -->
<p class="fetched fetched_dif fetched_vid"><!-- { fetched } --></p>
<p class="fetched fetched_dif fetched_vid">{{ translate "fetched_in" .Fetched }}</p>
{{ if .Results }}
{{ range .Results }}
<div>
@ -75,17 +75,17 @@
</div>
{{ end }}
{{ else }}
<div class="no-results">No results found for '{{ .Query }}'. Try different keywords.</div>
<div class="no-results">{{ translate "no_results" .Query }}</div>
{{ end }}
<div class="prev-next prev-img" id="prev-next">
<form action="/search" method="get">
<input type="hidden" name="q" value="{{ .Query }}">
<input type="hidden" name="t" value="video">
{{ 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>