-
Notifications
You must be signed in to change notification settings - Fork 0
/
cap.njk
99 lines (99 loc) · 5.12 KB
/
cap.njk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
{% macro escapeText(text, dangerouslyDisableAutoEscaping=false) %}
{% if dangerouslyDisableAutoEscaping -%}
{{ text | safe }}
{%- else -%}
{{ text }}
{%- endif %}
{% endmacro %}
{% macro escapeTitle(title, url, dangerouslyDisableAutoEscaping=false, showTitleAsUrl=false) %}
{% if dangerouslyDisableAutoEscaping %}
{% if showTitleAsUrl %}
<a href="{{ url }}"
style="text-decoration:none;
color:#ffffff"
target="_blank">{{ title | safe }}</a>
{% else %}
{{ title | safe }}
{% endif %}
{% else %}
{% if showTitleAsUrl %}
<a href="{{ url }}"
style="text-decoration:none;
color:#ffffff"
target="_blank">{{ title }}</a>
{% else %}
{{ title }}
{% endif %}
{% endif %}
{% endmacro %}
{% if loaded and items.length > 0 %}
{% if config.showAsList %}
<ul class="cap-list">
{% for item in items %}
<li>
{% if (item.config.showSourceTitle and item.sourceTitle) or item.config.showPublishDate %}
<span class="cap-source light small dimmed">
{% if item.sourceTitle and item.config.showSourceTitle %}
{{ escapeText(item.sourceTitle, item.config.dangerouslyDisableAutoEscaping) }}{% if item.config.showPublishDate %}, {% else %}:{% endif %}
{% endif %}
{% if item.config.showPublishDate %}{{ item.publishDate }}:{% endif %}
</span>
{% endif %}
<span class="cap-severity-{{ item.severity }} cap-title bright medium light{{ ' no-wrap' if not item.config.wrapTitle }}">
{% if item.config.showIcon %}
<span class="wi weathericon wi-{{ item.iconClass }} cap-severity-{{ item.severity }}"></span>
{% endif %}
{% if item.config.showAlertTitle %}
{{ escapeTitle(item.title, item.url, item.config.dangerouslyDisableAutoEscaping, false) }}
{% endif %}
</span>
{% if item.config.showOnset %}<span class="cap-onset">{{ item.onset }}</span>{% endif %}
{% if item.config.showAreaDescription %}<span class="cap-areas light"> {{item.areas}}</span>{% endif %}
{% if item.config.showDescription %}
<div class="cap-desc small light{{ ' no-wrap' if not item.config.wrapDescription }}">
{% if item.config.truncDescription %}
{{ escapeText(item.description | truncate(item.config.lengthDescription) , item.config.dangerouslyDisableAutoEscaping) }}
{% else %}
{{ escapeText(item.description, item.config.dangerouslyDisableAutoEscaping) }}
{% endif %}
</div>
{% endif %}
</li>
{% endfor %}
</ul>
{% else %}
<div class="cap-single">
{% if (item.config.showSourceTitle and item.sourceTitle) or item.config.showPublishDate %}
<div class="cap-source light small dimmed">
{% if item.sourceTitle and item.config.showSourceTitle %}
{{ escapeText(item.sourceTitle, item.config.dangerouslyDisableAutoEscaping) }}{% if item.config.showPublishDate %}, {% else %}:{% endif %}
{% endif %}
{% if item.config.showPublishDate %}{{ item.publishDate }}:{% endif %}
</div>
{% endif %}
<span class="cap-severity-{{ item.severity }} cap-title bright medium light{{ ' no-wrap' if not item.config.wrapTitle }}">
{% if item.config.showIcon %}
<span class="wi weathericon wi-{{ item.iconClass }} cap-severity-{{ item.severity }}"></span>
{% endif %}
{% if item.config.showAlertTitle %}
{{ escapeTitle(item.title, item.url, item.config.dangerouslyDisableAutoEscaping, false) }}
{% endif %}
</span>
{% if item.config.showOnset %}<span class="cap-onset">{{ item.onset }}</span>{% endif %}
{% if item.config.showAreaDescription %}<span class="cap-areas light"> {{item.areas}}</span>{% endif %}
{% if item.config.showDescription %}
<div class="cap-desc small light{{ ' no-wrap' if not item.config.wrapDescription }}">
{% if item.config.truncDescription %}
{{ escapeText(item.description | truncate(item.config.lengthDescription) , item.config.dangerouslyDisableAutoEscaping) }}
{% else %}
{{ escapeText(item.description, item.config.dangerouslyDisableAutoEscaping) }}
{% endif %}
</div>
{% endif %}
</div>
{% endif %}
{% else %}
{% if (not config.hideLoading) %}
<div class="small dimmed">{{ "LOADING" | translate | safe }}</div>
{% endif %}
{% endif %}