add event generation to atom_gen.py
This commit is contained in:
parent
3990f37738
commit
78ca7464b6
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
venv/
|
venv/
|
||||||
poster.html
|
poster.html
|
||||||
poster.pdf
|
poster.pdf
|
||||||
|
atom_blog.xml
|
||||||
|
atom_events.xml
|
||||||
|
56
atom_gen.py
56
atom_gen.py
@ -5,6 +5,7 @@
|
|||||||
# also expects that *.md files are in blog/ directory
|
# also expects that *.md files are in blog/ directory
|
||||||
|
|
||||||
from feedgen.feed import FeedGenerator
|
from feedgen.feed import FeedGenerator
|
||||||
|
import datetime
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@ -25,21 +26,48 @@ def blogposts_list_gen():
|
|||||||
output_list.append([author, title, time, content_html, full_path])
|
output_list.append([author, title, time, content_html, full_path])
|
||||||
return output_list
|
return output_list
|
||||||
|
|
||||||
def feedgen(blogs):
|
def events_list_gen():
|
||||||
fg = FeedGenerator()
|
output_list = []
|
||||||
fg.id('http://dmz.rs/')
|
events_file = open("dogadjaji.csv", "r")
|
||||||
fg.title('Decentrala Blog')
|
for line in events_file.readlines():
|
||||||
fg.author( {'name':'Decentrala','email':'dmz@dmz.rs'} )
|
date, time, location, title = line.split(", ")
|
||||||
fg.link( href='https://dmz.rs/atom.xml', rel='self' )
|
author = "Decentrala"
|
||||||
|
content_html = f"Event is taking place at {location} on {date} at {time}. For more information see the forum at https://forum.dmz.rs"
|
||||||
|
|
||||||
|
output_list.append([author, title, content_html])
|
||||||
|
events_file.close()
|
||||||
|
return output_list
|
||||||
|
|
||||||
|
def feedgen(blogs, events):
|
||||||
|
fg_blog = FeedGenerator()
|
||||||
|
fg_blog.id('http://dmz.rs/')
|
||||||
|
fg_blog.title('Decentrala Blog')
|
||||||
|
fg_blog.author( {'name':'Decentrala','email':'dmz@dmz.rs'} )
|
||||||
|
fg_blog.link( href='https://dmz.rs/atom_blog.xml', rel='self' )
|
||||||
|
|
||||||
|
fg_events = FeedGenerator()
|
||||||
|
fg_events.id('http://dmz.rs/')
|
||||||
|
fg_events.title('Decentrala Blog')
|
||||||
|
fg_events.author( {'name':'Decentrala','email':'dmz@dmz.rs'} )
|
||||||
|
fg_events.link( href='https://dmz.rs/atom_events.xml', rel='self' )
|
||||||
|
|
||||||
for post in blogs:
|
for post in blogs:
|
||||||
fe = fg.add_entry()
|
fe_blogs = fg_blog.add_entry()
|
||||||
fe.id("https://dmz.rs/" + post[4][:-3] + ".html")
|
fe_blogs.id("https://dmz.rs/" + post[4][:-3] + ".html")
|
||||||
fe.author({'name': post[0]})
|
fe_blogs.author({'name': post[0]})
|
||||||
fe.title(post[1])
|
fe_blogs.title(post[1])
|
||||||
fe.updated(post[2])
|
fe_blogs.updated(post[2])
|
||||||
fe.content(content=post[3], type='html')
|
fe_blogs.content(content=post[3], type='html')
|
||||||
|
|
||||||
fg.atom_file('atom.xml')
|
for event in events:
|
||||||
|
fe_events = fg_events.add_entry()
|
||||||
|
fe_events.id("https://dmz.rs/pages/events.html")
|
||||||
|
fe_events.author({'name': event[0]})
|
||||||
|
fe_events.title(event[1])
|
||||||
|
fe_events.updated(datetime.datetime.now(datetime.timezone.utc))
|
||||||
|
fe_events.content(content=event[2], type='html')
|
||||||
|
|
||||||
feedgen(blogposts_list_gen())
|
fg_blog.atom_file('atom_blog.xml')
|
||||||
|
fg_events.atom_file('atom_events.xml')
|
||||||
|
|
||||||
|
feedgen(blogposts_list_gen(), events_list_gen())
|
||||||
|
Loading…
Reference in New Issue
Block a user