diff --git a/README.md b/README.md index d953d4c..d3ff9fd 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,7 @@ http://127.0.0.1:8000/atom?pubsub=pubsub.movim.eu&node=jesus-christ-son-of-god&i ## Supported XEPs - [XEP-0060: Publish-Subscribe](https://xmpp.org/extensions/xep-0060.html) +- [XEP-0277: Microblogging over XMPP](https://xmpp.org/extensions/xep-0277.html) - [XEP-0472: Pubsub Social Feed](https://xmpp.org/extensions/xep-0472.html) ## Author diff --git a/css/stylesheet.css b/css/stylesheet.css index 58bd02d..00c8049 100644 --- a/css/stylesheet.css +++ b/css/stylesheet.css @@ -188,6 +188,15 @@ h3.title > a { text-decoration: underline; } +#articles div.entry span.tags { + display: inline-flex; + /* display: ruby; */ +} + +#articles div.entry span.tags > div { + margin: 5px; +} + .enclosures { cursor: help; direction: ltr; diff --git a/pubsub_to_atom.py b/pubsub_to_atom.py index 4bfe043..39ce383 100644 --- a/pubsub_to_atom.py +++ b/pubsub_to_atom.py @@ -8,7 +8,6 @@ from fastapi.staticfiles import StaticFiles import json from slixmpp import ClientXMPP from slixmpp.exceptions import IqError, IqTimeout -import xml import xml.etree.ElementTree as ET #import importlib.resources @@ -59,7 +58,7 @@ async def view_pubsub_nodes(request: Request): xml_opml = generate_opml(iq) result = append_stylesheet(xml_opml, 'opml') else: - text = 'Please check that PubSub Jabber ID is valid and accessible.' + text = 'Please ensure that the PubSub Jabber ID is valid and accessible.' xml_atom = error_message(text) result = append_stylesheet(xml_atom, 'atom') else: @@ -112,7 +111,7 @@ async def view_node_items(request: Request): generate_json(iq) else: operator = get_configuration('settings')['operator'] - json_data = [{'title' : 'Error retrieving items list.', + json_data = [{'title' : 'Error retrieving node items.', 'link' : ('javascript:alert("Rivista has experienced an error ' 'while attempting to retrieve the list of items for ' 'Node {} of PubSub {}.")') @@ -125,7 +124,7 @@ async def view_node_items(request: Request): with open(filename, 'w', encoding='utf-8') as f: json.dump(json_data, f, ensure_ascii=False, indent=4) else: - text = 'Please check that PubSub node and item are valid and accessible.' + text = 'Please ensure that the PubSub node and item are valid and accessible.' xml_atom = error_message(text) result = append_stylesheet(xml_atom, 'atom') @@ -145,7 +144,7 @@ async def view_node_items(request: Request): link = form_a_node_link(pubsub, node) xml_atom = generate_atom(iq, link) else: - text = 'Please check that PubSub node is valid and accessible.' + text = 'Please ensure that the PubSub node is valid and accessible.' xml_atom = error_message(text) result = append_stylesheet(xml_atom, 'atom') elif pubsub: @@ -281,12 +280,12 @@ def generate_atom(iq, link): namespace = '{http://www.w3.org/2005/Atom}' title = item_payload.find(namespace + 'title') links = item_payload.find(namespace + 'link') - if (not isinstance(title, xml.etree.ElementTree.Element) and - not isinstance(links, xml.etree.ElementTree.Element)): continue + if (not isinstance(title, ET.Element) and + not isinstance(links, ET.Element)): continue title_text = None if title == None else title.text e_entry = ET.SubElement(e_feed, 'entry') ET.SubElement(e_entry, 'title').text = title_text - if isinstance(links, xml.etree.ElementTree.Element): + if isinstance(links, ET.Element): for link in item_payload.findall(namespace + 'link'): link_href = link.attrib['href'] if 'href' in link.attrib else '' link_type = link.attrib['type'] if 'type' in link.attrib else '' @@ -297,11 +296,12 @@ def generate_atom(iq, link): link_xmpp = form_an_item_link(pubsub, node, item_id) ET.SubElement(e_entry, 'link', {'href': link_xmpp, 'rel': 'alternate', 'type': 'x-scheme-handler/xmpp'}) contents = item_payload.find(namespace + 'content') - if isinstance(contents, xml.etree.ElementTree.Element): + if isinstance(contents, ET.Element): for content in item_payload.findall(namespace + 'content'): - content_text = content.text if content.text else 'No content.' + if not content.text: continue + content_text = content.text content_type = content.attrib['type'] if 'type' in content.attrib else 'html' - content_type_text = 'html' if 'html' in content_type else 'html' + content_type_text = 'html' if 'html' in content_type else 'text' ET.SubElement(e_entry, 'content', {'type': content_type_text}).text = content_text else: ET.SubElement(e_entry, 'content').text = 'No content.' @@ -313,7 +313,7 @@ def generate_atom(iq, link): ET.SubElement(e_entry, 'updated').text = updated_text e_author = ET.SubElement(e_entry, 'author') authors = item_payload.find(namespace + 'author') - if isinstance(authors, xml.etree.ElementTree.Element): + if isinstance(authors, ET.Element): for author in item_payload.findall(namespace + 'author'): if not author.text: continue author_text = author.text @@ -322,6 +322,12 @@ def generate_atom(iq, link): author_summary = link.attrib['rel'] if 'rel' in link.attrib else '' ET.SubElement(e_author, 'name').text = author_text if author and author.attrib: print(author.attrib) + categories = item_payload.find(namespace + 'category') + if isinstance(categories, ET.Element): + for category in item_payload.findall(namespace + 'category'): + if not 'term' in category.attrib and not category.attrib['term']: continue + category_term = category.attrib['term'] + ET.SubElement(e_entry, 'category', {'term': category_term}) identifier = item_payload.find(namespace + 'id') diff --git a/script/postprocess.js b/script/postprocess.js index 000ae96..24667fe 100644 --- a/script/postprocess.js +++ b/script/postprocess.js @@ -81,7 +81,7 @@ window.onload = async function(){ } // Build a journal list - if (node) { + if (locationHref.pathname.startsWith('/atom') && node) { itemsList = await openJson(node) if (itemsList && locationHref.searchParams.get('item')) { node = locationHref.searchParams.get('node') @@ -135,7 +135,7 @@ window.onload = async function(){ // Convert URI xmpp: to URI http: links. for (let xmppLink of document.querySelectorAll( - '#articles > ul > li > div > h3 > a[href^="xmpp:"],' + + '#articles h3 > a[href^="xmpp:"][id^="rivista-"],' + '#journal > ol > li > a[href^="xmpp:"]')) { xmppUri = new URL(xmppLink); let parameters = xmppUri.search.split(';'); diff --git a/xsl/atom_as_xhtml.xsl b/xsl/atom_as_xhtml.xsl index 8c7fe4d..b9dc056 100644 --- a/xsl/atom_as_xhtml.xsl +++ b/xsl/atom_as_xhtml.xsl @@ -53,7 +53,7 @@ xmlns:atom='http://www.w3.org/2005/Atom'> - + @@ -359,10 +359,21 @@ xmlns:atom='http://www.w3.org/2005/Atom'> + + +

Tags

+ + + + + + + +

Enclosures

-
+
@@ -392,7 +403,7 @@ xmlns:atom='http://www.w3.org/2005/Atom'>
-
+
diff --git a/xsl/opml_as_xhtml.xsl b/xsl/opml_as_xhtml.xsl index 5f5a3a9..a0ac35e 100644 --- a/xsl/opml_as_xhtml.xsl +++ b/xsl/opml_as_xhtml.xsl @@ -45,12 +45,13 @@ xmlns:xml='http://www.w3.org/XML/1998/namespace'> - + +