From 602f22fabceeae4471e374209dfe38cd0454eee9 Mon Sep 17 00:00:00 2001 From: Shane Israel Date: Fri, 29 Dec 2023 23:35:50 -0700 Subject: [PATCH 1/2] add DOMAIN env variable to be injected into the metadata --- .env.dev | 1 + .env.prod | 1 + app/server/fireshare/__init__.py | 1 + app/server/fireshare/api.py | 5 +++-- app/server/fireshare/templates/metadata.html | 9 +++++---- docker-compose.yml | 2 ++ 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.env.dev b/.env.dev index bba8141..e405a01 100644 --- a/.env.dev +++ b/.env.dev @@ -1,6 +1,7 @@ export FLASK_APP="app/server/fireshare:create_app()" export FLASK_DEBUG=1 export ENVIRONMENT=dev +export DOMAIN="" export THUMBNAIL_VIDEO_LOCATION=50 export SECRET_KEY=dev-test-key export DATA_DIRECTORY=$(pwd)/dev_root/dev_data/ diff --git a/.env.prod b/.env.prod index 6502c7f..466efd2 100644 --- a/.env.prod +++ b/.env.prod @@ -4,6 +4,7 @@ export VIDEO_DIRECTORY=/videos/ export PROCESSED_DIRECTORY=/processed/ export TEMPLATE_PATH=/app/server/fireshare/templates export ENVIRONMENT=production +export DOMAIN="" export THUMBNAIL_VIDEO_LOCATION=0 export ADMIN_PASSWORD=admin export ADMIN_USERNAME=admin \ No newline at end of file diff --git a/app/server/fireshare/__init__.py b/app/server/fireshare/__init__.py index 794115e..93768f5 100644 --- a/app/server/fireshare/__init__.py +++ b/app/server/fireshare/__init__.py @@ -62,6 +62,7 @@ def create_app(init_schedule=False): raise Exception("DATA_DIRECTORY not found in environment") app.config['ENVIRONMENT'] = os.getenv('ENVIRONMENT') + app.config['DOMAIN'] = os.getenv('DOMAIN') app.config['THUMBNAIL_VIDEO_LOCATION'] = int(os.getenv('THUMBNAIL_VIDEO_LOCATION') or 0) app.config['SECRET_KEY'] = os.getenv('SECRET_KEY', secrets.token_hex(32)) app.config['DATA_DIRECTORY'] = os.getenv('DATA_DIRECTORY') diff --git a/app/server/fireshare/api.py b/app/server/fireshare/api.py index 62828ae..0e0c9fc 100644 --- a/app/server/fireshare/api.py +++ b/app/server/fireshare/api.py @@ -34,10 +34,11 @@ def get_video_path(id, subid=None): @api.route('/w/') def video_metadata(video_id): video = Video.query.filter_by(video_id=video_id).first() + domain = f"https://{current_app.config['DOMAIN']}" if current_app.config['DOMAIN'] else "" if video: - return render_template('metadata.html', video=video.json()) + return render_template('metadata.html', video=video.json(), domain=domain) else: - return redirect('/#/w/{}'.format(video_id), code=302) + return redirect('{}/#/w/{}'.format(domain, video_id), code=302) @api.route('/api/config') def config(): diff --git a/app/server/fireshare/templates/metadata.html b/app/server/fireshare/templates/metadata.html index a30f6bd..e458034 100644 --- a/app/server/fireshare/templates/metadata.html +++ b/app/server/fireshare/templates/metadata.html @@ -17,14 +17,15 @@ - - - + + + + - + {{ video.info.title }} diff --git a/docker-compose.yml b/docker-compose.yml index b8d897c..276d78b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,5 +16,7 @@ services: - MINUTES_BETWEEN_VIDEO_SCANS=5 # The location video thumbnails are generated. A value between 0-100 where 50 would be the frame in the middle of the video file and 0 would be the first frame of the video. - THUMBNAIL_VIDEO_LOCATION=0 + # The domain your instance is hosted at. (do not add http or https) e.x: v.fireshare.net, this is required for opengraph to work correctly for shared links. + - DOMAIN="" - PUID=1000 - PGID=1000 From 1751f244e109e05033d0b7777dfd5c56222c24a0 Mon Sep 17 00:00:00 2001 From: Shane Israel Date: Fri, 29 Dec 2023 23:50:38 -0700 Subject: [PATCH 2/2] minor version bump, typo fixes --- app/client/package.json | 2 +- app/client/src/components/admin/UploadCard.js | 2 +- docker-compose.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/client/package.json b/app/client/package.json index be8e150..819bc14 100644 --- a/app/client/package.json +++ b/app/client/package.json @@ -1,6 +1,6 @@ { "name": "fireshare", - "version": "1.2.18", + "version": "1.2.19", "private": true, "dependencies": { "@emotion/react": "^11.9.0", diff --git a/app/client/src/components/admin/UploadCard.js b/app/client/src/components/admin/UploadCard.js index d803598..ef4c941 100644 --- a/app/client/src/components/admin/UploadCard.js +++ b/app/client/src/components/admin/UploadCard.js @@ -46,7 +46,7 @@ const UploadCard = ({ authenticated, feedView = false, publicUpload = false, fet } handleAlert({ type: 'success', - message: 'Your upload will be in a few seconds.', + message: 'Your upload will be available in a few seconds.', autohideDuration: 3500, open: true, onClose: () => fetchVideos(), diff --git a/docker-compose.yml b/docker-compose.yml index 276d78b..f9bccf5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,7 @@ services: - ADMIN_PASSWORD=admin - SECRET_KEY=replace_this_with_some_random_string - MINUTES_BETWEEN_VIDEO_SCANS=5 - # The location video thumbnails are generated. A value between 0-100 where 50 would be the frame in the middle of the video file and 0 would be the first frame of the video. + # The location in the video thumbnails are generated. A value between 0-100 where 50 would be the frame in the middle of the video file and 0 would be the first frame of the video. - THUMBNAIL_VIDEO_LOCATION=0 # The domain your instance is hosted at. (do not add http or https) e.x: v.fireshare.net, this is required for opengraph to work correctly for shared links. - DOMAIN=""