summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2021-06-04 22:13:44 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2021-06-04 22:13:44 -0600
commit11b9e8505b8a92555cce6615f19268a620e9ce53 (patch)
treee39ce9da68045d7aa6c5cde7f09e2b5185262d18 /README.md
parent30607ae87ed36289d860a41f8027900bebeec1e8 (diff)
refactor and add support for jinija
Diffstat (limited to 'README.md')
-rw-r--r--README.md58
1 files changed, 50 insertions, 8 deletions
diff --git a/README.md b/README.md
index 59a1333..80bbe65 100644
--- a/README.md
+++ b/README.md
@@ -9,15 +9,15 @@ I'm writing this in *pYtHoN* (thought about doing it in Go, but I'm most comfort
**This is still a WIP. Still doesn't build `sitemap.xml` or `rss.xml` files.**
- [x] Build static site parsing `markdown` files ( `*.md` -> `*.html`)
- - [x] Using plain `*.html` files for templates.
- - [ ] Would like to change to something more flexible and easier to manage ([`jinja`](https://jinja.palletsprojects.com/en/3.0.x/), for example).
- - [x] Preserves hand-made `*.html` files.
- - [x] Tag functionality.
- - [ ] Open Graph (and similar) support.
+ - [x] ~~Using plain `*.html` files for templates.~~ Changed to Jinja templates.
+ - [x] Would like to change to something more flexible and easier to manage ([`jinja`](https://jinja.palletsprojects.com/en/3.0.x/), for example).
+ - [x] Preserves hand-made `*.html` files.
+ - [x] Tag functionality.
+ - [ ] Open Graph (and similar) support.
- [x] Build `sitemap.xml` file.
- [x] Build `rss.xml` file.
- [x] Only build page if `*.md` is new or updated.
- - [ ] Extend this to tag pages and index (right now all tags and index is built no matter if no new/updated file is present).
+ - [ ] Extend this to tag pages and index (right now all tags and index is built no matter if no new/updated file is present).
- [x] Configuration file as an alternative to using command line flags (configuration file options are prioritized).
### Markdown features
@@ -51,9 +51,9 @@ First initialize the directories you're going to use for the source files and de
pyssg -s src_dir -d dst_dir -i
```
-That creates the desired directories with the basic templates that can be edited as desired. Place your `*.md` files somewhere inside the source directory (`src_dir` in the command above), but outside of the `templates` directory. It accepts sub-directories.
+That creates the desired directories with the basic templates that can be edited as desired (see variables available for Jinja below). Place your `*.md` files somewhere inside the source directory (`src_dir` in the command above), but outside of the `templates` directory. It accepts sub-directories.
-Strongly recommended to edit `rss.xml` template under `rss` directory, since it has a lot of placeholder values.
+Strongly recommended to edit the `rss.xml` template.
Build the site with:
@@ -64,3 +64,45 @@ pyssg -s src_dir -d dst_dir -u https://base.url -b
That creates all `*.html` for the site and can be easily moved to the server. Here, the `-u` flag is technically optional in the sense that you'll not receive a warning/error, but it's used to prepend links with this URL (not strictly required everywhere), so don't ignore it; also don't include the trailing `/`.
For now, the `-b`uild tag also creates the `rss.xml` and `sitemap.xml` files based on templates including only all converted `*.md` files (and processed tags in case of the sitemap), meaning that separate `*.html` files should be included manually in the template.
+
+For more options/flags just checkout `pyssg -h`.
+
+## Available Jinja variables
+
+Here is the list of variables that you can use specific Jinja templates with a short description. Note that all urls are without the trailing slash `/`.
+
+- General:
+ - `site_title` (`str`) (all): title of the website.
+ - `site_base_url` (`str`) (all): base url of the website.
+ - `site_base_static_url` (`str`) (all): base static url where all static files are located, mostly needed for correct rss feed generator when using a `base` tag and using relative links to files. For more, see [<base>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base).
+ - `pyssg_version` (`str`) (all): version in numeric form, i.e. `0.5.0`.
+ - `run_date` (`str`) (all): date when the program was run, with format required for rss.
+- Pages:
+ - `all_pages` (`list(Page)`) (all): list of all the pages, sorted by creation time, reversed.
+ - `page` (`Page`) (`page.html`): page object that contains the following attributes:
+ - `title` (`str`): title of the page.
+ - `author` (`str`): author of the page.
+ - `content` (`str`): actual content of the page.
+ - `cdatetime` (`str`): creation datetime object of the page.
+ - `cdate` (`str`): formatted `cdatetime` as the configuration option `DATE_FORMAT`.
+ - `cdate_list` (`str`): formatted `cdatetime` as the configuration option `LIST_DATE_FORMAT`.
+ - `cdate_list_sep` (`str`): formatted `cdatetime` as the configuration option `LIST_SEP_DATE_FORMAT`.
+ - `cdate_rss` (`str`): formatted `cdatetime` as required by rss.
+ - `cdate_sitemap` (`str`): formatted `cdatetime` as required by sitemap.
+ - `mdatetime` (`str`): modification datetime object of the page. Defaults to None.
+ - `mdate` (`str`): formatted `mdatetime` as the configuration option `DATE_FORMAT`. Defaults to None.
+ - `mdate_list` (`str`): formatted `mdatetime` as the configuration option `LIST_DATE_FORMAT`.
+ - `mdate_list_sep` (`str`): formatted `mdatetime` as the configuration option `LIST_SEP_DATE_FORMAT`.
+ - `mdate_rss` (`str`): formatted `mdatetime` as required by rss.
+ - `mdate_sitemap` (`str`): formatted `mdatetime` as required by sitemap.
+ - `summary` (`str`): summary of the page, as specified in the `*.md` file.
+ - `lang` (`str`): page language, used for the general `html` tag `lang` attribute.
+ - `tags` (`list(tuple(str))`): list of tuple of tags of the page, containing the name and the url of the tag, in that order. Defaults to empty list.
+ - `url` (`str`): url of the page, this already includes the `site_base_url`.
+ - `next/previous` (`Page`): reference to the next or previous page object (containing all these attributes). Defaults to None
+ - `og` (`dict(str, str)`): dict for object graph metadata.
+ - `meta` (`dict(str, list(str))`): meta dict as obtained from python-markdown, in case you use a meta tag not yet supported, it will be available there.
+- Tags:
+ - `tag` (`tuple(str)`) (`tag.html`): tuple of name and url of the current tag.
+ - `tag_pages` (`list(Page)`) (`tag.html`): similar to `all_pages` but contains all the pages for the current tag.
+ - `all_tags` (`list(tuple(str))`) (all): similar to `page.tags` but contains all the tags.