diff --git a/templates/note.html b/templates/note.html index 4558550..a4b9c73 100644 --- a/templates/note.html +++ b/templates/note.html @@ -1,14 +1,14 @@ {% extends "layout.html" %} {% import 'utils.html' as utils %} -{% block title %}{{ config.NAME }}: "{{ note.activity.object.content | html2plaintext | trim | truncate(50) }}"{% endblock %} +{% block title %}{{ config.NAME }}{{ note.activity.object | get_text | html2plaintext | trim | truncate(50) }}"{% endblock %} {% block header %} - + - + diff --git a/templates/utils.html b/templates/utils.html index 8952b9d..842422a 100644 --- a/templates/utils.html +++ b/templates/utils.html @@ -198,7 +198,7 @@ {% else %} - {{ obj.content | update_inline_imgs | clean | replace_custom_emojis(obj) | code_highlight | safe }} + {{ obj | get_text | update_inline_imgs | clean | replace_custom_emojis(obj) | code_highlight | safe }} {% endif %} {% if obj | has_place %} diff --git a/utils/template_filters.py b/utils/template_filters.py index 302e567..ff8e6db 100644 --- a/utils/template_filters.py +++ b/utils/template_filters.py @@ -403,6 +403,14 @@ def get_video_link(data): return data return None +@filters.app_template_filter() +def get_text(data): + """return first in 'content', 'name' or ''""" + for _t in ("content", "name"): + if _t in data: + return data[_t] + return "" + @filters.app_template_filter() def has_type(doc, _types):