settings.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. {% set page_title = 'Settings' %}
  2. {% extends "base.html" %}
  3. {% block style %}
  4. <link href="/youtube.com/static/settings.css" rel="stylesheet">
  5. {% endblock style %}
  6. {% block main %}
  7. <form method="POST" class="settings-form">
  8. {% for categ in categories %}
  9. <h2>{{ categ|capitalize }}</h2>
  10. <ul class="settings-list">
  11. {% for setting_name, setting_info, value in settings_by_category[categ] %}
  12. {% if not setting_info.get('hidden', false) %}
  13. <li class="setting-item">
  14. {% if 'label' is in(setting_info) %}
  15. <label for="{{ 'setting_' + setting_name }}" {% if 'comment' is in(setting_info) %}title="{{ setting_info['comment'] }}" {% endif %}>{{ setting_info['label'] }}</label>
  16. {% else %}
  17. <label for="{{ 'setting_' + setting_name }}" {% if 'comment' is in(setting_info) %}title="{{ setting_info['comment'] }}" {% endif %}>{{ setting_name.replace('_', ' ')|capitalize }}</label>
  18. {% endif %}
  19. {% if setting_info['type'].__name__ == 'bool' %}
  20. <input type="checkbox" id="{{ 'setting_' + setting_name }}" name="{{ setting_name }}" {{ 'checked' if value else '' }}>
  21. {% elif setting_info['type'].__name__ == 'int' %}
  22. {% if 'options' is in(setting_info) %}
  23. <select id="{{ 'setting_' + setting_name }}" name="{{ setting_name }}">
  24. {% for option in setting_info['options'] %}
  25. <option value="{{ option[0] }}" {{ 'selected' if option[0] == value else '' }}>{{ option[1] }}</option>
  26. {% endfor %}
  27. </select>
  28. {% else %}
  29. <input type="number" id="{{ 'setting_' + setting_name }}" name="{{ setting_name }}" value="{{ value }}" step="1">
  30. {% endif %}
  31. {% elif setting_info['type'].__name__ == 'float' %}
  32. {% elif setting_info['type'].__name__ == 'str' %}
  33. <input type="text" id="{{ 'setting_' + setting_name }}" name="{{ setting_name }}" value="{{ value }}">
  34. {% else %}
  35. <span>Error: Unknown setting type: setting_info['type'].__name__</span>
  36. {% endif %}
  37. </li>
  38. {% endif %}
  39. {% endfor %}
  40. </ul>
  41. {% endfor %}
  42. <input type="submit" value="Save settings">
  43. </form>
  44. {% endblock main %}