Code Monkey home page Code Monkey logo

pelican-granular-signals's Introduction

pelican-granular-signals

Ensure that your Pelican plugin is called at the right time, every time.


Love Pelican but hate that your finalization plugin isn't always called in the right order? Don't let your plugin get lost in the shuffle of the finalized signal! pelican-granular-signals adds new finalization signals that guarantee your plugin is called at the right time, every time.

New Pelican signals

When pelican-granular-signals is installed, the following signals will be called immediately after the finalized signal:

  • sitemap
  • optimize
  • minify
  • compress
  • deploy

Each signal will be sent with the same argument that is sent to the finalized signal.

Connecting to granular signals

Your plugin must register with blinker directly. Here's a complete example:

import blinker

import pelican.plugins.granular_signals


def register():
    # This line is highly recommended so users
    # don't have to update their configurations.
    pelican.plugins.granular_signals.register()

    # Connect your awesome plugin to a granular signal.
    blinker.signal("deploy").connect(deploy_site)


# -----------------------------------------------------
# Put your awesome plugin code here.

import subprocess

def deploy_site(instance):
    subprocess.run(instance.settings["DEPLOY_COMMAND"])

Helping users out

To make life easier for users, consider taking these two steps:

  1. List pelican-granular-signals as a dependency so it will be automatically installed with your plugin.
  2. When Pelican calls your plugin's register() function, call pelican.plugins.granular_signals.register().

Pelican 4.5 introduced a new, automatic plugin loading feature and pelican-granular-signals is designed to work with this feature! Unfortunately, if a user specifies which plugins to load in their configuration file then automatic plugin loading will be disabled. It is therefore recommended that you call pelican.plugins.granular_signals.register() in your plugin's register() function.

pelican.plugins.granular_signals.register() can be called multiple times without creating any problems.

pelican-granular-signals's People

Contributors

dependabot[bot] avatar kurtmckee avatar pre-commit-ci[bot] avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.