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
3f235329
Commit
3f235329
authored
Jan 11, 2019
by
Marien Fressinaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load configuration at the beginning
parent
61b3d16d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
30 deletions
+30
-30
boop.py
boop.py
+30
-30
No files found.
boop.py
View file @
3f235329
...
...
@@ -144,6 +144,36 @@ def main(environment):
os
.
remove
(
output_path
)
os
.
mkdir
(
output_path
)
# Load the configuration (it can be overidden by a configuration.yml file)
configuration
=
{
"SITE_URL"
:
"filesystem"
,
"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
():
if
key
==
"development"
:
continue
site_key
=
f
"SITE_{key.upper()}"
configuration
[
site_key
]
=
value
if
environment
==
Environment
.
DEVELOPMENT
and
"development"
in
conf_data
:
for
key
,
value
in
conf_data
[
"development"
]
.
items
():
site_key
=
f
"SITE_{key.upper()}"
configuration
[
site_key
]
=
value
configuration
[
"SITE_UUID"
]
=
str
(
uuid
.
uuid5
(
uuid
.
NAMESPACE_URL
,
configuration
[
"SITE_URL"
])
)
if
"SITE_AUTHOR"
not
in
configuration
:
configuration
[
"SITE_AUTHOR"
]
=
f
"{configuration['SITE_TITLE']}'s author"
if
configuration
[
"SITE_URL"
]
==
"filesystem"
:
configuration
[
"SITE_URL"
]
=
f
"file://{os.path.abspath(output_path)}/"
# Check that index file exists and copy it under the ./site folder
index_filepath
=
os
.
path
.
join
(
os
.
curdir
,
"index.html"
)
if
not
os
.
path
.
exists
(
index_filepath
):
...
...
@@ -183,36 +213,6 @@ def main(environment):
# If not, just stop here
return
# Load the configuration (it can be overidden by a configuration.yml file)
configuration
=
{
"SITE_URL"
:
"filesystem"
,
"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
():
if
key
==
"development"
:
continue
site_key
=
f
"SITE_{key.upper()}"
configuration
[
site_key
]
=
value
if
environment
==
Environment
.
DEVELOPMENT
and
"development"
in
conf_data
:
for
key
,
value
in
conf_data
[
"development"
]
.
items
():
site_key
=
f
"SITE_{key.upper()}"
configuration
[
site_key
]
=
value
configuration
[
"SITE_UUID"
]
=
str
(
uuid
.
uuid5
(
uuid
.
NAMESPACE_URL
,
configuration
[
"SITE_URL"
])
)
if
"SITE_AUTHOR"
not
in
configuration
:
configuration
[
"SITE_AUTHOR"
]
=
f
"{configuration['SITE_TITLE']}'s author"
if
configuration
[
"SITE_URL"
]
==
"filesystem"
:
configuration
[
"SITE_URL"
]
=
f
"file://{os.path.abspath(output_path)}/"
# List files from ./articles
articles
=
[]
for
filename
in
dir_tree
(
articles_path
):
...
...
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