Browse Source

Exclude domain from link info, handle blank info

There's no need to show the domain separately on the comments page since
it's being displayed in the link itself just above. This also adds
handling for when there's no info to show, so we won't get the header
and an empty list in those cases.
merge-requests/85/head
Deimos 5 years ago
parent
commit
5c52a81ec0
  1. 8
      tildes/tildes/templates/topic.jinja2
  2. 8
      tildes/tildes/views/topic.py

8
tildes/tildes/templates/topic.jinja2

@ -80,8 +80,8 @@
<div class="topic-full-content">{{ topic.additional_content_html|safe }}</div>
{% endif %}
{% if topic.content_metadata %}
{{ content_metadata(topic) }}
{% if content_metadata %}
{{ topic_content_metadata(content_metadata) }}
{% endif %}
{% endif %}
{% endif %}
@ -305,12 +305,12 @@
</dl>
{% endblock %}
{% macro content_metadata(topic) %}
{% macro topic_content_metadata(content_metadata) %}
<section class="topic-full-content-metadata">
<h2>Link information</h2>
<p class="text-small text-secondary">This data is scraped automatically and may be incorrect.</p>
<dl>
{% for field, value in topic.content_metadata_fields_for_display.items() %}
{% for field, value in content_metadata.items() %}
<dt>{{ field }}</dt>
<dd>{{ value }}</dd>
{% endfor %}

8
tildes/tildes/views/topic.py

@ -388,6 +388,13 @@ def get_topic(request: Request, comment_order: CommentTreeSortOption) -> dict:
)
tree = CommentTree(comments, comment_order, request.user)
# check for link information (content metadata) to display
if topic.is_link_type:
content_metadata = topic.content_metadata_fields_for_display.copy()
content_metadata.pop("Domain", None)
else:
content_metadata = None
# check if there are any items in the log to show
visible_events = (
LogEventType.TOPIC_LINK_EDIT,
@ -423,6 +430,7 @@ def get_topic(request: Request, comment_order: CommentTreeSortOption) -> dict:
return {
"topic": topic,
"content_metadata": content_metadata,
"log": log,
"comments": tree,
"comment_order": comment_order,

Loading…
Cancel
Save