From b9851d665e11c415b429a34cb31f673e2088c82c Mon Sep 17 00:00:00 2001 From: "R.G. Wood" Date: Thu, 7 Sep 2023 13:41:31 +0100 Subject: [PATCH 1/3] Add: installable as PWA --- bookwyrm/templates/embed-layout.html | 1 + bookwyrm/templates/layout.html | 1 + bookwyrm/templates/manifest.json | 14 ++++++++++++++ bookwyrm/urls.py | 4 ++++ 4 files changed, 20 insertions(+) create mode 100644 bookwyrm/templates/manifest.json diff --git a/bookwyrm/templates/embed-layout.html b/bookwyrm/templates/embed-layout.html index c619bf2dc..865203627 100644 --- a/bookwyrm/templates/embed-layout.html +++ b/bookwyrm/templates/embed-layout.html @@ -12,6 +12,7 @@ + diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index e6f8a6f84..ba53685f4 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -14,6 +14,7 @@ + {% block opengraph %} {% include 'snippets/opengraph.html' %} diff --git a/bookwyrm/templates/manifest.json b/bookwyrm/templates/manifest.json new file mode 100644 index 000000000..c7d247cf3 --- /dev/null +++ b/bookwyrm/templates/manifest.json @@ -0,0 +1,14 @@ +{% load static %} +{ + "name": "Bookwyrm", + "description": "Social network for tracking your reading", + "icons": [ + { + "src": "{% if site.logo %}{{ media_full_url }}{{ site.logo }}{% else %}{% static 'images/logo.png' %}{% endif %}", + "type": "image/png", + "sizes": "512x512" + } + ], + "start_url": "/", + "display": "standalone" +} diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 0ebd7925c..60b630f49 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -33,6 +33,10 @@ urlpatterns = [ "robots.txt", TemplateView.as_view(template_name="robots.txt", content_type="text/plain"), ), + path( + "manifest.json", + TemplateView.as_view(template_name="manifest.json", content_type="application/json"), + ), # federation endpoints re_path(r"^inbox/?$", views.Inbox.as_view(), name="inbox"), re_path(rf"{LOCAL_USER_PATH}/inbox/?$", views.Inbox.as_view(), name="user_inbox"), From 34d5c557d8360d73932f8b61d70fe98056ca87be Mon Sep 17 00:00:00 2001 From: "R.G. Wood" Date: Sat, 7 Oct 2023 13:32:18 +0100 Subject: [PATCH 2/3] Fix syntax styling --- bookwyrm/urls.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 60b630f49..e8be9a540 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -35,7 +35,9 @@ urlpatterns = [ ), path( "manifest.json", - TemplateView.as_view(template_name="manifest.json", content_type="application/json"), + TemplateView.as_view( + template_name="manifest.json", content_type="application/json" + ), ), # federation endpoints re_path(r"^inbox/?$", views.Inbox.as_view(), name="inbox"), From 1798abfc3e671c339bae14917611cecb347e0786 Mon Sep 17 00:00:00 2001 From: "R.G. Wood" Date: Sat, 7 Oct 2023 13:32:49 +0100 Subject: [PATCH 3/3] Display site name and description for PWA manifest --- bookwyrm/templates/manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/manifest.json b/bookwyrm/templates/manifest.json index c7d247cf3..83ad77789 100644 --- a/bookwyrm/templates/manifest.json +++ b/bookwyrm/templates/manifest.json @@ -1,7 +1,7 @@ {% load static %} { - "name": "Bookwyrm", - "description": "Social network for tracking your reading", + "name": "{{ site.name }}", + "description": "{{ site.description }}", "icons": [ { "src": "{% if site.logo %}{{ media_full_url }}{{ site.logo }}{% else %}{% static 'images/logo.png' %}{% endif %}",