diff options
Diffstat (limited to 'youtube/templates/common_elements.html')
| -rw-r--r-- | youtube/templates/common_elements.html | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/youtube/templates/common_elements.html b/youtube/templates/common_elements.html index 94554d4..1b4b08c 100644 --- a/youtube/templates/common_elements.html +++ b/youtube/templates/common_elements.html @@ -20,14 +20,14 @@ {{ info['error'] }} {% else %} <div class="item-video {{ info['type'] + '-item' }}"> - <a class="thumbnail-box" href="{{ info['url'] }}" title="{{ info['title'] }}"> + <a class="thumbnail-box" href="{{ info['url'] or '#' }}" title="{{ info['title'] }}"> <div class="thumbnail {% if info['type'] == 'channel' %} channel {% endif %}"> {% if lazy_load %} - <img class="thumbnail-img lazy" alt=" " data-src="{{ info['thumbnail'] }}"> + <img class="thumbnail-img lazy" alt=" " data-src="{{ info['thumbnail'] }}" onerror="thumbnail_fallback(this)"> {% elif info['type'] == 'channel' %} - <img class="thumbnail-img channel" alt=" " src="{{ info['thumbnail'] }}"> + <img class="thumbnail-img channel" alt=" " src="{{ info['thumbnail'] }}" onerror="thumbnail_fallback(this)"> {% else %} - <img class="thumbnail-img" alt=" " src="{{ info['thumbnail'] }}"> + <img class="thumbnail-img" alt=" " src="{{ info['thumbnail'] }}" onerror="thumbnail_fallback(this)"> {% endif %} {% if info['type'] != 'channel' %} @@ -35,19 +35,32 @@ {% endif %} </div> </a> - <h4 class="title"><a href="{{ info['url'] }}" title="{{ info['title'] }}">{{ info['title'] }}</a></h4> + <h4 class="title"><a href="{{ info['url'] or '#' }}" title="{{ info['title'] }}">{{ info['title'] }}</a></h4> {% if include_author %} + {% set author_description = info['author'] %} + {% set AUTHOR_DESC_LENGTH = 35 %} + {% if author_description != None %} + {% if author_description|length >= AUTHOR_DESC_LENGTH %} + {% set author_description = author_description[:AUTHOR_DESC_LENGTH].split(' ')[:-1]|join(' ') %} + {% if not author_description[-1] in ['.', '?', ':', '!'] %} + {% set author_more = author_description + '…' %} + {% set author_description = author_more|replace('"','') %} + {% endif %} + {% endif %} + {% endif %} {% if info.get('author_url') %} - <address title="{{ info['author'] }}"><b><a href="{{ info['author_url'] }}">{{ info['author'] }}</a></b></address> + <address title="{{ info['author'] }}"><b><a href="{{ info['author_url'] }}">{{ author_description }}</a></b></address> {% else %} - <address title="{{ info['author'] }}"><b>{{ info['author'] }}</b></address> + <address title="{{ info['author'] }}"><b>{{ author_description }}</b></address> {% endif %} {% endif %} <div class="stats {{'horizontal-stats' if horizontal else 'vertical-stats'}}"> {% if info['type'] == 'channel' %} - <div>{{ info['approx_subscriber_count'] }} subscribers</div> + {% if info.get('approx_subscriber_count') %} + <div>{{ info['approx_subscriber_count'] }} subscribers</div> + {% endif %} <div>{{ info['video_count']|commatize }} videos</div> {% else %} {% if info.get('time_published') %} @@ -104,17 +117,18 @@ {% set parameters_dictionary = parameters_dictionary.to_dict() %} {% if current_page != 1 %} - {% set _ = parameters_dictionary.__setitem__('page', current_page - 1) %} - <a class="page-link previous-page" href="{{ url + '?' + parameters_dictionary|urlencode }}">Previous page</a> + {% set _ = parameters_dictionary.__setitem__('page', current_page - 1) %} + <a class="page-link previous-page" href="{{ url + '?' + parameters_dictionary|urlencode }}">Previous page</a> {% endif %} {% if not is_last_page %} - {% set _ = parameters_dictionary.__setitem__('page', current_page + 1) %} - <a class="page-link next-page" href="{{ url + '?' + parameters_dictionary|urlencode }}">Next page</a> + {% set _ = parameters_dictionary.__setitem__('page', current_page + 1) %} + <a class="page-link next-page" href="{{ url + '?' + parameters_dictionary|urlencode }}">Next page</a> {% endif %} +{% endmacro %} - {% macro next_previous_ctoken_buttons(prev_ctoken, next_ctoken, url, parameters_dictionary) %} - {% set parameters_dictionary = parameters_dictionary.to_dict() %} +{% macro next_previous_ctoken_buttons(prev_ctoken, next_ctoken, url, parameters_dictionary) %} + {% set parameters_dictionary = parameters_dictionary.to_dict() %} {% if prev_ctoken %} {% set _ = parameters_dictionary.__setitem__('ctoken', prev_ctoken) %} @@ -125,5 +139,4 @@ {% set _ = parameters_dictionary.__setitem__('ctoken', next_ctoken) %} <a class="page-link next-page" href="{{ url + '?' + parameters_dictionary|urlencode }}">Next page</a> {% endif %} - {% endmacro %} {% endmacro %} |
