Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
berumuron
Boop
Commits
4ca1ff06
Commit
4ca1ff06
authored
Feb 24, 2019
by
berumuron
Browse files
Refactor dirs with articles listing
parent
9a2c6459
Changes
1
Hide whitespace changes
Inline
Side-by-side
boop.py
View file @
4ca1ff06
...
...
@@ -331,19 +331,20 @@ def main(environment):
# We iterate on the directories of articles dir. If they contain
# "serie.html" file, it means they contain a serie. Otherwise, we list
# articles as usual.
for
dirname
in
list_dirs
(
articles_path
):
dirpath
=
os
.
path
.
join
(
articles_path
,
dirname
)
dirs_with_articles
=
list
(
list_dirs
(
articles_path
))
+
[
"."
]
for
dirname
in
dirs_with_articles
:
dirpath
=
os
.
path
.
realpath
(
os
.
path
.
join
(
articles_path
,
dirname
))
serie_filepath
=
os
.
path
.
join
(
dirpath
,
"serie.html"
)
serie
=
None
if
os
.
path
.
exists
(
serie_filepath
):
if
dirname
!=
"."
and
os
.
path
.
exists
(
serie_filepath
):
# We have a serie Page! Each article of the directory must be
# considered part of the serie.
slug
=
f
"serie/
{
dirname
}
"
with
open
(
serie_filepath
,
"r"
)
as
serie_file
:
serie
=
Page
(
slug
,
serie_file
.
read
(),
configuration
=
configuration
)
pages
.
append
(
serie
)
articles_by_series
[
serie
]
=
[]
articles_by_series
[
serie
]
=
[]
for
filename
in
list_files
(
dirpath
,
only
=
[
"md"
]):
article_filepath
=
os
.
path
.
join
(
dirpath
,
filename
)
...
...
@@ -354,11 +355,6 @@ def main(environment):
if
serie
:
articles_by_series
[
serie
].
append
(
article
)
for
filename
in
list_files
(
articles_path
,
only
=
[
"md"
]):
article_filepath
=
os
.
path
.
join
(
articles_path
,
filename
)
article
=
build_article_from_filepath
(
article_filepath
,
configuration
)
articles
.
append
(
article
)
# STEP 2: we write all the pages and articles
for
page
in
pages
:
output_filepath
=
os
.
path
.
join
(
output_path
,
f
"
{
page
.
slug
()
}
.html"
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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