Commit 61a54a53 authored by Matthieu Boileau's avatar Matthieu Boileau

Merge branch 'develop' into 'master'

V2.0

See merge request !9
parents b4099415 07ee443c
Pipeline #7743 passed with stages
in 2 minutes and 22 seconds
...@@ -55,14 +55,11 @@ class NbCourse: ...@@ -55,14 +55,11 @@ class NbCourse:
'authors': [], 'authors': [],
'chapter_preview_only': [], 'chapter_preview_only': [],
'license': None, 'license': None,
'links': [{ 'links': {'manual': {
'title': 'Manual', 'title': 'Manual',
'target': 'manual.html', 'target': 'manual.html',
'icon': { }
'path': 'img/Infobox_info_icon.svg', }
'width': '35px',
}
}]
} }
def __init__(self, user_conf=None): def __init__(self, user_conf=None):
...@@ -83,8 +80,14 @@ class NbCourse: ...@@ -83,8 +80,14 @@ class NbCourse:
self.conf['reveal_path'] = nbcourse_libdir / Path('reveal.js') self.conf['reveal_path'] = nbcourse_libdir / Path('reveal.js')
self.notebooks = tuple(self.conf['nb']['path'].glob('*-*.ipynb')) self.notebooks = tuple(self.conf['nb']['path'].glob('*-*.ipynb'))
if user_conf and not self.notebooks: if user_conf and not self.notebooks:
log.error("No notebooks found!\n" + \ log.error("""
"Check 'nb:dir:' field in nbcourse.yml file.") 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() sys.exit()
if self.conf['book']['file']: if self.conf['book']['file']:
self.titlepage_path = self.conf['pages']['path'] / \ self.titlepage_path = self.conf['pages']['path'] / \
...@@ -143,8 +146,10 @@ class NbCourse: ...@@ -143,8 +146,10 @@ class NbCourse:
with open(config_file, 'r') as f: with open(config_file, 'r') as f:
user_conf_dict = yaml.safe_load(f) user_conf_dict = yaml.safe_load(f)
except FileNotFoundError as e: except FileNotFoundError as e:
log.error(f'"{e.filename}" file not found.\n' + \ log.error(f'''"{e.filename}" file not found.
"Consider initializing an nbcourse project with 'nbcourse --init'.") Consider initializing an nbcourse project with:
nbcourse --init\
''')
sys.exit() sys.exit()
sanitize(user_conf_dict) sanitize(user_conf_dict)
update_dict(conf, user_conf_dict) update_dict(conf, user_conf_dict)
...@@ -222,7 +227,7 @@ class NbCourse: ...@@ -222,7 +227,7 @@ class NbCourse:
dst_files = [dst_path / file for file in files] dst_files = [dst_path / file for file in files]
else: # dealing with single file, preserve directory tree else: # dealing with single file, preserve directory tree
src_files = [src_path] 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_path = self.conf['output_path'] / rpath
dst_files = [dst_path] dst_files = [dst_path]
return src_files, dst_path, dst_files return src_files, dst_path, dst_files
......
...@@ -45,7 +45,7 @@ class Page: ...@@ -45,7 +45,7 @@ class Page:
class HomePage(Page): class HomePage(Page):
"""A class to handle a homepage to be rendered""" """A class to handle a homepage to be rendered"""
html_template = "index.html" html_template = "index.html.j2"
html = "index.html" html = "index.html"
name = 'home' name = 'home'
parent = None parent = None
...@@ -114,7 +114,7 @@ class HomePage(Page): ...@@ -114,7 +114,7 @@ class HomePage(Page):
class MarkdownPage(Page): class MarkdownPage(Page):
html_template = "page.html" html_template = "page.html.j2"
def __init__(self, nbcourse, src: Path): def __init__(self, nbcourse, src: Path):
super().__init__(nbcourse) super().__init__(nbcourse)
......
[tool.poetry] [tool.poetry]
name = "nbcourse" name = "nbcourse"
version = "0.1.5" version = "0.2.0"
description = "Create a minisite to publish a course based on Jupyter notebooks" description = "Create a minisite to publish a course based on Jupyter notebooks"
authors = ["Matthieu Boileau <matthieu.boileau@math.unistra.fr>"] authors = ["Matthieu Boileau <matthieu.boileau@math.unistra.fr>"]
license = "MIT" license = "MIT"
......
...@@ -18,31 +18,21 @@ chapter_preview_only: ...@@ -18,31 +18,21 @@ chapter_preview_only:
- 4 - 4
- 5 - 5
links: links:
- title: Notice manual:
title: Manual
target: manual.html target: manual.html
icon: binder:
path: img/Infobox_info_icon.svg title: Exécuter
width: 35px
- title: Exécuter
target: https://mybinder.org/v2/gh/fitzinger/cours-python/master target: https://mybinder.org/v2/gh/fitzinger/cours-python/master
icon: book:
path: https://mybinder.org/badge.svg title: Version pdf
width: auto
- title: Version pdf
target: cours-python.pdf target: cours-python.pdf
icon: gitlab:
path: img/Adobe_PDF_icon.svg title: Sources
width: 30px
- title: Sources
target: https://gitlab.math.unistra.fr/fitzinger/cours-python target: https://gitlab.math.unistra.fr/fitzinger/cours-python
icon: archive:
path: img/GitLab_Logo.svg title: Archive complète
width: 30px
- title: Archive complète
target: cours-python.zip target: cours-python.zip
icon:
path: img/download.svg
width: 35px
license: license:
text: Contenu mis à disposition sous licence text: Contenu mis à disposition sous licence
target: https://creativecommons.org/licenses/by-sa/4.0/ target: https://creativecommons.org/licenses/by-sa/4.0/
......
...@@ -5,7 +5,7 @@ parent: manual.md ...@@ -5,7 +5,7 @@ parent: manual.md
## Download ## Download
Download [Anaconda](https://www.anaconda.com/download) for Python 3.X for your operating system and install it. Download <a href="https://www.anaconda.com/download"><img src="fig/anaconda.png" style="display:inline" alt="Anaconda logo" width="100px"></a> for Python 3.X for your operating system and install it.
On Linux, open *Terminal* application and type: On Linux, open *Terminal* application and type:
......
...@@ -7,20 +7,20 @@ parent: home ...@@ -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. 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: In particular, it is shipped with:
- [Jupyter](http://jupyter.org/) - [Jupyter](http://jupyter.org/)
- The [Spyder](https://github.com/spyder-ide/spyder) IDE - The [Spyder](https://github.com/spyder-ide/spyder) IDE
- Scipy libraries: Numpy, Pandas, etc. - Scipy libraries: Numpy, Pandas, etc.
For a detailed installation of Anaconda and its extensions on Windows, Mac or Linux, follow the <a href="pages/anaconda.md"><img src="fig/anaconda.png" style="display:inline" alt="Anaconda logo" width="100px"></a> instructions. For a detailed installation of Anaconda and its extensions on Windows, Mac or Linux, follow the instructions <a href="pages/anaconda.md"><img src="fig/anaconda.png" style="display:inline" alt="Anaconda logo" width="100px"></a>.
### Finalize installation with conda #### Finalize installation with conda
From the project root directory, type: From the project root directory, type:
...@@ -28,15 +28,23 @@ From the project root directory, type: ...@@ -28,15 +28,23 @@ From the project root directory, type:
conda install --file requirements.txt conda install --file requirements.txt
``` ```
## Run a Jupyter server ### Run a Jupyter notebook
#### Start a Jupyter server
- Either from Anaconda graphical interface - 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 ```bash
jupyter-notebook 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 ## Optional: build and publish
If you want be able to build and publish this course material, follow these [instructions](pages/build.md). If you want be able to build and publish this course material, follow these [instructions](pages/build.md).
{% 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 %} {% block content %}
{% if picture %} {% if picture %}
...@@ -35,13 +54,13 @@ ...@@ -35,13 +54,13 @@
<hr> <hr>
<table id="bottom"> <table id="bottom">
<tr> <tr>
{% for link in links %} {% for link in links.values() %}
<td>{{ link.title }}</td> <td>{{ link.title }}</td>
{% endfor %} {% endfor %}
</tr> </tr>
<tr> <tr>
{% for link in links %} {% for link_type, link in links.items() %}
<td><a href="{{ link.target }}"><img src="{{ link.icon.path }}" width="{{ link.icon.width }}"></a></td> <td><a href="{{ link.target }}"><img src="{{ link_icons[link_type]['path'] }}" width="{{ link_icons[link_type]['width'] }}"></a></td>
{% endfor %} {% endfor %}
</tr> </tr>
</table> </table>
...@@ -50,7 +69,9 @@ ...@@ -50,7 +69,9 @@
{% for author in authors %} {% for author in authors %}
<tr> <tr>
<td>{{ author.name }}</td> <td>{{ author.name }}</td>
{% if author.email %}
<td><a href="mailto: {{ author.email }}"><img style="display:inline" width="20" src="img/email.svg"></a></td> <td><a href="mailto: {{ author.email }}"><img style="display:inline" width="20" src="img/email.svg"></a></td>
{% endif %}
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
......
{% extends "base.html" %} {% extends "base.html.j2" %}
{% block menu %} {% block menu %}
<p class="menu"> <p class="menu">
......
...@@ -14,21 +14,21 @@ authors: ...@@ -14,21 +14,21 @@ authors:
chapter_preview_only: chapter_preview_only:
- 2 - 2
links: links:
- title: Manual manual:
title: Manual
target: manual.html target: manual.html
icon: binder:
path: img/Infobox_info_icon.svg title: Run
width: 35px target: https://mybinder.org
- title: PDF version book:
title: PDF version
target: sample-cours.pdf target: sample-cours.pdf
icon: gitlab:
path: img/Adobe_PDF_icon.svg title: Sources
width: 30px target: https://gitlab.com
- title: Complete archive archive:
title: Complete archive
target: sample-course.zip target: sample-course.zip
icon:
path: img/download.svg
width: 35px
license: license:
text: Content available under license text: Content available under license
target: https://creativecommons.org/licenses/by-sa/4.0/ target: https://creativecommons.org/licenses/by-sa/4.0/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment