From 7f3ca7ee498fe0da2975750fc4864f5f8885165b Mon Sep 17 00:00:00 2001 From: James Taylor Date: Sun, 18 Aug 2019 15:57:27 -0700 Subject: Layout: Replace local playlists link with home link in header and use flexbox to make it work on smaller window sizes --- youtube/templates/base.html | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'youtube/templates') diff --git a/youtube/templates/base.html b/youtube/templates/base.html index 72e3691..aaa0351 100644 --- a/youtube/templates/base.html +++ b/youtube/templates/base.html @@ -16,6 +16,7 @@
+ Home -
-
- - - {% for playlist_name in header_playlist_names %} - - {% endfor %} - - - -
- Local playlists -
+
+ + + {% for playlist_name in header_playlist_names %} + + {% endfor %} + + + +
{% block main %} -- cgit v1.2.3 From 85572c94de77f4a51d5b64e44c6b50cbe200c946 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Fri, 23 Aug 2019 14:48:00 -0700 Subject: Layout: refactor item system to be more maintainable, add vertical item type --- youtube/templates/common_elements.html | 140 +++++++++------------------------ youtube/templates/search.html | 2 +- youtube/templates/watch.html | 5 +- 3 files changed, 38 insertions(+), 109 deletions(-) (limited to 'youtube/templates') diff --git a/youtube/templates/common_elements.html b/youtube/templates/common_elements.html index 49e2fad..b9ceafa 100644 --- a/youtube/templates/common_elements.html +++ b/youtube/templates/common_elements.html @@ -14,121 +14,53 @@ {%- endif -%} {% endmacro %} -{% macro small_item(info, include_author=true) %} -
-
- {% if info['type'] == 'video' %} - - - {{ info['duration'] }} - - {{ info['title'] }} - -
{{ info['author'] }}
- {{ info['views'] }} - - {% elif info['type'] == 'playlist' %} - - -
- {{ info['size'] }} +{% macro item(info, description=false, horizontal=true, include_author=true) %} +
+ - {% if info['type'] == 'video' %} - - {% endif %} -
-{% endmacro %} - -{% macro get_stats(info, include_author=true) %} - {% if include_author %} - {% if 'author_url' is in(info) %} -
By {{ info['author'] }}
- {% else %} -
{{ info['author'] }}
- {% endif %} - {% endif %} - {% if 'views' is in(info) %} - {{ info['views'] }} - {% endif %} - {% if 'published' is in(info) %} - - {% endif %} -{% endmacro %} - - - -{% macro medium_item(info, include_author=true) %} -
-
- {% if info['type'] == 'video' %} - - - {{ info['duration'] }} - - - {{ info['title'] }} - -
- {{ get_stats(info, include_author) }} -
- + {% endif %} + + + {{ info['title'] }} + +
    + {% if info['type'] == 'channel' %} +
  • {{ info['subscriber_count'] }} subscribers
  • +
  • {{ info['size'] }} videos
  • + {% else %} + {% if include_author %} + {% if 'author_url' is in(info) %} +
  • By {{ info['author'] }}
  • + {% else %} +
  • {{ info['author'] }}
  • + {% endif %} + {% endif %} + {% if 'views' is in(info) %} +
  • {{ info['views'] }}
  • + {% endif %} + {% if 'published' is in(info) %} +
  • + {% endif %} + {% endif %} +
+ + {% if description %} {{ text_runs(info.get('description', '')) }} - {{ info['badges']|join(' | ') }} - {% elif info['type'] == 'playlist' %} - - -
- {{ info['size'] }} -
-
- - {{ info['title'] }} - -
- {{ get_stats(info, include_author) }} -
- {% elif info['type'] == 'channel' %} - - - - - {{ info['title'] }} - - {{ info['subscriber_count'] }} subscribers - {{ info['size'] }} videos - - {{ text_runs(info.get('description', '')) }} - {% else %} - Error: unsupported item type {% endif %} + {{ info['badges']|join(' | ') }}
{% if info['type'] == 'video' %} {% endif %}
-{% endmacro %} - -{% macro item(info, include_author=true) %} - {% if info['item_size'] == 'small' %} - {{ small_item(info, include_author) }} - {% elif info['item_size'] == 'medium' %} - {{ medium_item(info, include_author) }} - {% else %} - Error: Unknown item size - {% endif %} {% endmacro %} - - {% macro page_buttons(estimated_pages, url, parameters_dictionary) %} {% set current_page = parameters_dictionary.get('page', 1)|int %} {% set parameters_dictionary = parameters_dictionary.to_dict() %} diff --git a/youtube/templates/search.html b/youtube/templates/search.html index 782a85e..f429da0 100644 --- a/youtube/templates/search.html +++ b/youtube/templates/search.html @@ -45,7 +45,7 @@
{% for info in results %} - {{ common_elements.item(info) }} + {{ common_elements.item(info, description=true) }} {% endfor %}