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 c940904
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 34 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) }}
20 changes: 10 additions & 10 deletions styles/all/template/topicpreview.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
<div class="topic_preview_content" style="display: none;">
{% if preview.TOPIC_PREVIEW_LAST_POST %}
{% if TOPIC_PREVIEW_LAST_POST %}
<strong>{{ lang('FIRST_POST') }}</strong>
<hr>
{% endif %}
{% if preview.TOPIC_PREVIEW_FIRST_AVATAR %}
{% if TOPIC_PREVIEW_FIRST_AVATAR %}
<div class="topic_preview_avatar">
{%- if preview.TOPIC_PREVIEW_FIRST_AVATAR != constant('\\vse\\topicpreview\\core\\display::NO_AVATAR') -%}
{{ preview.TOPIC_PREVIEW_FIRST_AVATAR }}
{%- if TOPIC_PREVIEW_FIRST_AVATAR != constant('\\vse\\topicpreview\\core\\display::NO_AVATAR') -%}
{{ TOPIC_PREVIEW_FIRST_AVATAR }}
{%- else -%}
<div class="topic_preview_no_avatar"></div>
{%- endif -%}
</div>
{% endif %}
<div class="topic_preview_first">{{ preview.TOPIC_PREVIEW_FIRST_POST }}</div>
{% if preview.TOPIC_PREVIEW_LAST_POST %}
<div class="topic_preview_first">{{ TOPIC_PREVIEW_FIRST_POST }}</div>
{% if TOPIC_PREVIEW_LAST_POST %}
<div class="topic_preview_break"></div>
<strong>{{ lang('LAST_POST') }}</strong>
<hr>
{% if preview.TOPIC_PREVIEW_LAST_AVATAR %}
{% if TOPIC_PREVIEW_LAST_AVATAR %}
<div class="topic_preview_avatar">
{%- if preview.TOPIC_PREVIEW_LAST_AVATAR != constant('\\vse\\topicpreview\\core\\display::NO_AVATAR') -%}
{{ preview.TOPIC_PREVIEW_LAST_AVATAR }}
{%- if TOPIC_PREVIEW_LAST_AVATAR != constant('\\vse\\topicpreview\\core\\display::NO_AVATAR') -%}
{{ TOPIC_PREVIEW_LAST_AVATAR }}
{%- else -%}
<div class="topic_preview_no_avatar"></div>
{%- endif -%}
</div>
{% endif %}
<div class="topic_preview_last">{{ preview.TOPIC_PREVIEW_LAST_POST }}</div>
<div class="topic_preview_last">{{ TOPIC_PREVIEW_LAST_POST }}</div>
{% endif %}
</div>
11 changes: 11 additions & 0 deletions styles/all/template/topicpreview_macro.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% macro renderTopicPreview(context) %}
{% if context.TOPIC_PREVIEW_FIRST_POST %}
{% set preview = {
TOPIC_PREVIEW_FIRST_POST: context.TOPIC_PREVIEW_FIRST_POST,
TOPIC_PREVIEW_LAST_POST: context.TOPIC_PREVIEW_LAST_POST,
TOPIC_PREVIEW_FIRST_AVATAR: context.TOPIC_PREVIEW_FIRST_AVATAR,
TOPIC_PREVIEW_LAST_AVATAR: context.TOPIC_PREVIEW_LAST_AVATAR
} %}
{% include '@vse_topicpreview/topicpreview.html' with preview %}
{% endif %}
{% endmacro %}

0 comments on commit c940904

Please sign in to comment.