Skip to content

Commit 530e93d

Browse files
authored
Merge pull request #210 from GeoinformationSystems/feature/feed_embedding_information
2 parents e73fd17 + 5387632 commit 530e93d

File tree

8 files changed

+100
-67
lines changed

8 files changed

+100
-67
lines changed

publications/templates/authenticated_menu_snippet.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<li class="nav-item dropdown">
2-
<a class="nav-link dropdown" href="#"id="navbarDarkDropdown" role="button" data-toggle="dropdown" aria-expanded="false">
2+
<a class="nav-link dropdown" href="#" id="navbarDarkDropdown" role="button" data-toggle="dropdown" aria-expanded="false">
33
<i class="fa-solid fa-circle-user fa-3x"></i>
44
</a>
55
<ul class="dropdown-menu dropdown-menu-right"

publications/templates/base.html

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<!DOCTYPE html>
33
<html lang="en">
44
<head>
5+
{% block head %}
56
<meta charset="utf-8" />
67
<meta name="viewport" content="width=device-width, initial-scale=1" />
78

@@ -21,7 +22,30 @@
2122
<script src="{% static 'js/jquery-3.4.1.slim.min.js' %}"></script>
2223
<script src="{% static 'js/bootstrap.min.js' %}"></script>
2324

24-
{% block head %}{% endblock %}
25+
{{ block.super }}
26+
27+
<!-- RSS feed autodiscovery -->
28+
<link
29+
rel="alternate"
30+
type="application/rss+xml"
31+
title="OPTIMAP Geo RSS"
32+
href="{% url 'optimap:georss_feed' %}"
33+
/>
34+
<!-- Atom feed autodiscovery -->
35+
<link
36+
rel="alternate"
37+
type="application/atom+xml"
38+
title="OPTIMAP Geo Atom"
39+
href="{% url 'optimap:geoatom_feed' %}"
40+
/>
41+
<!-- JSON feed autodiscovery -->
42+
<link
43+
rel="alternate"
44+
type="application/xml"
45+
title="OPTIMAP W3C Geo Feed"
46+
href="{% url 'optimap:w3cgeo_feed' %}"
47+
/>
48+
{% endblock head %}
2549

2650
<link rel="stylesheet" type="text/css" href="{% static 'css/main.css' %}" />
2751
</head>

publications/templates/feeds.html

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
1-
{% extends "base.html" %} {% block content %}
1+
{% extends "base.html" %}
2+
{% block title %}Feeds | {% endblock title %}
3+
4+
{% block content %}
25
<div class="container px-4 py-8 max-w-3xl text-wrap">
36

4-
<h1 class="text-3xl mb-6 py-4">Predefined Feeds</h1>
7+
<h1 class="text-3xl mb-6 py-4">OPTIMAP feeds</h1>
8+
9+
{% if global_feeds %}
10+
<h2 class="text-2xl mb-4">General feeds</h2>
11+
<p>Subscribe to research works from all sources, time periods, and regions.</p>
12+
<ul class="list-disc list-inside mb-8">
13+
{% for feed in global_feeds %}
14+
<li>
15+
<a href="{{ feed.url }}" class="text-blue-600 hover:underline">
16+
{{ feed.title }}
17+
</a>
18+
</li>
19+
{% endfor %}
20+
</ul>
21+
{% endif %}
22+
23+
<h2 class="text-2xl mb-4">Global region feeds</h2>
24+
<p>Subscribe to research works from all sources and time periods for selected regions.</p>
25+
<ul class="list-disc list-inside space-y-2 mb-8">
26+
{% for region in regions %}
27+
<li class="flex flex-wrap items-center space-x-2">
28+
<strong>{{ region.name }}</strong>
29+
<span>({{ region.get_region_type_display }})</span>:<br>
530

6-
<p class="lead">Follow your favourite countinent or ocean with these predefined feeds.</p>
31+
<a href="{% url 'optimap:feed-georss-by-slug' region.name|slugify %}"
32+
class="text-blue-600 hover:underline"
33+
title="GeoRSS for {{ region.name }}">GeoRSS</a>
34+
<span>|</span>
735

36+
<a href="{{% url 'optimap:feed-geoatom-by-slug' region.name|slugify %}"
37+
class="text-blue-600 hover:underline"
38+
title="Atom for {{ region.name }}">GeoAtom</a>
839

9-
<ul class="list-disc list-inside space-y-2">
10-
{% for region in regions %}
11-
<li class="flex flex-wrap items-center space-x-2">
12-
<strong>{{ region.name }}</strong> ({{ region.get_region_type_display }}):
13-
14-
{# GeoRSS feed link #}
15-
<a
16-
href="{% url 'optimap:feed-georss-by-slug' region.name|slugify %}"
17-
class="text-blue-600 hover:underline"
18-
title="GeoRSS feed for {{ region.name }}"
19-
>
20-
GeoRSS
21-
</a>
22-
<span>|</span>
23-
24-
{# Atom feed link #}
25-
<a
26-
href="{% url 'optimap:feed-geoatom-by-slug' region.name|slugify %}"
27-
class="text-blue-600 hover:underline"
28-
title="Atom feed for {{ region.name }}"
29-
>
30-
GeoAtom
31-
</a>
32-
33-
<small class="text-gray-500">
34-
(updated {{ region.last_loaded|date:"Y-m-d H:i" }})
35-
</small>
36-
</li>
40+
<small class="text-gray-500">(updated {{ region.last_loaded|date:"Y-m-d H:i" }})</small>
41+
</li>
3742
{% endfor %}
3843
</ul>
3944

40-
<strong class="font-semibold mt-8 mb-4">Sources &amp; Licenses</strong>
41-
42-
<ul class="list-disc list-inside space-y-2 text-sm text-gray-700">
45+
<span class="mt-8 mb-4">Sources &amp; licenses for region data:</span>
46+
<ul class="list-inline text-sm text-gray-700">
4347
{% for region in regions %}
44-
<li class="flex items-center space-x-2">
45-
<span class="flex-shrink-0"></span>
46-
<a
47-
href="{{ region.source_url }}"
48-
title="Source for geospatial extent of {{ region.name }}"
49-
target="_blank"
50-
class="flex-1 min-w-0 truncate text-blue-600 hover:underline"
51-
>
52-
{{ region.name }}
53-
</a>
54-
<span class="flex-shrink-0">(<a href="{{ region.license }}">license URL</a>)</span>
55-
</li>
48+
<li class="list-inline-item flex mr-0">
49+
<a href="{{ region.source_url }}"
50+
class="flex-1 min-w-0 truncate text-blue-600 hover:underline"
51+
target="_blank"
52+
title="Source for {{ region.name }}">{{ region.name|safe }}</a>&nbsp;<span>(<a href="{{ region.license }}">license</a>)</span>
53+
{% if not forloop.last %}, {% endif %}
54+
</li>
5655
{% endfor %}
5756
</ul>
57+
5858
</div>
59-
{% endblock %}
59+
{% endblock content %}

publications/templates/footer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<a class="px-2 text-white" title="Privacy information / Datenschutzerklärung" href="{% url 'optimap:privacy' %}">Privacy</a>
66
<a class="px-2 text-white" title="Accessibility / Barrierefreiheit" href="{% url 'optimap:accessibility' %}">Accessibility</a>
77
<a class="px-2 text-white" title="Data & API documentation and browser" href="{% url 'optimap:data' %}">Data & API</a>
8-
<a class="px-3 text-white" title="Feeds" href="{% url 'optimap:feeds_list' %}">Feeds</a>
8+
<a class="px-3 text-white" title="Feeds" href="{% url 'optimap:feeds' %}">Feeds</a>
99
<a class="px-2 text-white" title="Link to source code project" href="https://github.com/GeoinformationSystems/optimap">Code&nbsp;(v{{ optimap_version }})</a>
1010
<a class="px-2 text-white" title="About / Contact / Imprint" href="{% url 'optimap:about' %}">About / Contact / Imprint</a>
1111
<span class="px-3">Data license: <a class="text-white" title="Publication metadata license" href='https://creativecommons.org/publicdomain/zero/1.0/'>CC-0</a></span>

publications/templates/main.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
{% load static %}
44

55
{% block head %}
6-
<!-- Leaflet-->
76

7+
{{ block.super }}
8+
9+
<!-- Leaflet-->
810
<link rel="stylesheet" href="{% static 'css/leaflet.css' %}" />
9-
{# <script type="text/javascript" src="https://unpkg.com/vis-timeline@latest/standalone/umd/vis-timeline-graph2d.min.js"></script> #}
1011
<script src="{% static 'js/leaflet.js' %}"></script>
11-
{% endblock %}
12+
13+
{% endblock head %}
1214

1315
{% block navbar %}
1416

publications/templates/subscriptions.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{% extends "base.html" %}
22
{% load static %}
3+
34
{% block head %}
45
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" integrity="sha512-mSYUmp1HYZDFaVKK//63EcZq4iFWFjxSL+Z3T/aCt4IO9Cejm03q3NKKYN6pFQzY0SBOr8h+eCIAZHPXcpZaNw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
56
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
67
<link rel="stylesheet" href="{% static 'css/main.css' %}" />
7-
{% endblock %}
8+
{% endblock head %}
89

910
{% block navbar %}
1011

@@ -16,7 +17,7 @@
1617
{% endif %}
1718
</ul>
1819

19-
{% endblock %}
20+
{% endblock navbar %}
2021

2122
{% block content %}
2223
<div id="accordion">

publications/urls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView
1212
from publications.api import router as publications_router
13+
from publications.api import router as publications_router
1314

1415

1516
app_name = "optimap"
@@ -47,10 +48,10 @@
4748
path("subscriptions/", views.user_subscriptions, name="subscriptions"),
4849
path("unsubscribe/", views.unsubscribe, name="unsubscribe"),
4950
path("usersettings/", views.user_settings, name="usersettings"),
51+
path("feeds/", views.feeds, name="feeds"),
5052
path("feeds/georss/<slug:geometry_slug>/",
5153
GeoFeedByGeometry(feed_type_variant="georss"), name="feed-georss-by-slug",),
5254
path("feeds/geoatom/<slug:geometry_slug>/",
5355
GeoFeedByGeometry(feed_type_variant="geoatom"), name="feed-geoatom-by-slug"),
54-
path("feeds/", views.feeds_list, name="feeds_list"),
5556

5657
]

publications/views.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,17 @@
1414
from django.views.decorators.cache import never_cache
1515
from django.urls import reverse
1616
import uuid
17-
from django.contrib.gis.serializers import geojson
18-
from django.http import JsonResponse
19-
from django.utils import timezone
20-
from django.utils.timezone import now, get_default_timezone
17+
from django.utils.timezone import get_default_timezone
2118
from datetime import datetime
2219
import imaplib
2320
import time
2421
from math import floor
2522
from urllib.parse import unquote
2623
from django.conf import settings
27-
from django.core.serializers import serialize
2824
from publications.models import BlockedEmail, BlockedDomain, Subscription, UserProfile, Publication, GlobalRegion
2925
from django.contrib.auth import get_user_model
3026
User = get_user_model()
31-
import tempfile, os, glob
27+
import tempfile, os
3228
from pathlib import Path
3329
from publications.tasks import regenerate_geojson_cache, regenerate_geopackage_cache
3430
from osgeo import ogr, osr
@@ -538,6 +534,20 @@ def finalize_account_deletion(request):
538534
del request.session[USER_DELETE_TOKEN_PREFIX]
539535
request.session.modified = True
540536

537+
def feeds(request):
538+
global_feeds = [
539+
{ "title": "Geo RSS", "url": reverse("optimap:georss_feed") },
540+
{ "title": "Geo Atom", "url": reverse("optimap:geoatom_feed") },
541+
{ "title": "W3C Geo", "url": reverse("optimap:w3cgeo_feed") },
542+
]
543+
544+
regions = GlobalRegion.objects.all().order_by("region_type", "name")
545+
546+
return render(request, "feeds.html", {
547+
"global_feeds": global_feeds,
548+
"regions": regions,
549+
})
550+
541551
class RobotsView(View):
542552
http_method_names = ['get']
543553
def get(self, request):
@@ -547,8 +557,3 @@ def get(self, request):
547557
)
548558
return response
549559

550-
def feeds_list(request):
551-
regions = GlobalRegion.objects.all().order_by("region_type", "name")
552-
return render(request,
553-
"feeds.html",
554-
{"regions": regions})

0 commit comments

Comments
 (0)