Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
Boop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Marien Fressinaud
Boop
Commits
39c7a809
Commit
39c7a809
authored
Dec 12, 2018
by
Marien Fressinaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accept a yaml configuration file
parent
96cd2873
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletion
+33
-1
README.md
README.md
+13
-0
boop.py
boop.py
+20
-1
No files found.
README.md
View file @
39c7a809
...
...
@@ -153,6 +153,19 @@ $ tree
└── index.html
```
Finally, you might want to create a
`./configuration.yml`
file. Four
information are used by the Atom feed, so you might want to declare them:
```
yaml
url
:
http://my-website.org/
title
:
My website
author
:
Dale Cooper
timezone
:
Europe/Paris
```
You can declare as many variables as you want, they all will be accessible in
the article template, uppercased and prepended by
`SITE_`
.
## Tests
There are some tests (i.e. doctests) that can be run to check that everything
...
...
boop.py
View file @
39c7a809
...
...
@@ -5,6 +5,7 @@ import sys
import
shutil
import
distutils.dir_util
import
locale
import
yaml
import
markdown
...
...
@@ -108,6 +109,24 @@ def main():
# If not, just stop here
return
# Load the configuration (it can be overidden by a configuration.yml file)
configuration
=
{
"SITE_URL"
:
"http://localhost"
,
"SITE_TITLE"
:
"A website"
,
"SITE_TIMEZONE"
:
"UTC"
,
}
configuration_path
=
os
.
path
.
join
(
os
.
curdir
,
"configuration.yml"
)
if
os
.
path
.
exists
(
configuration_path
):
with
open
(
configuration_path
)
as
conf_file
:
conf_data
=
yaml
.
load
(
conf_file
)
for
key
,
value
in
conf_data
.
items
():
site_key
=
f
"SITE_{key.upper()}"
configuration
[
site_key
]
=
value
if
"SITE_AUTHOR"
not
in
configuration
:
configuration
[
"SITE_AUTHOR"
]
=
f
"{configuration['SITE_TITLE']}'s author"
# List files from ./articles
articles
=
[]
for
filename
in
dir_tree
(
articles_path
):
...
...
@@ -119,7 +138,7 @@ def main():
# We read the article file and initialize an Article from it
article_filepath
=
os
.
path
.
join
(
articles_path
,
filename
)
with
open
(
article_filepath
,
"r"
)
as
article_file
:
article
=
Article
(
slug
,
article_file
.
read
())
article
=
Article
(
slug
,
article_file
.
read
()
,
configuration
=
configuration
)
articles
.
append
(
article
)
# And write them in the ./site folder
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment