Skip to content
Commits on Source (6)
# Changelog
## [1.1.0](https://gitlab.der-jd.de/python/mkblog/compare/1.0.1...1.1.0) (2021-04-13)
### Features
* **plugin:** Add blog_dir to livereload ([3db4656](https://gitlab.der-jd.de/python/mkblog/commit/3db46562b280640895dcbb572ad135408153dc00))
### Documentation
* fix badge links ([0883bb1](https://gitlab.der-jd.de/python/mkblog/commit/0883bb13e8c6e65c567214c5307ad7671e60c883))
* Format docstrings ([96af28b](https://gitlab.der-jd.de/python/mkblog/commit/96af28b981aef700925fe6297efaf59531b32433))
### Build System
* **Makefile:** Expose liveserver port ([9514b3d](https://gitlab.der-jd.de/python/mkblog/commit/9514b3d6d45be952e15db498454fb2aaf118613b))
* **Makefile:** Seperate container bin from flags ([93a4155](https://gitlab.der-jd.de/python/mkblog/commit/93a41553aefe141cd79053dd3198795408acac15))
### [1.0.1](https://gitlab.der-jd.de/python/mkblog/compare/1.0.0...1.0.1) (2021-03-19)
......
......@@ -3,8 +3,10 @@
# containers/python-build is a container with
# build, setuptools_scm, pylint, twine installed via pip3
#
PODMAN := podman run -it --rm \
CBIN := podman
CFLAGS := run -it --rm \
--pull always \
-p 8000:8000 \
-v ./:/builds/${PWD##*/} \
-w /builds/${PWD##*/} \
containers/python-build:latest
......@@ -14,7 +16,7 @@ PODMAN := podman run -it --rm \
all: help
package:
${PODMAN} pyproject-build --sdist --wheel
${CBIN} ${CFLAGS} pyproject-build --sdist --wheel
install:
pip install .
......@@ -23,10 +25,10 @@ list:
pip show ${PWD##*/}
lint:
${PODMAN} bash -c 'pip install .; pylint --exit-zero -f parseable src/'
${CBIN} ${CFLAGS} bash -c 'pip install .; pylint --exit-zero -f parseable src/'
serve:
${PODMAN} bash -c 'pip install .; mkdocs -v serve -f example/mkdocs.yml -a 0.0.0.0:8000'
${CBIN} ${CFLAGS} bash -c 'pip install .; mkdocs -v serve -f example/mkdocs.yml -a 0.0.0.0:8000'
help:
@echo -e "Available targets:\n"
......
# python-mkblog
[![PyPI version](https://badge.fury.io/py/python-mkblog.svg)](https://badge.fury.io/py/python-mkblog)
[![PyPI version](https://badge.fury.io/py/mkblog.svg)](https://badge.fury.io/py/mkblog)
[![PyPI downloads](https://img.shields.io/pypi/dm/mkblog)](https://pypi.org/project/mkblog/)
[![pylint](https://gitlab.der-jd.de/python/mkblog/-/jobs/artifacts/main/raw/pylint.svg?job=lint:pylint)](#python-mkblog)
......
......@@ -31,8 +31,8 @@ class MkBlog(BasePlugin):
For determening a release date markdown metadata `date` is used.
Example:
blog/first-post.md:
```markdown
blog/first-post.md:
```markdown
---
author: JD
date: 1990-01-01
......@@ -48,9 +48,9 @@ class MkBlog(BasePlugin):
Bye
```
```
This will be published under /blog/1990/01/01/first-post/
This will be published under /blog/1990/01/01/first-post/
"""
config_scheme = (
('blog_dir', Type(str, default='blog')),
......@@ -58,6 +58,7 @@ class MkBlog(BasePlugin):
def __init__(self):
self._blog_md_file = None
self._blog_path = None
def get_blog_md(self):
"""
......@@ -66,10 +67,12 @@ class MkBlog(BasePlugin):
Returns:
files collection from all blogposts as list
"""
basedir = Path(self.config['docs_dir']).parent
blogdir = Path(f'{str(basedir)}/{self.config["blog_dir"]}')
self._blog_path = (
f'{Path(self.config["docs_dir"]).parent}/'
f'{self.config["blog_dir"]}'
)
blog_md_files = list(Path(self._blog_path).rglob('*.md'))
blog_md_files = list(blogdir.rglob('*.md'))
return blog_md_files
def get_blog_post_date(self):
......@@ -78,6 +81,7 @@ class MkBlog(BasePlugin):
Parameters:
file: absolute path to blogpost markdown file
Returns:
blogpost's release date as uri path
"""
......@@ -120,6 +124,7 @@ class MkBlog(BasePlugin):
def on_files(self, files: Files, config: Config):
"""
From `https://www.mkdocs.org/user-guide/plugins/#on_files`:
The files event is called after the files collection is populated from
the docs_dir. Use this event to add, remove, or alter files in the
collection. Note that Page objects have not yet been associated with
......@@ -129,6 +134,7 @@ class MkBlog(BasePlugin):
Parameters:
files: global files collection
config: global configuration object
Returns:
global files collection
"""
......@@ -154,3 +160,25 @@ class MkBlog(BasePlugin):
files.append(blogpost)
return files
def on_serve(self, server, config, builder):
"""
From `https://www.mkdocs.org/user-guide/plugins/#on_serve`:
The serve event is only called when the serve command is used during
development. It is passed the Server instance which can be modified
before it is activated.
For example, additional files or directories could be added to the list
of "watched" files for auto-reloading.
Parameters:
server: livereload.Server instance
config: global configuration object
builder: a callable which gets passed to each call to server.watch
Returns:
livereload.Server instance
"""
# docs_dir and configuration will still be watched
# no need for adding them here (again)
server.watch(self._blog_path, builder)