From 3eecec0a51f5e31e10db23aa0dc174ebcb8f8a94 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 4 Dec 2022 19:02:22 +0000 Subject: [PATCH] downloadable videos on apple devices (#42) ![image](/attachments/bd1b3e1e-c0a9-4eee-9b1c-a03e1e8a8cbd) Co-authored-by: Aevann1 Co-authored-by: Snakes Co-authored-by: Snakes Reviewed-on: https://fsdfsd.net/rDrama/rDrama/pulls/42 Co-authored-by: Aevann Co-committed-by: Aevann --- files/assets/css/main.css | 6 ++++++ files/classes/user.py | 5 ++++- files/routes/allroutes.py | 9 ++++++++- files/templates/app.html | 11 +++-------- files/templates/default.html | 23 +++++++++++++++++++++++ files/templates/header.html | 2 +- files/templates/home.html | 2 +- files/templates/submission.html | 12 ------------ 8 files changed, 46 insertions(+), 24 deletions(-) diff --git a/files/assets/css/main.css b/files/assets/css/main.css index 02b8d154c..3a039d56e 100644 --- a/files/assets/css/main.css +++ b/files/assets/css/main.css @@ -6433,3 +6433,9 @@ div.markdown { font-size: 11px; } } + +@media (max-width: 768px) { + .download-video { + font-size: 10px; + } +} diff --git a/files/classes/user.py b/files/classes/user.py index 0149235c9..e855d91f5 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -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: diff --git a/files/routes/allroutes.py b/files/routes/allroutes.py index 59bb74738..9091c7ff1 100644 --- a/files/routes/allroutes.py +++ b/files/routes/allroutes.py @@ -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" diff --git a/files/templates/app.html b/files/templates/app.html index c14d697e5..3d3cbd79e 100644 --- a/files/templates/app.html +++ b/files/templates/app.html @@ -4,15 +4,10 @@
How to install {{SITE_NAME}}'s mobile app - {% 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 %}
First step:
diff --git a/files/templates/default.html b/files/templates/default.html index bda4dc49f..b1aea8d25 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -70,4 +70,27 @@ {% endif %} + +{% if g.browser == 'apple' %} + +{% endif %} + {% endblock %} diff --git a/files/templates/header.html b/files/templates/header.html index a26700515..4f2467bdd 100644 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -97,7 +97,7 @@
{% endif %} - {% if g.webview %} + {% if g.browser == 'webview' %} {% endif %} diff --git a/files/templates/home.html b/files/templates/home.html index 04cbcb557..059589f0d 100644 --- a/files/templates/home.html +++ b/files/templates/home.html @@ -179,7 +179,7 @@ {% 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 %}