Browse Source

adding media to the general post text, and using CDATA to display HTML elements in RSS' <description> element

master
manetta 3 years ago
parent
commit
49298b2ae2
  1. 11
      LogBot/logbot.py
  2. 2
      LogBot/template.rss

11
LogBot/logbot.py

@ -132,9 +132,8 @@ class Logbot(Bot):
new_key = str(int(keys[-1]) + 1)
if media_post:
self.db[message.room]["messages"][new_key] = {}
self.db[message.room]["messages"][new_key]['post'] = ''
self.db[message.room]["messages"][new_key]['post'] = media_post
self.db[message.room]["messages"][new_key]['media'] = {}
self.db[message.room]["messages"][new_key]['media']['post'] = media_post
self.db[message.room]["messages"][new_key]['media']['type'] = media_type
self.db[message.room]["messages"][new_key]['media']['url'] = os.path.join("https://vvvvvvaria.org/logs/", media_url)
self.db[message.room]["messages"][new_key]['media']['size'] = media_size
@ -171,17 +170,15 @@ class Logbot(Bot):
if "folder" not in self.db[room]:
self.db[room]["folder"] = self._parse_room_name(room)
if "stylesheet" not in self.db[room]:
self.db[room]["stylesheet"] = "timeline" # default stylesheet
self.db[room]["stylesheet"] = "timeline" # default stylesheet
if "font" not in self.db[room]:
self.db[room]["font"] = "none" # default font
self.db[room]["font"] = "none" # default font
self.db._dumps()
self.log.info(f"Added to the database: { room }")
if not os.path.exists(room_path):
os.mkdir(room_path)
stylesheet_path = os.path.join(
"stylesheets", self.db[room]["stylesheet"] + ".css"
)
stylesheet_path = os.path.join("stylesheets", self.db[room]["stylesheet"] + ".css")
stylesheet_dest_path = os.path.join(room_path, "stylesheet.css")
shutil.copy(stylesheet_path, stylesheet_dest_path)
self.log.info(f"Created a folder for: { room }")

2
LogBot/template.rss

@ -11,7 +11,7 @@
<title>{{ x }}</title>
<link>{{ log_path }}#{{ x }}</link>
<guid>{{ log_path }}#{{ x }}</guid>
<description>{{ post.post }}</description>
<description><![CDATA[{{ post.post }}]]></description>
{% if 'media' in post %}<enclosure url="{{ post.media.url }}" length="{{ post.media.size }}" type="{{ post.media.type }}" />{% endif %}
<dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">LogBot</dc:creator>
<pubDate>{{ post.date }}</pubDate>

Loading…
Cancel
Save