Bugfixes in RSS and tag pages

* Correct article ordering by date in tags pages
* Clickable links in RSS
This commit is contained in:
Phyks 2014-04-13 19:10:37 +02:00
parent b659014bbc
commit 1d845d4db2
2 changed files with 21 additions and 11 deletions

View File

@ -755,16 +755,16 @@ rss = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
if os.path.isfile("raw/rss.css"): if os.path.isfile("raw/rss.css"):
rss += ("<?xml-stylesheet type=\"text/css\" " + rss += ("<?xml-stylesheet type=\"text/css\" " +
"href=\""+params["BLOG_URL"]+"/rss.css\"?>\n") "href=\""+params["PROTOCOL"]+params["BLOG_URL"]+"/rss.css\"?>\n")
rss += ("<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\" " rss += ("<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\" "
"xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n") "xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n")
rss += ("\t<channel>" rss += ("\t<channel>"
"\t\t<atom:link href=\""+params["BLOG_URL"]+"/rss.xml\" " "\t\t<atom:link href=\""+params["PROTOCOL"]+params["BLOG_URL"] +
"rel=\"self\" type=\"application/rss+xml\"/>\n" "/rss.xml\" rel=\"self\" type=\"application/rss+xml\"/>\n"
"\t\t<title>"+params["BLOG_TITLE"]+"</title>\n" "\t\t<title>"+params["BLOG_TITLE"]+"</title>\n"
"\t\t<link>"+params["BLOG_URL"]+"</link>\n" "\t\t<link>"+params["PROTOCOL"] + params["BLOG_URL"]+"</link>\n"
"\t\t<description>"+params["DESCRIPTION"]+"</description>\n" "\t\t<description>"+params["DESCRIPTION"]+"</description>\n"
"\t\t<language>"+params["LANGUAGE"]+"</language>\n" "\t\t<language>"+params["LANGUAGE"]+"</language>\n"
"\t\t<copyright>"+params["COPYRIGHT"]+"</copyright>\n" "\t\t<copyright>"+params["COPYRIGHT"]+"</copyright>\n"
@ -812,10 +812,10 @@ for i, article in enumerate(["gen/"+x[4:-5]+".gen" for x in last_articles]):
rss += ("\t\t<item>\n" rss += ("\t\t<item>\n"
"\t\t\t<title>"+remove_tags(title)+"</title>\n" "\t\t\t<title>"+remove_tags(title)+"</title>\n"
"\t\t\t<link>"+params["BLOG_URL"]+"/" + "\t\t\t<link>"+params["PROTOCOL"]+params["BLOG_URL"]+"/" +
article[4:-4]+".html</link>\n" + article[4:-4]+".html</link>\n" +
"\t\t\t<guid isPermaLink=\"false\">" + "\t\t\t<guid isPermaLink=\"false\">" +
params["BLOG_URL"]+"/"+article[4:-4]+"</guid>\n" params["PROTOCOL"] + params["BLOG_URL"]+"/"+article[4:-4]+"</guid>\n"
"\t\t\t<description><![CDATA[" + "\t\t\t<description><![CDATA[" +
replace_tags(get_text_rss(content), search_list, replace_list) + replace_tags(get_text_rss(content), search_list, replace_list) +
"]]></description>\n" "]]></description>\n"
@ -878,11 +878,17 @@ for tag in tags_full_list:
tag_content = header.replace("@title", params["BLOG_TITLE"] + tag_content = header.replace("@title", params["BLOG_TITLE"] +
" - "+tag[4:-4], 1) " - "+tag[4:-4], 1)
# Sort by date
with open(tag, "r") as tag_gen_fh: with open(tag, "r") as tag_gen_fh:
for line in tag_gen_fh.readlines(): articles_list = ["gen/"+line.replace(".html", ".gen").strip() for line
line = line.replace(".html", ".gen") in tag_gen_fh.readlines()]
with open("gen/"+line.strip(), "r") as article_fh: articles_list.sort(key=lambda x: (get_date(x)[4:8], get_date(x)[2:4],
tag_content += article_fh.read() get_date(x)[:2], get_date(x)[9:]),
reverse=True)
for article in articles_list:
with open(article.strip(), "r") as article_fh:
tag_content += article_fh.read()
tag_content += footer tag_content += footer
try: try:
@ -941,7 +947,10 @@ for i in years_list:
params["BLOG_TITLE"]+" - "+i+"/"+j, 1) params["BLOG_TITLE"]+" - "+i+"/"+j, 1)
articles_list = list_directory("gen/"+i+"/"+j) articles_list = list_directory("gen/"+i+"/"+j)
articles_list.sort(key=lambda x: get_date(x), reverse=True) articles_list.sort(key=lambda x: (get_date(x)[4:8], get_date(x)[2:4],
get_date(x)[:2], get_date(x)[9:]),
reverse=True)
for article in articles_list: for article in articles_list:
try: try:
with open(article, "r") as article_fh: with open(article, "r") as article_fh:

View File

@ -1,6 +1,7 @@
BLOG_TITLE = Blog BLOG_TITLE = Blog
NB_ARTICLES_INDEX = 20 NB_ARTICLES_INDEX = 20
BLOG_URL = #BLOG_URL BLOG_URL = #BLOG_URL
PROTOCOL = http
IGNORE_FILES = IGNORE_FILES =