Rename project to XMPP Journal Publisher;

Retrieve dates of PubSub node items;
Improve CSS stylesheet;
Fix JS error.
This commit is contained in:
Schimon Jehudah, Adv. 2024-07-11 20:56:20 +03:00
parent 16bd475be2
commit e07ff6e838
5 changed files with 41 additions and 30 deletions

View file

@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#import datetime
import datetime
from fastapi import FastAPI, Request, Response
from fastapi.responses import FileResponse
from fastapi.staticfiles import StaticFiles
@ -65,8 +65,14 @@ async def view_pubsub(request: Request):
generate_json(iq, node)
else:
operator = get_configuration('settings')['operator']
json_data = [{'title' : 'Timeout Error: Press here to contact the operator.',
'link' : 'xmpp:{}?message'.format(operator)}]
json_data = [{'title' : 'Error retrieving items list.',
'link' : ('javascript:alert("XJP: XMPP Journal Publisher has experienced an error '
'while attempting to retrieve the list of items for Node {} of PubSub {}.")')
.format(node, pubsub)},
{'title' : 'Contact the operator.',
'link' : ('xmpp:{}?message;subject=XJP: XMPP Journal Publisher;body=Greetings! '
'I am contacting you to inform you that there is an error listing '
'node items for Node {} on PubSub {}.').format(operator, node, pubsub)}]
filename = 'data/{}.json'.format(node)
with open(filename, 'w', encoding='utf-8') as f:
json.dump(json_data, f, ensure_ascii=False, indent=4)
@ -172,12 +178,13 @@ def form_a_link(pubsub, node):
def error_message(text):
"""Error message in RFC 4287: The Atom Syndication Format."""
feed = feedgenerator.Atom1Feed(
description = ('This is a syndication feed generated with PubSub To '
'Atom, which conveys XEP-0060: Publish-Subscribe nodes '
'to standard RFC 4287: The Atom Syndication Format.'),
description = ('This is a syndication feed generated with XMPP Journal '
'Publisher (XJP), which conveys XEP-0060: Publish-'
'Subscribe nodes to standard RFC 4287: The Atom '
'Syndication Format.'),
language = 'en',
link = '',
subtitle = 'XMPP PubSub To Atom',
subtitle = 'XMPP Journal Publisher',
title = 'StreamBurner')
namespace = '{http://www.w3.org/2005/Atom}'
feed_url = 'gemini://schimon.i2p/'
@ -194,7 +201,7 @@ def error_message(text):
xml_atom_extended = append_element(
xml_atom,
'generator',
'XPTA: XMPP PubSub To Atom')
'XMPP Journal Publisher (XJP)')
return xml_atom_extended
def generate_rfc_4287(iq, link):
@ -216,7 +223,9 @@ def generate_rfc_4287(iq, link):
title = None if title == None else title.text
updated = item.find(namespace + 'updated')
updated = None if updated == None else updated.text
# if updated: updated = datetime.datetime.fromisoformat(updated)
published = item.find(namespace + 'published')
published = None if published == None else published.text
if not updated and not published: updated = datetime.datetime.utcnow().isoformat()
content = item.find(namespace + 'content')
content = 'No content' if content == None else content.text
link = item.find(namespace + 'link')
@ -229,14 +238,14 @@ def generate_rfc_4287(iq, link):
description = content,
# enclosure = feedgenerator.Enclosure(enclosure, enclosure_size, enclosure_type) if args.entry_enclosure else None,
link = link,
# pubdate = updated,
pubdate = published or updated,
title = title,
unique_id = link)
xml_atom = feed.writeString('utf-8')
xml_atom_extended = append_element(
xml_atom,
'generator',
'XPTA: XMPP PubSub To Atom')
'XMPP Journal Publisher (XJP)')
return xml_atom_extended
def generate_json(iq, node):