From 8ed8a436e58ff4fb7971907bd63d3d87ac1b87a9 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Wed, 17 Jul 2019 09:29:48 +0200 Subject: [PATCH] Improve template title --- app.py | 8 ++++++-- templates/layout.html | 2 +- templates/note.html | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index 3ae3498..2da1358 100644 --- a/app.py +++ b/app.py @@ -34,7 +34,7 @@ from flask import request from flask import session from flask import url_for from flask_wtf.csrf import CSRFProtect -from html2text import html2text +import html2text from itsdangerous import BadSignature from little_boxes import activitypub as ap from little_boxes.activitypub import ActivityType @@ -123,6 +123,10 @@ else: SIG_AUTH = HTTPSigAuth(KEY) +H2T = html2text.HTML2Text() +H2T.ignore_links = True +H2T.ignore_images = True + def is_blacklisted(url: str) -> bool: return urlparse(url).netloc in BLACKLIST @@ -340,7 +344,7 @@ def clean(html): @app.template_filter() def html2plaintext(body): - return html2text(body) + return H2T.handle(body) @app.template_filter() diff --git a/templates/layout.html b/templates/layout.html index 65ff664..284256f 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -4,7 +4,7 @@ -{% block title %}{{ config.NAME }}{% endblock %}'s microblog +{% block title %}{{ config.NAME }}'s microblog{% endblock %} diff --git a/templates/note.html b/templates/note.html index 053b6c7..46603b4 100644 --- a/templates/note.html +++ b/templates/note.html @@ -1,6 +1,6 @@ {% extends "layout.html" %} {% import 'utils.html' as utils %} -{% block title %}{{ config.NAME }}: "{{ note.activity.object.content | html2plaintext | truncate(50) }}"{% endblock %} +{% block title %}{{ config.NAME }}: {{ note.activity.object.content | html2plaintext | truncate(50) }}{% endblock %} {% block header %}