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

This commit is contained in:
manetta 2022-02-18 16:01:25 +01:00
parent 101c111834
commit 49298b2ae2
2 changed files with 5 additions and 8 deletions

View File

@ -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 }")

View File

@ -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>