aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2020-10-22 15:00:06 -0700
committerJames Taylor <user234683@users.noreply.github.com>2020-10-22 15:00:06 -0700
commit9f1b69d22f6ad691a3c679d6fdda5d4cae1369a4 (patch)
tree2bfab77b4df9daa8da88c0ca13f296f1103456ce
parent5f4884dce8e3eb3215ee8b97469a741310669083 (diff)
downloadyt-local-9f1b69d22f6ad691a3c679d6fdda5d4cae1369a4.tar.lz
yt-local-9f1b69d22f6ad691a3c679d6fdda5d4cae1369a4.tar.xz
yt-local-9f1b69d22f6ad691a3c679d6fdda5d4cae1369a4.zip
Organize settings into categories
-rw-r--r--settings.py28
-rw-r--r--youtube/templates/settings.html9
2 files changed, 32 insertions, 5 deletions
diff --git a/settings.py b/settings.py
index e1cec13..a8fdd13 100644
--- a/settings.py
+++ b/settings.py
@@ -20,18 +20,21 @@ SETTINGS_INFO = collections.OrderedDict([
(1, 'On, except video'),
(2, 'On, including video (see warnings)'),
],
+ 'category': 'network',
}),
('tor_port', {
'type': int,
'default': 9150,
'comment': '',
+ 'category': 'network',
}),
('port_number', {
'type': int,
'default': 8080,
'comment': '',
+ 'category': 'network',
}),
('allow_foreign_addresses', {
@@ -40,6 +43,7 @@ SETTINGS_INFO = collections.OrderedDict([
'comment': '''This will allow others to connect to your Youtube Local instance as a website.
For security reasons, enabling this is not recommended.''',
'hidden': True,
+ 'category': 'network',
}),
('subtitles_mode', {
@@ -54,12 +58,14 @@ For security reasons, enabling this is not recommended.''',
(1, 'Manually created only'),
(2, 'Automatic if manual unavailable'),
],
+ 'category': 'playback',
}),
('subtitles_language', {
'type': str,
'default': 'en',
'comment': '''ISO 639 language code: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes''',
+ 'category': 'playback',
}),
('related_videos_mode', {
@@ -73,6 +79,7 @@ For security reasons, enabling this is not recommended.''',
(1, 'Always shown'),
(2, 'Shown by clicking button'),
],
+ 'category': 'interface',
}),
('comments_mode', {
@@ -86,12 +93,14 @@ For security reasons, enabling this is not recommended.''',
(1, 'Always shown'),
(2, 'Shown by clicking button'),
],
+ 'category': 'interface',
}),
('enable_comment_avatars', {
'type': bool,
'default': True,
'comment': '',
+ 'category': 'interface',
}),
('default_comment_sorting', {
@@ -109,6 +118,7 @@ For security reasons, enabling this is not recommended.''',
'type': bool,
'default': True,
'comment': '',
+ 'category': 'interface',
}),
('default_resolution', {
@@ -119,6 +129,7 @@ For security reasons, enabling this is not recommended.''',
(360, '360p'),
(720, '720p'),
],
+ 'category': 'playback',
}),
('use_video_hotkeys', {
@@ -126,6 +137,7 @@ For security reasons, enabling this is not recommended.''',
'type': bool,
'default': True,
'comment': '',
+ 'category': 'interface',
}),
('proxy_images', {
@@ -133,6 +145,7 @@ For security reasons, enabling this is not recommended.''',
'type': bool,
'default': True,
'comment': '',
+ 'category': 'network',
}),
('use_comments_js', {
@@ -140,6 +153,7 @@ For security reasons, enabling this is not recommended.''',
'type': bool,
'default': True,
'comment': '',
+ 'category': 'interface',
}),
('use_sponsorblock_js', {
@@ -147,6 +161,7 @@ For security reasons, enabling this is not recommended.''',
'type': bool,
'default': False,
'comment': '',
+ 'category': 'playback',
}),
('theme', {
@@ -158,6 +173,7 @@ For security reasons, enabling this is not recommended.''',
(1, 'Gray'),
(2, 'Dark'),
],
+ 'category': 'interface',
}),
('font', {
@@ -171,6 +187,7 @@ For security reasons, enabling this is not recommended.''',
(3, 'Verdana'),
(4, 'Tahoma'),
],
+ 'category': 'interface',
}),
('autocheck_subscriptions', {
@@ -362,11 +379,18 @@ set_img_prefix()
add_setting_changed_hook('proxy_images', set_img_prefix)
-
+categories = ['network', 'interface', 'playback', 'other']
def settings_page():
if request.method == 'GET':
+ settings_by_category = {categ: [] for categ in categories}
+ for setting_name, setting_info in SETTINGS_INFO.items():
+ categ = setting_info.get('category', 'other')
+ settings_by_category[categ].append(
+ (setting_name, setting_info, current_settings_dict[setting_name])
+ )
return flask.render_template('settings.html',
- settings = [(setting_name, setting_info, current_settings_dict[setting_name]) for setting_name, setting_info in SETTINGS_INFO.items()]
+ categories = categories,
+ settings_by_category = settings_by_category,
)
elif request.method == 'POST':
for key, value in request.values.items():
diff --git a/youtube/templates/settings.html b/youtube/templates/settings.html
index 5d1df5f..19817dd 100644
--- a/youtube/templates/settings.html
+++ b/youtube/templates/settings.html
@@ -27,8 +27,10 @@
{% block main %}
<form method="POST" class="settings-form">
- <ul class="settings-list">
- {% for setting_name, setting_info, value in settings %}
+ {% for categ in categories %}
+ <h2>{{ categ|capitalize }}</h2>
+ <ul class="settings-list">
+ {% for setting_name, setting_info, value in settings_by_category[categ] %}
{% if not setting_info.get('hidden', false) %}
<li class="setting-item">
{% if 'label' is in(setting_info) %}
@@ -59,7 +61,8 @@
</li>
{% endif %}
{% endfor %}
- </ul>
+ </ul>
+ {% endfor %}
<input type="submit" value="Save settings">
</form>
{% endblock main %}