mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +00:00
Correctly display newlines in diario page
This commit is contained in:
parent
b8c39f93e2
commit
5e98ca76d8
2 changed files with 5 additions and 1 deletions
4
db.py
4
db.py
|
@ -20,6 +20,7 @@ from telegram import User as TelegramUser
|
||||||
import loldata
|
import loldata
|
||||||
from dirty import Dirty
|
from dirty import Dirty
|
||||||
import query_discord_music
|
import query_discord_music
|
||||||
|
from flask import escape
|
||||||
|
|
||||||
# Init the config reader
|
# Init the config reader
|
||||||
import configparser
|
import configparser
|
||||||
|
@ -685,6 +686,9 @@ class Diario(Base):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.id} - {self.timestamp} - {self.author}: {self.text}"
|
return f"{self.id} - {self.timestamp} - {self.author}: {self.text}"
|
||||||
|
|
||||||
|
def to_html(self):
|
||||||
|
return str(escape(self.text)).replace("\n", "<br>")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def import_from_json(file):
|
def import_from_json(file):
|
||||||
import json
|
import json
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<blockquote id="entry-{{ entry.id }}" class="entry {% if entry.spoiler %}spoiler{% endif %}">
|
<blockquote id="entry-{{ entry.id }}" class="entry {% if entry.spoiler %}spoiler{% endif %}">
|
||||||
<div class="left">
|
<div class="left">
|
||||||
<p>
|
<p>
|
||||||
<span class="text">{{ entry.text }}</span>
|
<span class="text">{{ entry.to_html() | safe }}</span>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<cite>— {% if entry.author is not none %}<a class="author" href="{{ url_for("page_profile", name=entry.author.royal.username) }}">{{ entry.author.royal.username }}</a>{% else %}<span class="author anonymous">Anonimo</span>{% endif %}, <span class="timestamp">{{ entry.timestamp.strftime('%Y-%m-%d %H:%M:%S %Z') }}</span> {% if entry.saver is not none and entry.saver != entry.author %}<span class="saver">(salvato da <a href="/profile/{{ entry.saver.royal.username }}">{{ entry.saver.royal.username }}</a>)</span>{% endif %}</cite>
|
<cite>— {% if entry.author is not none %}<a class="author" href="{{ url_for("page_profile", name=entry.author.royal.username) }}">{{ entry.author.royal.username }}</a>{% else %}<span class="author anonymous">Anonimo</span>{% endif %}, <span class="timestamp">{{ entry.timestamp.strftime('%Y-%m-%d %H:%M:%S %Z') }}</span> {% if entry.saver is not none and entry.saver != entry.author %}<span class="saver">(salvato da <a href="/profile/{{ entry.saver.royal.username }}">{{ entry.saver.royal.username }}</a>)</span>{% endif %}</cite>
|
||||||
|
|
Loading…
Reference in a new issue