Mercurial > libervia-web
annotate libervia/web/server/html_tools.py @ 1618:5d9889f14012 default tip @
server: start major redesign
- Add icons to menu items
- Switch menu items representation from tuple to dictionary for future extensibility:
- Include icon information
- Prepare for additional data
- Remove "login" from main menu, add login page URL to template data, as it is now a separate right-aligned item
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 26 Oct 2024 23:07:01 +0200 |
parents | eb00d593801d |
children |
rev | line source |
---|---|
1239 | 1 #!/usr/bin/env python3 |
2 | |
8 | 3 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
331
diff
changeset
|
4 # Libervia: a Salut à Toi frontend |
1396 | 5 # Copyright (C) 2011-2021 Jérôme Poisson <goffi@goffi.org> |
8 | 6 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
331
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
331
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
331
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
331
diff
changeset
|
10 # (at your option) any later version. |
8 | 11 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
331
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
331
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
331
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
331
diff
changeset
|
15 # GNU Affero General Public License for more details. |
8 | 16 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
331
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
331
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
8 | 19 |
451 | 20 |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
21 def sanitize_html(text): |
8 | 22 """Sanitize HTML by escaping everything""" |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1054
diff
changeset
|
23 # this code comes from official python wiki: http://wiki.python.org/moin/EscapingHtml |
8 | 24 html_escape_table = { |
25 "&": "&", | |
26 '"': """, | |
27 "'": "'", | |
28 ">": ">", | |
29 "<": "<", | |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1054
diff
changeset
|
30 } |
8 | 31 |
451 | 32 return "".join(html_escape_table.get(c, c) for c in text) |
588
c8cca1a373dd
server_side: static blog: convert \n in raw text message to <br/>
souliane <souliane@mailoo.org>
parents:
451
diff
changeset
|
33 |
c8cca1a373dd
server_side: static blog: convert \n in raw text message to <br/>
souliane <souliane@mailoo.org>
parents:
451
diff
changeset
|
34 |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
35 def convert_new_lines_to_xhtml(text): |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1054
diff
changeset
|
36 return text.replace("\n", "<br/>") |