diff --git a/courses/mi-pyt/plan.yml b/courses/mi-pyt/plan.yml index 21a7dd7b97..d8214e8283 100644 --- a/courses/mi-pyt/plan.yml +++ b/courses/mi-pyt/plan.yml @@ -1,14 +1,14 @@ - name: Lekce materials: - - link: lessons/intro/requests-click - - link: lessons/intro/flask - - link: lessons/intro/moduly - - link: lessons/intro/testovani - - link: lessons/intro/dokumentace - - link: lessons/intro/pandas - - link: lessons/intro/numpy - - link: lessons/intro/cython - - link: lessons/intro/pyqt - - link: lessons/intro/async - - link: lessons/intro/magie - - link: lessons/intro/micropython + - link: intro/requests-click + - link: intro/flask + - link: intro/moduly + - link: intro/testovani + - link: intro/dokumentace + - link: intro/pandas + - link: intro/numpy + - link: intro/cython + - link: intro/pyqt + - link: intro/async + - link: intro/magie + - link: intro/micropython diff --git a/courses/pyladies/plan.yml b/courses/pyladies/plan.yml index 0b26863894..ab5e833e97 100644 --- a/courses/pyladies/plan.yml +++ b/courses/pyladies/plan.yml @@ -1,67 +1,67 @@ - name: Instalace materials: - - link: lessons/beginners/cmdline - - link: lessons/beginners/install - - link: lessons/beginners/install_editor - - link: lessons/beginners/install_git + - link: beginners/cmdline + - link: beginners/install + - link: beginners/install_editor + - link: beginners/install_git - name: První program materials: - - link: lessons/beginners/hello-world - - link: lessons/beginners/printing - - link: lessons/beginners/variables - - link: lessons/beginners/comparisons - - link: lessons/beginners/and-or + - link: beginners/hello-world + - link: beginners/printing + - link: beginners/variables + - link: beginners/comparisons + - link: beginners/and-or - name: Cykly materials: - - link: lessons/beginners/functions - - link: lessons/intro/turtle - - link: lessons/beginners/while + - link: beginners/functions + - link: intro/turtle + - link: beginners/while - name: Správa zdrojového kódu materials: - - link: lessons/beginners/git - - link: lessons/beginners/branching + - link: beginners/git + - link: beginners/branching - name: Funkce & Řetězce materials: - - link: lessons/beginners/own_functions - - link: lessons/beginners/strings + - link: beginners/own_functions + - link: beginners/strings - name: Testování materials: - - link: lessons/beginners/exceptions - - link: lessons/beginners/modules - - link: lessons/beginners/testing - - link: lessons/beginners/circular_imports + - link: beginners/exceptions + - link: beginners/modules + - link: beginners/testing + - link: beginners/circular_imports - name: Spolupráce a Open-Source materials: - - link: lessons/beginners/cooperation_and_OSS - - link: lessons/beginners/files + - link: beginners/cooperation_and_OSS + - link: beginners/files - name: Seznamy materials: - - link: lessons/beginners/lists - - link: lessons/beginners/tuples + - link: beginners/lists + - link: beginners/tuples - name: Grafika materials: - - link: lessons/intro/pyglet - - link: lessons/projects/pong + - link: intro/pyglet + - link: projects/pong - name: Slovníky materials: - - link: lessons/beginners/dicts - - link: lessons/intro/json - - link: lessons/beginners/github-api + - link: beginners/dicts + - link: intro/json + - link: beginners/github-api - name: Třídy materials: - - link: lessons/beginners/classes - - link: lessons/beginners/inheritance + - link: beginners/classes + - link: beginners/inheritance - name: Závěrečný projekt materials: - - link: lessons/projects/asteroids + - link: projects/asteroids diff --git a/lessons/beginners/and-or/index.html b/lessons/beginners/and-or/index.html index 024628b4ba..1129d98593 100644 --- a/lessons/beginners/and-or/index.html +++ b/lessons/beginners/and-or/index.html @@ -1,6 +1,6 @@ -{% extends 'templates/_base.html' %} +{% extends 'templates/_html_page.html' %} -{% block content %} +{% block lesson %}

Nebo anebo a

diff --git a/lessons/beginners/cmdline/index.html b/lessons/beginners/cmdline/index.html index f0a99250e9..512187ab21 100644 --- a/lessons/beginners/cmdline/index.html +++ b/lessons/beginners/cmdline/index.html @@ -1,6 +1,6 @@ -{% extends 'templates/_base.html' %} +{% extends 'templates/_html_page.html' %} -{% block content %} +{% block lesson %}
diff --git a/lessons/beginners/git/index.html b/lessons/beginners/git/index.html index d990827fbe..b36d5af17e 100644 --- a/lessons/beginners/git/index.html +++ b/lessons/beginners/git/index.html @@ -1,4 +1,4 @@ -{% extends 'templates/_base.html' %} +{% extends 'templates/_html_page.html' %} {% block style %} .green { color: #0A3; } diff --git a/lessons/beginners/install/index.html b/lessons/beginners/install/index.html index 0ecfa0ce70..d282cd53e3 100644 --- a/lessons/beginners/install/index.html +++ b/lessons/beginners/install/index.html @@ -1,6 +1,6 @@ -{% extends 'templates/_base.html' %} +{% extends 'templates/_html_page.html' %} -{% block content %} +{% block lesson %}

Instalace

diff --git a/lessons/beginners/install_editor/index.html b/lessons/beginners/install_editor/index.html index 5db36d3747..f7c98c55c5 100644 --- a/lessons/beginners/install_editor/index.html +++ b/lessons/beginners/install_editor/index.html @@ -1,6 +1,6 @@ -{% extends 'templates/_base.html' %} +{% extends 'templates/_html_page.html' %} -{% block content %} +{% block lesson %}

Nastavení editoru

diff --git a/lessons/beginners/install_git/index.html b/lessons/beginners/install_git/index.html index 0e44813d65..8809028d6d 100644 --- a/lessons/beginners/install_git/index.html +++ b/lessons/beginners/install_git/index.html @@ -1,6 +1,6 @@ -{% extends 'templates/_base.html' %} +{% extends 'templates/_html_page.html' %} -{% block content %} +{% block lesson %}
diff --git a/naucse/routes.py b/naucse/routes.py index 06f07b03c9..0381d96540 100644 --- a/naucse/routes.py +++ b/naucse/routes.py @@ -59,10 +59,10 @@ def title_loader(plan): for lesson in plan: for mat in lesson['materials']: - lesson_link = mat['link'] - if lesson_link.split('/')[0] == "lessons": + lesson_link = "/".join(mat['link'].split("/")[-2:]) + if lesson_link[-3:] != "pdf": lesson_type = lesson_link.split("/")[1] - info_file = read_yaml(lesson_link + "/info.yml") + info_file = read_yaml("lessons/" + lesson_link + "/info.yml") lesson_dict[mat['link']] = (lesson_type, info_file['title']) return lesson_dict @@ -84,18 +84,88 @@ def course_page(course): @app.route('/runs///') def run_page(year, run): - """Run's page.""" + """Run page.""" template = "runs/{}/{}/index.html".format(year, run) plan = read_yaml("runs/{}/{}/plan.yml".format(year, run)) title = (read_yaml("runs/runs.yml"))[int(year)][run]['title'] lesson_dict = title_loader(plan) + def lesson_url(lesson_type, lesson): + """Link to the specific lesson.""" + return url_for('run_lesson', year=year, run=run, lesson_type=lesson_type, lesson=lesson) + try: - return render_template(template, plan=plan, names=lesson_dict, title=title) + return render_template(template, plan=plan, names=lesson_dict, title=title, lesson_url=lesson_url) + except TemplateNotFound: + abort(404) + + +def prv_nxt_teller(year, run, lesson): + """Determine the previous and the next lesson.""" + plan = read_yaml("runs/{}/{}/plan.yml".format(year, run)) + + tmp_prv = None + nxt = None + next_one = False + + for l in plan: + for mat in l["materials"]: + if next_one: + nxt = "/".join(mat["link"].split("/")[-2:]) + break + + if mat["link"].split("/")[-1] == lesson: + prv = tmp_prv + next_one = True + else: + tmp_prv = "/".join(mat["link"].split("/")[-2:]) + + if prv != None and prv[-3:] == "pdf": + prv = None + if nxt != None and nxt[-3:] == "pdf": + nxt = None + + return (prv, nxt) + + +@app.route('/runs/////', defaults={'page': 'index'}) +@app.route('/runs//////') +def run_lesson(year, run, lesson_type, lesson, page): + """Run's lesson page.""" + info = read_yaml("lessons/{}/{}/info.yml".format(lesson_type, lesson)) + + template = 'lessons/{}/{}/{}.{}'.format(lesson_type, lesson, page, info['style']) + + + def lesson_static_url(path): + """Static in the specific lesson.""" + return url_for('lesson_static', lesson_type=lesson_type, lesson=lesson, path=path) + + + def lesson_url(lesson): + """Link to the specific lesson.""" + return url_for('run_lesson', year=year, run=run, lesson_type=lesson.split('/')[0], lesson=lesson.split('/')[1], page=page) + + + prv, nxt = prv_nxt_teller(year, run, lesson) + + file = open(template, 'r') + content = file.read() + title = info['course'] + ': ' + info['title'] + + try: + if info['style'] == "md": + return render_template('templates/_markdown_page.html', static=lesson_static_url, lesson=lesson_url, title=title, content=content) + elif info['style'] == "ipynb": + return render_template('templates/_ipython_page.html', static=lesson_static_url, lesson=lesson_url, title=title, content=content) + else: + return render_template(template, static=lesson_static_url, lesson=lesson_url, title=title, nxt=nxt, prv=prv) except TemplateNotFound: abort(404) + file.close() + @app.route('/lessons///', defaults={'page': 'index'}) @app.route('/lessons////') diff --git a/naucse/templates/_html_page.html b/naucse/templates/_html_page.html new file mode 100644 index 0000000000..536b90dcb1 --- /dev/null +++ b/naucse/templates/_html_page.html @@ -0,0 +1,20 @@ +{% extends "templates/_base.html" %} + +{% block content %} + +{% block lesson %} +{% endblock lesson %} + +{% if prv is defined and prv != None %} + + ← {{prv}} + +{% endif %} + +{% if nxt is defined and nxt != None %} + + {{nxt}} → + +{% endif %} + +{% endblock content %} diff --git a/naucse/templates/_lessons_list.html b/naucse/templates/_lessons_list.html index 1efc9dc271..3a1a0f95c2 100644 --- a/naucse/templates/_lessons_list.html +++ b/naucse/templates/_lessons_list.html @@ -1,4 +1,4 @@ -{% extends 'templates/_base.html' %} +{% extends "templates/_base.html" %} {% block content %} @@ -11,19 +11,19 @@ {% for lesson in plan %}

- {% if 'date' in lesson %} - Lekce {{ loop.index }} - {{ lesson['name'] }} ({{ lesson['date'] }}) + {% if "date" in lesson %} + Lekce {{ loop.index }} - {{ lesson["name"] }} ({{ lesson["date"] }}) {% else %} - Lekce {{ loop.index }} - {{ lesson['name'] }} + Lekce {{ loop.index }} - {{ lesson["name"] }} {% endif %}

- {% for mat in lesson['materials'] %} + {% for mat in lesson["materials"] %}
- {% if mat['link'].split('/')[0] == "lessons" %} - {{ names.get(mat['link'])[1] }} + {% if mat["link"][:4] == "http" %} + {{ mat["name"] }} {% else %} - {{ mat['name'] }} + {{ names.get(mat["link"])[1] }} {% endif %}
{% endfor %} diff --git a/runs/2017/pyladies-brno-jaro-po/plan.yml b/runs/2017/pyladies-brno-jaro-po/plan.yml index 739b7c0046..eafa3e20a0 100644 --- a/runs/2017/pyladies-brno-jaro-po/plan.yml +++ b/runs/2017/pyladies-brno-jaro-po/plan.yml @@ -1,10 +1,10 @@ - name: Instalace date: "27. 2. 2017" materials: - - link: lessons/beginners/cmdline - - link: lessons/beginners/install - - link: lessons/beginners/install_editor - - link: lessons/beginners/install_git + - link: runs/2017/pyladies-brno-jaro-po/beginners/cmdline + - link: runs/2017/pyladies-brno-jaro-po/beginners/install + - link: runs/2017/pyladies-brno-jaro-po/beginners/install_editor + - link: runs/2017/pyladies-brno-jaro-po/beginners/install_git - link: https://github.com/pyvec/cheatsheets/raw/master/keyboard/keyboard-cs.pdf name: Tahák na klávesnici (PDF) - link: https://github.com/PyLadiesCZ/pyladies.cz/raw/master/original/v1/s001-install/handout/handout.pdf diff --git a/runs/index.html b/runs/index.html index 92ec47e1f1..5913c884cd 100644 --- a/runs/index.html +++ b/runs/index.html @@ -13,7 +13,6 @@

{{ runs[year][run]['title'] }}

{{ runs[year][run]['description'] }}

{% endfor %} - {% endfor %}
diff --git a/static/css/nausce.css b/static/css/nausce.css index 4ff021feaa..ca367e8e76 100644 --- a/static/css/nausce.css +++ b/static/css/nausce.css @@ -204,3 +204,12 @@ details.detail-not-expanded { width: 100%; } } + +span.align-right { + float: right; +} + +span.align-center { + text-align: center; +} +