adding rss support + moving data structure logic to the python script
This commit is contained in:
parent
9485ab95b2
commit
6b0fe8ad5a
@ -8,6 +8,7 @@ from urllib.parse import urlparse
|
|||||||
import jinja2
|
import jinja2
|
||||||
from xbotlib import Bot
|
from xbotlib import Bot
|
||||||
|
|
||||||
|
# Functions that are used as Jinja filters
|
||||||
|
|
||||||
def _href_wrap(post):
|
def _href_wrap(post):
|
||||||
"""Wrap links in a tags as a Jinja template filter."""
|
"""Wrap links in a tags as a Jinja template filter."""
|
||||||
@ -16,6 +17,7 @@ def _href_wrap(post):
|
|||||||
post = post.replace(url, url_with_href)
|
post = post.replace(url, url_with_href)
|
||||||
return post
|
return post
|
||||||
|
|
||||||
|
# Main Logbot class
|
||||||
|
|
||||||
class Logbot(Bot):
|
class Logbot(Bot):
|
||||||
|
|
||||||
@ -122,12 +124,13 @@ class Logbot(Bot):
|
|||||||
html = template.render(
|
html = template.render(
|
||||||
title=self.db[message.room]["title"],
|
title=self.db[message.room]["title"],
|
||||||
db=self.db[message.room]["messages"],
|
db=self.db[message.room]["messages"],
|
||||||
|
sorted_keys=[str(num) for num in sorted([int(num) for num in self.db[message.room]["messages"].keys()])]
|
||||||
)
|
)
|
||||||
out.write(html)
|
out.write(html)
|
||||||
self.log.info(f"writing to: { log_path }")
|
self.log.info(f"writing to: { log_path }")
|
||||||
|
|
||||||
def _generate_feed(self, message):
|
def _generate_feed(self, message):
|
||||||
template = jinja2.Template(open("feed.rss").read())
|
template = jinja2.Template(open("template.rss").read())
|
||||||
folder_name = self.db[message.room]["folder"]
|
folder_name = self.db[message.room]["folder"]
|
||||||
if "@" in folder_name: # hacky
|
if "@" in folder_name: # hacky
|
||||||
folder_name = self._parse_room_name(folder_name)
|
folder_name = self._parse_room_name(folder_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user