Skip to content
This repository was archived by the owner on Oct 13, 2024. It is now read-only.

Commit 8874645

Browse files
feat(ui): add video animation background (#427)
1 parent 316505a commit 8874645

File tree

6 files changed

+77
-1
lines changed

6 files changed

+77
-1
lines changed

pyra/config.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,18 @@ def on_change_tray_toggle() -> bool:
193193
extra_class='col-lg-6',
194194
),
195195
),
196+
User_Interface=dict(
197+
type='section',
198+
name=_('User Interface'),
199+
description=_('User interface settings.'),
200+
icon='display',
201+
BACKGROUND_VIDEO=dict(
202+
type='boolean',
203+
name=_('Background video'),
204+
description=_('Enable background video.'),
205+
default=True,
206+
),
207+
),
196208
Updater=dict(
197209
type='section',
198210
name=_('Updater'),

pyra/webapp.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
# lib imports
1212
from flask import Flask, Response
13-
from flask import jsonify, render_template, request, send_from_directory
13+
from flask import jsonify, render_template as flask_render_template, request, send_from_directory
1414
from flask_babel import Babel
1515

1616
# local imports
@@ -61,6 +61,35 @@
6161
app.logger.addHandler(handler)
6262

6363

64+
def render_template(template_name_or_list, **context):
65+
"""
66+
Render a template, while providing our default context.
67+
68+
This function is a wrapper around ``flask.render_template``.
69+
Our UI config is added to the template context.
70+
In the future, this function may be used to add other default contexts to templates.
71+
72+
Parameters
73+
----------
74+
template_name_or_list : str
75+
The name of the template to render.
76+
**context
77+
The context to pass to the template.
78+
79+
Returns
80+
-------
81+
render_template
82+
The rendered template.
83+
84+
Examples
85+
--------
86+
>>> render_template(template_name_or_list='home.html', title=_('Home'))
87+
"""
88+
context['ui_config'] = pyra.CONFIG['User_Interface'].copy()
89+
90+
return flask_render_template(template_name_or_list=template_name_or_list, **context)
91+
92+
6493
@app.route('/')
6594
@app.route('/home')
6695
def home() -> render_template:

web/css/custom.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,25 @@ li.beta-setting {
253253
.form-check-input:not(:checked):enabled {
254254
background-color: #151515;
255255
}
256+
257+
/* Style the background video */
258+
#backgroundVideo {
259+
position: fixed;
260+
right: 0;
261+
bottom: 0;
262+
min-width: 100%;
263+
min-height: 100%;
264+
z-index: -1000;
265+
}
266+
267+
/* transparent background video overlay */
268+
.backgroundVideoOverlay {
269+
position: fixed;
270+
top: 0;
271+
bottom: 0;
272+
left: 0;
273+
right: 0;
274+
background-color: black;
275+
opacity: 0.8;
276+
z-index: -999;
277+
}

web/templates/base.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@
3939
<!-- Include navbar -->
4040
{% include 'navbar.html' %}
4141

42+
{% if ui_config['BACKGROUND_VIDEO'] %}
43+
<div class="backgroundVideoContainer">
44+
<video autoplay muted loop id="backgroundVideo" disablePictureInPicture="true" controlsList="nodownload">
45+
<source src="{{ url_for('static', filename='videos/Retro Delorean.mp4') }}" type="video/mp4">
46+
</video>
47+
48+
<div class="backgroundVideoOverlay"></div>
49+
</div>
50+
{% endif %}
51+
4252
<!-- The page template -->
4353
{% block content %}{% endblock content %}
4454
</main>

web/videos/Retro Delorean.license

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Retro Delorean video is under CC license, https://support.google.com/youtube/answer/2797468
2+
3+
https://www.youtube.com/watch?v=97DgTj0NKK0

web/videos/Retro Delorean.mp4

28.1 MB
Binary file not shown.

0 commit comments

Comments
 (0)