Rich flairs

This commit is contained in:
robrobinbin 2021-01-12 23:34:16 +01:00
parent bbe7024323
commit a4d77926b6
5 changed files with 23 additions and 13 deletions

View File

@ -22,7 +22,9 @@
</div> </div>
<details class="comment_right" open> <details class="comment_right" open>
<summary class="comment_data"><a class="comment_author {% if item.author == post.author %}op{% endif %}" href="/u/{{ item.author }}">u/{{ item.author }}</a> <summary class="comment_data"><a class="comment_author {% if item.author == post.author %}op{% endif %}" href="/u/{{ item.author }}">u/{{ item.author }}</a>
{% call utils::render_flair(item.flair) %} {% if item.flair.flair_parts.len() > 0 %}
<small class="author_flair">{% call utils::render_flair(item.flair.flair_parts) %}</small>
{% endif %}
<span class="datetime">{{ item.time }}</span> <span class="datetime">{{ item.time }}</span>
</summary> </summary>
<p class="comment_body">{{ item.body }}</p> <p class="comment_body">{{ item.body }}</p>
@ -48,13 +50,17 @@
<a class="post_subreddit" href="/r/{{ post.community }}">r/{{ post.community }}</a> <a class="post_subreddit" href="/r/{{ post.community }}">r/{{ post.community }}</a>
<span class="dot">&bull;</span> <span class="dot">&bull;</span>
<a class="post_author" href="/u/{{ post.author }}">u/{{ post.author }}</a> <a class="post_author" href="/u/{{ post.author }}">u/{{ post.author }}</a>
{% call utils::render_flair(post.author_flair) %} {% if post.author_flair.flair_parts.len() > 0 %}
<small class="author_flair">{% call utils::render_flair(post.author_flair.flair_parts) %}</small>
{% endif %}
<span class="dot">&bull;</span> <span class="dot">&bull;</span>
<span class="datetime">{{ post.time }}</span> <span class="datetime">{{ post.time }}</span>
</p> </p>
<a href="{{ post.permalink }}" class="post_title"> <a href="{{ post.permalink }}" class="post_title">
{{ post.title }} {{ post.title }}
{% call utils::render_flair(post.flair) %} {% if post.flair.flair_parts.len() > 0 %}
<small class="post_flair" style="color:{{ post.flair.foreground_color }}; background:{{ post.flair.background_color }}">{% call utils::render_flair(post.flair.flair_parts) %}</small>
{% endif %}
</a> </a>
<!-- POST MEDIA --> <!-- POST MEDIA -->

View File

@ -34,12 +34,16 @@
<a class="post_subreddit" href="/r/{{ post.community }}">r/{{ post.community }}</a> <a class="post_subreddit" href="/r/{{ post.community }}">r/{{ post.community }}</a>
<span class="dot">&bull;</span> <span class="dot">&bull;</span>
<a class="post_author" href="/u/{{ post.author }}">u/{{ post.author }}</a> <a class="post_author" href="/u/{{ post.author }}">u/{{ post.author }}</a>
{% call utils::render_flair(post.author_flair) %} {% if post.author_flair.flair_parts.len() > 0 %}
<small class="author_flair">{% call utils::render_flair(post.author_flair.flair_parts) %}</small>
{% endif %}
<span class="dot">&bull;</span> <span class="dot">&bull;</span>
<span class="datetime">{{ post.time }}</span> <span class="datetime">{{ post.time }}</span>
</p> </p>
<p class="post_title"> <p class="post_title">
{% call utils::render_flair(post.flair) %} {% if post.flair.flair_parts.len() > 0 %}
<small class="post_flair" style="color:{{ post.flair.foreground_color }}; background:{{ post.flair.background_color }}">{% call utils::render_flair(post.flair.flair_parts) %}</small>
{% endif %}
<a href="{{ post.permalink }}">{{ post.title }}</a> <a href="{{ post.permalink }}">{{ post.title }}</a>
</p> </p>
</div> </div>

View File

@ -46,7 +46,9 @@
<span class="datetime">{{ post.time }}</span> <span class="datetime">{{ post.time }}</span>
</p> </p>
<p class="post_title"> <p class="post_title">
{% call utils::render_flair(post.flair) %} {% if post.flair.flair_parts.len() > 0 %}
<small class="post_flair" style="color:{{ post.flair.foreground_color }}; background:{{ post.flair.background_color }}">{% call utils::render_flair(post.flair.flair_parts) %}</small>
{% endif %}
<a href="{{ post.permalink }}">{{ post.title }}</a> <a href="{{ post.permalink }}">{{ post.title }}</a>
</p> </p>
</div> </div>

View File

@ -32,7 +32,9 @@
<div class="post_text"> <div class="post_text">
<p class="post_header"> <p class="post_header">
<a class="post_subreddit" href="/r/{{ post.community }}">r/{{ post.community }}</a> <a class="post_subreddit" href="/r/{{ post.community }}">r/{{ post.community }}</a>
{% call utils::render_flair(post.author_flair) %} {% if post.author_flair.flair_parts.len() > 0 %}
<small class="author_flair">{% call utils::render_flair(post.author_flair.flair_parts) %}</small>
{% endif %}
<span class="dot">&bull;</span> <span class="dot">&bull;</span>
<span class="datetime">{{ post.time }}</span> <span class="datetime">{{ post.time }}</span>
</p> </p>
@ -40,7 +42,7 @@
{% if post.flair.background_color == "Comment" %} {% if post.flair.background_color == "Comment" %}
{% else if post.flair.background_color == "" %} {% else if post.flair.background_color == "" %}
{% else %} {% else %}
{% call utils::render_flair(post.flair) %} <small class="post_flair" style="color:{{ post.flair.foreground_color }}; background:{{ post.flair.background_color }}">{% call utils::render_flair(post.flair.flair_parts) %}</small>
{% endif %} {% endif %}
<a href="{{ post.permalink }}">{{ post.title }}</a> <a href="{{ post.permalink }}">{{ post.title }}</a>
</p> </p>

View File

@ -28,15 +28,11 @@
{%- endmacro %} {%- endmacro %}
{% macro render_flair(flair) -%} {% macro render_flair(flair) -%}
{% if flair.flair_parts.len() > 0 %} {% for flair_part in flair %}
<small class="post_flair" style="color:{{ flair.foreground_color }}; background:{{ flair.background_color }}">
{% for flair_part in flair.flair_parts %}
{% if flair_part.flair_part_type == "emoji" %} {% if flair_part.flair_part_type == "emoji" %}
<span class="emoji" style="background-image:url('{{ flair_part.value }}')"></span> <span class="emoji" style="background-image:url('{{ flair_part.value }}')"></span>
{% else if flair_part.flair_part_type == "text" %} {% else if flair_part.flair_part_type == "text" %}
<span>{{ flair_part.value }}</span> <span>{{ flair_part.value }}</span>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</small>
{% endif %}
{%- endmacro %} {%- endmacro %}