2020-12-31 23:54:13 +00:00
{% macro options(current, values, default) -%}
{% for value in values %}
2021-12-27 05:18:20 +00:00
< option value = "{{ value }}" { % if current = = value . to_string ( ) | | ( current = = " " & & value . to_string ( ) = = default . to_string ( ) ) % } selected { % endif % } >
2021-02-20 20:14:32 +00:00
{{ format!("{}{}", value.get(0..1).unwrap_or_default().to_uppercase(), value.get(1..).unwrap_or_default()) }}
2020-12-31 23:54:13 +00:00
< / option >
{% endfor %}
{%- endmacro %}
{% macro sort(root, methods, selected) -%}
{% for method in methods %}
2021-12-27 05:18:20 +00:00
< a { % if method . to_string ( ) = = selected . to_string ( ) % } class = "selected" { % endif % } href = "{{ root }}/{{ method }}" >
2021-02-20 20:14:32 +00:00
{{ format!("{}{}", method.get(0..1).unwrap_or_default().to_uppercase(), method.get(1..).unwrap_or_default()) }}
2020-12-31 23:54:13 +00:00
< / a >
{% endfor %}
{%- endmacro %}
{% macro search(root, search) -%}
2021-03-18 00:28:05 +00:00
< form action = "{% if root != " / r / " & & ! root . is_empty ( ) % } { { root } } { % endif % } / search " id = "searchbox" >
2021-01-17 22:49:36 +00:00
< input id = "search" type = "text" name = "q" placeholder = "Search" title = "Search libreddit" value = "{{ search }}" >
2021-01-01 04:21:56 +00:00
{% if root != "/r/" & & !root.is_empty() %}
2020-12-31 23:54:13 +00:00
< div id = "inside" >
2022-01-05 22:06:41 +00:00
< input type = "checkbox" name = "restrict_sr" id = "restrict_sr" checked >
2021-02-13 04:53:33 +00:00
< label for = "restrict_sr" class = "search_label" title = "Restrict search to this subreddit" > in {{ root }}< / label >
2020-12-31 23:54:13 +00:00
< / div >
{% endif %}
2021-01-17 23:51:03 +00:00
< button class = "submit" >
< svg width = "15" viewBox = "0 0 110 100" fill = "none" stroke-width = "10" stroke-linecap = "round" >
< path d = "M20 50 H100" / >
< path d = "M75 15 L100 50 L75 85" / >
→
< / svg >
< / button >
2020-12-31 23:54:13 +00:00
< / form >
2021-01-12 21:43:03 +00:00
{%- endmacro %}
2021-02-20 21:59:16 +00:00
{% macro render_flair(flair_parts) -%}
2021-12-27 05:18:20 +00:00
{% for flair_part in flair_parts.clone() %}{% 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" & & !flair_part.value.is_empty() %}< span > {{ flair_part.value }}< / span > {% endif %}{% endfor %}
2021-01-12 21:43:03 +00:00
{%- endmacro %}
2021-01-30 05:00:55 +00:00
2021-01-30 22:52:18 +00:00
{% macro sub_list(current) -%}
2021-02-02 01:50:00 +00:00
< details id = "feeds" >
< summary > Feeds< / summary >
< div id = "feed_list" >
< p > MAIN FEEDS< / p >
< a href = "/" > Home< / a >
< a href = "/r/popular" > Popular< / a >
< a href = "/r/all" > All< / a >
2022-05-21 05:42:05 +00:00
{% if prefs.subscriptions.len() > 0 %}
< p > REDDIT FEEDS< / p >
{% for sub in prefs.subscriptions %}
< a href = "/r/{{ sub }}" { % if sub = = current % } class = "selected" { % endif % } > {{ sub }}< / a >
{% endfor %}
{% endif %}
2021-01-31 02:16:42 +00:00
< / div >
< / details >
2021-01-30 05:00:55 +00:00
{%- endmacro %}
2021-02-03 19:11:04 +00:00
2021-05-10 01:25:52 +00:00
{% macro render_hls_notification(redirect_url) -%}
{% if post.post_type == "video" & & !post.media.alt_url.is_empty() & & prefs.hide_hls_notification != "on" %}
2021-05-16 15:41:47 +00:00
< div class = "post_notification" > < p > < a href = "/settings/update/?use_hls=on&redirect={{ redirect_url }}" > Enable HLS< / a > to view with audio, or < a href = "/settings/update/?hide_hls_notification=on&redirect={{ redirect_url }}" > disable this notification< / a > < / p > < / div >
2021-05-10 01:25:52 +00:00
{% endif %}
{%- endmacro %}
2021-02-03 19:11:04 +00:00
{% macro post_in_list(post) -%}
2021-05-10 01:25:52 +00:00
< div class = "post {% if post.flags.stickied %}stickied{% endif %}" id = "{{ post.id }}" >
2021-02-03 19:11:04 +00:00
< p class = "post_header" >
2021-04-06 17:23:05 +00:00
{% let community -%}
{% if post.community.starts_with("u_") -%}
{% let community = format!("u/{}", & post.community[2..]) -%}
{% else -%}
{% let community = format!("r/{}", post.community) -%}
{% endif -%}
< a class = "post_subreddit" href = "/{{ community }}" > {{ community }}< / a >
2021-02-03 19:11:04 +00:00
< span class = "dot" > • < / span >
2022-01-09 02:50:53 +00:00
< a class = "post_author {{ post.author.distinguished }}" href = "/u/{{ post.author.name }}" > u/{{ post.author.name }}< / a >
2021-02-03 19:11:04 +00:00
< span class = "dot" > • < / span >
< span class = "created" title = "{{ post.created }}" > {{ post.rel_time }}< / span >
2021-11-25 02:08:27 +00:00
{% if !post.awards.is_empty() %}
{% for award in post.awards.clone() %}
< span class = "award" title = "{{ award.name }}" >
< img alt = "{{ award.name }}" src = "{{ award.icon_url }}" width = "16" height = "16" / >
< / span >
{% endfor %}
{% endif %}
2021-02-03 19:11:04 +00:00
< / p >
2022-05-21 22:47:58 +00:00
< h2 class = "post_title" >
2021-02-03 19:11:04 +00:00
{% if post.flair.flair_parts.len() > 0 %}
2021-03-18 00:28:05 +00:00
< a href = "/r/{{ post.community }}/search?q=flair_name%3A%22{{ post.flair.text }}%22&restrict_sr=on"
2021-02-22 04:28:04 +00:00
class="post_flair"
2021-05-06 19:11:25 +00:00
style="color:{{ post.flair.foreground_color }}; background:{{ post.flair.background_color }};"
dir="ltr">{% call render_flair(post.flair.flair_parts) %}< / a >
2021-02-03 19:11:04 +00:00
{% endif %}
< a href = "{{ post.permalink }}" > {{ post.title }}< / a > {% if post.flags.nsfw %} < small class = "nsfw" > NSFW< / small > {% endif %}
2022-05-21 22:47:58 +00:00
< / h2 >
2021-02-03 19:11:04 +00:00
<!-- POST MEDIA/THUMBNAIL -->
{% if (prefs.layout.is_empty() || prefs.layout == "card") & & post.post_type == "image" %}
2022-09-27 01:35:23 +00:00
< div class = "post_media_content" >
< a href = "{{ post.media.url }}" class = "post_media_image {% if post.media.height / post.media.width < 2 %}short{% endif %}" >
< svg
{%if post.flags.nsfw & & prefs.blur_nsfw=="on" %}class="post_nsfw_blur"{% endif %}
width="{{ post.media.width }}px"
height="{{ post.media.height }}px"
xmlns="http://www.w3.org/2000/svg">
< image width = "100%" height = "100%" href = "{{ post.media.url }}" / >
< desc >
< img loading = "lazy" alt = "Post image" src = "{{ post.media.url }}" / >
< / desc >
< / svg >
< / a >
< / div >
2021-02-08 00:22:14 +00:00
{% else if (prefs.layout.is_empty() || prefs.layout == "card") & & post.post_type == "gif" %}
2022-09-27 01:35:23 +00:00
< div class = "post_media_content" >
< video class = "post_media_video short {%if post.flags.nsfw && prefs.blur_nsfw==" on " % } post_nsfw_blur { % endif % } " src = "{{ post.media.url }}" width = "{{ post.media.width }}" height = "{{ post.media.height }}" poster = "{{ post.media.poster }}" preload = "none" controls loop { % if prefs . autoplay_videos = = " on " % } autoplay { % endif % } > < a href = {{ post . media . url } } > Video< / a > < / video >
< / div >
2021-02-08 00:22:14 +00:00
{% else if (prefs.layout.is_empty() || prefs.layout == "card") & & post.post_type == "video" %}
2021-05-10 01:25:52 +00:00
{% if prefs.use_hls == "on" & & !post.media.alt_url.is_empty() %}
2022-09-27 01:35:23 +00:00
< div class = "post_media_content" >
< video class = "post_media_video short {%if post.flags.nsfw && prefs.blur_nsfw==" on " % } post_nsfw_blur { % endif % } { % if prefs . autoplay_videos = = " on " % } hls_autoplay { % endif % } " width = "{{ post.media.width }}" height = "{{ post.media.height }}" poster = "{{ post.media.poster }}" controls preload = "none" >
< source src = "{{ post.media.alt_url }}" type = "application/vnd.apple.mpegurl" / >
< source src = "{{ post.media.url }}" type = "video/mp4" / >
< / video >
< / div >
2021-05-10 01:25:52 +00:00
{% else %}
2022-09-27 01:35:23 +00:00
< div class = "post_media_content" >
< video class = "post_media_video short {%if post.flags.nsfw && prefs.blur_nsfw==" on " % } post_nsfw_blur { % endif % } " src = "{{ post.media.url }}" width = "{{ post.media.width }}" height = "{{ post.media.height }}" poster = "{{ post.media.poster }}" preload = "none" controls { % if prefs . autoplay_videos = = " on " % } autoplay { % endif % } > < a href = {{ post . media . url } } > Video< / a > < / video >
< / div >
2021-08-04 18:52:24 +00:00
{% call render_hls_notification(format!("{}%23{}", & self.url[1..].replace("& ", "%26").replace("+", "%2B"), post.id)) %}
2021-05-10 01:25:52 +00:00
{% endif %}
2021-02-03 19:11:04 +00:00
{% else if post.post_type != "self" %}
2021-05-10 17:31:19 +00:00
< a class = "post_thumbnail {% if post.thumbnail.url.is_empty() %}no_thumbnail{% endif %}" href = "{% if post.post_type == " link " % } { { post . media . url } } { % else % } { { post . permalink } } { % endif % } " rel = "nofollow" >
2021-02-03 19:11:04 +00:00
{% if post.thumbnail.url.is_empty() %}
< svg viewBox = "0 0 100 106" width = "140" height = "53" xmlns = "http://www.w3.org/2000/svg" >
< title > Thumbnail< / title >
< path d = "M35,15h-15a10,10 0,0,0 0,20h25a10,10 0,0,0 10,-10m-12.5,0a10, 10 0,0,1 10, -10h25a10,10 0,0,1 0,20h-15" fill = "none" stroke-width = "5" stroke-linecap = "round" / >
< / svg >
{% else %}
2022-09-27 01:35:23 +00:00
< div style = "max-width:{{ post.thumbnail.width }}px;max-height:{{ post.thumbnail.height }}px;" >
< svg { % if post . flags . nsfw & & prefs . blur_nsfw = ="on" % } class = "thumb_nsfw_blur" { % endif % } width = "{{ post.thumbnail.width }}px" height = "{{ post.thumbnail.height }}px" xmlns = "http://www.w3.org/2000/svg" >
< image width = "100%" height = "100%" href = "{{ post.thumbnail.url }}" / >
< desc >
< img loading = "lazy" alt = "Thumbnail" src = "{{ post.thumbnail.url }}" / >
< / desc >
< / svg >
< / div >
2021-02-03 19:11:04 +00:00
{% endif %}
< span > {% if post.post_type == "link" %}{{ post.domain }}{% else %}{{ post.post_type }}{% endif %}< / span >
< / a >
{% endif %}
2021-03-20 22:42:47 +00:00
< div class = "post_score" title = "{{ post.score.1 }}" > {{ post.score.0 }}< span class = "label" > Upvotes< / span > < / div >
2021-11-20 21:13:50 +00:00
< div class = "post_body post_preview" >
2022-05-21 05:28:31 +00:00
{{ post.body|safe }}
2021-11-20 21:13:50 +00:00
< / div >
2021-02-03 19:11:04 +00:00
< div class = "post_footer" >
2022-11-01 01:36:24 +00:00
< a href = "{{ post.permalink }}" class = "post_comments" title = "{{ post.comments.1 }} {% if post.comments.1 == " 1 " % } comment { % else % } comments { % endif % } " > {{ post.comments.0 }} {% if post.comments.1 == "1" %}comment{% else %}comments{% endif %}< / a >
2021-02-03 19:11:04 +00:00
< / div >
< / div >
{%- endmacro %}