diff --git a/nbcourse/nbcourse.py b/nbcourse/nbcourse.py index 275e5c06bd50b553c331031442423021d4b7cbe2..e45982e87a364f1fd4a4d6a11984006aa7ea129e 100755 --- a/nbcourse/nbcourse.py +++ b/nbcourse/nbcourse.py @@ -55,14 +55,11 @@ class NbCourse: 'authors': [], 'chapter_preview_only': [], 'license': None, - 'links': [{ - 'title': 'Manual', - 'target': 'manual.html', - 'icon': { - 'path': 'img/Infobox_info_icon.svg', - 'width': '35px', - } - }] + 'links': {'manual': { + 'title': 'Manual', + 'target': 'manual.html', + } + } } def __init__(self, user_conf=None): @@ -83,8 +80,14 @@ class NbCourse: self.conf['reveal_path'] = nbcourse_libdir / Path('reveal.js') self.notebooks = tuple(self.conf['nb']['path'].glob('*-*.ipynb')) if user_conf and not self.notebooks: - log.error("No notebooks found!\n" + \ - "Check 'nb:dir:' field in nbcourse.yml file.") + log.error(""" +No notebooks found! +1. Check 'nb:dir:' field in nbcourse.yml file. +2. Ensure that your notebooks are named using the pattern: + - "01-my_first_chapter_name.ipynb", + - "02-my_second_chapter_name.ipynb", + - etc. +""") sys.exit() if self.conf['book']['file']: self.titlepage_path = self.conf['pages']['path'] / \ @@ -143,8 +146,10 @@ class NbCourse: with open(config_file, 'r') as f: user_conf_dict = yaml.safe_load(f) except FileNotFoundError as e: - log.error(f'"{e.filename}" file not found.\n' + \ - "Consider initializing an nbcourse project with 'nbcourse --init'.") + log.error(f'''"{e.filename}" file not found. +Consider initializing an nbcourse project with: +nbcourse --init\ +''') sys.exit() sanitize(user_conf_dict) update_dict(conf, user_conf_dict) @@ -222,7 +227,7 @@ class NbCourse: dst_files = [dst_path / file for file in files] else: # dealing with single file, preserve directory tree src_files = [src_path] - rpath = src_path.relative_to(self.conf['nb']['dir']) + rpath = src_path.relative_to(self.conf['nb']['path']) dst_path = self.conf['output_path'] / rpath dst_files = [dst_path] return src_files, dst_path, dst_files diff --git a/nbcourse/pages.py b/nbcourse/pages.py index d2017c1088fdfc7c1a841f997df9a05c4ebd4658..76b462b61ee6c34f86908217cd6b7386a30a8f81 100644 --- a/nbcourse/pages.py +++ b/nbcourse/pages.py @@ -45,7 +45,7 @@ class Page: class HomePage(Page): """A class to handle a homepage to be rendered""" - html_template = "index.html" + html_template = "index.html.j2" html = "index.html" name = 'home' parent = None @@ -114,7 +114,7 @@ class HomePage(Page): class MarkdownPage(Page): - html_template = "page.html" + html_template = "page.html.j2" def __init__(self, nbcourse, src: Path): super().__init__(nbcourse) diff --git a/pyproject.toml b/pyproject.toml index 4ba07ce7ff17a51cfeb4bf088495783ac2ecbf55..39dbc9b76a2c51d6b48dd08dfc895ee821cab198 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nbcourse" -version = "0.1.5" +version = "0.2.0" description = "Create a minisite to publish a course based on Jupyter notebooks" authors = ["Matthieu Boileau "] license = "MIT" diff --git a/skeleton/nbcourse.yml b/skeleton/nbcourse.yml index 77920ffc352e4f7f3d53e4c59188e9a2b659f41a..0e29265a322169aa1b2059e09669d25bf454afc7 100644 --- a/skeleton/nbcourse.yml +++ b/skeleton/nbcourse.yml @@ -18,31 +18,21 @@ chapter_preview_only: - 4 - 5 links: - - title: Notice + manual: + title: Manual target: manual.html - icon: - path: img/Infobox_info_icon.svg - width: 35px - - title: Exécuter + binder: + title: Exécuter target: https://mybinder.org/v2/gh/fitzinger/cours-python/master - icon: - path: https://mybinder.org/badge.svg - width: auto - - title: Version pdf + book: + title: Version pdf target: cours-python.pdf - icon: - path: img/Adobe_PDF_icon.svg - width: 30px - - title: Sources + gitlab: + title: Sources target: https://gitlab.math.unistra.fr/fitzinger/cours-python - icon: - path: img/GitLab_Logo.svg - width: 30px - - title: Archive complète + archive: + title: Archive complète target: cours-python.zip - icon: - path: img/download.svg - width: 35px license: text: Contenu mis à disposition sous licence target: https://creativecommons.org/licenses/by-sa/4.0/ diff --git a/skeleton/pages/anaconda.md b/skeleton/pages/anaconda.md index def9e96884023dfc8660d30705ff88fa5bf21db7..361796129e2c82f6aec5fa3af8c4833a632b0db1 100644 --- a/skeleton/pages/anaconda.md +++ b/skeleton/pages/anaconda.md @@ -5,7 +5,7 @@ parent: manual.md ## Download -Download [Anaconda](https://www.anaconda.com/download) for Python 3.X for your operating system and install it. +Download Anaconda logo for Python 3.X for your operating system and install it. On Linux, open *Terminal* application and type: diff --git a/skeleton/pages/manual.md b/skeleton/pages/manual.md index bd1265dbfe910f2945879f81cd682de7a522dbba..7b15500f7686083bf5edcef921977bd818b9052c 100644 --- a/skeleton/pages/manual.md +++ b/skeleton/pages/manual.md @@ -7,20 +7,20 @@ parent: home This course content is provided as Jupyter notebooks that require to be powered by a Jupyter server with Python3 kernel. -## Install Jupyter +### Install Jupyter and other dependencies -### First install Anaconda +#### First install Anaconda -[Anaconda](https://www.anaconda.com/distribution) is complete and easy to install. +Anaconda is easy to install but the installer is quite heavy to download because it contains a lot of components. In particular, it is shipped with: - [Jupyter](http://jupyter.org/) - The [Spyder](https://github.com/spyder-ide/spyder) IDE - Scipy libraries: Numpy, Pandas, etc. -For a detailed installation of Anaconda and its extensions on Windows, Mac or Linux, follow the Anaconda logo instructions. +For a detailed installation of Anaconda and its extensions on Windows, Mac or Linux, follow the instructions Anaconda logo. -### Finalize installation with conda +#### Finalize installation with conda From the project root directory, type: @@ -28,15 +28,23 @@ From the project root directory, type: conda install --file requirements.txt ``` -## Run a Jupyter server +### Run a Jupyter notebook + +#### Start a Jupyter server - Either from Anaconda graphical interface -- or the command line interface from the project root directory: +- or from the command line interface from the project root directory: ```bash jupyter-notebook ``` +#### Execute a notebook + +- Download and extract the archive of the first chapter +- In the Jupyter, open the `.ipynb` file +- Execute the notebook using the menu "Cell > Run All" + ## Optional: build and publish If you want be able to build and publish this course material, follow these [instructions](pages/build.md). diff --git a/skeleton/theme/default/img/python-logo_full.png b/skeleton/theme/default/img/python-logo_full.png new file mode 100644 index 0000000000000000000000000000000000000000..71f942075dda7fb0b25cb28bfe6555e4ccbbe6dc Binary files /dev/null and b/skeleton/theme/default/img/python-logo_full.png differ diff --git a/skeleton/theme/default/templates/base.html b/skeleton/theme/default/templates/base.html.j2 similarity index 100% rename from skeleton/theme/default/templates/base.html rename to skeleton/theme/default/templates/base.html.j2 diff --git a/skeleton/theme/default/templates/index.html b/skeleton/theme/default/templates/index.html.j2 similarity index 75% rename from skeleton/theme/default/templates/index.html rename to skeleton/theme/default/templates/index.html.j2 index 52e62f6848d73c145264bcc732d5cee02951bfc5..81da77e369309616cd87b3214d31b46195ab5e0c 100644 --- a/skeleton/theme/default/templates/index.html +++ b/skeleton/theme/default/templates/index.html.j2 @@ -1,4 +1,23 @@ -{% extends "base.html" %} +{% extends "base.html.j2" %} + +{% set link_icons = + {'manual': + {'path': 'img/Infobox_info_icon.svg', + 'width': '35px'}, + 'binder': + {'path': 'https://mybinder.org/badge.svg', + 'width': 'auto'}, + 'book': + {'path': 'img/Adobe_PDF_icon.svg', + 'width': '30px'}, + 'gitlab': + {'path': 'img/GitLab_Logo.svg', + 'width': '30px'}, + 'archive': + {'path': 'img/download.svg', + 'width': '35px'} + } +%} {% block content %} {% if picture %} @@ -35,13 +54,13 @@
- {% for link in links %} + {% for link in links.values() %} {% endfor %} - {% for link in links %} - + {% for link_type, link in links.items() %} + {% endfor %}
{{ link.title }}
@@ -50,7 +69,9 @@ {% for author in authors %} {{ author.name }} + {% if author.email %} + {% endif %} {% endfor %} diff --git a/skeleton/theme/default/templates/page.html b/skeleton/theme/default/templates/page.html.j2 similarity index 94% rename from skeleton/theme/default/templates/page.html rename to skeleton/theme/default/templates/page.html.j2 index 5cf33231455790536b291e2db4ec6bd11460b91f..d1cedc0e8b7f6658a7319f6335d54e1a6bfba735 100644 --- a/skeleton/theme/default/templates/page.html +++ b/skeleton/theme/default/templates/page.html.j2 @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "base.html.j2" %} {% block menu %}