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) -%}
5 <div class="card-main">
7 <img src="{{ thumbnail or fallback_img}}">
8 {% if badge is not none %}
9 <span class="badge">{{ badge | e }}</span>
12 <div class="title">{{ title | e }}</div>
13 <a class="link-main" href="{{ link }}" title="{{ title | e }}"></a>
21 {% macro card(video_id, title='', advanced_text='', pinned="undefined", advanced_title='', post_url=None, badge=None) -%}
22 {% set caller_ = caller %}
23 {% call card_generic("/watch?v="~video_id, "https://i.ytimg.com/vi/"~video_id~"/mqdefault.jpg", title, badge) %}
25 <details class="advanced"><summary title="{{advanced_title}}">{{ advanced_text }}</summary>
28 {{ emoji_link("comments", post_url, False) }}
30 {% if pinned != "undefined" %}
31 {{ emoji_button("pin", video_id, pinned, False) }}
32 {{ emoji_button("hide", video_id, False, False) }}
34 {{ emoji_link("audio", video_id, False) }}
35 {{ emoji_link("raw", video_id, False) }}
36 {{ emoji_link("json", video_id, False) }}
41 {% macro typed_card(params) -%}
42 {% set c = params.content %}
43 {% if params.type == 'VIDEO' %}
44 {% set badge = 'LIVE' if c.live else c.length %}
45 {% call card(c.video_id, c.title, c.published, badge=badge) %}
46 {{ infobar_subscriptions(c.video_id, c.channel_id, c.author) }}
48 {% elif params.type == 'CHANNEL' %}
49 {% call card_generic("/channel/"~c.channel_id~"/", c.icons[c.icons.largest] if 'icons' in c else '', c.title) %}
50 <span class=channel>Channel</span>
51 <span class=advanced>{{ c.subscribers }}</span>
53 {% elif params.type == 'PLAYLIST' %}
54 {% call card_generic("/playlist?list="~c.playlist_id, "https://i.ytimg.com/vi/"~c.video_id~"/mqdefault.jpg", c.title) %}
55 <span class=channel>{{ infobar_subscriptions(None, c.channel_id, c.author) }}</span>
56 <span class=advanced>{{ c.n_videos }} videos</span>
58 {% elif params.type == 'WEBSITE' %}
59 {% call card_generic(c.url, c.icons[c.icons.largest] if 'icons' in c else '', c.title) %}
60 <span class=channel>{{ c.domain }}</span>
65 {% macro dummycard() -%}
66 {% for _ in range(4) %}
67 <div class="dummy card"></div>
71 {# TODO: remove video_id parameter (unused) #}
72 {% macro infobar_subscriptions(video_id, channel_id, author) -%}
73 {% if channel_id is defined and channel_id is not none %}
74 <a class="info-main" href="/channel/{{ channel_id }}/">{{ author | e }}</a>
76 <span class="info-main">{{ author | e }}</span>
80 {% macro emoji_button(action, subject, reverse=False, text=False) -%}
82 'pin': ['📌️', '📌️⃠'],
83 'hide': ['💨️', ''],
84 'subscribe': ['📝️', '🗑️'],
87 'pin': ['pin to subscription feed', 'unpin'],
88 'hide': ['hide video', ''],
89 'subscribe': ['subscribe', 'unsubscribe'],
92 'pin': 'youtube.feed_post',
93 'hide': 'youtube.feed_post',
94 'subscribe': 'youtube.manage_subscriptions',
96 <form method=post action="{{ url_for(actions[action]) }}" class="emoji-form">
97 <input type="hidden" name="{{ 'un' if reverse }}{{ action }}" value="{{ subject }}">
98 <label title="{{ texts[action][reverse] }}">
99 <input type="submit" hidden>
100 <span class="emoji">{{ icons[action][reverse] }}</span>{#
101 #}<span class="notemoji">{{ texts[action][reverse] if text }}</span>
105 {% macro emoji_link(action, subject, text=False) -%}
107 'raw': '🎞️',
109 'audio': '🎧',
110 'comments': '💬',
113 'raw': 'show raw video',
114 'json': 'view json metadata',
115 'audio': 'listen to audio only',
116 'comments': 'view comments',
119 'raw': '/watch?v='~subject~'&show=raw',
120 'json': '/watch?v='~subject~'&show=json',
121 'audio': '/watch?v='~subject~'&show=audio',
122 'comments': 'https://old.reddit.com'~subject,
124 <a href="{{ actions[action] }}" title="{{ texts[action] }}">{#
125 #}<span class="emoji">{{ icons[action] }}</span>{#
126 #}<span class="notemoji">{{ texts[action] if text }}</span>
130 {% macro pagination(text, fields, direction) -%}
131 <a href="?{{ querystring_page(fields) }}" class="pagination {{ 'next' if direction > 0 else 'prev' }}">{{ text }}</a>