Skip to content
GitLab
Menu
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
e0e669e1
Commit
e0e669e1
authored
Dec 12, 2018
by
berumuron
Browse files
Add more information to article and site
parent
39c7a809
Changes
3
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
e0e669e1
...
...
@@ -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
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
copied under the `./site` folder:
...
...
boop.py
View file @
e0e669e1
...
...
@@ -6,8 +6,11 @@ import shutil
import
distutils.dir_util
import
locale
import
yaml
import
datetime
import
uuid
import
markdown
import
pytz
import
boopsy
...
...
@@ -63,9 +66,46 @@ class Article:
def
title
(
self
):
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
):
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
):
"""List all the tree directory under the given path.
...
...
@@ -124,6 +164,9 @@ def main():
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"
...
...
requirements.txt
View file @
e0e669e1
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