CSS: Ad support for element category;
XSLT: Add a reference to script postprocess.js to file opml_as_xhtml.xsl; XSLT: Add support for element category; Python: Add support for element category.
This commit is contained in:
parent
cb4507bb78
commit
8ab7396a36
6 changed files with 46 additions and 21 deletions
|
@ -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')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue