Plugin pack for render-engine static site generator
Project description
re-plugin-pack
This is a plugin pack for the render-engine static site generator. It currently includes the
following plugins:
Installation
To install just run:
pip install re-plugin-pack
Once installed you can access the plugins by importing re_plugin_pack:
import re_plugin_pack
from re_plugin_pack import <plugin>
LatestEntries
This plugin will add a list of the latest entries for one or more Collections to a given Page.
It can be configured at the Page or Site levels and can be configured to provide the latest entries
for any number of Collections. The entries used are in the sort order as defined in the Collection
object.
Settings
The plugin has the following default settings:
{
"collection": ["url"],
"entries": ["title", "url"],
"pages": ["index"],
"max_entries": 3,
}
collection- a list of attributes to include for the collection.entries- a list of attributes to include for a given entry.pages- a list of pages to add theCOLLECTIONSentry to it'stemplate_vars(Only needed when running as aSiteplugin)max_entries- The maximum number of entries to include for a collection. The default is 3.-1indicates that all entries should be populated.
In addition to the default settings entries can be added for each Collection defining how many
entries it should include:
- Positive integer - Include up to the number specified entries. For example:
'Collection1': 5will include the 5 latest entries in thetemplate_vars. 0- Exclude this collection. For example:'Collection2': 0will not includeCollection2in thetemplate_vars.- Negative integer - Include all entries. For example:
'Collection3': -1will include all entries forCollection3in thetemplate_vars
Page level configuration
To configure at the Page level just include (LatestEntris, <settings_dict) in the plugins
attribute when declaring the Page. If no settings overrides are needed, include LatestEntries
by itself in the plugin attribute.
Example:
from render_engine import Site, Page
from re-plugin-pack import LatestEntries
app = Site()
@app.page
class MyPage(Page):
plugins = [
(
LatestEntries,
{
"Collection1": 5, # Include the 5 most recent entries
"Collection2": 0, # Exclude this collection
"Collection3": -1, # Include all entries in the collection
},
)
]
...
Site level configuration
To configure at the Site level call app.register_plugins(LatestEntries, LatestEntries=<settings>)
if settings overrides are being used. To configure without additional settings, call
app.register_plugin(LatestEntries).
Example:
from render_engine import Site, Page
from re-plugin-pack import LatestEntries
app = Site()
# The following will use the default settings overriding the pages to run on to be page1 and page2
app.register_plugins(LatestEntries, LatestEntries={'pages': ['page1', 'page2']})
# The following will only enable for the Blog collection:
app.register_plugins(LatestEntries, LatestEntries={'max_entries': 0, 'Blog': 3})
NOTE: If configuring at the Site level the registration should be done after adding all
Page entries to the Site. When adding a Page to a Site all plugins registered to the
Site are automatically registered to the new Page object.
Including in the Page template
The latest entries will be added to the COLLECTIONS key of the template_vars for the Page
and can be accessed in the template as COLLECTIONS.
Example template implementation:
{% for collection, collection_data in COLLECTIONS.items() %}
Most recent <a href="{{ collection_data['url'] }}">{{ collection }}</a> entries:
<ul>
{% for entry in collection_data['entries'] %}
<li><a href="{{ entry['url'] }}">{{ entry['title'] }}</a></li>
{% endfor %}
</ul>
{% endfor %}
NextPrevPlugin
This plugin will give each page in a Collection access to certain attributes of the next and
previous pages in the collection. By default, only the URL and title of those pages will be
made available, however additional attributes may also be requested via the settings. If an
attributes is in the list to include but does not exist in the page(s) None will be used.
This plugin runs at the Collection level and can be registered at the Site or Collection
level.
Settings
This plugin has no default settings. If you wish to add additional attributes, include in the
registration a settings dictionary with a key of additional_attributes having a list of
attributes as its value.
Site level configuration
To configure at the Site level call app.register_plugins(NextPrevPlugin, NextPrevPlugin=<settings>)
if settings overrides are being used. To configure without additional settings, call
app.register_plugin(NextPrevPlugin).
Example:
from render_engine import Site, Page
from re-plugin-pack import NextPrevPlugin
app = Site()
# The following will include the date attribute in in the data made available.
app.register_plugins(NextPrevPlugin, NextPrevPlugin={'additional_attributes': ['date']})
# The following will not include any additional attributes
app.register_plugins(NextPrevPlugin)
NOTE: If configuring at the Site level the registration should be done after adding all
Collection entries to the Site. When adding a Collection to a Site all plugins
registered to the Site are automatically registered to the new Collection object.
Collection level configuration
To configure at the Page level just include (NextPrevPlugin, <settings_dict) in the plugins
attribute when declaring the Collection. If no settings overrides are needed, include
NextPrevPlugin by itself in the plugin attribute.
Example:
from render_engine import Site, Page
from re-plugin-pack import NextPrevPlugin
app = Site()
@app.page
class MyPage(Page):
plugins = [
(
NextPrevPlugin,
{
'additional_attributes': [ # This will make the date and description attributes available
'date',
'description',
]
},
)
]
...
Including in the Collection template
When run this plugin will add a dictionary with the requested data to the template_vars of
each page in the Collection. The dictionary added looks like:
{
'collection_url': <url>,
'collection_title': <title>,
'next_url': <url>,
'next_title': <title>,
'prev_url': <url>,
'prev_title': <title>,
}
If additional_attributes are included in the settings, they will be in the dictionary as:
prev_<attr>: <value> and next_<attr>: <value>.
{% if prev_url %}
<span class="prev_data">
Previous: <a href="{{ prev_url }}">{{ prev_title }}</a>
</span>
{% endif %}
{% if next_url %}
<span class="next_data">
Next: <a href="{{ next_url }}">{{ next_title }}</a>
</span>
{% endif %}
Drafts
This is a plugin that will skip pages in a Collection that are marked as draft. This allows
you to have WIP posts and still make changes to other things without publishing things that are
not ready to be posted.
Settings
The Drafts plugin has a single setting:
{
'show_drafts': True,
}
When show_drafts is set to False the plugin will run, prior to rendering the Collection
and remove all pages in the collection that have a True value for the draft attribute will
not be rendered when building the site. This plugin runs at the Collection level and can be
registered either Site-wide or for individual collections.
NOTE: Plugins run in the reverse order of registration. If you are using both this and
NextPrevPlugin make sure that you register NextPrevPlugin (or any similar
plugin) before you register Drafts or you might have unexpected results as pages that were
processed will have been removed.
Making sure that drafts show locally but not on your production site
In order to have this work effectively, so that you can see the draft posts locally when you
use render-engine serve, you will need to differentiate between the environments. To
accomplish this you can use an environment variable and add this line of code into your
app.py:
import os
ENABLE_DRAFTS = {"show_drafts": os.environ.get("SHOW_DRAFTS", False)}
When you register the plugin make sure to include the ENABLE_DRAFTS as the settings
for the plugin:
import os
from re_plugin_pack import Drafts
from render_engine import Site, Collection
ENABLE_DRAFTS = {"show_drafts": os.environ.get("SHOW_DRAFTS", False)}app=Site()
# Either at the `Site` level:
app.register_plugins(Drafts, Drafts=ENABLE_DRAFTS)
# Or at the `Collection` level:
@app.collection
class MyCollection(Collection):
plugins=[(Drafts, ENABLE_DRAFTS)]
...
Using Drafts with NextPrevPlugin (or other, similar, Collection level plugins)
Make sure that you register plugins in the order that you want them to run. Remember that
any plugin that is registered with the Site prior to creating the Collection is included
in the Collection the will have been registered first and will run after plugins that
are registered at the Collection level. Since plugins are invoked in the reverse order
of registration Drafts should be the last plugin run for a Collection.
Example registration:
import os
from re_plugin_pack import Drafts, NextPrevPlugin
from render_engine import Site, Collection
ENABLE_DRAFTS = {"show_drafts": os.environ.get("SHOW_DRAFTS", False)}app=Site()
@app.collection
class MyCollection(Collection):
plugins = [
NextPrevPlugin,
(Drafts, ENABLE_DRAFTS),
]
The above order will run the Drafts plugin first on that collection.
Marking a post as a draft
To mark a post as a draft just add a truthy value for the draft attribute to the content:
---
title: WIP Post
date: 2025-06-01T02:49:18
draft: Yes
---
This is a draft post
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file re_plugin_pack-2025.6.1b4.tar.gz.
File metadata
- Download URL: re_plugin_pack-2025.6.1b4.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
727d27d6a38d198058659a12c7e939a520c2ae79b637fe34decc11f0a6ea511d
|
|
| MD5 |
5039d4cfe1e56ab4f3f2455e8c326afa
|
|
| BLAKE2b-256 |
af72a669c812aabb28561846b46faff5d920bd85ee09e0ec8c7f6393d2a8f079
|
Provenance
The following attestation bundles were made for re_plugin_pack-2025.6.1b4.tar.gz:
Publisher:
publish.yml on brass75/re_plugin_pack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
re_plugin_pack-2025.6.1b4.tar.gz -
Subject digest:
727d27d6a38d198058659a12c7e939a520c2ae79b637fe34decc11f0a6ea511d - Sigstore transparency entry: 242406539
- Sigstore integration time:
-
Permalink:
brass75/re_plugin_pack@9f8483ae0ff171d0cbf08a80ac4df71f780baf48 -
Branch / Tag:
refs/tags/2025.6.1b4 - Owner: https://github.com/brass75
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9f8483ae0ff171d0cbf08a80ac4df71f780baf48 -
Trigger Event:
release
-
Statement type:
File details
Details for the file re_plugin_pack-2025.6.1b4-py3-none-any.whl.
File metadata
- Download URL: re_plugin_pack-2025.6.1b4-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa9c093abf6e1d79e751ef143c147b0213b481db8db64626f735fffebdb854d6
|
|
| MD5 |
77741c390620cc34b856fe29691ce581
|
|
| BLAKE2b-256 |
3fc6f4ad179a5e9964e75f1954a4aba0cbbe51184b7a8a16950f13395a59f012
|
Provenance
The following attestation bundles were made for re_plugin_pack-2025.6.1b4-py3-none-any.whl:
Publisher:
publish.yml on brass75/re_plugin_pack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
re_plugin_pack-2025.6.1b4-py3-none-any.whl -
Subject digest:
aa9c093abf6e1d79e751ef143c147b0213b481db8db64626f735fffebdb854d6 - Sigstore transparency entry: 242406551
- Sigstore integration time:
-
Permalink:
brass75/re_plugin_pack@9f8483ae0ff171d0cbf08a80ac4df71f780baf48 -
Branch / Tag:
refs/tags/2025.6.1b4 - Owner: https://github.com/brass75
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9f8483ae0ff171d0cbf08a80ac4df71f780baf48 -
Trigger Event:
release
-
Statement type: