downloadable videos on apple devices (#42)

![image](/attachments/bd1b3e1e-c0a9-4eee-9b1c-a03e1e8a8cbd)

Co-authored-by: Aevann1 <randomname42029@gmail.com>
Co-authored-by: Snakes <duolsm@outlook.com>
Co-authored-by: Snakes <snakes@noreply.fsdfsd.net>
Reviewed-on: rDrama/rDrama#42
Co-authored-by: Aevann <aevann@noreply.fsdfsd.net>
Co-committed-by: Aevann <aevann@noreply.fsdfsd.net>
master
Aevann 2022-12-04 19:02:22 +00:00 committed by Snakes
parent e105035272
commit 3eecec0a51
8 changed files with 46 additions and 24 deletions

View File

@ -6433,3 +6433,9 @@ div.markdown {
font-size: 11px;
}
}
@media (max-width: 768px) {
.download-video {
font-size: 10px;
}
}

View File

@ -1016,12 +1016,15 @@ class User(Base):
Whether a user can strictly see this item. can_see_content is used where
content of a thing can be hidden from view
'''
browser = g and g.browser # TODO: request state object to pass to models for purity
if isinstance(other, (Submission, Comment)):
if not cls.can_see(user, other.author): return False
if user and user.id == other.author_id: return True
if isinstance(other, Submission):
if "!YOU!" in other.title and not user: return False
if not g.webview and other.author_id == AEVANN_ID and other.title.startswith('[ANDROID]'):
if browser != 'webview' and other.author_id == AEVANN_ID and other.title.startswith('[ANDROID]'):
return False
if browser != 'apple' and other.author_id == CARP_ID and other.title.startswith('[APPLE]'):
return False
if other.sub and not cls.can_see(user, other.subr): return False
else:

View File

@ -30,7 +30,14 @@ def before_request():
if not get_setting('bots') and request.headers.get("Authorization"): abort(403)
g.webview = '; wv) ' in ua
if '; wv) ' in ua:
g.browser = 'webview'
elif ' firefox/' in ua:
g.browser = 'firefox'
elif 'iphone' in ua or 'ipad' in ua or 'ipod' in ua or 'mac os' in ua:
g.browser = 'apple'
else:
g.browser = 'chromium'
g.is_tor = request.headers.get("cf-ipcountry") == "T1"

View File

@ -4,15 +4,10 @@
<div class="ml-3 mt-4">
<b>How to install {{SITE_NAME}}'s mobile app</b>
{% set ua = g.agent.lower() %}
{% if ' firefox/' in ua %}
{% set type = 'firefox' %}
{% elif 'iphone' in ua or 'ipad' in ua or 'ipod' in ua or 'mac os' in ua %}
{% set type = 'apple' %}
{% elif v %}
{% set type = 'chromium' %}
{% else %}
{% if not v and type == 'chromium' %}
{% set type = 'chromium-lo' %}
{% else %}
{% set type = g.browser %}
{% endif %}
<div class="font-weight-bold mt-4 mb-2">First step:</div>

View File

@ -70,4 +70,27 @@
<script defer src="{{'js/vendor/critters.js' | asset}}"></script>
<script defer src="{{'js/spider.js' | asset}}"></script>
{% endif %}
{% if g.browser == 'apple' %}
<script>
document.addEventListener('DOMContentLoaded', function() {
const videos = document.querySelectorAll('video')
for (const video of videos) {
const link = video.src
const htmlString = `
<a rel="nofollow noopener" href="${link}" target="_blank">
<div class="d-flex justify-content-between align-items-center border rounded p-2 mb-3 download-video">
<span>${link}</span>
<i class="fas fa-external-link-alt text-small"></i>
</div>
</a>`
const div = document.createElement('div');
div.innerHTML = htmlString;
video.after(div)
}
});
</script>
{% endif %}
{% endblock %}

View File

@ -97,7 +97,7 @@
</div>
{% endif %}
{% if g.webview %}
{% if g.browser == 'webview' %}
<button type="button" class="mobile-nav-icon d-md-none" onclick="location.reload()"><i class="fas fa-arrow-rotate-right align-middle text-gray-500 black"></i></button>
{% endif %}

View File

@ -179,7 +179,7 @@
</script>
{% endif %}
{% if request.path == '/' and not g.webview and time.time() > session.get('tooltip_last_dismissed',0)+86400*30 %}
{% if request.path == '/' and g.browser != 'webview' and time.time() > session.get('tooltip_last_dismissed',0)+86400*30 %}
<style>
.dismiss-beg {
color: #919191;

View File

@ -108,18 +108,6 @@
{% if not v_forbid_deleted %}
<div id="post-body" class="post-body mt-3">
{% if p.realurl(v) %}
{% if not p.embed_url and not p.is_image %}
<a rel="nofollow noopener" href="{{p.realurl(v)}}" {% if not v or v.newtabexternal %}target="_blank"{% endif %}>
<div class="d-flex {% if p.is_video or p.is_audio %}d-md-none{% endif %} justify-content-between align-items-center border rounded p-2 mb-3">
<span>{{p.realurl(v)}}</span>
<i class="fas fa-external-link-alt text-small"></i>
</div>
</a>
{% endif %}
{% endif %}
{% if p.embed_url %}
{% if p.domain == "twitter.com" %}
{{p.embed_url | safe}}