Commit 07ee443c authored by Matthieu Boileau's avatar Matthieu Boileau

V2.0

parent b4099415
......@@ -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
......
......@@ -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)
......
[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 <matthieu.boileau@math.unistra.fr>"]
license = "MIT"
......
......@@ -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/
......
......@@ -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 <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:
......
......@@ -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 <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:
......@@ -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).
{% 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 @@
<hr>
<table id="bottom">
<tr>
{% for link in links %}
{% for link in links.values() %}
<td>{{ link.title }}</td>
{% endfor %}
</tr>
<tr>
{% for link in links %}
<td><a href="{{ link.target }}"><img src="{{ link.icon.path }}" width="{{ link.icon.width }}"></a></td>
{% for link_type, link in links.items() %}
<td><a href="{{ link.target }}"><img src="{{ link_icons[link_type]['path'] }}" width="{{ link_icons[link_type]['width'] }}"></a></td>
{% endfor %}
</tr>
</table>
......@@ -50,7 +69,9 @@
{% for author in authors %}
<tr>
<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>
{% endif %}
</tr>
{% endfor %}
</table>
......
{% extends "base.html" %}
{% extends "base.html.j2" %}
{% block menu %}
<p class="menu">
......
......@@ -14,21 +14,21 @@ authors:
chapter_preview_only:
- 2
links:
- title: Manual
manual:
title: Manual
target: manual.html
icon:
path: img/Infobox_info_icon.svg
width: 35px
- title: PDF version
binder:
title: Run
target: https://mybinder.org
book:
title: PDF version
target: sample-cours.pdf
icon:
path: img/Adobe_PDF_icon.svg
width: 30px
- title: Complete archive
gitlab:
title: Sources
target: https://gitlab.com
archive:
title: Complete archive
target: sample-course.zip
icon:
path: img/download.svg
width: 35px
license:
text: Content available under license
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