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 +++++++++------------------------ 1 file changed, 36 insertions(+), 104 deletions(-) (limited to 'youtube/templates/common_elements.html') 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() %} -- cgit v1.2.3 From 9f67a970c602f82a761b90587033d9beaf7c122b Mon Sep 17 00:00:00 2001 From: James Taylor Date: Sat, 24 Aug 2019 18:19:22 -0700 Subject: Layout: Make item titles non-clickable in empty space after wrapped text --- youtube/templates/common_elements.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'youtube/templates/common_elements.html') diff --git a/youtube/templates/common_elements.html b/youtube/templates/common_elements.html index b9ceafa..33d50b7 100644 --- a/youtube/templates/common_elements.html +++ b/youtube/templates/common_elements.html @@ -26,7 +26,7 @@ {% endif %} - {{ info['title'] }} +
    {% if info['type'] == 'channel' %} -- cgit v1.2.3 From 69e64f726eef1c92b8b5d50c8822afdc1cde2134 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Sat, 24 Aug 2019 18:25:37 -0700 Subject: Layout: Prevent long author name from overflowing in items with vertical stats --- youtube/templates/common_elements.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'youtube/templates/common_elements.html') diff --git a/youtube/templates/common_elements.html b/youtube/templates/common_elements.html index 33d50b7..67655b3 100644 --- a/youtube/templates/common_elements.html +++ b/youtube/templates/common_elements.html @@ -35,9 +35,9 @@ {% else %} {% if include_author %} {% if 'author_url' is in(info) %} -
  • By {{ info['author'] }}
  • +
  • By {{ info['author'] }}
  • {% else %} -
  • {{ info['author'] }}
  • +
  • {{ info['author'] }}
  • {% endif %} {% endif %} {% if 'views' is in(info) %} -- cgit v1.2.3