summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/ld.py12
-rw-r--r--core/views.py37
2 files changed, 48 insertions, 1 deletions
diff --git a/core/ld.py b/core/ld.py
index 346708c..6692dab 100644
--- a/core/ld.py
+++ b/core/ld.py
@@ -414,6 +414,18 @@ def canonicalise(json_data: Dict, include_security: bool = False) -> Dict:
return jsonld.compact(jsonld.expand(json_data), context)
+def get_list(container, key) -> List:
+ """
+ Given a JSON-LD value (that can be either a list, or a dict if it's just
+ one item), always returns a list"""
+ if key not in container:
+ return []
+ value = container[key]
+ if not isinstance(value, list):
+ return [value]
+ return value
+
+
def format_ld_date(value: datetime.datetime) -> str:
return value.strftime(DATETIME_FORMAT)
diff --git a/core/views.py b/core/views.py
index 30eaf90..2ef83cc 100644
--- a/core/views.py
+++ b/core/views.py
@@ -1,4 +1,6 @@
-from django.views.generic import TemplateView
+from django.http import JsonResponse
+from django.templatetags.static import static
+from django.views.generic import TemplateView, View
from activities.views.timelines import Home
from users.models import Identity
@@ -19,3 +21,36 @@ class LoggedOutHomepage(TemplateView):
return {
"identities": Identity.objects.filter(local=True),
}
+
+
+class AppManifest(View):
+ """
+ Serves a PWA manifest file. This is a view as we want to drive some
+ items from settings.
+ """
+
+ def get(self, request):
+ return JsonResponse(
+ {
+ "$schema": "https://json.schemastore.org/web-manifest-combined.json",
+ "name": "Takahē",
+ "short_name": "Takahē",
+ "start_url": "/",
+ "display": "standalone",
+ "background_color": "#26323c",
+ "theme_color": "#26323c",
+ "description": "An ActivityPub server",
+ "icons": [
+ {
+ "src": static("img/icon-128.png"),
+ "sizes": "128x128",
+ "type": "image/png",
+ },
+ {
+ "src": static("img/icon-1024.png"),
+ "sizes": "1024x1024",
+ "type": "image/png",
+ },
+ ],
+ }
+ )