pyfedi/app/templates/post/_post_full.html

185 lines
14 KiB
HTML
Raw Normal View History

2024-09-05 20:10:26 +12:00
<div class="row position-relative post_full">
2024-12-09 13:39:05 +01:00
<div class="col post_col {% if post.type == POST_TYPE_IMAGE %}post_col post_type_image{% else %}post_type_normal{% endif %}">
2024-12-09 13:47:54 +01:00
{% include "post/_breadcrumb_nav.html" %}
2024-08-28 19:15:49 +12:00
<h1 class="mt-2 post_title" {% if post.language_id and post.language.code != 'en' %}lang="{{ post.language.code }}"{% endif %}>{{ post.title }}
2024-06-01 22:58:11 +12:00
{% if post.nsfw -%}<span class="warning_badge nsfw" title="{{ _('Not safe for work') }}">nsfw</span>{% endif -%}
{% if post.nsfl -%}<span class="warning_badge nsfl" title="{{ _('Potentially emotionally scarring content') }}">nsfl</span>{% endif -%}
2024-01-10 09:34:58 +13:00
</h1>
2024-06-01 22:58:11 +12:00
{% if post.type == POST_TYPE_LINK and post.image_id and not (post.url and 'youtube.com' in post.url) -%}
<div class="url_thumbnail">
2024-02-29 22:45:17 +13:00
<a href="{{ post.url }}" target="_blank" rel="nofollow ugc" class="post_link"><img src="{{ post.image.thumbnail_url() }}" alt="{{ post.image.alt_text if post.image.alt_text else '' }}"
2024-02-10 06:41:24 +13:00
width="{{ post.image.thumbnail_width }}" height="{{ post.image.thumbnail_height }}" loading="lazy" /></a>
</div>
2024-12-09 13:39:05 +01:00
{% elif post.type == POST_TYPE_IMAGE and post.url -%}
<p><a href="{{ post.url }}" rel="nofollow ugc" target="_blank" aria-label="Go to image">{{ post.url|shorten_url }}
<span class="fe fe-external"></span></a></p>
2024-06-01 22:58:11 +12:00
{% endif -%}
<p>{% if post.reports > 0 and current_user.is_authenticated and post.community.is_moderator(current_user) -%}
<span class="red fe fe-report" title="{{ _('Reported. Check post for issues.') }}"></span>
{% endif -%}<small>submitted {{ arrow.get(post.posted_at).humanize(locale=locale) }} by
2023-10-23 17:22:21 +13:00
{{ render_username(post.author) }}
{% if post.edited_at -%} edited {{ arrow.get(post.edited_at).humanize(locale=locale) }}{% endif -%}</small>
2023-10-23 17:22:21 +13:00
</p>
2024-12-09 13:39:05 +01:00
{% if post.type == POST_TYPE_IMAGE -%}
<div class="post_image">
{% if post.image_id -%}
{% if low_bandwidth -%}
<a href="{{ post.image.view_url(resize=True) }}" rel="nofollow ugc"><img src="{{ post.image.medium_url() }}"
alt="{{ post.image.alt_text if post.image.alt_text else post.title }}" fetchpriority="high" referrerpolicy="same-origin"
width="{{ post.image.width }}" height="{{ post.image.height }}" /></a>
{% else -%}
<a href="{{ post.image.view_url() }}" rel="nofollow ugc">
<img src="{{ post.image.view_url(resize=True) }}" lowsrc="{{ post.image.medium_url() }}"
sizes="(max-width: 512px) 100vw, 854px" srcset="{{ post.image.medium_url() }} 512w, {{ post.image.view_url(resize=True) }} 1024w"
alt="{{ post.image.alt_text if post.image.alt_text else post.title }}"
fetchpriority="high" referrerpolicy="same-origin" >
</a>
{% endif -%}
{% else -%}
<a href="{{ post.url }}" rel="nofollow ugc" target="_blank" aria-label="Go to image"><img src="{{ post.url }}" style="max-width: 100%; height: auto;" /></a>
{% endif -%}
</div>
{% elif post.type == POST_TYPE_LINK -%}
2024-02-29 22:45:17 +13:00
<p><a href="{{ post.url }}" rel="nofollow ugc" target="_blank" class="post_link" aria-label="Go to post url">{{ post.url|shorten_url }}
2024-01-24 09:52:08 +13:00
<span class="fe fe-external"></span></a></p>
2024-06-01 22:58:11 +12:00
{% if post.url.endswith('.mp3') -%}
2024-02-25 15:55:27 +13:00
<p><audio controls preload="{{ 'none' if low_bandwidth else 'metadata' }}" src="{{ post.url }}"></audio></p>
2024-06-01 22:58:11 +12:00
{% elif post.url.endswith('.mp4') or post.url.endswith('.webm') -%}
<p>
<video class="responsive-video" controls preload="{{ 'metadata' if low_bandwidth else 'auto' }}" {{ 'loop' if post.community.loop_videos() }}>
2024-06-01 22:58:11 +12:00
{% if post.url.endswith('.mp4') -%}
2024-05-06 14:23:07 +12:00
<source src="{{ post.url }}" type="video/mp4" />
2024-06-01 22:58:11 +12:00
{% elif post.url.endswith('.webm') -%}
2024-05-06 14:23:07 +12:00
<source src="{{ post.url }}" type="video/webm" />
2024-06-01 22:58:11 +12:00
{% endif -%}
</video></p>
2024-06-01 22:58:11 +12:00
{% elif post.url.startswith('https://streamable.com') -%}
2024-04-16 20:59:58 +12:00
<div style="padding-bottom: 56.25%; position: relative;"><iframe style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;" src="{{ post.url.replace('streamable.com/', 'streamable.com/e/') }}" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture; fullscreen" width="100%" height="100%" frameborder="0"></iframe></div>
2024-06-01 22:58:11 +12:00
{% elif post.url.startswith('https://www.redgifs.com/watch/') -%}
2024-04-16 20:59:58 +12:00
<div style="padding-bottom: 56.25%; position: relative;"><iframe style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;" src="{{ post.url.replace('redgifs.com/watch/', 'redgifs.com/ifr/') }}" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture; fullscreen" width="100%" height="100%" frameborder="0"></iframe></div>
2024-06-01 22:58:11 +12:00
{% endif -%}
{% if 'youtube.com' in post.url -%}
2024-04-16 20:59:58 +12:00
<p><a href="https://piped.video/watch?v={{ post.youtube_embed() }}">{{ _('Watch on piped.video') }} <span class="fe fe-external"></span></a></p>
<div style="padding-bottom: 56.25%; position: relative;"><iframe style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;" src="https://www.youtube.com/embed/{{ post.youtube_embed() }}" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture; fullscreen" width="100%" height="100%" frameborder="0"></iframe></div>
2024-06-01 22:58:11 +12:00
{% endif -%}
{% elif post.type == POST_TYPE_VIDEO -%}
2024-04-16 20:59:58 +12:00
<p><a href="{{ post.url }}" rel="nofollow ugc" target="_blank" class="post_link" aria-label="Go to post url">{{ post.url|shorten_url }}
<span class="fe fe-external"></span></a></p>
2024-06-01 22:58:11 +12:00
{% if post.url.endswith('.mp4') or post.url.endswith('.webm') -%}
2024-04-16 20:59:58 +12:00
<p>
<video class="responsive-video" controls preload="{{ 'none' if low_bandwidth else 'auto' }}" {{ 'autoplay muted' if autoplay }} {{ 'loop' if post.community.loop_videos() }}>
2024-06-01 22:58:11 +12:00
{% if post.url.endswith('.mp4') -%}
2024-05-06 14:23:07 +12:00
<source src="{{ post.url }}" type="video/mp4" />
2024-06-01 22:58:11 +12:00
{% elif post.url.endswith('.webm') -%}
2024-05-06 14:23:07 +12:00
<source src="{{ post.url }}" type="video/webm" />
2024-06-01 22:58:11 +12:00
{% endif -%}
2024-04-16 20:59:58 +12:00
</video></p>
2024-06-01 22:58:11 +12:00
{% elif post.url.startswith('https://streamable.com') -%}
2024-04-17 19:42:36 +12:00
<div style="padding-bottom: 56.25%; position: relative;"><iframe style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;" src="{{ post.url.replace('streamable.com/', 'streamable.com/e/') }}" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture; fullscreen" width="100%" height="100%" frameborder="0"></iframe></div>
2024-06-01 22:58:11 +12:00
{% elif post.url.startswith('https://www.redgifs.com/watch/') -%}
2024-04-17 19:42:36 +12:00
<div style="padding-bottom: 56.25%; position: relative;"><iframe style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;" src="{{ post.url.replace('redgifs.com/watch/', 'redgifs.com/ifr/') }}" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture; fullscreen" width="100%" height="100%" frameborder="0"></iframe></div>
2024-06-01 22:58:11 +12:00
{% endif -%}
{% if 'youtube.com' in post.url -%}
2024-04-10 18:00:59 +12:00
<p><a href="https://piped.video/watch?v={{ post.youtube_embed() }}">{{ _('Watch on piped.video') }} <span class="fe fe-external"></span></a></p>
<div style="padding-bottom: 56.25%; position: relative;"><iframe style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;" src="https://www.youtube.com/embed/{{ post.youtube_embed() }}" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture; fullscreen" width="100%" height="100%" frameborder="0"></iframe></div>
2024-06-01 22:58:11 +12:00
{% endif -%}
{% if 'videos/watch' in post.url -%}
2024-05-26 02:19:57 +01:00
<div style="padding-bottom: 56.25%; position: relative;"><iframe style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;" src="{{ post.peertube_embed() }}" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture; fullscreen" width="100%" height="100%" frameborder="0"></iframe></div>
2024-06-01 22:58:11 +12:00
{% endif -%}
{% elif post.type == POST_TYPE_IMAGE -%}
2023-11-27 22:05:35 +13:00
<div class="post_image">
2024-01-28 18:33:47 +13:00
<a href="{{ post.image.view_url() }}" target="_blank" class="post_link" rel="nofollow ugc"><img src="{{ post.image.view_url() }}" alt="{{ post.image.alt_text if post.image.alt_text else post.title }}"
2024-02-10 06:41:24 +13:00
width="{{ post.image.width }}" height="{{ post.image.height }}" loading="lazy" /></a>
2023-11-27 22:05:35 +13:00
</div>
2024-06-01 22:58:11 +12:00
{% else -%}
{% if post.image_id and not (post.url and 'youtube.com' in post.url) -%}
2024-02-29 22:45:17 +13:00
<a href="{{ post.image.view_url() }}" target="_blank" class="post_link" aria-label="Go to video" rel="nofollow ugc"><img src="{{ post.image.thumbnail_url() }}" alt="{{ post.image.alt_text if post.image.alt_text else post.title }}"
2024-02-10 06:41:24 +13:00
width="{{ post.image.thumbnail_width }}" height="{{ post.image.thumbnail_height }}" loading="lazy" /></a>
2024-06-01 22:58:11 +12:00
{% endif -%}
{% endif -%}
2024-08-28 19:25:05 +12:00
<div class="post_body"{% if post.language_id and post.language.code != 'en' %} lang="{{ post.language.code }}"{% endif %}>
2024-03-28 03:40:42 +00:00
{{ post.body_html|community_links|safe if post.body_html else '' }}
{% if archive_link -%}
2024-06-16 21:26:10 +08:00
<p><a href="{{ archive_link }}" rel="nofollow ucg noindex" target="_blank">{{ _('Archive.ph link') }} <span class="fe fe-external"></span></a></p>
{% endif -%}
2024-11-02 16:02:29 +13:00
{% if post.licence_id -%}
<p>Licence: {{ post.licence.name }}</p>
{% endif -%}
</div>
2024-06-01 22:58:11 +12:00
{% if post.type == POST_TYPE_POLL -%}
2024-05-18 19:41:20 +12:00
<div class="post_poll">
2024-06-01 22:58:11 +12:00
{% if poll_results and poll_total_votes == 0 -%}
2024-05-21 22:20:08 +12:00
<p>{{ _('The poll has finished, yet no votes were cast.') }}</p>
2024-06-01 22:58:11 +12:00
{% elif poll_results and poll_total_votes -%}
2024-05-18 19:41:20 +12:00
<ul>
2024-06-01 22:58:11 +12:00
{% for choice in poll_choices -%}
2024-05-18 19:41:20 +12:00
<li>
<div class="vote_bar">
<p class="mb-0 mt-3">{{ choice.choice_text }}</p>
<div class="vote_score" style="width: {{ choice.percentage(poll_total_votes) }}%">{{ choice.percentage(poll_total_votes) }}%</div>
</div>
</li>
2024-06-01 22:58:11 +12:00
{% endfor -%}
2024-05-18 19:41:20 +12:00
</ul>
<p>{{ _('Total votes: %(total_votes)d.', total_votes=poll_total_votes) }}</p>
<p>{{ _('Poll closes') }} {{ arrow.get(poll_data.end_poll).humanize(locale=locale) }}.</p>
2024-06-01 22:58:11 +12:00
{% elif poll_form -%}
{% if current_user.is_authenticated -%}
<form action='/poll/{{ post.id }}/vote' method="post">
2024-06-01 22:58:11 +12:00
{% else -%}
<form action='/auth/login' method="get">
<input type="hidden" name="next" value="/post/{{ post.id }}">
2024-06-01 22:58:11 +12:00
{% endif -%}
2024-05-18 19:41:20 +12:00
<ul>
2024-06-01 22:58:11 +12:00
{% for choice in poll_choices -%}
{% if poll_data.mode == 'single' -%}
2024-05-18 19:41:20 +12:00
<li><label for="choice_{{ choice.id }}">
<input type="radio" name="poll_choice" id="choice_{{ choice.id }}" required value="{{ choice.id }}"> {{ choice.choice_text }}
</label></li>
2024-06-01 22:58:11 +12:00
{% else -%}
2024-05-18 19:41:20 +12:00
<li><label for="choice_{{ choice.id }}">
<input type="checkbox" name="poll_choice[]" id="choice_{{ choice.id }}" value="{{ choice.id }}"> {{ choice.choice_text }}
</label></li>
2024-06-01 22:58:11 +12:00
{% endif -%}
{% endfor -%}
2024-05-18 19:41:20 +12:00
</ul>
<input type="submit" class="btn btn-primary" value="Vote">
</form>
2024-06-01 22:58:11 +12:00
{% endif -%}
2024-05-18 19:41:20 +12:00
</div>
2024-06-01 22:58:11 +12:00
{% endif -%}
2023-10-23 17:22:21 +13:00
</div>
2024-05-12 13:02:45 +12:00
2024-09-05 20:10:26 +12:00
{% if post.tags.count() > 0 -%}
<nav role="navigation">
<h3 class="visually-hidden">{{ _('Hashtags') }}</h3>
<ul class="post_tags">
{% for tag in post.tags -%}
<li class="post_tag small"><a href="{{ url_for('tag.show_tag', tag=tag.name) }}">#{{ tag.display_as }}</a></li>
{% endfor -%}
</ul>
</nav>
{% endif -%}
<div class="post_utilities_bar">
2024-09-05 20:10:26 +12:00
<div class="voting_buttons_new" aria-live="assertive">
{% include "post/_post_voting_buttons.html" -%}
</div>
2024-06-01 22:58:11 +12:00
{% if post.cross_posts -%}
<div class="cross_post_button">
<a href="{{ url_for('post.post_cross_posts', post_id=post.id) }}" aria-label="{{ _('Show cross-posts') }}"
title="{{ _('Show cross-posts') }}"><span class="fe fe-layers"></span>
<span aria-label="{{ _('Number of cross-posts:') }}">{{ len(post.cross_posts) }}</span></a>
</div>
2024-06-01 22:58:11 +12:00
{% endif -%}
<div class="notify_toggle">
{% if current_user.is_authenticated and current_user.verified -%}
{% include 'post/_post_notification_toggle.html' -%}
{% endif -%}
</div>
<div class="post_options_link">
<a href="{{ url_for('post.post_options', post_id=post.id) }}" rel="nofollow"><span class="fe fe-options" title="Options"> </span></a>
</div>
</div>
</div>