{% macro options(current, values, default) -%} {% for value in values %} <option value="{{ value }}" {% if current == value.to_string() || (current == "" && value.to_string() == default.to_string()) %}selected{% endif %}> {{ format!("{}{}", value.get(0..1).unwrap_or_default().to_uppercase(), value.get(1..).unwrap_or_default()) }} </option> {% endfor %} {%- endmacro %} {% macro sort(root, methods, selected) -%} {% for method in methods %} <a {% if method.to_string() == selected.to_string() %}class="selected"{% endif %} href="{{ root }}/{{ method }}"> {{ format!("{}{}", method.get(0..1).unwrap_or_default().to_uppercase(), method.get(1..).unwrap_or_default()) }} </a> {% endfor %} {%- endmacro %} {% macro search(root, search) -%} <form action="{% if root != "/r/" && !root.is_empty() %}{{ root }}{% endif %}/search" id="searchbox"> <input id="search" type="text" name="q" placeholder="Search" title="Search libreddit" value="{{ search }}"> {% if root != "/r/" && !root.is_empty() %} <div id="inside"> <input type="checkbox" name="restrict_sr" id="restrict_sr" checked> <label for="restrict_sr" class="search_label" title="Restrict search to this subreddit">in {{ root }}</label> </div> {% endif %} <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> </form> {%- endmacro %} {% macro render_flair(flair_parts) -%} {% 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 %} {%- endmacro %} {% macro sub_list(current) -%} <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> {% 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 %} </div> </details> {%- endmacro %} {% macro render_hls_notification(redirect_url) -%} {% if post.post_type == "video" && !post.media.alt_url.is_empty() && prefs.hide_hls_notification != "on" %} <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> {% endif %} {%- endmacro %} {% macro post(post) -%} <!-- POST CONTENT --> <div class="post highlighted"> <p class="post_header"> <a class="post_subreddit" href="/r/{{ post.community }}">r/{{ post.community }}</a> <span class="dot">•</span> <a class="post_author {{ post.author.distinguished }}" href="/user/{{ post.author.name }}">u/{{ post.author.name }}</a> {% if post.author.flair.flair_parts.len() > 0 %} <small class="author_flair">{% call render_flair(post.author.flair.flair_parts) %}</small> {% endif %} <span class="dot">•</span> <span class="created" title="{{ post.created }}">{{ post.rel_time }}</span> {% if !post.awards.is_empty() %} <span class="dot">•</span> <span class="awards"> {% for award in post.awards.clone() %} <span class="award" title="{{ award.name }}"> <img alt="{{ award.name }}" src="{{ award.icon_url }}" width="16" height="16"/> {{ award.count }} </span> {% endfor %} </span> {% endif %} </p> <h1 class="post_title"> {{ post.title }} {% if post.flair.flair_parts.len() > 0 %} <a href="/r/{{ post.community }}/search?q=flair_name%3A%22{{ post.flair.text }}%22&restrict_sr=on" class="post_flair" style="color:{{ post.flair.foreground_color }}; background:{{ post.flair.background_color }};">{% call render_flair(post.flair.flair_parts) %}</a> {% endif %} {% if post.flags.nsfw %} <small class="nsfw">NSFW</small>{% endif %} </h1> <!-- POST MEDIA --> <!-- post_type: {{ post.post_type }} --> {% if post.post_type == "image" %} <div class="post_media_content"> <a href="{{ post.media.url }}" class="post_media_image" > <svg 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> {% else if post.post_type == "video" || post.post_type == "gif" %} {% if prefs.use_hls == "on" && !post.media.alt_url.is_empty() %} <script src="/hls.min.js"></script> <div class="post_media_content"> <video class="post_media_video short {% if prefs.autoplay_videos == "on" %}hls_autoplay{% endif %}" {% if post.media.width > 0 && post.media.height > 0 %}width="{{ post.media.width }}" height="{{ post.media.height }}"{% endif %} poster="{{ post.media.poster }}" preload="none" controls> <source src="{{ post.media.alt_url }}" type="application/vnd.apple.mpegurl" /> <source src="{{ post.media.url }}" type="video/mp4" /> </video> </div> <script src="/playHLSVideo.js"></script> {% else %} <div class="post_media_content"> <video class="post_media_video" src="{{ post.media.url }}" controls {% if prefs.autoplay_videos == "on" %}autoplay{% endif %} loop><a href={{ post.media.url }}>Video</a></video> </div> {% call render_hls_notification(post.permalink[1..]) %} {% endif %} {% else if post.post_type == "gallery" %} <div class="gallery"> {% for image in post.gallery -%} <figure> <a href="{{ image.url }}" ><img loading="lazy" alt="Gallery image" src="{{ image.url }}"/></a> <figcaption> <p>{{ image.caption }}</p> {% if image.outbound_url.len() > 0 %} <p><a class="outbound_url" href="{{ image.outbound_url }}" rel="nofollow">{{ image.outbound_url }}</a> {% endif %} </figcaption> </figure> {%- endfor %} </div> {% else if post.post_type == "link" %} <a id="post_url" href="{{ post.media.url }}" rel="nofollow">{{ post.media.url }}</a> {% endif %} <!-- POST BODY --> <div class="post_body">{{ post.body|safe }}</div> <div class="post_score" title="{{ post.score.1 }}">{{ post.score.0 }}<span class="label"> Upvotes</span></div> <div class="post_footer"> <ul id="post_links"> <li class="desktop_item"><a href="{{ post.permalink }}">permalink</a></li> <li class="mobile_item"><a href="{{ post.permalink }}">link</a></li> {% if post.num_duplicates > 0 %} <li class="desktop_item"><a href="/r/{{ post.community }}/duplicates/{{ post.id }}">duplicates</a></li> <li class="mobile_item"><a href="/r/{{ post.community }}/duplicates/{{ post.id }}">dupes</a></li> {% endif %} <li class="desktop_item"><a href="https://reddit.com{{ post.permalink }}" rel="nofollow">reddit</a></li> <li class="mobile_item"><a href="https://reddit.com{{ post.permalink }}" rel="nofollow">reddit</a></li> </ul> <p>{{ post.upvote_ratio }}%<span id="upvoted"> Upvoted</span></p> </div> </div> {%- endmacro %} {% macro post_in_list(post) -%} <div class="post {% if post.flags.stickied %}stickied{% endif %}" id="{{ post.id }}"> <p class="post_header"> {% 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> <span class="dot">•</span> <a class="post_author {{ post.author.distinguished }}" href="/u/{{ post.author.name }}">u/{{ post.author.name }}</a> <span class="dot">•</span> <span class="created" title="{{ post.created }}">{{ post.rel_time }}</span> {% 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 %} </p> <h2 class="post_title"> {% if post.flair.flair_parts.len() > 0 %} <a href="/r/{{ post.community }}/search?q=flair_name%3A%22{{ post.flair.text }}%22&restrict_sr=on" class="post_flair" style="color:{{ post.flair.foreground_color }}; background:{{ post.flair.background_color }};" dir="ltr">{% call render_flair(post.flair.flair_parts) %}</a> {% endif %} <a href="{{ post.permalink }}">{{ post.title }}</a>{% if post.flags.nsfw %} <small class="nsfw">NSFW</small>{% endif %} </h2> <!-- POST MEDIA/THUMBNAIL --> {% if (prefs.layout.is_empty() || prefs.layout == "card") && post.post_type == "image" %} <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> {% else if (prefs.layout.is_empty() || prefs.layout == "card") && post.post_type == "gif" %} <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 }}" {% if post.media.width > 0 && post.media.height > 0 %}width="{{ post.media.width }}" height="{{ post.media.height }}"{% endif %} poster="{{ post.media.poster }}" preload="none" controls loop {% if prefs.autoplay_videos == "on" %}autoplay{% endif %}><a href={{ post.media.url }}>Video</a></video> </div> {% else if (prefs.layout.is_empty() || prefs.layout == "card") && post.post_type == "video" %} {% if prefs.use_hls == "on" && !post.media.alt_url.is_empty() %} <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 %}" {% if post.media.width > 0 && post.media.height > 0 %}width="{{ post.media.width }}" height="{{ post.media.height }}"{% endif %} 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> {% else %} <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 }}" {% if post.media.width > 0 && post.media.height > 0 %}width="{{ post.media.width }}" height="{{ post.media.height }}"{% endif %} poster="{{ post.media.poster }}" preload="none" controls {% if prefs.autoplay_videos == "on" %}autoplay{% endif %}><a href={{ post.media.url }}>Video</a></video> </div> {% call render_hls_notification(format!("{}%23{}", &self.url[1..].replace("&", "%26").replace("+", "%2B"), post.id)) %} {% endif %} {% else if post.post_type != "self" %} <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"> {% 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 %} <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> {% endif %} <span>{% if post.post_type == "link" %}{{ post.domain }}{% else %}{{ post.post_type }}{% endif %}</span> </a> {% endif %} <div class="post_score" title="{{ post.score.1 }}">{{ post.score.0 }}<span class="label"> Upvotes</span></div> <div class="post_body post_preview"> {{ post.body|safe }} </div> <div class="post_footer"> <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> </div> </div> {%- endmacro %}