Syndication feed fixed

This commit is contained in:
Stephane Bortzmeyer 2023-08-03 16:40:18 +02:00
parent dce4cba60f
commit 210f011a09
5 changed files with 14 additions and 17 deletions

5
TODO
View File

@ -1,5 +1,4 @@
* HTTPS for all links (grep http:// *.xml) * HTTPS for all links (grep http:// *.xml)
* lsr.atom (requires some porting) * lsr.atom (requires some porting)
* Email * link to find-subtags
* link to find-subtags (search engine first?) * post search engine
* HTML output (more beautiful, detailed, and fix SIL links)

View File

@ -30,6 +30,7 @@
<html xml:lang="en"> <html xml:lang="en">
<head> <head>
<link rel="stylesheet" type="text/css" href="ltru.css" /> <link rel="stylesheet" type="text/css" href="ltru.css" />
<link rel="alternate" type="application/atom+xml" title="Atom syndication feed" href="/registries/lsr.atom" />
<title>Language Tags: <xsl:value-of select="$title"/></title> <title>Language Tags: <xsl:value-of select="$title"/></title>
</head> </head>
<body> <body>

View File

@ -79,8 +79,7 @@ if [ -e ${LTR_LOCAL}.TMP ]; then
mv lsr-sqlite-ncr.sql lsr-sqlite.sql mv lsr-sqlite-ncr.sql lsr-sqlite.sql
${CONVERT_HTML} ${CONVERT_HTML}
${FILL_DATABASE} ${FILL_DATABASE}
# Needs to be ported away from.DateTime ./lsr2atom.py > lsr.atom
#./lsr2atom.py > lsr.atom
version=`head -n 1 ${LTR_LOCAL} | awk '{print $2}'` version=`head -n 1 ${LTR_LOCAL} | awk '{print $2}'`
echo $version > ${LTR_LOCAL}-version echo $version > ${LTR_LOCAL}-version
exit 0 exit 0

View File

@ -4,19 +4,15 @@ __version__ = "BETA"
domain = "langtag.net" domain = "langtag.net"
tag_prefix = "tag:%s,2007-05:LSR" % domain tag_prefix = "tag:%s,2007-05:LSR" % domain
# Standard library
import sys import sys
import urllib.request, urllib.parse, urllib.error import urllib.request, urllib.parse, urllib.error
# Now a standard part of Python >= 2.5
import xml.etree.ElementTree as ET
import datetime
# External libraries
import psycopg2 import psycopg2
# ElementTree is painful, with all its renamings :-(
try:
import cElementTree as ET
except ImportError:
try:
import ElementTree as ET
except ImportError:
# Now a standard part of Python >= 2.5
import xml.etree.ElementTree as ET
import mx.DateTime as DateTime # TODO move to another package
max = 10 max = 10
@ -73,7 +69,7 @@ feed.attrib["xmlns"] = "http://www.w3.org/2005/Atom"
title = ET.SubElement(feed, "title") title = ET.SubElement(feed, "title")
title.text = "Language Tag Registry syndication feed" title.text = "Language Tag Registry syndication feed"
updated = ET.SubElement(feed, "updated") updated = ET.SubElement(feed, "updated")
updated.text = DateTime.now().strftime("%Y-%m-%dT%H:%M:00Z") updated.text = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:00Z")
link_html = ET.SubElement(feed, "link") link_html = ET.SubElement(feed, "link")
link_html.attrib["rel"] = "alternate" link_html.attrib["rel"] = "alternate"
link_html.attrib["type"] = "text/html" link_html.attrib["type"] = "text/html"
@ -100,4 +96,5 @@ process_type(feed, "region")
process_type(feed, "extlang") process_type(feed, "extlang")
cursor.close() cursor.close()
connection.close() connection.close()
print(ET.tostring(feed, encoding="UTF-8")) print("<?xml version=\"1.0\" encoding=\"utf-8\"?>")
print(ET.tostring(feed, encoding="UTF-8").decode())

View File

@ -10,6 +10,7 @@ import psycopg2
# HTML templates http://www.yattag.org/ # HTML templates http://www.yattag.org/
from yattag import Doc from yattag import Doc
# TODO include the standard elements such as CSS and footer
REDIRECTION_URL = "https://www.langtag.net/registries/registry-html" # For REDIRECTION_URL = "https://www.langtag.net/registries/registry-html" # For
# local testing: Firefox apparently does not accept a redirect to a # local testing: Firefox apparently does not accept a redirect to a