Skip to content

Commit 6917162

Browse files
committed
widgets/keyboard.html use jinja2
1 parent c71e008 commit 6917162

File tree

2 files changed

+52
-34
lines changed

2 files changed

+52
-34
lines changed
Lines changed: 48 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,49 @@
11

2-
div.instapaper_ignore.readability-extra
3-
h2.facebox-header
4-
Keyboard shortcuts
5-
small
6-
button.btn-link.js-see-all-keyboard-shortcuts type="button"
7-
(Show all)
8-
div.columns
9-
-py
10-
columns = zip(*[iter(keyboards)] * 2)
11-
-for index, column in enumerate(columns)
12-
div.column.one-half
13-
table.keyboard-mappings
14-
-for block_info, keyboard in column
15-
-py
16-
attrs = {'class': 'js-hidden-pane'} if index else {}
17-
tbody**attrs
18-
tr
19-
th
20-
th
21-
${block_info}
22-
-for dbds, key_info in keyboard
23-
-py
24-
keys = dbds.split()
25-
tr
26-
td.keys
27-
-for key in keys
28-
- if key != '/':
29-
kbd
30-
${key}
31-
-else
32-
/
33-
td
34-
${key_info}
2+
<div class="instapaper_ignore readability-extra">
3+
<h2 class="facebox-header">
4+
Keyboard shortcuts
5+
<small>
6+
<button class="btn-link js-see-all-keyboard-shortcuts" type="button">
7+
(Show all)
8+
</button>
9+
</small>
10+
</h2>
11+
<div class="columns">
12+
{% for column in columns %}
13+
<div class="column one-half">
14+
<table class="keyboard-mappings">
15+
{% for block_info, keyboard in column %}
16+
{% if loop.index0 %}
17+
{% set class="js-hidden-pane" %}
18+
{% else %}
19+
{% set class="" %}
20+
{% endif %}
21+
22+
<tbody class="{{ class }}">
23+
<tr>
24+
<th></th>
25+
<th>{{ block_info }}</th>
26+
{% for dbds, key_info in keyboard %}
27+
<!-- keys = dbds.split() -->
28+
<tr>
29+
<td class="keys">
30+
{% for key in dbds.split() %}
31+
{% if key != '/' %}
32+
<kbd>{{ key }}</kbd>
33+
{% else %}
34+
/
35+
{% endif %}
36+
{% endfor %}
37+
</td>
38+
<td>
39+
{{ key_info }}
40+
</td>
41+
</tr>
42+
{% endfor %}
43+
</tr>
44+
</tbody>
45+
{% endfor %}
46+
</table>
47+
</div>
48+
{% endfor %}
49+
</div>

firefly/views/keyboard.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ def get(self):
1818
keyboards = KEYBOARD_URL_MAPS['default']
1919
if url_pattern in KEYBOARD_URL_MAPS:
2020
keyboards += KEYBOARD_URL_MAPS[url_pattern]
21-
return render_template('widgets/keyboard.html', keyboards=keyboards)
21+
columns = zip(*[iter(keyboards)] * 2)
22+
return render_template(
23+
'widgets/keyboard.html', columns=columns
24+
)
2225

2326

2427
bp.add_url_rule('/', view_func=KeyboardView.as_view('keyboard'))

0 commit comments

Comments
 (0)