Skip to content

Commit

Permalink
Code duplications removed and memory usage improved
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Friedman <[email protected]>
  • Loading branch information
iMattPro committed Jul 7, 2024
1 parent 68ac950 commit fa96050
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% if top_five_topic.TOPIC_PREVIEW_FIRST_POST %}
{% set preview = top_five_topic %}
{% include '@vse_topicpreview/topicpreview.html' %}
{% endif %}
{% import '@vse_topicpreview/topicpreview_macro.html' as macro %}

{# Display topic preview in Top Five extension #}
{{ macro.renderTopicPreview(top_five_topic) }}
27 changes: 7 additions & 20 deletions styles/all/template/event/topiclist_row_append.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
{% import '@vse_topicpreview/topicpreview_macro.html' as macro %}

{# display topic preview in view forum #}
{% if topicrow.TOPIC_PREVIEW_FIRST_POST %}
{% set preview = topicrow %}
{% include '@vse_topicpreview/topicpreview.html' %}
{% endif %}
{{ macro.renderTopicPreview(topicrow) }}

{# display topic preview in search results #}
{% if searchresults.TOPIC_PREVIEW_FIRST_POST %}
{% set preview = searchresults %}
{% include '@vse_topicpreview/topicpreview.html' %}
{% endif %}
{{ macro.renderTopicPreview(searchresults) }}

{# display topic preview in Similar Topics extension #}
{% if similar.TOPIC_PREVIEW_FIRST_POST %}
{% set preview = similar %}
{% include '@vse_topicpreview/topicpreview.html' %}
{% endif %}
{{ macro.renderTopicPreview(similar) }}

{# display topic preview in Recent Topics extension #}
{% if recent_topics.TOPIC_PREVIEW_FIRST_POST %}
{% set preview = recent_topics %}
{% include '@vse_topicpreview/topicpreview.html' %}
{% endif %}
{{ macro.renderTopicPreview(recent_topics) }}

{# DEPRECTATED: @v2.2.1 display topic preview in Top Five extension #}
{% if top_five_topic.TOPIC_PREVIEW_FIRST_POST %}
{% set preview = top_five_topic %}
{% include '@vse_topicpreview/topicpreview.html' %}
{% endif %}
{{ macro.renderTopicPreview(top_five_topic) }}
31 changes: 0 additions & 31 deletions styles/all/template/topicpreview.html

This file was deleted.

35 changes: 35 additions & 0 deletions styles/all/template/topicpreview_macro.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% macro renderTopicPreview(context) %}
{% if context.TOPIC_PREVIEW_FIRST_POST %}
<div class="topic_preview_content" style="display: none;">
{% if context.TOPIC_PREVIEW_LAST_POST %}
<strong>{{ lang('FIRST_POST') }}</strong>
<hr>
{% endif %}
{% if context.TOPIC_PREVIEW_FIRST_AVATAR %}
<div class="topic_preview_avatar">
{%- if context.TOPIC_PREVIEW_FIRST_AVATAR != constant('\\vse\\topicpreview\\core\\display::NO_AVATAR') -%}
{{ context.TOPIC_PREVIEW_FIRST_AVATAR }}
{%- else -%}
<div class="topic_preview_no_avatar"></div>
{%- endif -%}
</div>
{% endif %}
<div class="topic_preview_first">{{ context.TOPIC_PREVIEW_FIRST_POST }}</div>
{% if context.TOPIC_PREVIEW_LAST_POST %}
<div class="topic_preview_break"></div>
<strong>{{ lang('LAST_POST') }}</strong>
<hr>
{% if context.TOPIC_PREVIEW_LAST_AVATAR %}
<div class="topic_preview_avatar">
{%- if context.TOPIC_PREVIEW_LAST_AVATAR != constant('\\vse\\topicpreview\\core\\display::NO_AVATAR') -%}
{{ context.TOPIC_PREVIEW_LAST_AVATAR }}
{%- else -%}
<div class="topic_preview_no_avatar"></div>
{%- endif -%}
</div>
{% endif %}
<div class="topic_preview_last">{{ context.TOPIC_PREVIEW_LAST_POST }}</div>
{% endif %}
</div>
{% endif %}
{% endmacro %}

0 comments on commit fa96050

Please sign in to comment.