Skip to main content

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:

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 the COLLECTIONS entry to it's template_vars (Only needed when running as a Site plugin)
  • max_entries - The maximum number of entries to include for a collection. The default is 3. -1 indicates 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': 5 will include the 5 latest entries in the template_vars.
  • 0 - Exclude this collection. For example: 'Collection2': 0 will not include Collection2 in the template_vars.
  • Negative integer - Include all entries. For example: 'Collection3': -1 will include all entries for Collection3 in the template_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 %}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

re_plugin_pack-2025.6.1b1.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

re_plugin_pack-2025.6.1b1-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file re_plugin_pack-2025.6.1b1.tar.gz.

File metadata

  • Download URL: re_plugin_pack-2025.6.1b1.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for re_plugin_pack-2025.6.1b1.tar.gz
Algorithm Hash digest
SHA256 12a6af73d688fdb21247c5fda27dbeb1086184f1beeeb70ce28d6b60043ad84d
MD5 d0949e18d352129182cd05445cacde7f
BLAKE2b-256 53bcd354079be9476e3c1c7ed7089aa2230686efbbe86edafdc0b021e24dab04

See more details on using hashes here.

Provenance

The following attestation bundles were made for re_plugin_pack-2025.6.1b1.tar.gz:

Publisher: publish.yml on brass75/re_plugin_pack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file re_plugin_pack-2025.6.1b1-py3-none-any.whl.

File metadata

File hashes

Hashes for re_plugin_pack-2025.6.1b1-py3-none-any.whl
Algorithm Hash digest
SHA256 348779c8a71a0ed78f03f6def573f1cc1efe0310af1850efedee974e6f3e3eb1
MD5 aaae8874620c66b3a2158773865b4d56
BLAKE2b-256 8e2de6110b6673bad825a6f97d90dbd0afba5ff505a203cfbae8e0d273e98a6a

See more details on using hashes here.

Provenance

The following attestation bundles were made for re_plugin_pack-2025.6.1b1-py3-none-any.whl:

Publisher: publish.yml on brass75/re_plugin_pack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page