Merge branch 'refonte' of github.com:Mindiell/AfpyLogs into refonte
This commit is contained in:
commit
e8c7cb313e
12
app.py
12
app.py
|
@ -18,6 +18,8 @@ application.jinja_env.lstrip_blocks = application.config["JINJA_ENV"]["LSTRIP_BL
|
|||
LOG_PATTERN = re.compile(application.config["LOG_PATTERN"])
|
||||
LINK_PATTERN = re.compile(application.config["LINK_PATTERN"])
|
||||
BOLD_PATTERN = re.compile(application.config["BOLD_PATTERN"])
|
||||
SAFE_LT_PATTERN = re.compile(application.config["SAFE_LT_PATTERN"])
|
||||
SAFE_GT_PATTERN = re.compile(application.config["SAFE_GT_PATTERN"])
|
||||
|
||||
|
||||
def get_archives():
|
||||
|
@ -59,7 +61,7 @@ def archives(year=None, month=None, day=None):
|
|||
# Ok, on charge et on affiche le contenu du fichier
|
||||
filename = "log-%s-%s-%s.txt" % (year, month, day)
|
||||
filepath = os.path.join(application.config["LOG_PATH"], filename)
|
||||
with open(filepath) as f:
|
||||
with open(filepath, encoding="utf-8") as f:
|
||||
lines = f.read().splitlines()
|
||||
g.lines = []
|
||||
g.year, g.month, g.day = year, month, day
|
||||
|
@ -67,6 +69,14 @@ def archives(year=None, month=None, day=None):
|
|||
result = LOG_PATTERN.match(line)
|
||||
if result is not None:
|
||||
message = result.group("message")
|
||||
for text in SAFE_GT_PATTERN.findall(message):
|
||||
message = message.replace(
|
||||
text, application.config["SAFE_GT_HTML"].format(text=text)
|
||||
)
|
||||
for text in SAFE_LT_PATTERN.findall(message):
|
||||
message = message.replace(
|
||||
text, application.config["SAFE_LT_HTML"].format(text=text)
|
||||
)
|
||||
for link in LINK_PATTERN.findall(message):
|
||||
message = message.replace(
|
||||
link, application.config["LINK_HTML"].format(link=link)
|
||||
|
|
|
@ -16,8 +16,11 @@ LOG_PATTERN = r"^%s\s+[<*]\s*(?P<nick>[^> ]+)[> ]\s+(?P<message>.*)$" % DATE_FOR
|
|||
# Patterns
|
||||
LINK_PATTERN = r"https?://\S+"
|
||||
BOLD_PATTERN = r"\*[^\*\s]+\*"
|
||||
SAFE_LT_PATTERN = r"<"
|
||||
SAFE_GT_PATTERN = r">"
|
||||
|
||||
# html
|
||||
LINK_HTML = '<a href="{link}">{link}</a>'
|
||||
BOLD_HTML = "<b>{text}</b>"
|
||||
|
||||
SAFE_LT_HTML = "<"
|
||||
SAFE_GT_HTML = ">"
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Logs du chan #afpy pour le </title>
|
||||
<style type="text/css">
|
||||
body {background-color: #000; color: #fff; font-family: "Verdana"}
|
||||
|
@ -67,7 +69,7 @@
|
|||
</div>
|
||||
<div id="content">
|
||||
{% for line in g.lines %}
|
||||
<span class="time">{{ line.time }}</span> <span class="bracket"><</span><span class="nick">{{ line.nick }}</span><span class="bracket">></span> <span class="message">{{ line.message |safe }}</span><br />
|
||||
<span class="time">{{ line.time }}</span> <span class="bracket"><</span><span class="nick">{{ line.nick }}</span><span class="bracket">></span> <span class="message">{{ line.message|safe }}</span><br />
|
||||
{% endfor %}
|
||||
</div>
|
||||
</body>
|
||||
|
|
Loading…
Reference in New Issue