geo.js fix

This commit is contained in:
NN Solex 2023-05-01 22:59:40 +03:00
parent 20c0224bc8
commit 4203301112
35 changed files with 556 additions and 23 deletions

View file

@ -4,12 +4,16 @@ const ios = ua.indexOf("ios") > -1;
const windows = ua.indexOf("windows") > -1;
const linux = ua.indexOf("linux") > -1;
const mac = ua.indexOf("macos") > -1;
var hashlinks = document.querySelectorAll(".geo a");
var hashlinks = document.querySelectorAll('[href*="geo:"]');
var hasharray = [...hashlinks];
if ( hasharray.length > 0 ) {
hasharray.forEach(hashlink => {
if ( windows || mac || linux ) hashlink.href = "https://maps.google.com/?q=" + hashlink.getAttribute("latlon");
else if ( android ) hashlink.href = "geo:0,0?q=" + hashlink.getAttribute("latlon");
else if ( ios ) hashlink.href = "http://maps.apple.com/?ll=" + hashlink.getAttribute("latlon") + "&q=" + hashlink.innerHTML;
const geolink = hashlink.getAttribute("href").match(/(-?\d+(\.\d+)?),\s*(-?\d+(\.\d+)?)/g);
var latlon;
if ( geolink.length > 1 && geolink[0] == '0,0') latlon = geolink[1];
else latlon = geolink[0];
if ( windows || mac || linux ) hashlink.href = "https://maps.google.com/?q=" + latlon;
else if ( android ) hashlink.href = "geo:0,0?q=" + latlon;
else if ( ios ) hashlink.href = "http://maps.apple.com/?ll=" + latlon + "&q=" + hashlink.innerHTML;
});
}

View file

@ -9,9 +9,12 @@
<article class="hentry">
<header>
<h2 class="entry-title">
<a href="{{ SITEURL }}/{{ article.url }}" rel="bookmark">{{ article.category }}: {{ article.title }}</a>
<a href="{{ SITEURL }}/{{ article.url }}" rel="bookmark">{{ article.category }}: {{ article.title }}</a>
{% if article.metadata['geohash'] %}
[<a href="geo:{{ article.metadata['lat'] }},{{ article.metadata['lon'] }}">{{ article.metadata['geohash'] }}</a>]
{% endif %}
</h2>
<span class="entry-summary">{{ article.summary }}</span>
</header>
</article>
{% endfor %}

View file

@ -4,7 +4,7 @@
<div class="entry-content">
{{ article.content }}
{% if article.metadata.geohash %}
<a href="{{ SITEURL }}/{{ article.category.url }}">NFC</a>
<a href="{{ SITEURL }}/{{ article.category.url }}">Map</a>
{% endif %}
</div>
</section>

View file

@ -24,6 +24,7 @@
"id" : "{{ category.slug }}",
"features": [
{% for article in articles_page.object_list %}
{% if article.metadata['lat'] and article.metadata['lon'] %}
{
"type": "Feature",
"id": "{{ article.slug }}",
@ -35,6 +36,7 @@
"title": "{{ article.title }}"
},
},
{% endif %}
{% endfor %}
]
};