Update RSS feed to make it valid
This commit is contained in:
parent
dc9e9a10af
commit
0f15a2b471
@ -283,6 +283,10 @@ def get_text_rss(content):
|
||||
def remove_tags(html):
|
||||
return ''.join(BeautifulSoup(html).findAll(text=True))
|
||||
|
||||
|
||||
def truncate(text, length=100):
|
||||
return text[:text.find('.', length) - 1] + "…"
|
||||
|
||||
# Set locale
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
|
||||
@ -812,19 +816,27 @@ for i, article in enumerate(["gen/"+x[4:-5]+".gen" for x in last_articles]):
|
||||
"%d%m%Y-%H%M")
|
||||
.timetuple()))))
|
||||
|
||||
rss += ("\t\t<item>\n"
|
||||
"\t\t\t<title>"+remove_tags(title)+"</title>\n"
|
||||
rss += ("\t\t<item>\n" +
|
||||
"\t\t\t<title>"+remove_tags(title)+"</title>\n" +
|
||||
"\t\t\t<link>"+params["PROTOCOL"]+params["BLOG_URL"]+"/" +
|
||||
article[4:-4]+".html</link>\n" +
|
||||
"\t\t\t<guid isPermaLink=\"false\">" +
|
||||
params["PROTOCOL"] + params["BLOG_URL"]+"/"+article[4:-4]+"</guid>\n"
|
||||
"\t\t\t<description><![CDATA[" +
|
||||
replace_tags(get_text_rss(content), search_list, replace_list) +
|
||||
"]]></description>\n"
|
||||
"\t\t\t<pubDate>"+date_rss+"</pubDate>\n"
|
||||
"\t\t\t<category>" +
|
||||
', '.join([i.strip() for i in tags.split(",")])+"</category>\n"
|
||||
"\t\t\t<author>"+params["WEBMASTER"]+"</author>\n"
|
||||
"\t\t\t<guid isPermaLink=\"true\">" +
|
||||
params["PROTOCOL"] + params["BLOG_URL"]+"/"+article[4:-4]+".html</guid>\n"
|
||||
# Apply remove_tags twice to also remove tags in @title and so
|
||||
"\t\t\t<description>" + truncate(remove_tags(remove_tags(replace_tags(get_text_rss(content),
|
||||
search_list,
|
||||
replace_list)))) +
|
||||
"</description>\n" +
|
||||
"\t\t\t<content:encoded><![CDATA[" +
|
||||
replace_tags(get_text_rss(content),
|
||||
search_list,
|
||||
replace_list).replace(params['BLOG_URL'],
|
||||
params['BLOG_URL_RSS']) +
|
||||
"]]></content:encoded>\n" +
|
||||
"\t\t\t<pubDate>"+date_rss+"</pubDate>\n" +
|
||||
("\n".join(["\t\t\t<category>" + i.strip() + "</category>"
|
||||
for i in tags.split(",")]))+"\n" +
|
||||
"\t\t\t<author>"+params["WEBMASTER"]+"</author>\n" +
|
||||
"\t\t</item>\n")
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user