]> git.gir.st - subscriptionfeed.git/blob - app/templates/macros.imp.j2
move audio-only next to raw-video button
[subscriptionfeed.git] / app / templates / macros.imp.j2
1 {% macro card_generic(link, thumbnail, title='') -%}
2 <div class="card">
3 <div class="card-main">
4 <img class="thumb" src="{{ thumbnail or "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>"}}">
5 <div class="title">{{ title | e }}</div>
6 <a class="link-main" href="{{ link }}" title="{{ title | e }}"></a>
7 </div>
8 <div class="infobar">
9 {{ caller() }}
10 </div>
11 </div>
12 {%- endmacro %}
13
14 {% macro card(video_id, title='', advanced_text='', pinned="undefined", advanced_title='', post_url=None) -%}
15 {% set caller_ = caller %}
16 {% call card_generic("/watch?v="~video_id, "https://i.ytimg.com/vi/"~video_id~"/mqdefault.jpg", title) %}
17 {{ caller_() }}
18 <details class="advanced"><summary title="{{advanced_title}}">{{ advanced_text }}</summary>
19 <div class="details">
20 {% if post_url %}
21 {{ emoji_link("comments", post_url, False) }}
22 {%endif%}
23 {% if pinned != "undefined" %}
24 {{ emoji_button("pin", video_id, pinned, False) }}
25 {{ emoji_button("hide", video_id, False, False) }}
26 {%endif%}
27 {{ emoji_link("audio", video_id, False) }}
28 {{ emoji_link("raw", video_id, False) }}
29 {{ emoji_link("json", video_id, False) }}
30 </div></details>
31 {% endcall %}
32 {%- endmacro %}
33
34 {% macro dummycard() -%}
35 {% for _ in range(4) %}
36 <div class="dummy card"></div>
37 {% endfor %}
38 {%- endmacro %}
39
40 {% macro infobar_subscriptions(video_id, channel_id, author) -%}
41 <a class="info-main" href="/channel/{{ channel_id }}">{{ author | e }}</a>
42 {%- endmacro %}
43
44 {% macro emoji_button(action, subject, reverse=False, text=False) -%}
45 {% set icons = {
46 'pin': ['&#x1f4cc;&#xFE0F;', '&#x1f4cc;&#xFE0F;&#8416;'],
47 'hide': ['&#x1f4a8;&#xFE0F;', ''],
48 'subscribe': ['&#128221;&#xFE0F;', '&#128465;&#xFE0F;'],
49 } %}
50 {% set texts = {
51 'pin': ['pin to <!--top of subscription--> feed', 'unpin'],
52 'hide': ['hide video', ''],
53 'subscribe': ['subscribe', 'unsubscribe'],
54 } %}
55 {% set actions = {
56 'pin': 'youtube.feed_post',
57 'hide': 'youtube.feed_post',
58 'subscribe': 'youtube.manage_subscriptions',
59 } %}
60 <form method=post action="{{ url_for(actions[action]) }}" class="emoji-form">
61 <input type="hidden" name="{{ 'un' if reverse }}{{ action }}" value="{{ subject }}">
62 <label title="{{ texts[action][reverse] }}">
63 <input type="submit" hidden>
64 <span class="emoji">{{ icons[action][reverse] }}</span>{#
65 #}<span class="notemoji">{{ texts[action][reverse] if text }}</span>
66 </label>
67 </form>
68 {%- endmacro %}
69 {% macro emoji_link(action, subject, text=False) -%}
70 {% set icons = {
71 'raw': '&#x1F39E;&#xFE0F;',
72 'json': '&#x1f4a1;',
73 'audio': '&#x1f3a7;',
74 'comments': '&#x1f4ac;',
75 } %}
76 {% set texts = {
77 'raw': 'show raw video',
78 'json': 'view json metadata',
79 'audio': 'listen to audio only',
80 'comments': 'view comments',
81 } %}
82 {% set actions = {
83 'raw': '/watch?v='~subject~'&show=raw',
84 'json': '/watch?v='~subject~'&show=json',
85 'audio': '/watch?v='~subject~'&show=audio',
86 'comments': 'https://old.reddit.com'~subject,
87 } %}
88 <a href="{{ actions[action] }}" title="{{ texts[action] }}">{#
89 #}<span class="emoji">{{ icons[action] }}</span>{#
90 #}<span class="notemoji">{{ texts[action] if text }}</span>
91 </a>
92 {%- endmacro %}
Imprint / Impressum