forked from github.com/blag
Compare commits
103 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
595356e915 | ||
|
|
6005369108 | ||
|
|
db4e03afde | ||
|
|
877c47c391 | ||
|
|
3bd7125873 | ||
|
|
35f6ef05b6 | ||
|
|
7e8f2a5b9a | ||
|
|
d942bf150c | ||
|
|
48cfb49acb | ||
|
|
c3edbeb511 | ||
|
|
a60887e0d6 | ||
|
|
bfbedcc3df | ||
|
|
dff60d7399 | ||
|
|
f9b6afa80a | ||
|
|
c469b9b591 | ||
|
|
d76a0834e3 | ||
|
|
20b1e281a1 | ||
|
|
58e74f8d55 | ||
|
|
aad5f288af | ||
|
|
dc76295203 | ||
|
|
8a9a8cd2eb | ||
|
|
55e82393b6 | ||
|
|
b74cea8296 | ||
|
|
58a164899c | ||
|
|
769dcca83a | ||
|
|
f8bcaafc30 | ||
|
|
f1fe211ac6 | ||
|
|
c88628350f | ||
|
|
60e8b98232 | ||
|
|
b74c34839f | ||
|
|
2a8f93147f | ||
|
|
4c12ef738c | ||
|
|
bc71f51443 | ||
|
|
4cfbdd5108 | ||
|
|
6a07b19eda | ||
|
|
d486b7a90b | ||
|
|
2355799aaa | ||
|
|
788c07446d | ||
|
|
c1375a1478 | ||
|
|
67d9a31256 | ||
|
|
25c6a4c089 | ||
|
|
e75fd4eacb | ||
|
|
88905db579 | ||
|
|
702bc2e986 | ||
|
|
7cc4d8be45 | ||
|
|
764317aa24 | ||
|
|
a8a976403f | ||
|
|
fd9a6e6fa2 | ||
|
|
8f02c107e2 | ||
|
|
489e546173 | ||
|
|
9143a4dc7f | ||
|
|
512c12eaae | ||
|
|
ab3eaf934d | ||
|
|
db30fe1d06 | ||
|
|
27a760d834 | ||
|
|
a9abcd753a | ||
|
|
3deb62ed88 | ||
|
|
2366a2ae86 | ||
|
|
0fb01e3249 | ||
|
|
78316725cf | ||
|
|
4f1632e3cd | ||
|
|
d23f3666dc | ||
|
|
60cfd0290a | ||
|
|
10ea8df1ac | ||
|
|
edc89581af | ||
|
|
6d75891ace | ||
|
|
6367f5a55a | ||
|
|
3cd316a537 | ||
|
|
3b8d2fe9d6 | ||
|
|
1fe576a771 | ||
|
|
2f4d2267a0 | ||
|
|
7bb51ff060 | ||
|
|
5a8012d62b | ||
|
|
713b53d0d9 | ||
|
|
2d1d0ab302 | ||
|
|
572710fab1 | ||
|
|
0b66c5fbf4 | ||
|
|
18ecd82c5a | ||
|
|
a74f36be8a | ||
|
|
dd7d6cdae2 | ||
|
|
39e6aa2676 | ||
|
|
93f6840168 | ||
|
|
e27d82ac2a | ||
|
|
88b4fc8233 | ||
|
|
8923b0bb6e | ||
|
|
2671239ac1 | ||
|
|
7aa6cebb63 | ||
|
|
4869ea0fd2 | ||
|
|
aeedd9b73a | ||
|
|
52412b8926 | ||
|
|
c0dae31b60 | ||
|
|
2366ee2def | ||
|
|
67f24642e5 | ||
|
|
f1020637e6 | ||
|
|
a4d596b79d | ||
|
|
79edd04ee8 | ||
|
|
9cdecdccf7 | ||
|
|
499b0dfe11 | ||
|
|
72971408b2 | ||
|
|
6445f31204 | ||
|
|
98b97fbbbd | ||
|
|
df65dee488 | ||
|
|
d227392c79 |
6
.github/dependabot.yml
vendored
Normal file
6
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "pip"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
5
.github/workflows/python-package.yaml
vendored
5
.github/workflows/python-package.yaml
vendored
@@ -17,8 +17,9 @@ jobs:
|
|||||||
- macos-latest
|
- macos-latest
|
||||||
- windows-latest
|
- windows-latest
|
||||||
python-version:
|
python-version:
|
||||||
- 3.8
|
- "3.8"
|
||||||
- 3.9
|
- "3.9"
|
||||||
|
- "3.10"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -5,6 +5,9 @@ build/
|
|||||||
dist/
|
dist/
|
||||||
*.egg-info/
|
*.egg-info/
|
||||||
|
|
||||||
|
docs/_build/
|
||||||
|
docs/api/
|
||||||
|
|
||||||
htmlcov/
|
htmlcov/
|
||||||
.coverage
|
.coverage
|
||||||
|
|
||||||
|
|||||||
59
CHANGELOG.md
59
CHANGELOG.md
@@ -1,6 +1,61 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## [0.0.0] - YYYY-MM-DD
|
## [1.3.2] - 2022-06-29
|
||||||
|
|
||||||
*
|
* Added --version option
|
||||||
|
* Improved quickstart:
|
||||||
|
* respective default answers will be written to config if user provided no
|
||||||
|
answer
|
||||||
|
* added tests for quickstart
|
||||||
|
* Added some test cases for the MarkdownLinktreeProcessor
|
||||||
|
|
||||||
|
## [1.3.1] - 2022-06-10
|
||||||
|
|
||||||
|
* fixed man page
|
||||||
|
|
||||||
|
## [1.3.0] - 2022-06-09
|
||||||
|
|
||||||
|
* debianized package
|
||||||
|
* Small fix in makefile
|
||||||
|
* updated dependencies:
|
||||||
|
* pytest 7.1.2
|
||||||
|
* sphinx 5.0.0
|
||||||
|
* twine 3.7.1
|
||||||
|
* wheel 0.37.1
|
||||||
|
* markdown 3.3.7
|
||||||
|
* jinja 3.1.2
|
||||||
|
* pygments 2.12.0
|
||||||
|
|
||||||
|
## [1.2.0] - 2021-11-06
|
||||||
|
|
||||||
|
* `make serve` now rebuilds immediately once after called to avoid serving
|
||||||
|
stale files
|
||||||
|
* updated dependencies:
|
||||||
|
* feedgenerator 2.0.0
|
||||||
|
* jinja2 3.0.1
|
||||||
|
* pytest-cov 3.0.0
|
||||||
|
* flake8 4.0.1
|
||||||
|
* twine 3.5.0
|
||||||
|
|
||||||
|
## [1.1.0] - 2021-10-06
|
||||||
|
|
||||||
|
* added Python 3.10 to list of supported versions to test against
|
||||||
|
* added dependabot to github workflows
|
||||||
|
* updated various dependencies:
|
||||||
|
* pygments 2.10.0
|
||||||
|
* sphinx 4.2.0
|
||||||
|
* twine 3.4.2
|
||||||
|
* wheel 0.37.0
|
||||||
|
* pytest 6.2.5
|
||||||
|
|
||||||
|
## [1.0.0] - 2021-08-18
|
||||||
|
|
||||||
|
* first 1.0 release!
|
||||||
|
* bump requirements of feedgenerator to 1.9.2. this version uses the
|
||||||
|
description to provide a subtitle for the feed
|
||||||
|
|
||||||
|
## [0.0.9] - 2021-06-22
|
||||||
|
|
||||||
|
* updated to jinja 3.0
|
||||||
|
* updated to sphinx 4.0
|
||||||
|
* added link to changelog
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -13,6 +13,7 @@ ifeq ($(OS), Windows_NT)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
all: lint test
|
all: lint test
|
||||||
|
|
||||||
$(VENV): requirements.txt requirements-dev.txt setup.py
|
$(VENV): requirements.txt requirements-dev.txt setup.py
|
||||||
@@ -45,6 +46,7 @@ clean:
|
|||||||
rm -rf build dist *.egg-info
|
rm -rf build dist *.egg-info
|
||||||
rm -rf $(VENV)
|
rm -rf $(VENV)
|
||||||
rm -rf $(DOCS_OUT)
|
rm -rf $(DOCS_OUT)
|
||||||
|
rm -rf $(DOCS_SRC)/api
|
||||||
find . -type f -name *.pyc -delete
|
find . -type f -name *.pyc -delete
|
||||||
find . -type d -name __pycache__ -delete
|
find . -type d -name __pycache__ -delete
|
||||||
# coverage
|
# coverage
|
||||||
|
|||||||
17
README.md
17
README.md
@@ -3,7 +3,7 @@
|
|||||||
blag is a blog-aware, static site generator, written in [Python][].
|
blag is a blog-aware, static site generator, written in [Python][].
|
||||||
|
|
||||||
* an example "deployment" can be found [here][venthur.de]
|
* an example "deployment" can be found [here][venthur.de]
|
||||||
* online [documentation][] is available on readthedocs
|
* online [documentation][] is available on https://readthedocs.org.
|
||||||
|
|
||||||
blag is named after [the blag of the webcomic xkcd][blagxkcd].
|
blag is named after [the blag of the webcomic xkcd][blagxkcd].
|
||||||
|
|
||||||
@@ -30,6 +30,21 @@ blag runs on Linux, Mac and Windows and requires Python >= 3.8
|
|||||||
[pypi]: https://pypi.org/project/blag/
|
[pypi]: https://pypi.org/project/blag/
|
||||||
|
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
blag is available on [PyPI][], you can install it via:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ pip install blag
|
||||||
|
```
|
||||||
|
|
||||||
|
On Debian or Ubuntu, you can also just install the Debian package:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ sudo aptitude install blag
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Quickstart
|
## Quickstart
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
41
blag/blag.py
41
blag/blag.py
@@ -16,6 +16,8 @@ import feedgenerator
|
|||||||
|
|
||||||
from blag.markdown import markdown_factory, convert_markdown
|
from blag.markdown import markdown_factory, convert_markdown
|
||||||
from blag.devserver import serve
|
from blag.devserver import serve
|
||||||
|
from blag.version import __VERSION__
|
||||||
|
from blag.quickstart import quickstart
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
@@ -54,6 +56,11 @@ def parse_args(args=None):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument(
|
||||||
|
'--version',
|
||||||
|
action='version',
|
||||||
|
version='%(prog)s '+__VERSION__,
|
||||||
|
)
|
||||||
|
|
||||||
commands = parser.add_subparsers(dest='command')
|
commands = parser.add_subparsers(dest='command')
|
||||||
commands.required = True
|
commands.required = True
|
||||||
@@ -289,7 +296,7 @@ def process_markdown(convertibles, input_dir, output_dir,
|
|||||||
articles.append((dst, context))
|
articles.append((dst, context))
|
||||||
result = article_template.render(context)
|
result = article_template.render(context)
|
||||||
else:
|
else:
|
||||||
pages.append((dst, content))
|
pages.append((dst, context))
|
||||||
result = page_template.render(context)
|
result = page_template.render(context)
|
||||||
with open(f'{output_dir}/{dst}', 'w') as fh_dest:
|
with open(f'{output_dir}/{dst}', 'w') as fh_dest:
|
||||||
fh_dest.write(result)
|
fh_dest.write(result)
|
||||||
@@ -392,7 +399,7 @@ def generate_tags(articles, tags_template, tag_template, output_dir):
|
|||||||
# get tags number of occurrences
|
# get tags number of occurrences
|
||||||
all_tags = {}
|
all_tags = {}
|
||||||
for _, context in articles:
|
for _, context in articles:
|
||||||
tags = context.get('tags', None)
|
tags = context.get('tags', [])
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
all_tags[tag] = all_tags.get(tag, 0) + 1
|
all_tags[tag] = all_tags.get(tag, 0) + 1
|
||||||
# sort by occurrence
|
# sort by occurrence
|
||||||
@@ -405,7 +412,7 @@ def generate_tags(articles, tags_template, tag_template, output_dir):
|
|||||||
# get tags and archive per tag
|
# get tags and archive per tag
|
||||||
all_tags = {}
|
all_tags = {}
|
||||||
for dst, context in articles:
|
for dst, context in articles:
|
||||||
tags = context.get('tags', None)
|
tags = context.get('tags', [])
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
archive = all_tags.get(tag, [])
|
archive = all_tags.get(tag, [])
|
||||||
entry = context.copy()
|
entry = context.copy()
|
||||||
@@ -419,33 +426,5 @@ def generate_tags(articles, tags_template, tag_template, output_dir):
|
|||||||
fh.write(result)
|
fh.write(result)
|
||||||
|
|
||||||
|
|
||||||
def quickstart(args):
|
|
||||||
"""Quickstart.
|
|
||||||
|
|
||||||
This method asks the user some questions and generates a
|
|
||||||
configuration file that is needed in order to run blag.
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
args : argparse.Namespace
|
|
||||||
|
|
||||||
"""
|
|
||||||
base_url = input("Hostname (and path) to the root? "
|
|
||||||
"[https://example.com/]: ")
|
|
||||||
title = input("Title of your website? ")
|
|
||||||
description = input("Description of your website [John Does's Blog]? ")
|
|
||||||
author = input("Author of your website [John Doe]? ")
|
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
|
||||||
config['main'] = {
|
|
||||||
'base_url': base_url,
|
|
||||||
'title': title,
|
|
||||||
'description': description,
|
|
||||||
'author': author,
|
|
||||||
}
|
|
||||||
with open('config.ini', 'w') as fh:
|
|
||||||
config.write(fh)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ def autoreload(args):
|
|||||||
last modified time). If the last modified time has changed, a
|
last modified time). If the last modified time has changed, a
|
||||||
rebuild is triggered.
|
rebuild is triggered.
|
||||||
|
|
||||||
|
A rebuild is also performed immediately when this method is called
|
||||||
|
to avoid serving stale contents.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
args : argparse.Namespace
|
args : argparse.Namespace
|
||||||
@@ -62,12 +65,14 @@ def autoreload(args):
|
|||||||
"""
|
"""
|
||||||
dirs = [args.input_dir, args.template_dir, args.static_dir]
|
dirs = [args.input_dir, args.template_dir, args.static_dir]
|
||||||
logger.info(f'Monitoring {dirs} for changes...')
|
logger.info(f'Monitoring {dirs} for changes...')
|
||||||
last_mtime = get_last_modified(dirs)
|
# make sure we trigger the rebuild immediately when we enter the
|
||||||
|
# loop to avoid serving stale contents
|
||||||
|
last_mtime = 0
|
||||||
while True:
|
while True:
|
||||||
mtime = get_last_modified(dirs)
|
mtime = get_last_modified(dirs)
|
||||||
if mtime > last_mtime:
|
if mtime > last_mtime:
|
||||||
last_mtime = mtime
|
last_mtime = mtime
|
||||||
logger.debug('Change detected, rebuilding...')
|
logger.info('Change detected, rebuilding...')
|
||||||
blag.build(args)
|
blag.build(args)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
@@ -84,4 +89,5 @@ def serve(args):
|
|||||||
directory=args.output_dir))
|
directory=args.output_dir))
|
||||||
proc = multiprocessing.Process(target=autoreload, args=(args,))
|
proc = multiprocessing.Process(target=autoreload, args=(args,))
|
||||||
proc.start()
|
proc.start()
|
||||||
|
logger.info("\n\n Devserver Started -- visit http://localhost:8000\n")
|
||||||
httpd.serve_forever()
|
httpd.serve_forever()
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ def markdown_factory():
|
|||||||
"""
|
"""
|
||||||
md = Markdown(
|
md = Markdown(
|
||||||
extensions=[
|
extensions=[
|
||||||
'meta', 'fenced_code', 'codehilite',
|
'meta', 'fenced_code', 'codehilite', 'smarty',
|
||||||
MarkdownLinkExtension()
|
MarkdownLinkExtension()
|
||||||
],
|
],
|
||||||
output_format='html5',
|
output_format='html5',
|
||||||
|
|||||||
68
blag/quickstart.py
Normal file
68
blag/quickstart.py
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
"""Helper methods for blag's quickstart command.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
import configparser
|
||||||
|
|
||||||
|
|
||||||
|
def get_input(question, default):
|
||||||
|
"""Prompt for user input.
|
||||||
|
|
||||||
|
This is a wrapper around the input-builtin. It will show the default answer
|
||||||
|
in the prompt and -- if no answer was given -- use the default.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
question : str
|
||||||
|
the question the user is presented
|
||||||
|
default : str
|
||||||
|
the default value that will be used if no answer was given
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
str
|
||||||
|
|
||||||
|
"""
|
||||||
|
reply = input(f"{question} [{default}]: ")
|
||||||
|
if not reply:
|
||||||
|
reply = default
|
||||||
|
return reply
|
||||||
|
|
||||||
|
|
||||||
|
def quickstart(args):
|
||||||
|
"""Quickstart.
|
||||||
|
|
||||||
|
This method asks the user some questions and generates a
|
||||||
|
configuration file that is needed in order to run blag.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
args : argparse.Namespace
|
||||||
|
|
||||||
|
"""
|
||||||
|
base_url = get_input(
|
||||||
|
"Hostname (and path) to the root?",
|
||||||
|
"https://example.com/",
|
||||||
|
)
|
||||||
|
title = get_input(
|
||||||
|
"Title of your website?",
|
||||||
|
"My little blog",
|
||||||
|
)
|
||||||
|
description = get_input(
|
||||||
|
"Description of your website?",
|
||||||
|
"John Doe's Blog",
|
||||||
|
)
|
||||||
|
author = get_input(
|
||||||
|
"Author of your website",
|
||||||
|
"John Doe",
|
||||||
|
)
|
||||||
|
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config['main'] = {
|
||||||
|
'base_url': base_url,
|
||||||
|
'title': title,
|
||||||
|
'description': description,
|
||||||
|
'author': author,
|
||||||
|
}
|
||||||
|
with open('config.ini', 'w') as fh:
|
||||||
|
config.write(fh)
|
||||||
@@ -1 +1 @@
|
|||||||
__VERSION__ = '0.0.6'
|
__VERSION__ = '1.3.2'
|
||||||
|
|||||||
1
debian/blag-doc.docs
vendored
Normal file
1
debian/blag-doc.docs
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
build/html/
|
||||||
1
debian/blag.install
vendored
Normal file
1
debian/blag.install
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
build/man/blag.1 /usr/share/man/man1
|
||||||
22
debian/changelog
vendored
Normal file
22
debian/changelog
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
blag (1.3.2) unstable; urgency=medium
|
||||||
|
|
||||||
|
* Added --version option
|
||||||
|
* Improved quickstart:
|
||||||
|
* respective default answers will be written to config if user provided no
|
||||||
|
answer
|
||||||
|
* added tests for quickstart
|
||||||
|
* Added some test cases for the MarkdownLinktreeProcessor
|
||||||
|
|
||||||
|
-- Bastian Venthur <venthur@debian.org> Wed, 29 Jun 2022 21:27:15 +0200
|
||||||
|
|
||||||
|
blag (1.3.1) unstable; urgency=medium
|
||||||
|
|
||||||
|
* re-upload with man pages
|
||||||
|
|
||||||
|
-- Bastian Venthur <venthur@debian.org> Fri, 10 Jun 2022 07:26:19 +0200
|
||||||
|
|
||||||
|
blag (1.3.0) unstable; urgency=medium
|
||||||
|
|
||||||
|
* Initial release. Closes: #1012584
|
||||||
|
|
||||||
|
-- Bastian Venthur <venthur@debian.org> Sun, 05 Jun 2022 15:20:48 +0200
|
||||||
59
debian/control
vendored
Normal file
59
debian/control
vendored
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
Source: blag
|
||||||
|
Section: python
|
||||||
|
Priority: optional
|
||||||
|
Maintainer: Bastian Venthur <venthur@debian.org>
|
||||||
|
Rules-Requires-Root: no
|
||||||
|
Build-Depends:
|
||||||
|
debhelper-compat (= 13),
|
||||||
|
dh-sequence-sphinxdoc,
|
||||||
|
dh-sequence-python3,
|
||||||
|
dh-python,
|
||||||
|
python3-setuptools,
|
||||||
|
python3-all,
|
||||||
|
python3-markdown,
|
||||||
|
python3-feedgenerator,
|
||||||
|
python3-jinja2,
|
||||||
|
python3-pygments,
|
||||||
|
python3-pytest,
|
||||||
|
python3-pytest-cov,
|
||||||
|
python3-sphinx,
|
||||||
|
#Testsuite: autopkgtest-pkg-python
|
||||||
|
Standards-Version: 4.6.0.1
|
||||||
|
Homepage: https://github.com/venthur/blag
|
||||||
|
Vcs-Browser: https://github.com/venthur/blag
|
||||||
|
Vcs-Git: https://github.com/venthur/blag.git
|
||||||
|
|
||||||
|
Package: blag
|
||||||
|
Architecture: all
|
||||||
|
Depends:
|
||||||
|
${python3:Depends},
|
||||||
|
${misc:Depends},
|
||||||
|
Suggests:
|
||||||
|
python-blag-doc,
|
||||||
|
Description: Blog-aware, static site generator
|
||||||
|
Blag is a blog-aware, static site generator, written in Python. It supports
|
||||||
|
the following features:
|
||||||
|
* Write content in Markdown
|
||||||
|
* Theming support using Jinja2 templates
|
||||||
|
* Generation of Atom feeds for blog content
|
||||||
|
* Fenced code blocks and syntax highlighting using Pygments
|
||||||
|
* Integrated devserver
|
||||||
|
* Available on PyPI
|
||||||
|
|
||||||
|
Package: blag-doc
|
||||||
|
Section: doc
|
||||||
|
Architecture: all
|
||||||
|
Depends:
|
||||||
|
${sphinxdoc:Depends},
|
||||||
|
${misc:Depends},
|
||||||
|
Description: Blog-aware, static site generator (documentation)
|
||||||
|
Blag is a blog-aware, static site generator, written in Python. It supports
|
||||||
|
the following features:
|
||||||
|
* Write content in Markdown
|
||||||
|
* Theming support using Jinja2 templates
|
||||||
|
* Generation of Atom feeds for blog content
|
||||||
|
* Fenced code blocks and syntax highlighting using Pygments
|
||||||
|
* Integrated devserver
|
||||||
|
* Available on PyPI
|
||||||
|
.
|
||||||
|
This is the common documentation package.
|
||||||
35
debian/copyright
vendored
Normal file
35
debian/copyright
vendored
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||||
|
Source: https://github.com/venthur/blag
|
||||||
|
Upstream-Name: blag
|
||||||
|
Upstream-Contact: Bastian Venthur venthur@debian.org
|
||||||
|
|
||||||
|
Files:
|
||||||
|
*
|
||||||
|
Copyright:
|
||||||
|
2022 Bastian Venthur venthur@debian.org
|
||||||
|
License: MIT
|
||||||
|
|
||||||
|
Files:
|
||||||
|
debian/*
|
||||||
|
Copyright:
|
||||||
|
2022 Bastian Venthur <venthur@debian.org>
|
||||||
|
License: MIT
|
||||||
|
|
||||||
|
License: MIT
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
.
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
.
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
25
debian/rules
vendored
Executable file
25
debian/rules
vendored
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/make -f
|
||||||
|
|
||||||
|
# See debhelper(7) (uncomment to enable).
|
||||||
|
# Output every command that modifies files on the build system.
|
||||||
|
#export DH_VERBOSE = 1
|
||||||
|
|
||||||
|
export PYBUILD_DESTDIR=debian/blag
|
||||||
|
export PYBUILD_TEST_ARGS=--no-cov
|
||||||
|
export PYBUILD_NAME=blag
|
||||||
|
|
||||||
|
%:
|
||||||
|
dh $@ --with python3,sphinxdoc --buildsystem=pybuild
|
||||||
|
|
||||||
|
|
||||||
|
# If you need to rebuild the Sphinx documentation:
|
||||||
|
# Add sphinxdoc to the dh --with line.
|
||||||
|
#
|
||||||
|
# And uncomment the following lines.
|
||||||
|
execute_after_dh_auto_build-indep: export http_proxy=127.0.0.1:9
|
||||||
|
execute_after_dh_auto_build-indep: export https_proxy=127.0.0.1:9
|
||||||
|
execute_after_dh_auto_build-indep:
|
||||||
|
PYTHONPATH=. python3 -m sphinx -N -bhtml \
|
||||||
|
docs/ build/html # HTML generator
|
||||||
|
PYTHONPATH=. python3 -m sphinx -N -bman \
|
||||||
|
docs/ build/man # Manpage generator
|
||||||
1
debian/source/format
vendored
Normal file
1
debian/source/format
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
3.0 (native)
|
||||||
@@ -9,3 +9,4 @@ API
|
|||||||
blag.blag
|
blag.blag
|
||||||
blag.markdown
|
blag.markdown
|
||||||
blag.devserver
|
blag.devserver
|
||||||
|
blag.quickstart
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
sphinx==3.5.3
|
sphinx==5.0.0
|
||||||
twine==3.4.1
|
twine==4.0.0
|
||||||
wheel==0.36.2
|
wheel==0.37.1
|
||||||
pytest==6.2.2
|
pytest==7.1.2
|
||||||
pytest-cov==2.11.1
|
pytest-cov==3.0.0
|
||||||
flake8==3.9.0
|
flake8==4.0.1
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
markdown==3.3.4
|
markdown==3.3.7
|
||||||
feedgenerator==1.9.1
|
feedgenerator==2.0.0
|
||||||
jinja2==2.11.3
|
jinja2==3.1.2
|
||||||
pygments==2.8.1
|
pygments==2.12.0
|
||||||
|
|||||||
3
setup.py
3
setup.py
@@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
meta = {}
|
meta = {}
|
||||||
@@ -20,6 +19,8 @@ setup(
|
|||||||
project_urls={
|
project_urls={
|
||||||
'Documentation': 'https://blag.readthedocs.io/',
|
'Documentation': 'https://blag.readthedocs.io/',
|
||||||
'Source': 'https://github.com/venthur/blag',
|
'Source': 'https://github.com/venthur/blag',
|
||||||
|
'Changelog':
|
||||||
|
'https://github.com/venthur/blag/blob/master/CHANGELOG.md',
|
||||||
},
|
},
|
||||||
python_requires='>=3.8',
|
python_requires='>=3.8',
|
||||||
package_data={
|
package_data={
|
||||||
|
|||||||
86
tests/conftest.py
Normal file
86
tests/conftest.py
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
from tempfile import TemporaryDirectory
|
||||||
|
import os
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from blag import blag
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def environment():
|
||||||
|
site = {
|
||||||
|
'base_url': 'site base_url',
|
||||||
|
'title': 'site title',
|
||||||
|
'description': 'site description',
|
||||||
|
'author': 'site author',
|
||||||
|
}
|
||||||
|
env = blag.environment_factory(globals_=dict(site=site))
|
||||||
|
yield env
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def page_template(environment):
|
||||||
|
yield environment.get_template('page.html')
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def article_template(environment):
|
||||||
|
yield environment.get_template('article.html')
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def archive_template(environment):
|
||||||
|
yield environment.get_template('archive.html')
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def tags_template(environment):
|
||||||
|
yield environment.get_template('tags.html')
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def tag_template(environment):
|
||||||
|
yield environment.get_template('tag.html')
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def cleandir():
|
||||||
|
"""Create a temporary workind directory and cwd.
|
||||||
|
|
||||||
|
"""
|
||||||
|
config = """
|
||||||
|
[main]
|
||||||
|
base_url = https://example.com/
|
||||||
|
title = title
|
||||||
|
description = description
|
||||||
|
author = a. u. thor
|
||||||
|
"""
|
||||||
|
|
||||||
|
with TemporaryDirectory() as dir:
|
||||||
|
for d in 'content', 'build', 'static', 'templates':
|
||||||
|
os.mkdir(f'{dir}/{d}')
|
||||||
|
with open(f'{dir}/config.ini', 'w') as fh:
|
||||||
|
fh.write(config)
|
||||||
|
# change directory
|
||||||
|
old_cwd = os.getcwd()
|
||||||
|
os.chdir(dir)
|
||||||
|
yield dir
|
||||||
|
# and change back afterwards
|
||||||
|
os.chdir(old_cwd)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def args(cleandir):
|
||||||
|
|
||||||
|
class NameSpace:
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
for name in kwargs:
|
||||||
|
setattr(self, name, kwargs[name])
|
||||||
|
|
||||||
|
args = NameSpace(
|
||||||
|
input_dir='content',
|
||||||
|
output_dir='build',
|
||||||
|
static_dir='static',
|
||||||
|
template_dir='templates',
|
||||||
|
)
|
||||||
|
yield args
|
||||||
@@ -7,19 +7,13 @@ import pytest
|
|||||||
from blag import blag
|
from blag import blag
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
def test_generate_feed(cleandir):
|
||||||
def outdir():
|
|
||||||
with TemporaryDirectory() as dir:
|
|
||||||
yield dir
|
|
||||||
|
|
||||||
|
|
||||||
def test_generate_feed(outdir):
|
|
||||||
articles = []
|
articles = []
|
||||||
blag.generate_feed(articles, outdir, ' ', ' ', ' ', ' ')
|
blag.generate_feed(articles, 'build', ' ', ' ', ' ', ' ')
|
||||||
assert os.path.exists(f'{outdir}/atom.xml')
|
assert os.path.exists('build/atom.xml')
|
||||||
|
|
||||||
|
|
||||||
def test_feed(outdir):
|
def test_feed(cleandir):
|
||||||
articles = [
|
articles = [
|
||||||
[
|
[
|
||||||
'dest1.html',
|
'dest1.html',
|
||||||
@@ -40,9 +34,9 @@ def test_feed(outdir):
|
|||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
blag.generate_feed(articles, outdir, 'https://example.com/', 'blog title',
|
blag.generate_feed(articles, 'build', 'https://example.com/',
|
||||||
'blog description', 'blog author')
|
'blog title', 'blog description', 'blog author')
|
||||||
with open(f'{outdir}/atom.xml') as fh:
|
with open('build/atom.xml') as fh:
|
||||||
feed = fh.read()
|
feed = fh.read()
|
||||||
|
|
||||||
assert '<title>blog title</title>' in feed
|
assert '<title>blog title</title>' in feed
|
||||||
@@ -66,7 +60,7 @@ def test_feed(outdir):
|
|||||||
assert '<link href="https://example.com/dest2.html"' in feed
|
assert '<link href="https://example.com/dest2.html"' in feed
|
||||||
|
|
||||||
|
|
||||||
def test_generate_feed_with_description(outdir):
|
def test_generate_feed_with_description(cleandir):
|
||||||
# if a description is provided, it will be used as the summary in
|
# if a description is provided, it will be used as the summary in
|
||||||
# the feed, otherwise we simply use the title of the article
|
# the feed, otherwise we simply use the title of the article
|
||||||
articles = [[
|
articles = [[
|
||||||
@@ -78,9 +72,9 @@ def test_generate_feed_with_description(outdir):
|
|||||||
'content': 'content',
|
'content': 'content',
|
||||||
}
|
}
|
||||||
]]
|
]]
|
||||||
blag.generate_feed(articles, outdir, ' ', ' ', ' ', ' ')
|
blag.generate_feed(articles, 'build', ' ', ' ', ' ', ' ')
|
||||||
|
|
||||||
with open(f'{outdir}/atom.xml') as fh:
|
with open('build/atom.xml') as fh:
|
||||||
feed = fh.read()
|
feed = fh.read()
|
||||||
|
|
||||||
assert '<title>title</title>' in feed
|
assert '<title>title</title>' in feed
|
||||||
@@ -180,3 +174,116 @@ def test_environment_factory():
|
|||||||
env = blag.environment_factory(globals_=globals_)
|
env = blag.environment_factory(globals_=globals_)
|
||||||
assert env.globals['foo'] == 'bar'
|
assert env.globals['foo'] == 'bar'
|
||||||
assert env.globals['test'] == 'me'
|
assert env.globals['test'] == 'me'
|
||||||
|
|
||||||
|
|
||||||
|
def test_process_markdown(cleandir, page_template, article_template):
|
||||||
|
page1 = """\
|
||||||
|
title: some page
|
||||||
|
|
||||||
|
some text
|
||||||
|
foo bar
|
||||||
|
"""
|
||||||
|
|
||||||
|
article1 = """\
|
||||||
|
title: some article1
|
||||||
|
date: 2020-01-01
|
||||||
|
|
||||||
|
some text
|
||||||
|
foo bar
|
||||||
|
"""
|
||||||
|
|
||||||
|
article2 = """\
|
||||||
|
title: some article2
|
||||||
|
date: 2021-01-01
|
||||||
|
|
||||||
|
some text
|
||||||
|
foo bar
|
||||||
|
"""
|
||||||
|
|
||||||
|
convertibles = []
|
||||||
|
for i, txt in enumerate((page1, article1, article2)):
|
||||||
|
i = str(i)
|
||||||
|
with open(f'content/{i}', 'w') as fh:
|
||||||
|
fh.write(txt)
|
||||||
|
convertibles.append([i, i])
|
||||||
|
|
||||||
|
articles, pages = blag.process_markdown(
|
||||||
|
convertibles,
|
||||||
|
'content',
|
||||||
|
'build',
|
||||||
|
page_template,
|
||||||
|
article_template
|
||||||
|
)
|
||||||
|
|
||||||
|
assert isinstance(articles, list)
|
||||||
|
assert len(articles) == 2
|
||||||
|
for dst, context in articles:
|
||||||
|
assert isinstance(dst, str)
|
||||||
|
assert isinstance(context, dict)
|
||||||
|
assert 'content' in context
|
||||||
|
|
||||||
|
assert isinstance(pages, list)
|
||||||
|
assert len(pages) == 1
|
||||||
|
for dst, context in pages:
|
||||||
|
assert isinstance(dst, str)
|
||||||
|
assert isinstance(context, dict)
|
||||||
|
assert 'content' in context
|
||||||
|
|
||||||
|
|
||||||
|
def test_build(args):
|
||||||
|
page1 = """\
|
||||||
|
title: some page
|
||||||
|
|
||||||
|
some text
|
||||||
|
foo bar
|
||||||
|
"""
|
||||||
|
|
||||||
|
article1 = """\
|
||||||
|
title: some article1
|
||||||
|
date: 2020-01-01
|
||||||
|
tags: foo, bar
|
||||||
|
|
||||||
|
some text
|
||||||
|
foo bar
|
||||||
|
"""
|
||||||
|
|
||||||
|
article2 = """\
|
||||||
|
title: some article2
|
||||||
|
date: 2021-01-01
|
||||||
|
tags: baz
|
||||||
|
|
||||||
|
some text
|
||||||
|
foo bar
|
||||||
|
"""
|
||||||
|
|
||||||
|
# write some convertibles
|
||||||
|
convertibles = []
|
||||||
|
for i, txt in enumerate((page1, article1, article2)):
|
||||||
|
i = str(i)
|
||||||
|
with open(f'{args.input_dir}/{i}.md', 'w') as fh:
|
||||||
|
fh.write(txt)
|
||||||
|
convertibles.append([i, i])
|
||||||
|
|
||||||
|
# some static files
|
||||||
|
with open(f'{args.static_dir}/test', 'w') as fh:
|
||||||
|
fh.write('hello')
|
||||||
|
|
||||||
|
os.mkdir(f'{args.input_dir}/testdir')
|
||||||
|
with open(f'{args.input_dir}/testdir/test', 'w') as fh:
|
||||||
|
fh.write('hello')
|
||||||
|
|
||||||
|
blag.build(args)
|
||||||
|
|
||||||
|
|
||||||
|
def test_main(cleandir):
|
||||||
|
blag.main(['build'])
|
||||||
|
|
||||||
|
|
||||||
|
def test_cli_version(capsys):
|
||||||
|
with pytest.raises(SystemExit) as ex:
|
||||||
|
blag.main(['--version'])
|
||||||
|
# normal system exit
|
||||||
|
assert ex.value.code == 0
|
||||||
|
# proper version reported
|
||||||
|
out, _ = capsys.readouterr()
|
||||||
|
assert blag.__VERSION__ in out
|
||||||
|
|||||||
@@ -1,30 +1,66 @@
|
|||||||
import time
|
import time
|
||||||
|
import threading
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from tempfile import TemporaryDirectory
|
|
||||||
from blag import devserver
|
from blag import devserver
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
def test_get_last_modified(cleandir):
|
||||||
def tempdir():
|
|
||||||
with TemporaryDirectory() as dir:
|
|
||||||
yield dir
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_last_modified(tempdir):
|
|
||||||
# take initial time
|
# take initial time
|
||||||
t1 = devserver.get_last_modified([tempdir])
|
t1 = devserver.get_last_modified(['content'])
|
||||||
|
|
||||||
# wait a bit, create a file and measure again
|
# wait a bit, create a file and measure again
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
with open(f'{tempdir}/test', 'w') as fh:
|
with open('content/test', 'w') as fh:
|
||||||
fh.write('boo')
|
fh.write('boo')
|
||||||
t2 = devserver.get_last_modified([tempdir])
|
t2 = devserver.get_last_modified(['content'])
|
||||||
|
|
||||||
# wait a bit and take time again
|
# wait a bit and take time again
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
t3 = devserver.get_last_modified([tempdir])
|
t3 = devserver.get_last_modified(['content'])
|
||||||
|
|
||||||
assert t2 > t1
|
assert t2 > t1
|
||||||
assert t2 == t3
|
assert t2 == t3
|
||||||
|
|
||||||
|
|
||||||
|
def test_autoreload_builds_immediately(args):
|
||||||
|
# create a dummy file that can be build
|
||||||
|
with open('content/test.md', 'w') as fh:
|
||||||
|
fh.write('boo')
|
||||||
|
|
||||||
|
t = threading.Thread(target=devserver.autoreload,
|
||||||
|
args=(args, ),
|
||||||
|
daemon=True,)
|
||||||
|
t0 = devserver.get_last_modified(['build'])
|
||||||
|
t.start()
|
||||||
|
# try for 5 seconds...
|
||||||
|
for i in range(5):
|
||||||
|
time.sleep(1)
|
||||||
|
t1 = devserver.get_last_modified(['build'])
|
||||||
|
print(t1)
|
||||||
|
if t1 > t0:
|
||||||
|
break
|
||||||
|
assert t1 > t0
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.filterwarnings("ignore::pytest.PytestUnhandledThreadExceptionWarning") # noqa
|
||||||
|
def test_autoreload(args):
|
||||||
|
t = threading.Thread(target=devserver.autoreload,
|
||||||
|
args=(args, ),
|
||||||
|
daemon=True,)
|
||||||
|
t.start()
|
||||||
|
|
||||||
|
t0 = devserver.get_last_modified(['build'])
|
||||||
|
|
||||||
|
# create a dummy file that can be build
|
||||||
|
with open('content/test.md', 'w') as fh:
|
||||||
|
fh.write('boo')
|
||||||
|
|
||||||
|
# try for 5 seconds to see if we rebuild once...
|
||||||
|
for i in range(5):
|
||||||
|
time.sleep(1)
|
||||||
|
t1 = devserver.get_last_modified(['build'])
|
||||||
|
if t1 > t0:
|
||||||
|
break
|
||||||
|
assert t1 > t0
|
||||||
|
|||||||
@@ -32,6 +32,20 @@ def test_convert_markdown_links(input_, expected):
|
|||||||
assert expected in html
|
assert expected in html
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("input_, expected", [
|
||||||
|
# scheme
|
||||||
|
('[test](https://)', 'https://'),
|
||||||
|
# netloc
|
||||||
|
('[test](//test.md)', '//test.md'),
|
||||||
|
# no path
|
||||||
|
('[test]()', ''),
|
||||||
|
])
|
||||||
|
def test_dont_convert_normal_links(input_, expected):
|
||||||
|
md = markdown_factory()
|
||||||
|
html, _ = convert_markdown(md, input_)
|
||||||
|
assert expected in html
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("input_, expected", [
|
@pytest.mark.parametrize("input_, expected", [
|
||||||
('foo: bar', {'foo': 'bar'}),
|
('foo: bar', {'foo': 'bar'}),
|
||||||
('foo: those are several words', {'foo': 'those are several words'}),
|
('foo: those are several words', {'foo': 'those are several words'}),
|
||||||
@@ -49,3 +63,31 @@ def test_convert_metadata(input_, expected):
|
|||||||
def test_markdown_factory():
|
def test_markdown_factory():
|
||||||
md = markdown_factory()
|
md = markdown_factory()
|
||||||
assert isinstance(md, markdown.Markdown)
|
assert isinstance(md, markdown.Markdown)
|
||||||
|
|
||||||
|
|
||||||
|
def test_smarty():
|
||||||
|
md = markdown_factory()
|
||||||
|
|
||||||
|
md1 = """
|
||||||
|
|
||||||
|
this --- is -- a test ...
|
||||||
|
|
||||||
|
"""
|
||||||
|
html, meta = convert_markdown(md, md1)
|
||||||
|
assert 'mdash' in html
|
||||||
|
assert 'ndash' in html
|
||||||
|
assert 'hellip' in html
|
||||||
|
|
||||||
|
|
||||||
|
def test_smarty_code():
|
||||||
|
md = markdown_factory()
|
||||||
|
|
||||||
|
md1 = """
|
||||||
|
```
|
||||||
|
this --- is -- a test ...
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
html, meta = convert_markdown(md, md1)
|
||||||
|
assert 'mdash' not in html
|
||||||
|
assert 'ndash' not in html
|
||||||
|
assert 'hellip' not in html
|
||||||
|
|||||||
24
tests/test_quickstart.py
Normal file
24
tests/test_quickstart.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
from blag.quickstart import get_input, quickstart
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_input_default_answer(monkeypatch):
|
||||||
|
monkeypatch.setattr('builtins.input', lambda x: '')
|
||||||
|
answer = get_input("foo", "bar")
|
||||||
|
assert answer == 'bar'
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_input(monkeypatch):
|
||||||
|
monkeypatch.setattr('builtins.input', lambda x: 'baz')
|
||||||
|
answer = get_input("foo", "bar")
|
||||||
|
assert answer == 'baz'
|
||||||
|
|
||||||
|
|
||||||
|
def test_quickstart(cleandir, monkeypatch):
|
||||||
|
monkeypatch.setattr('builtins.input', lambda x: 'foo')
|
||||||
|
quickstart(None)
|
||||||
|
with open('config.ini', 'r') as fh:
|
||||||
|
data = fh.read()
|
||||||
|
assert 'base_url = foo' in data
|
||||||
|
assert 'title = foo' in data
|
||||||
|
assert 'description = foo' in data
|
||||||
|
assert 'author = foo' in data
|
||||||
@@ -1,46 +1,5 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
from blag import blag
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def environment():
|
|
||||||
site = {
|
|
||||||
'base_url': 'site base_url',
|
|
||||||
'title': 'site title',
|
|
||||||
'description': 'site description',
|
|
||||||
'author': 'site author',
|
|
||||||
}
|
|
||||||
env = blag.environment_factory(globals_=dict(site=site))
|
|
||||||
yield env
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def page_template(environment):
|
|
||||||
yield environment.get_template('page.html')
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def article_template(environment):
|
|
||||||
yield environment.get_template('article.html')
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def archive_template(environment):
|
|
||||||
yield environment.get_template('archive.html')
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def tags_template(environment):
|
|
||||||
yield environment.get_template('tags.html')
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def tag_template(environment):
|
|
||||||
yield environment.get_template('tag.html')
|
|
||||||
|
|
||||||
|
|
||||||
def test_page(page_template):
|
def test_page(page_template):
|
||||||
ctx = {
|
ctx = {
|
||||||
|
|||||||
Reference in New Issue
Block a user