forked from varia/bots
Go back to using homebrew templating
This commit is contained in:
parent
cdb2ce8b04
commit
57c2dbc881
@ -1,17 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf8">
|
|
||||||
<title>{{ title }} - (Generator: LogBot)</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="stylesheet.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>{{ title }}</h1>
|
|
||||||
{% for num, msg in db.items() %}
|
|
||||||
<div class="post">
|
|
||||||
<p class="key">[{{ num }}]</p>
|
|
||||||
<p class="message">{{ msg }}</p>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -102,10 +102,11 @@ class Logbot(Bot):
|
|||||||
|
|
||||||
def _write_log(self, message):
|
def _write_log(self, message):
|
||||||
"""Write new log to the file system."""
|
"""Write new log to the file system."""
|
||||||
|
template = jinja2.Template(open("template.html").read())
|
||||||
room_name = self._parse_room_name(message.room)
|
room_name = self._parse_room_name(message.room)
|
||||||
log_path = os.path.join(self.output, room_name, "index.html")
|
log_path = os.path.join(self.output, room_name, "index.html")
|
||||||
with open(log_path, "w") as out:
|
with open(log_path, "w") as out:
|
||||||
html = self.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"],
|
||||||
)
|
)
|
||||||
|
20
LogBot/template.html
Normal file
20
LogBot/template.html
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf8">
|
||||||
|
<title>{{ title }} - (Generator: LogBot)</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="stylesheet.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>{{ title }}</h1>
|
||||||
|
|
||||||
|
{% for num, msg in db.items() %}
|
||||||
|
|
||||||
|
<div class="post">
|
||||||
|
<p class="key">[{{ num }}]</p>
|
||||||
|
<p class="message">{{ msg }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user