added lang support to all html templates and cleaned up template rendering
This commit is contained in:
parent
5dd3114e2d
commit
d9d0301548
18 changed files with 645 additions and 410 deletions
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue