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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
<!doctype html>
<html lang="de">
<head>
<title>Lehrerspruch-Wahlplattform</title>
<link rel="stylesheet" type="text/css" href="/static/materialize.min.css">
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0" />
</head>
<body>
<script type="text/javascript" src="/static/jquery.min.js"></script>
<script type="text/javascript" src="/static/smoothstate.min.js"></script>
<script type="text/javascript" src="/static/materialize.min.js"></script>
<header>
<div class="navbar-fixed">
<nav class="nav-wrapper">
<a href="#" class="left brand-logo">Lehrersprüche</a>
<ul class="right">
<li>
{% if user.loggedin %}
<a href="/logout">Logout ({{ user.name }})</a>
{% else %}
<a data-target="modal-login" class="modal-trigger" href="#modal-login">Login</button>
{% endif %}
</li>
<li>
<a class="dropdown-button" href="#!" data-activates="sort-dropdown">
Sortierung<i class="material-icons right">arrow_drop_down</i>
</a>
</li>
<li>
<a id="export" target="_blank" href="/export?filter={{ request.args.get("filter") or "" }}&sort={{ request.args.get("sort") or "" }}">
<i class="material-icons">file_download</i>
</a>
</li>
</ul>
<form id="searchform" style="margin-left: 17em; margin-right: 24em;"><!-- TODO get rid of these magic margins -->
<div class="input-field">
<label for="filter"><i class="material-icons">search</i></label>
<input type="search" name="filter" required>
<i class="material-icons">close</i>
</div>
</form>
<a onclick="$('#searchform').removeClass('hide');"><i class="material-icons">search</i></a>
</nav>
</div>
<ul id="sort-dropdown" class="dropdown-content">
{% for meth in [["rank", "Angesagt"], ["score", "Punkte"], ["age", "Alter"], ["unread", "Ungelesen"]] %}
<li><a href="/?filter={{ request.args.get("filter") or "" }}&sort={{ meth[0] }}">{{ meth[1] }}</a></li>
{% endfor %}
</ul>
<form id="modal-login" class="modal row" action="/login" method="post">
<div class="modal-content">
<h4>Anmelden/Registrieren</h4>
<p>Als registrierter Benutzer werden deine Stimmen höher gewichtet. Veröffentlichte Sprüche kannst du später bearbeiten und löschen.</p>
<div class="col s6 input-field">
<label for="user">Benutzer</label>
<input type="text" name="user">
</div>
<div class="col s6 input-field">
<label for="user">Passwort</label>
<input type="password" name="password">
</div>
</div>
<div class="modal-footer">
<button class="modal-action modal-close btn-flat" type="submit">Anmelden</button>
</div>
</form>
</header>
<main class="section container" id="main">
<noscript><p class="center section">Bitte aktiviere JavaScript, um alle Funktionen der Seite nutzen zu können.</p></noscript>
{% with msgs = get_flashed_messages() %}
{% if msgs %}
<div class="section">
{% for msg in msgs %}
<p>{{ msg }}</p>
{% endfor %}
</div>
{% endif %}
{% endwith %}
{% if tags %}
<div class="section">
{% for tag in tags %}
<div class="chip">
{{ tag }}
<a href="/?filter={{ tags|reject('sameas', tag)|join('+') }}"><i class="material-icons">close</i></a>
</div>
{% endfor %}
</div>
{% endif %}
<ul class="collection">
{% for joke in jokes[currentpage*perpage:(currentpage+1)*perpage] %}
<li class="collection-item row valign-wrapper">
<div class="col s4 m2 valign">
{% if not joke.deleted %}
<div>
<i class="material-icons">whatshot</i> <span class="right">{{ joke.score }} Punkte</span>
</div>
<form action="/upvote" method="post">
<input type="hidden" name="id" value="{{ joke.id }}">
<button class="btn{% if joke.upvoted %} disabled{% endif %}" type="submit" style="width: 100%;">
<i class="material-icons">thumb_up</i>
</button>
</form>
<form action="/downvote" method="post">
<input type="hidden" name="id" value="{{ joke.id }}">
<button class="btn{% if joke.downvoted %} disabled{% endif %}" type="submit" style="width: 100%;">
<i class="material-icons">thumb_down</i>
</button>
</form>
{% else %}
<form action="/undelete" method="post">
<input type="hidden" name="id" value="{{ joke.id }}">
<button class="btn-flat" type="submit" style="width: 100%;">
<i class="material-icons">delete undo</i>
</button>
</form>
{% endif %}
</div>
<div class="joke flow-text col s8 m10{% if joke.deleted %} grey-text{% endif %}" style="line-height: 1.5">
{% if joke.mine %}
<form action="/edit" method="post">
<input type="hidden" name="id" value="{{ joke.id }}">
<button type="button" class="btn-floating right blue noteditor" onclick="openEditor(this)"><i class="material-icons">edit</i></button>
<div class="input-field hide editor">
<label for="text">Spruch bearbeiten</label>
<textarea class="materialize-textarea" name="text">{{ joke.text }}</textarea>
<button type="submit" class="btn-floating right blue"><i class="material-icons">done</i></button>
</div>
</form>
{% endif %}
<div class="textfield noteditor">
{{ joke.html|safe }}
</div>
{% if joke.mine and not joke.deleted %}
<form action="/delete" method="post">
<input type="hidden" name="id" value="{{ joke.id }}">
<button class="btn-floating right red noteditor" type="submit"><i class="material-icons">delete</i></button>
</form>
{% endif %}
</div>
</li>
{% endfor %}
</ul>
{% if jokes|length > perpage %}
<div class="section center">
<ul class="pagination">
<li{% if currentpage==0 %} class="disabled"{% endif %}><a href="/page/{{ currentpage-1 }}{% if query %}?{{ query }}{% endif %}"><i class="material-icons">chevron_left</i></a></li>
{% for page in range((jokes|length/perpage)|round(0, 'ceil')|int) %}
<li{% if currentpage==loop.index0 %} class="active"{% endif %}><a href="/page/{{ loop.index0 }}{% if query %}?{{ query }}{% endif %}">{{ loop.index }}</a></li>
{% endfor %}
<li{% if currentpage==loop.length-1 %} class="disabled"{% endif %}><a href="/page/{{ currentpage+1 }}{% if query %}?{{ query }}{% endif %}"><i class="material-icons">chevron_right</i></a></li>
</ul>
</div>
{% endif %}
<div class="fixed-action-btn" style="bottom: 45px; right: 24px;">
<a data-target="modal-submit" class="modal-trigger btn-floating btn-large red" href="#modal-submit">
<i class="material-icons">add</i>
</a>
</div>
<form id="modal-submit" class="modal bottom-sheet" action="/submit" method="post">
<div class="modal-content">
<h4>Spruch hinzufügen</h4>
<p>Du kannst <em>/kursiv/</em>, <b>*fett*</b> schreiben, und <a>#Tags</a> verwenden.</p>
<div class="input-field">
<textarea class="materialize-textarea" name="text"></textarea>
</div>
</div>
<div class="modal-footer">
<input type="submit" class="modal-action modal-close btn-flat" value="Abschicken">
</div>
</form>
</main>
<script type="text/javascript">
function materialjs() {
$('.dropdown-button').dropdown();
$('.modal-trigger').leanModal();
}
$(document).ready(function() {
materialjs();
$('#main').smoothState({
prefetch: true,
locationHeader: 'X-SmoothState-Location',
blacklist: '#export',
onAfter: materialjs
});
});
function openEditor(me) {
var joke = $(me).closest('.joke');
$('.editor', joke).removeClass('hide');
$('.noteditor', joke).addClass('hide');
}
</script>
</body>
</html>
|