Commit d1587e9e authored by Marien Fressinaud's avatar Marien Fressinaud

Copy static folder's content under the site folder

parent 5d7de713
......@@ -55,7 +55,7 @@ $ tree
Well OK, Boop! basically just copied the `index.html` file under the `site`
directory. Let's write an article then.
For that, you'll need a template file:
For that, you'll need a template file under a `./theme` folder:
```console
$ mkdir theme
......@@ -68,6 +68,16 @@ Then, you can create a Markdown file under a `./content` folder:
$ mkdir content
$ echo '# My first article' > content/my-article.md
$ boop.py
$ tree
.
├── content
│   └── my-article.md
├── site
│   ├── index.html
│   ├── my-article.html
├── theme
│   └── article.html
└── index.html
$ echo site/my-article.html
<html><body><h1>My first article</h1></body></html>
```
......@@ -121,7 +131,26 @@ For now, you can use any valid Python expression between `{{ }}`, you have
access to the variables defined in the meta header, the Python builtin
functions and the `datetime` module.
Other files under `./content` are copied to the `./site` folder.
The `./theme` folder can contain a `static` folder as well. Its content will be
copied under the `./site` folder:
```console
$ tree
.
├── content
│   └── my-article.md
├── site
│   ├── index.html
│   ├── my-article.html
│   └── style.css
├── theme
│   ├── static
│   │   └── style.css
│   └── article.html
└── index.html
```
Other files under `./content` are also copied to the `./site` folder.
## Tests
......
......@@ -3,6 +3,7 @@
import os
import sys
import shutil
import distutils.dir_util
import locale
import markdown
......@@ -79,6 +80,12 @@ def main():
index_output_filepath = os.path.join(output_path, "index.html")
shutil.copyfile(index_filepath, index_output_filepath)
# Check that a ./theme/static folder exists and copy its content under the
# ./site folder
static_dirpath = os.path.join(os.curdir, "theme", "static")
if os.path.isdir(static_dirpath):
distutils.dir_util.copy_tree(static_dirpath, output_path)
# Check that content directory exists on the filesystem
content_path = os.path.join(os.curdir, "content")
if not os.path.isdir(content_path):
......
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