Improve PWA capabilities (#630)

* Improve PWA capabilities

* Invert background_color theme logic

* Revert build changes
This commit is contained in:
Hugo van Rijswijk 2024-03-16 15:20:22 +01:00 committed by GitHub
parent 2deecc5c91
commit 6f52bafda8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 261 additions and 4 deletions

View file

@ -40,6 +40,7 @@ The name comes from:
- Automatically provides titles, descriptions and icons of bookmarked websites
- Automatically creates snapshots of bookmarked websites on [the Internet Archive Wayback Machine](https://archive.org/web/)
- Import and export bookmarks in Netscape HTML format
- Installable as a Progressive Web App (PWA)
- Extensions for [Firefox](https://addons.mozilla.org/firefox/addon/linkding-extension/) and [Chrome](https://chrome.google.com/webstore/detail/linkding-extension/beakmhbijpdhipnjhnclmhgjlddhidpe), as well as a bookmarklet
- Light and dark themes
- REST API for developing 3rd party apps

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

View file

@ -0,0 +1 @@
<svg clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.5" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><circle cx="255.0164" cy="254.9236" fill="#5856e0" r="224.78528" stroke-width="1.18"/><g fill="none" stroke="#fff" stroke-width="31.25"><path d="m1244.39 1293.95v199.64s-.81 67.89 74.9 68.88c75.98.99 74.88-68.88 74.88-68.88v-199.64" transform="matrix(.70710678 .70710678 -.70710678 .70710678 284.139117 -1684.198509)"/><path d="m1244.39 1293.95v199.64s-.81 67.89 74.9 68.88c75.98.99 74.88-68.88 74.88-68.88v-199.64" transform="matrix(-.70957074 -.70463421 .70463421 -.70957074 235.113139 2195.434643)"/></g></svg>

After

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -0,0 +1 @@
<svg clip-rule="evenodd" fill-rule="evenodd" height="512" stroke-linejoin="round" stroke-miterlimit="1.5" viewBox="0 0 512 512" width="512" xmlns="http://www.w3.org/2000/svg"><circle cx="255.0164" cy="254.9236" fill="#5856e0" r="224.78528" stroke-width="1.18"/><g fill="none" stroke="#fff" stroke-width="31.25"><path d="m1244.39 1293.95v199.64s-.81 67.89 74.9 68.88c75.98.99 74.88-68.88 74.88-68.88v-199.64" transform="matrix(.70710678 .70710678 -.70710678 .70710678 284.139117 -1684.198509)"/><path d="m1244.39 1293.95v199.64s-.81 67.89 74.9 68.88c75.98.99 74.88-68.88 74.88-68.88v-199.64" transform="matrix(-.70957074 -.70463421 .70463421 -.70957074 235.113139 2195.434643)"/></g></svg>

After

Width:  |  Height:  |  Size: 688 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View file

@ -0,0 +1 @@
<svg clip-rule="evenodd" fill-rule="evenodd" height="512" stroke-linejoin="round" stroke-miterlimit="1.5" width="512" xmlns="http://www.w3.org/2000/svg"><path d="m512 512h-512v-512h512" fill="#5856e0" fill-rule="nonzero" stroke-width=".293"/><g fill="none" stroke="#fff" stroke-width="31.25"><path d="m249.095 110.679-141.167 141.167s-48.578 47.432 4.257 101.668c53.026 54.426 101.654 4.242 101.654 4.242l141.166-141.166"/><path d="m263.892 400.446 140.673-141.659s48.412-47.602-4.612-101.652c-53.215-54.24-101.667-3.888-101.667-3.888l-140.674 141.659"/></g></svg>

After

Width:  |  Height:  |  Size: 564 B

View file

@ -0,0 +1 @@
<svg height="700pt" preserveAspectRatio="xMidYMid meet" viewBox="0 0 700 700" width="700pt" xmlns="http://www.w3.org/2000/svg"><path d="m3210 6573c-780-79-1463-417-1985-983-444-481-716-1082-791-1750-18-160-18-490 0-650 80-713 380-1341 880-1842 492-494 1125-801 1822-883 150-18 512-21 654-5 407 44 737 142 1094 323 775 394 1350 1108 1571 1952 71 271 98 487 98 785-1 311-35 562-117 847-54 188-99 302-201 508-216 439-510 795-900 1090-441 335-992 550-1544 605-95 9-499 12-581 3zm-639-2228c-543-544-1003-1011-1020-1038-91-134-135-274-134-422 1-167 61-314 200-485 135-165 308-291 467-338 110-32 264-27 376 12 185 65 130 15 1233 1115l1007 1006 150-150c83-82 150-154 150-160s-442-452-982-992c-658-656-1010-1000-1064-1040-304-223-643-298-965-214-271 72-548 272-751 543-115 153-179 283-226 457-22 85-26 115-25 256 0 140 3 172 26 257 34 130 95 266 169 380 54 83 172 205 1067 1101l1006 1007 152-152 153-153zm2359 1051c242-44 461-167 675-381 282-281 415-567 415-890 0-119-17-230-51-336-32-101-123-277-188-363-54-71-2003-2046-2020-2046-11 0-301 281-301 292 0 6 435 449 967 985 533 536 986 998 1007 1027 53 70 121 216 140 303 30 136 14 277-48 416-65 147-245 351-396 449-211 137-403 161-617 79-162-63-173-73-1009-913-428-431-871-876-984-991-112-114-207-207-211-207s-75 67-160 148l-153 149 785 789c431 434 865 872 964 973 266 271 397 369 612 455 176 70 396 94 573 62z" transform="matrix(.1 0 0 -.1 0 700)"/></svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -6,8 +6,10 @@
<html lang="en" data-api-base-url="{% url 'bookmarks:api-root' %}">
<head>
<meta charset="UTF-8">
<link rel="icon" href="{% static 'favicon.png' %}"/>
<link rel="apple-touch-icon" href="{% static 'apple-touch-icon.png' %}">
<link rel="icon" href="{% static 'favicon.ico' %}" sizes="48x48">
<link rel="icon" href="{% static 'favicon.svg' %}" sizes="any" type="image/svg+xml">
<link rel="apple-touch-icon" sizes="180x180" href="{% static 'apple-touch-icon.png' %}">
<link rel="mask-icon" href="{% static 'safari-pinned-tab.svg' %}" color="#5856e0">
<link rel="manifest" href="{% url 'bookmarks:manifest' %}">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimal-ui">
@ -19,14 +21,18 @@
{# Include specific theme variant based on user profile setting #}
{% if request.user_profile.theme == 'light' %}
<link href="{% sass_src 'theme-light.scss' %}?v={{ app_version }}" rel="stylesheet" type="text/css"/>
<meta name="theme-color" content="#5856e0">
{% elif request.user_profile.theme == 'dark' %}
<link href="{% sass_src 'theme-dark.scss' %}?v={{ app_version }}" rel="stylesheet" type="text/css"/>
<meta name="theme-color" content="#161822">
{% else %}
{# Use auto theme as fallback #}
<link href="{% sass_src 'theme-dark.scss' %}?v={{ app_version }}" rel="stylesheet" type="text/css"
media="(prefers-color-scheme: dark)"/>
<link href="{% sass_src 'theme-light.scss' %}?v={{ app_version }}" rel="stylesheet" type="text/css"
media="(prefers-color-scheme: light)"/>
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#161822">
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#5856e0">
{% endif %}
</head>
<body ld-global-shortcuts>

View file

@ -11,9 +11,91 @@ class MetadataViewTestCase(TestCase):
response_body = response.json()
expected_body = {
"short_name": "linkding",
"name": "linkding",
"description": "Self-hosted bookmark service",
"start_url": "bookmarks",
"display": "standalone",
"scope": "/",
"theme_color": "#5856e0",
"background_color": "#ffffff",
"icons": [
{
"src": "/static/logo.svg",
"type": "image/svg+xml",
"sizes": "512x512",
"purpose": "any"
},
{
"src": "/static/logo-512.png",
"type": "image/png",
"sizes": "512x512",
"purpose": "any"
},
{
"src": "/static/logo-192.png",
"type": "image/png",
"sizes": "192x192",
"purpose": "any"
},
{
"src": "/static/maskable-logo.svg",
"type": "image/svg+xml",
"sizes": "512x512",
"purpose": "maskable"
},
{
"src": "/static/maskable-logo-512.png",
"type": "image/png",
"sizes": "512x512",
"purpose": "maskable"
},
{
"src": "/static/maskable-logo-192.png",
"type": "image/png",
"sizes": "192x192",
"purpose": "maskable"
},
],
"shortcuts": [
{
"name": "Add bookmark",
"url": "/bookmarks/new",
},
{
"name": "Archived",
"url": "/bookmarks/archived",
},
{
"name": "Unread",
"url": "/bookmarks?unread=yes",
},
{
"name": "Untagged",
"url": "/bookmarks?q=!untagged",
},
{
"name": "Shared",
"url": "/bookmarks/shared",
}
],
"screenshots": [
{
"src": "/static/linkding-screenshot.png",
"type": "image/png",
"sizes": "2158x1160",
"form_factor": "wide"
}
],
"share_target": {
"action": "/bookmarks/new",
"method": "GET",
"enctype": "application/x-www-form-urlencoded",
"params": {
"url": "url",
"text": "url",
"title": "title",
}
}
}
self.assertDictEqual(response_body, expected_body)
@ -26,8 +108,90 @@ class MetadataViewTestCase(TestCase):
response_body = response.json()
expected_body = {
"short_name": "linkding",
"name": "linkding",
"description": "Self-hosted bookmark service",
"start_url": "bookmarks",
"display": "standalone",
"scope": "/linkding/",
"theme_color": "#5856e0",
"background_color": "#ffffff",
"icons": [
{
"src": "/linkding/static/logo.svg",
"type": "image/svg+xml",
"sizes": "512x512",
"purpose": "any"
},
{
"src": "/linkding/static/logo-512.png",
"type": "image/png",
"sizes": "512x512",
"purpose": "any"
},
{
"src": "/linkding/static/logo-192.png",
"type": "image/png",
"sizes": "192x192",
"purpose": "any"
},
{
"src": "/linkding/static/maskable-logo.svg",
"type": "image/svg+xml",
"sizes": "512x512",
"purpose": "maskable"
},
{
"src": "/linkding/static/maskable-logo-512.png",
"type": "image/png",
"sizes": "512x512",
"purpose": "maskable"
},
{
"src": "/linkding/static/maskable-logo-192.png",
"type": "image/png",
"sizes": "192x192",
"purpose": "maskable"
},
],
"shortcuts": [
{
"name": "Add bookmark",
"url": "/linkding/bookmarks/new",
},
{
"name": "Archived",
"url": "/linkding/bookmarks/archived",
},
{
"name": "Unread",
"url": "/linkding/bookmarks?unread=yes",
},
{
"name": "Untagged",
"url": "/linkding/bookmarks?q=!untagged",
},
{
"name": "Shared",
"url": "/linkding/bookmarks/shared",
}
],
"screenshots": [
{
"src": "/linkding/static/linkding-screenshot.png",
"type": "image/png",
"sizes": "2158x1160",
"form_factor": "wide"
}
],
"share_target": {
"action": "/linkding/bookmarks/new",
"method": "GET",
"enctype": "application/x-www-form-urlencoded",
"params": {
"url": "url",
"text": "url",
"title": "title",
}
}
}
self.assertDictEqual(response_body, expected_body)

View file

@ -5,9 +5,91 @@ from django.conf import settings
def manifest(request):
response = {
"short_name": "linkding",
"name": "linkding",
"description": "Self-hosted bookmark service",
"start_url": "bookmarks",
"display": "standalone",
"scope": "/" + settings.LD_CONTEXT_PATH,
"theme_color": "#5856e0",
"background_color": "#161822" if request.user_profile.theme == "dark" else "#ffffff",
"icons": [
{
"src": "/" + settings.LD_CONTEXT_PATH + "static/logo.svg",
"type": "image/svg+xml",
"sizes": "512x512",
"purpose": "any"
},
{
"src": "/" + settings.LD_CONTEXT_PATH + "static/logo-512.png",
"type": "image/png",
"sizes": "512x512",
"purpose": "any"
},
{
"src": "/" + settings.LD_CONTEXT_PATH + "static/logo-192.png",
"type": "image/png",
"sizes": "192x192",
"purpose": "any"
},
{
"src": "/" + settings.LD_CONTEXT_PATH + "static/maskable-logo.svg",
"type": "image/svg+xml",
"sizes": "512x512",
"purpose": "maskable"
},
{
"src": "/" + settings.LD_CONTEXT_PATH + "static/maskable-logo-512.png",
"type": "image/png",
"sizes": "512x512",
"purpose": "maskable"
},
{
"src": "/" + settings.LD_CONTEXT_PATH + "static/maskable-logo-192.png",
"type": "image/png",
"sizes": "192x192",
"purpose": "maskable"
},
],
"shortcuts": [
{
"name": "Add bookmark",
"url": "/" + settings.LD_CONTEXT_PATH + "bookmarks/new",
},
{
"name": "Archived",
"url": "/" + settings.LD_CONTEXT_PATH + "bookmarks/archived",
},
{
"name": "Unread",
"url": "/" + settings.LD_CONTEXT_PATH + "bookmarks?unread=yes",
},
{
"name": "Untagged",
"url": "/" + settings.LD_CONTEXT_PATH + "bookmarks?q=!untagged",
},
{
"name": "Shared",
"url": "/" + settings.LD_CONTEXT_PATH + "bookmarks/shared",
}
],
"screenshots": [
{
"src": "/" + settings.LD_CONTEXT_PATH + "static/linkding-screenshot.png",
"type": "image/png",
"sizes": "2158x1160",
"form_factor": "wide"
}
],
"share_target": {
"action": "/" + settings.LD_CONTEXT_PATH + "bookmarks/new",
"method": "GET",
"enctype": "application/x-www-form-urlencoded",
"params": {
"url": "url",
"text": "url",
"title": "title",
}
}
}
return JsonResponse(response, status=200)