redsunlib/templates/utils.html

36 lines
1.4 KiB
HTML
Raw Normal View History

2021-01-01 12:54:13 +13:00
{% macro options(current, values, default) -%}
{% for value in values %}
<option value="{{ value }}" {% if current == value || (current == "" && value == default) %}selected{% endif %}>
{{ format!("{}{}", value.get(0..1).unwrap().to_uppercase(), value.get(1..).unwrap()) }}
</option>
{% endfor %}
{%- endmacro %}
{% macro sort(root, methods, selected) -%}
{% for method in methods %}
<a {% if method == selected %}class="selected"{% endif %} href="{{ root }}/{{ method }}">
{{ format!("{}{}", method.get(0..1).unwrap().to_uppercase(), method.get(1..).unwrap()) }}
</a>
{% endfor %}
{%- endmacro %}
{% macro search(root, search) -%}
<form action="{% if root != "/r/" && !root.is_empty() %}{{ root }}{% endif %}/search/" id="searchbox">
2021-01-01 12:54:13 +13:00
<input id="search" type="text" name="q" placeholder="Search" value="{{ search }}">
{% if root != "/r/" && !root.is_empty() %}
2021-01-01 12:54:13 +13:00
<div id="inside">
2021-01-03 17:50:23 +13:00
<input type="checkbox" name="restrict_sr" id="restrict_sr">
<label for="restrict_sr" class="search_label">in {{ root }}</label>
2021-01-01 12:54:13 +13:00
</div>
{% endif %}
<input type="submit" value="&rarr;">
</form>
2021-01-13 10:43:03 +13:00
{%- endmacro %}
{% macro render_flair(flair) -%}
2021-01-15 11:56:28 +13:00
{% for flair_part in flair %}
{% if flair_part.flair_part_type == "emoji" %}<span class="emoji" style="background-image:url('{{ flair_part.value }}')"></span>
{% else if flair_part.flair_part_type == "text" %}<span>{{ flair_part.value }}</span>{% endif %}
{% endfor %}
2021-01-13 10:43:03 +13:00
{%- endmacro %}