Some processors for FolderCompiler to compile a static website
This static website generator is meant to generate simple webpages as simple as possible by mainly applying a markdown generator and jinjer templates in an organized way. The general assumption is, that every output file only requires a single input file (+template). You just specify which Processor is applied for which files (e.g., the MarkdownProcessor for all files ending with ".md" in the input directory).
See also the base project folder_compiler.
Principles
- The primary focus is to apply a template to content files (e.g. a navigation bar).
- Keep it super simple (I update my webpage maybe every year and don't want it to take much knowledge that I immediately forget afterwards)
- Keep it open (especially do not hide jinja)
- Allow more complex behavior where possible without increasing the complexity of the generator (actually, this is included in the previous point).
Processors
A processor gets an input file (e.g., a markdown file) and compiles it to an arbitrary amount of output files.
It is very simple to create your own processor (e.g., for automatically compressing every jpg into _small, _medium, and _large). For the cases I need myself, a set of processors is already provided:
- HtmlProcessor: Simply passes the content to a jinjer template (thus, file content must already be html readable)
- MarkdownProcessor: Parses a markdown file including metadata and lets a jinjer template render it.
- BibtexProcessor: Parses a bibtex file and lets a jinjer template create a nice bibliography.
- FileCopyProcessor: Simply copies a file (Part of FolderCompiler)
- DevNullProcessor: Ignores files (Part of FolderCompiler)
Example
See in the following example, how simple it is to configure:
import jinja2 as jinja2
from folder_compiler import FolderCompiler
from folder_compiler.processors import FileCopyProcessor
from static_webpage_folder_compiler import MarkdownProcessor
# Create jinja2 environment as powerful template engine
# ./template holds the template files in this case
jinja = jinja2.Environment(
loader=jinja2.FileSystemLoader('./templates'),
)
# jinja templates (see example folder)
md_template = jinja.get_template("markdown_default.html")
# Processors
processors = [
MarkdownProcessor(md_template).add_include(".*.md"), # apply to all *.md files
FileCopyProcessor().add_exclude(".*/\..*") # copy the rest (except hidden files)
]
# Compile the files in the folder ./content to ./output
FolderCompiler(input="./content", output="./output").compile(processors).remove_orphaned_files()
A complete example can be found in ./example/simple_researcher_profile.
But if you want to do something complex like a blog, try something more advanced like Hyde.
Metadata
Release files for folder-compiler-static-website 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| folder_compiler_static_website-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Release files / folder_compiler_static_website-0.1.4-py3-none-any.whl
| Download URL | folder_compiler_static_website-0.1.4-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ed7edf2b1b76c545ec06381a58b0fc3f23bcf7bb59b2f10a43267be1d2b957d
|
|
BLAKE2b-256 checksum How to use checksums |
24a4b343b9c9f2293a180170c394423dcf1dee2859a53849eb40d62422413a0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.4
|
Security for folder-compiler-static-website 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.