From 233d8fc4eb254306dc5fb6b80ff58014e1822539 Mon Sep 17 00:00:00 2001 From: Aevann Date: Thu, 1 Aug 2024 04:09:48 +0300 Subject: [PATCH] switch giphy verbiage to tenor --- env_template.env | 2 +- files/assets/css/main.css | 2 +- files/assets/js/gif_modal.js | 8 ++++---- files/helpers/config/const.py | 2 +- files/routes/__init__.py | 2 +- files/routes/{giphy.py => tenor.py} | 12 ++++++------ 6 files changed, 14 insertions(+), 14 deletions(-) rename files/routes/{giphy.py => tenor.py} (81%) diff --git a/env_template.env b/env_template.env index 416984d4a..de0fd401b 100644 --- a/env_template.env +++ b/env_template.env @@ -7,7 +7,7 @@ export REDIS_URL='redis://redis:6379' export PROXY_URL='http://localhost:18080' export LOG_DIRECTORY='/var/log/rdrama' export SETTINGS_FILENAME='/site_settings.json' -export GIPHY_KEY='blahblahblah' +export TENOR_KEY='blahblahblah' export TURNSTILE_SITEKEY='blahblahblah' export TURNSTILE_SECRET='blahblahblah' export YOUTUBE_KEY='blahblahblah' diff --git a/files/assets/css/main.css b/files/assets/css/main.css index dd4804522..33ffb87e7 100644 --- a/files/assets/css/main.css +++ b/files/assets/css/main.css @@ -6921,7 +6921,7 @@ div.markdown { margin-top: 5px; } -.giphy { +.tenor { overflow: hidden; background-color: var(--gray-600); cursor: pointer; diff --git a/files/assets/js/gif_modal.js b/files/assets/js/gif_modal.js index 662f5cd59..54cf988c2 100644 --- a/files/assets/js/gif_modal.js +++ b/files/assets/js/gif_modal.js @@ -123,19 +123,19 @@ async function searchGifs(searchTerm) { container.innerHTML = ''; - let response = await fetch("/giphy?searchTerm=" + searchTerm + "&limit=48"); + let response = await fetch("/tenor?searchTerm=" + searchTerm + "&limit=48"); let data = await response.json() data = data.results if (data) { for (const e of data) { const url = e.media_formats.webp.url - const insert = `` + const insert = `` container.insertAdjacentHTML('beforeend', insert); } - const giphy = document.getElementsByClassName('giphy') - for (const element of giphy) { + const tenor = document.getElementsByClassName('tenor') + for (const element of tenor) { element.addEventListener('click', () => {insertGif (element.src)}); } } diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index 6912f3688..3ec7906b2 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -29,7 +29,7 @@ SECRET_KEY = environ.get("SECRET_KEY").strip() PROXY_URL = environ.get("PROXY_URL").strip() LOG_DIRECTORY = environ.get("LOG_DIRECTORY") SETTINGS_FILENAME = environ.get("SETTINGS_FILENAME") -GIPHY_KEY = environ.get("GIPHY_KEY").strip() +TENOR_KEY = environ.get("TENOR_KEY").strip() TURNSTILE_SITEKEY = environ.get("TURNSTILE_SITEKEY").strip() TURNSTILE_SECRET = environ.get("TURNSTILE_SECRET").strip() YOUTUBE_KEY = environ.get("YOUTUBE_KEY").strip() diff --git a/files/routes/__init__.py b/files/routes/__init__.py index a9d71c31e..6c74d9ab7 100644 --- a/files/routes/__init__.py +++ b/files/routes/__init__.py @@ -36,7 +36,7 @@ from .votes import * from .feeds import * if FEATURES['AWARDS']: from .awards import * -from .giphy import * +from .tenor import * from .holes import * if FEATURES['GAMBLING']: from .lottery import * diff --git a/files/routes/giphy.py b/files/routes/tenor.py similarity index 81% rename from files/routes/giphy.py rename to files/routes/tenor.py index 66288a556..fdc2007b4 100644 --- a/files/routes/giphy.py +++ b/files/routes/tenor.py @@ -5,12 +5,12 @@ from files.routes.wrappers import * from files.__main__ import app -@app.get("/giphy") -@app.get("/giphy") +@app.get("/tenor") +@app.get("/tenor") @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID) @auth_required -def giphy(v, path=None): +def tenor(v, path=None): searchTerm = request.values.get("searchTerm", "").strip() limit = 48 @@ -19,9 +19,9 @@ def giphy(v, path=None): except: pass if searchTerm and limit: - url = f"https://tenor.googleapis.com/v2/search?media_filter=webp&q={searchTerm}&key={GIPHY_KEY}&limit={limit}" + url = f"https://tenor.googleapis.com/v2/search?media_filter=webp&q={searchTerm}&key={TENOR_KEY}&limit={limit}" elif searchTerm and not limit: - url = f"https://tenor.googleapis.com/v2/search?media_filter=webp&q={searchTerm}&key={GIPHY_KEY}&limit=48" + url = f"https://tenor.googleapis.com/v2/search?media_filter=webp&q={searchTerm}&key={TENOR_KEY}&limit=48" else: - url = f"https://tenor.googleapis.com/v2?media_filter=webp&key={GIPHY_KEY}&limit=48" + url = f"https://tenor.googleapis.com/v2?media_filter=webp&key={TENOR_KEY}&limit=48" return requests.get(url, headers=HEADERS, timeout=5).json()