[gnome-software/mwleeds/pwa-plugin] WIP
- From: Phaedrus Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/mwleeds/pwa-plugin] WIP
- Date: Thu, 23 Dec 2021 19:42:13 +0000 (UTC)
commit 46928b63f336deba54a31826edc318063d300e50
Author: Phaedrus Leeds <mwleeds protonmail com>
Date: Thu Dec 23 11:42:04 2021 -0800
WIP
.../gnome-software-foss-pwa-list.xml | 9 ++++++
pwa-metainfo-generator/pwa-metainfo-generator.py | 34 +++++++++++++++++++++-
2 files changed, 42 insertions(+), 1 deletion(-)
---
diff --git a/pwa-metainfo-generator/gnome-software-foss-pwa-list.xml
b/pwa-metainfo-generator/gnome-software-foss-pwa-list.xml
index 5adacea05..2e08d8ae0 100644
--- a/pwa-metainfo-generator/gnome-software-foss-pwa-list.xml
+++ b/pwa-metainfo-generator/gnome-software-foss-pwa-list.xml
@@ -4,45 +4,54 @@
<launchable type="url">https://app.diagrams.net/</launchable>
<project_license>Apache-2.0</project_license>
<metadata_license>FSFAP</metadata_license>
+ <name>diagrams.net</name>
</component>
<component type="webapp">
<launchable type="url">https://pinafore.social/</launchable>
<project_license>AGPL-3.0-only</project_license>
<metadata_license>FSFAP</metadata_license>
+ <name>Pinafore for Mastodon</name>
</component>
<component type="webapp">
<launchable type="url">https://devdocs.io/</launchable>
<project_license>MPL-2.0</project_license>
<metadata_license>FSFAP</metadata_license>
+ <name>DevDocs</name>
</component>
<component type="webapp">
<launchable type="url">https://snapdrop.net/</launchable>
<project_license>GPL-3.0-only</project_license>
<metadata_license>FSFAP</metadata_license>
+ <name>Snapdrop</name>
</component>
<component type="webapp">
<launchable type="url">https://stackedit.io/app</launchable>
<project_license>Apache-2.0</project_license>
<metadata_license>FSFAP</metadata_license>
+ <name>StackEdit</name>
</component>
<component type="webapp">
<launchable type="url">https://squoosh.app/</launchable>
<project_license>Apache-2.0</project_license>
<metadata_license>FSFAP</metadata_license>
+ <name>Squoosh</name>
</component>
<component type="webapp">
<launchable type="url">https://excalidraw.com/</launchable>
<project_license>MIT</project_license>
<metadata_license>FSFAP</metadata_license>
+ <name>Excalidraw</name>
</component>
<component type="webapp">
<launchable type="url">https://crypt.ee/</launchable>
<project_license>MIT</project_license>
<metadata_license>FSFAP</metadata_license>
+ <name>Cryptee</name>
</component>
<component type="webapp">
<launchable type="url">https://web.5217.app/</launchable>
<project_license>GPL-2.0-only</project_license>
<metadata_license>FSFAP</metadata_license>
+ <name>5217 Web</name>
</component>
</components>
\ No newline at end of file
diff --git a/pwa-metainfo-generator/pwa-metainfo-generator.py
b/pwa-metainfo-generator/pwa-metainfo-generator.py
index 7f66d9fc4..72a55c97a 100755
--- a/pwa-metainfo-generator/pwa-metainfo-generator.py
+++ b/pwa-metainfo-generator/pwa-metainfo-generator.py
@@ -24,8 +24,33 @@ Internet connection is required
import csv
import sys
import xml.etree.ElementTree as ET
+import requests
+import json
+from urllib.parse import urljoin
+from bs4 import BeautifulSoup
+def get_manifest_for_url(url):
+ response = requests.get(url)
+ response.raise_for_status()
+ soup = BeautifulSoup(response.text, 'html.parser')
+ manifest_path = soup.head.find('link', rel='manifest', href=True)['href']
+ manifest_response = requests.get(urljoin(url, manifest_path))
+ manifest_response.raise_for_status()
+ return json.loads(manifest_response.text)
+
+def copy_metainfo_from_manifest(app_component, manifest):
+ # Short name seems more suitable in practice
+ try:
+ ET.SubElement(app_component, 'name').text = manifest['short_name']
+ except KeyError:
+ ET.SubElement(app_component, 'name').text = manifest['name']
+ #TODO determine id
+ #TODO get icon
+ #TODO get screenshots
+ #TODO get categories
+ #TODO get description (summary)
+
def main():
if len(sys.argv) != 2 or not sys.argv[1].endswith('.csv'):
print('Usage: {} input.csv'.format(sys.argv[0]))
@@ -45,12 +70,19 @@ def main():
launchable.set('type', 'url')
launchable.text = app[0]
+ url = ET.SubElement(app_component, 'url')
+ url.set('type', 'homepage')
+ url.text = app[0]
+
project_license = ET.SubElement(app_component, 'project_license')
project_license.text = app[1]
- metadata_license = ET.SubElement(app_component, 'metadata_license')
+
# metadata license is a required field but we don't have one, assume FSFAP?
+ metadata_license = ET.SubElement(app_component, 'metadata_license')
metadata_license.text = 'FSFAP'
+ copy_metainfo_from_manifest(app_component, get_manifest_for_url(app[0]))
+
tree = ET.ElementTree(components)
ET.indent(tree)
tree.write(out_filename, xml_declaration=True, encoding='utf-8', method='xml')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]