1 {% set fallback_img = "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 300' fill='%23fff'><circle r='30' cx='80' cy='150' fill='%23fff' stroke='%23000'/><circle r='30' cx='150' cy='150' fill='%23fff' stroke='%23000'/><circle r='30' cx='220' cy='150' fill='%23fff' stroke='%23000'/></svg>" %}
3 {% macro card_generic(link, thumbnail, title='', badge=None, pinned=False) -%}
4 <div class="card {{ "pinned" if pinned else "" }}">
5 <div class="card-main">
6 <a class="link-main" href="{{ link }}" title="{{ title | e }}">
8 <img src="{{ thumbnail or fallback_img}}">
9 {% if badge is not none %}
10 <span class="badge">{{ badge | e }}</span>
13 <div class="title">{{ title | e }}</div>
22 {% macro card(video_id, title='', advanced_text='', pinned="undefined", advanced_title='', post_url=None, badge=None) -%}
23 {% set caller_ = caller %}
24 {% set pinned_ = False if pinned == "undefined" else pinned %}
25 {% call card_generic("/watch?v="~video_id, "https://i.ytimg.com/vi/"~video_id~"/mqdefault.jpg", title, badge, pinned_) %}
27 <details class="advanced"><summary title="{{advanced_title}}">{{ advanced_text }}</summary>
30 {{ emoji_link("comments", post_url, False) }}
32 {% if pinned != "undefined" %}
33 {{ emoji_button("pin", video_id, pinned, False) }}
34 {{ emoji_button("hide", video_id, False, False) }}
36 {{ emoji_link("audio", video_id, False) }}
37 {{ emoji_link("raw", video_id, False) }}
38 {{ emoji_link("json", video_id, False) }}
43 {% macro typed_card(params) -%}
44 {% set c = params.content %}
45 {% if params.type == 'VIDEO' %}
46 {% set pinned = c.pinned if c.pinned is defined else "undefined" %}
47 {% set badge = 'LIVE' if c.live else c.length %}
48 {% call card(c.video_id, c.title, c.published, pinned=pinned, badge=badge) %}
49 {{ infobar_subscriptions(c.video_id, c.channel_id, c.author) }}
51 {% elif params.type == 'CHANNEL' %}
52 {% call card_generic("/channel/"~c.channel_id~"/", c.icons[c.icons.largest] if 'icons' in c else '', c.title) %}
53 <span class=channel>Channel</span>
54 <span class=advanced>{{ c.subscribers }}</span>
56 {% elif params.type == 'PLAYLIST' %}
57 {% call card_generic("/playlist?list="~c.playlist_id, "https://i.ytimg.com/vi/"~c.video_id~"/mqdefault.jpg", c.title) %}
58 <span class=channel>{{ infobar_subscriptions(None, c.channel_id, c.author) }}</span>
59 <span class=advanced>{{ c.n_videos }} videos</span>
61 {% elif params.type == 'WEBSITE' %}
62 {% call card_generic(c.url, c.icons[c.icons.largest] if 'icons' in c else '', c.title) %}
63 <span class=channel>{{ c.domain }}</span>
68 {% macro dummycard() -%}
69 {% for _ in range(4) %}
70 <div class="dummy card"></div>
74 {# TODO: remove video_id parameter (unused) #}
75 {% macro infobar_subscriptions(video_id, channel_id, author) -%}
76 {% if channel_id is defined and channel_id is not none %}
77 <a class="info-main" href="/channel/{{ channel_id }}/">{{ author | e }}</a>
79 <span class="info-main">{{ author | e }}</span>
83 {% macro emoji_button(action, subject, reverse=False, text=False) -%}
85 'pin': ['📌️', '📌️⃠'],
86 'hide': ['💨️', ''],
87 'subscribe': ['📝️', '🗑️'],
90 'pin': ['pin to subscription feed', 'unpin'],
91 'hide': ['hide video', ''],
92 'subscribe': ['subscribe', 'unsubscribe'],
95 'pin': 'youtube.feed_post',
96 'hide': 'youtube.feed_post',
97 'subscribe': 'youtube.manage_subscriptions',
99 <form method=post action="{{ url_for(actions[action]) }}" class="emoji-form">
100 <input type="hidden" name="{{ 'un' if reverse }}{{ action }}" value="{{ subject }}">
101 <label title="{{ texts[action][reverse] }}">
102 <input type="submit" hidden>
103 <span class="emoji">{{ icons[action][reverse] }}</span>{#
104 #}<span class="notemoji">{{ texts[action][reverse] if text }}</span>
108 {% macro emoji_link(action, subject, text=False) -%}
110 'raw': '🎞️',
112 'audio': '🎧',
113 'comments': '💬',
116 'raw': 'show raw video',
117 'json': 'view json metadata',
118 'audio': 'listen to audio only',
119 'comments': 'view comments',
122 'raw': '/watch?v='~subject~'&show=raw',
123 'json': '/watch?v='~subject~'&show=json',
124 'audio': '/watch?v='~subject~'&show=audio',
125 'comments': 'https://old.reddit.com'~subject,
127 <a href="{{ actions[action] }}" title="{{ texts[action] }}">{#
128 #}<span class="emoji">{{ icons[action] }}</span>{#
129 #}<span class="notemoji">{{ texts[action] if text }}</span>
133 {% macro pagination(text, fields, direction) -%}
134 <a href="?{{ querystring_page(fields) }}" class="pagination {{ 'next' if direction > 0 else 'prev' }}">{{ text }}</a>