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
e0e669e1
Commit
e0e669e1
authored
Dec 12, 2018
by
Marien Fressinaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more information to article and site
parent
39c7a809
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
0 deletions
+59
-0
README.md
README.md
+15
-0
boop.py
boop.py
+43
-0
requirements.txt
requirements.txt
+1
-0
No files found.
README.md
View file @
e0e669e1
...
@@ -134,6 +134,21 @@ For now, you can use any valid Python expression between `{{ }}`, you have
...
@@ -134,6 +134,21 @@ For now, you can use any valid Python expression between `{{ }}`, you have
access to the variables defined in the meta header, the Python builtin
access to the variables defined in the meta header, the Python builtin
functions and the
`datetime`
module.
functions and the
`datetime`
module.
The following meta variables have specific significance, especially in the Atom
feed:
-
`slug`
(defines the final URL of the article)
-
`title`
-
`author`
-
`date`
(the date of publication)
-
`update`
(the date of the last update)
It is highly recommended to always specify
`title`
and
`date`
(or default
values will be generated). The default value of
`slug`
is the name of the file
without its extension. A default value for
`author`
can be set in the
`configuration.yml`
file.
`date`
and
`update`
must follow this format:
`YYYY-MM-DD HH:MM`
.
The
`./theme`
folder can contain a
`static`
folder as well. Its content will be
The
`./theme`
folder can contain a
`static`
folder as well. Its content will be
copied under the
`./site`
folder:
copied under the
`./site`
folder:
...
...
boop.py
View file @
e0e669e1
...
@@ -6,8 +6,11 @@ import shutil
...
@@ -6,8 +6,11 @@ import shutil
import
distutils.dir_util
import
distutils.dir_util
import
locale
import
locale
import
yaml
import
yaml
import
datetime
import
uuid
import
markdown
import
markdown
import
pytz
import
boopsy
import
boopsy
...
@@ -63,9 +66,46 @@ class Article:
...
@@ -63,9 +66,46 @@ class Article:
def
title
(
self
):
def
title
(
self
):
return
self
.
meta
.
get
(
"ARTICLE_TITLE"
,
"An article"
)
return
self
.
meta
.
get
(
"ARTICLE_TITLE"
,
"An article"
)
def
author
(
self
):
if
"ARTICLE_AUTHOR"
in
self
.
meta
:
return
self
.
meta
[
"ARTICLE_AUTHOR"
]
elif
"SITE_AUTHOR"
in
self
.
meta
:
return
self
.
meta
[
"SITE_AUTHOR"
]
else
:
return
None
def
url
(
self
):
site_url
=
self
.
meta
.
get
(
"SITE_URL"
,
""
)
return
f
"{site_url}{self.slug()}.html"
def
uuid
(
self
):
return
str
(
uuid
.
uuid5
(
uuid
.
NAMESPACE_URL
,
self
.
url
()))
def
content
(
self
):
def
content
(
self
):
return
self
.
meta
[
"ARTICLE_CONTENT"
]
return
self
.
meta
[
"ARTICLE_CONTENT"
]
def
timezone
(
self
):
site_timezone
=
self
.
meta
.
get
(
"SITE_TIMEZONE"
,
"UTC"
)
return
pytz
.
timezone
(
site_timezone
)
def
date
(
self
):
if
"ARTICLE_DATE"
not
in
self
.
meta
:
return
datetime
.
datetime
.
now
(
tz
=
self
.
timezone
())
article_date
=
datetime
.
datetime
.
strptime
(
self
.
meta
[
"ARTICLE_DATE"
],
"
%
Y-
%
m-
%
d
%
H:
%
M"
)
return
article_date
.
astimezone
(
tz
=
self
.
timezone
())
def
update
(
self
):
if
"ARTICLE_UPDATE"
not
in
self
.
meta
:
return
None
article_update
=
datetime
.
datetime
.
strptime
(
self
.
meta
[
"ARTICLE_UPDATE"
],
"
%
Y-
%
m-
%
d
%
H:
%
M"
)
return
article_update
.
astimezone
(
tz
=
self
.
timezone
())
def
dir_tree
(
path
):
def
dir_tree
(
path
):
"""List all the tree directory under the given path.
"""List all the tree directory under the given path.
...
@@ -124,6 +164,9 @@ def main():
...
@@ -124,6 +164,9 @@ def main():
site_key
=
f
"SITE_{key.upper()}"
site_key
=
f
"SITE_{key.upper()}"
configuration
[
site_key
]
=
value
configuration
[
site_key
]
=
value
configuration
[
"SITE_UUID"
]
=
str
(
uuid
.
uuid5
(
uuid
.
NAMESPACE_URL
,
configuration
[
"SITE_URL"
])
)
if
"SITE_AUTHOR"
not
in
configuration
:
if
"SITE_AUTHOR"
not
in
configuration
:
configuration
[
"SITE_AUTHOR"
]
=
f
"{configuration['SITE_TITLE']}'s author"
configuration
[
"SITE_AUTHOR"
]
=
f
"{configuration['SITE_TITLE']}'s author"
...
...
requirements.txt
View file @
e0e669e1
markdown
markdown
pytz
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