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. 7
      LogBot/logbot.py
  2. 2
      LogBot/template.rss

7
LogBot/logbot.py

@ -132,9 +132,8 @@ class Logbot(Bot):
new_key = str(int(keys[-1]) + 1) new_key = str(int(keys[-1]) + 1)
if media_post: if media_post:
self.db[message.room]["messages"][new_key] = {} 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'] = {}
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']['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']['url'] = os.path.join("https://vvvvvvaria.org/logs/", media_url)
self.db[message.room]["messages"][new_key]['media']['size'] = media_size self.db[message.room]["messages"][new_key]['media']['size'] = media_size
@ -179,9 +178,7 @@ class Logbot(Bot):
if not os.path.exists(room_path): if not os.path.exists(room_path):
os.mkdir(room_path) os.mkdir(room_path)
stylesheet_path = os.path.join( stylesheet_path = os.path.join("stylesheets", self.db[room]["stylesheet"] + ".css")
"stylesheets", self.db[room]["stylesheet"] + ".css"
)
stylesheet_dest_path = os.path.join(room_path, "stylesheet.css") stylesheet_dest_path = os.path.join(room_path, "stylesheet.css")
shutil.copy(stylesheet_path, stylesheet_dest_path) shutil.copy(stylesheet_path, stylesheet_dest_path)
self.log.info(f"Created a folder for: { room }") self.log.info(f"Created a folder for: { room }")

2
LogBot/template.rss

@ -11,7 +11,7 @@
<title>{{ x }}</title> <title>{{ x }}</title>
<link>{{ log_path }}#{{ x }}</link> <link>{{ log_path }}#{{ x }}</link>
<guid>{{ log_path }}#{{ x }}</guid> <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 %} {% 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> <dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">LogBot</dc:creator>
<pubDate>{{ post.date }}</pubDate> <pubDate>{{ post.date }}</pubDate>

Loading…
Cancel
Save