]> git.gir.st - subscriptionfeed.git/blob - app/templates/macros.imp.j2
awful hack to align last row of cards
[subscriptionfeed.git] / app / templates / macros.imp.j2
1 {% macro headerbar(search_query="") -%}
2 <style>
3 [name=q]::placeholder{
4 color:#eee;
5 opacity: .7;
6 }
7 </style>
8 <span style=float:left>
9 <a href="/">
10 <b style=font-size:large><span style=font-family:serif>&Delta;</span>{{ request.host }}</b>
11 </a>
12 </span>
13 {% if current_user.is_anonymous %}
14 <a href="/login?next={{ request.url | urlencode }}" style=float:right>log in or sign up</a>
15 {% else %}
16 <span style=float:right>{{ current_user.name }} (<a href="/login">log out</a>)</span>
17 {% endif %}
18 <form method=get action=/search>
19 <input name=q style="margin:auto;display:block;width:30em;box-sizing:border-box;border:0;background:#666;color:#eee;padding:.2em"
20 placeholder="Search (through invidio.us)" value="{{ search_query | e }}">
21 <input type=hidden name=provider value="invidio.us:443">
22 <!--input type=submit value="?"-->
23 </form>
24 <hr>
25 {%- endmacro %}
26
27 {% macro card_generic(link, thumbnail, title='') -%}
28 <div class="card">
29 <div class="card-main">
30 <img class="thumb" src="{{ thumbnail }}">
31 <div class="title">{{ title | e }}</div>
32 <a class="link-main" href="{{ link }}" title="{{ title | e }}"></a>
33 </div>
34 <div class="infobar">
35 {{ caller() }}
36 </div>
37 </div>
38 {%- endmacro %}
39
40 {% macro card(video_id, title='', advanced_text='', pinned="undefined", advanced_title='', post_url=None) -%}
41 {% set caller_ = caller %}
42 {% call card_generic("/watch?v="~video_id, "https://i.ytimg.com/vi/"~video_id~"/mqdefault.jpg", title) %}
43 {{ caller_() }}
44 <details class="advanced"><summary title="{{advanced_title}}">{{ advanced_text }}</summary>
45 <div class="details">
46 {% if post_url %}
47 {{ emoji_link("comments", post_url, False) }}
48 {%endif%}
49 {% if pinned != "undefined" %}
50 {{ emoji_button("pin", video_id, pinned, False) }}
51 {{ emoji_button("hide", video_id, False, False) }}
52 {%endif%}
53 {{ emoji_link("raw", video_id, False) }}
54 {{ emoji_link("json", video_id, False) }}
55 </div></details>
56 {% endcall %}
57 {%- endmacro %}
58
59 {% macro dummycard() -%}
60 {% for _ in range(4) %}
61 <div class="dummy card"></div>
62 {% endfor %}
63 {%- endmacro %}
64
65 {% macro infobar_subscriptions(video_id, channel_id, author) -%}
66 <a class="info-main" href="/channel/{{ channel_id }}">{{ author | e }}</a>
67 {%- endmacro %}
68
69 {% macro emoji_button(action, subject, reverse=False, text=False) -%}
70 {% set icons = {
71 'pin': ['&#x1f4cc;&#xFE0F;', '&#x1f4cc;&#xFE0F;&#8416;'],
72 'hide': ['&#x1f4a8;&#xFE0F;', ''],
73 'subscribe': ['&#128221;&#xFE0F;', '&#128465;&#xFE0F;'],
74 } %}
75 {% set texts = {
76 'pin': ['pin to <!--top of subscription--> feed', 'unpin'],
77 'hide': ['hide video', ''],
78 'subscribe': ['subscribe', 'unsubscribe'],
79 } %}
80 {% set actions = {
81 'pin': 'youtube.feed_post',
82 'hide': 'youtube.feed_post',
83 'subscribe': 'youtube.manage_subscriptions',
84 } %}
85 <form method=post action="{{ url_for(actions[action]) }}" class="emoji-form">
86 <input type="hidden" name="{{ 'un' if reverse }}{{ action }}" value="{{ subject }}">
87 <label>
88 <input class="emoji" type=submit value="{{ icons[action][reverse] }}" title="{{ texts[action][reverse] }}">
89 {{ texts[action][reverse] if text }}
90 </label>
91 </form>
92 {%- endmacro %}
93 {% macro emoji_link(action, subject, text=False) -%}
94 {% set icons = {
95 'raw': '&#x1F39E;&#xFE0F;',
96 'json': '&#x1f4a1;',
97 'comments': '&#x1f4ac;',
98 } %}
99 {% set texts = {
100 'raw': 'show raw video',
101 'json': 'view json metadata',
102 'comments': 'view comments',
103 } %}
104 {% set actions = {
105 'raw': '/watch?v='~subject~'&show=raw',
106 'json': '/watch?v='~subject~'&show=json',
107 'comments': 'https://old.reddit.com'~subject,
108 } %}
109 <a href="{{ actions[action] }}" title="{{ texts[action] }}"><span class="emoji">{{ icons[action] }}</span>{{ texts[action] if text }}</a>
110 {%- endmacro %}
Imprint / Impressum