From 57c2dbc8815860c61790a96cc7defee50218bafe Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sat, 27 Feb 2021 20:20:19 +0100 Subject: [PATCH] Go back to using homebrew templating --- LogBot/index.html.j2 | 17 ----------------- LogBot/logbot.py | 3 ++- LogBot/template.html | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 18 deletions(-) delete mode 100644 LogBot/index.html.j2 create mode 100644 LogBot/template.html diff --git a/LogBot/index.html.j2 b/LogBot/index.html.j2 deleted file mode 100644 index a243627..0000000 --- a/LogBot/index.html.j2 +++ /dev/null @@ -1,17 +0,0 @@ - - - - - {{ title }} - (Generator: LogBot) - - - -

{{ title }}

- {% for num, msg in db.items() %} -
-

[{{ num }}]

-

{{ msg }}

-
- {% endfor %} - - diff --git a/LogBot/logbot.py b/LogBot/logbot.py index 92ce607..d8dfaf1 100644 --- a/LogBot/logbot.py +++ b/LogBot/logbot.py @@ -102,10 +102,11 @@ class Logbot(Bot): def _write_log(self, message): """Write new log to the file system.""" + template = jinja2.Template(open("template.html").read()) room_name = self._parse_room_name(message.room) log_path = os.path.join(self.output, room_name, "index.html") with open(log_path, "w") as out: - html = self.template.render( + html = template.render( title=self.db[message.room]["title"], db=self.db[message.room]["messages"], ) diff --git a/LogBot/template.html b/LogBot/template.html new file mode 100644 index 0000000..0b74587 --- /dev/null +++ b/LogBot/template.html @@ -0,0 +1,20 @@ + + + + + {{ title }} - (Generator: LogBot) + + + +

{{ title }}

+ + {% for num, msg in db.items() %} + +
+

[{{ num }}]

+

{{ msg }}

+
+ + {% endfor %} + +