Skip to content

Commit 01f651f

Browse files
committed
More work on learning platform
1 parent 57637fd commit 01f651f

File tree

5 files changed

+51
-22
lines changed

5 files changed

+51
-22
lines changed

core/static/css/theme.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ html, body {
99
padding: 0;
1010
width: 100%;
1111
height: 100%;
12+
line-height: 155%;
1213
}
1314

1415
.block {

learn/management/commands/updatelearn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def parse(dir, name, parent):
3131
module.title = data['title']
3232

3333
file = open(os.path.join(dir, 'contents.md'))
34-
module.text = markdown2.markdown(file.read())
34+
module.text = markdown2.markdown(file.read(), extras=['code-friendly', 'tables'])
3535
file.close()
3636

3737
module.parent = parent

learn/static/css/learn.css

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,28 @@ nav.module-nav {
88
nav.module-nav > ol {
99
margin-top: 1em;
1010
margin-bottom: 1em;
11-
padding: 0;
11+
padding-left: 0!important;
12+
}
13+
14+
nav.module-nav ol {
15+
list-style-type: none;
16+
padding-left: 1em;
1217
}
1318

1419
nav.module-nav #active {
15-
color: #95a5a6;
20+
color: #2c3e50;
1621
}
1722

1823
div.module {
1924
padding-left: 3em;
2025
}
2126

22-
ol {
23-
counter-reset: section;
24-
list-style-type: none;
25-
padding-left: 1em;
27+
/* This part will hopefully be unnecessary with Bootstrap 4 */
28+
figure {
29+
padding-top: 2em;
30+
padding-bottom: 2em;
2631
}
2732

28-
li::before {
29-
counter-increment: section;
30-
content: counters(section,".") " ";
33+
figure > figcaption.figure-caption {
34+
font-style: italic;
3135
}

learn/templates/module.html

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,34 @@ <h1></h1>
2222

2323
<div class="row">
2424
<nav class="col-xs-12 col-sm-3 module-nav">
25+
<h3>Contents</h3>
26+
2527
{% module_tree root %}
2628
</nav>
2729
<div class="col-xs-12 col-sm-9 module">
2830
<header class="page-title">
29-
<div class="container">
30-
<h1>{{ module.title }}</h1>
31-
</div>
31+
<h1>{{ module.title }}</h1>
3232
</header>
3333

34-
{{ contents|safe|linebreaks }}
34+
<hr/>
35+
36+
{{ contents|safe }}
3537

36-
<div style="float: right;">
37-
{% if module.first_child %}
38-
Next: <a href="{% url 'learn:module' module.first_child.name %}">{{ module.first_child.title }} &raquo;</a>
39-
{% elif module.next %}
40-
Next: <a href="{% url 'learn:module' module.next.name %}">{{ module.next.title }} &raquo;</a>
41-
{% endif %}
42-
</div>
38+
{% if module.children.count > 0 %}
39+
<h3>Section Contents</h3>
4340

41+
<ol>
42+
{% for child in module.children.all %}
43+
<li><a href="{% url 'learn:module' child.name %}">{{ child.title }}</a></li>
44+
{% endfor %}
45+
</ol>
46+
{% endif %}
47+
48+
{% if next %}
49+
<div style="float: right;">
50+
Next: <a href="{% url 'learn:module' next.name %}">{{ next.title }} &raquo;</a>
51+
</div>
52+
{% endif %}
4453
</div>
4554
</div>
4655
{% endblock %}

learn/views.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,23 @@ def module(request, module_name):
1010

1111
template = Template(module.text)
1212

13+
next = None
14+
15+
if module.first_child:
16+
next = module.first_child
17+
18+
current = module
19+
20+
while current:
21+
if current.next:
22+
next = current.next
23+
break
24+
25+
current = current.parent
26+
1327
return render(request, "module.html", {
1428
'module': module,
1529
'root': root,
16-
'contents': template.render(Context())
30+
'contents': template.render(Context()),
31+
'next': next
1732
})

0 commit comments

Comments
 (0)