Git Product home page Git Product logo

grav-plugin-scheduler's Introduction

Scheduler Plugin

Abandonment Notice: I'm afraid I simply don't have the time to maintain my Grav themes and plugins. Those interested in taking over should refer to the "Abandoned Resource Protocol". Feel free to fork and replace. So long, and thanks for all the fish.

The Scheduler Plugin is for Grav CMS. It's a simple content scheduler that hides/shows content in a page based on the date.

A demo is available.

Installation

Installing the Scheduler plugin can be done in one of two ways. The GPM (Grav Package Manager) installation method enables you to quickly and easily install the plugin with a simple terminal command, while the manual method enables you to do so via a zip file.

GPM Installation (Preferred)

The simplest way to install this plugin is via the Grav Package Manager (GPM) through your system's terminal (also called the command line). From the root of your Grav install type:

bin/gpm install scheduler

This will install the Scheduler plugin into your /user/plugins directory within Grav. Its files can be found under /your/site/grav/user/plugins/scheduler.

Manual Installation

To install this plugin, just download the zip version of this repository and unzip it under /your/site/grav/user/plugins. Then, rename the folder to scheduler. You can find these files on GitHub or via GetGrav.org.

You should now have all the plugin files under

/your/site/grav/user/plugins/scheduler

NOTE: This plugin is a modular component for Grav which requires Grav and the Error and Problems plugins to operate.

Configuration

Before configuring this plugin, you should copy the user/plugins/scheduler/scheduler.yaml to user/config/plugins/scheduler.yaml and only edit that copy.

Here is the default configuration and an explanation of available options:

enabled: true
active: false
  • enabled turns the plugin off and on. If set to false, then no codes will processed at all.

  • active lets you run the plugin on a page-by-page basis. Usually you set it to false in the main config, and then in pages with time-sensitive content, you put the following in the header:

      scheduler:
        active: true

Usage

This is a simple and naive content scheduler. It assumes that caching is disabled. While this plugin uses what looks like shortcodes, it does not extend the Shortcode Core infrastructure. For maximum speed, it processes the page content before the Markdown and shortcode parsers see it.

Nesting is not currently supported.

The plugin looks for content surrounded by the following codes:

[scheduler ...]
Time-sensitive content
[/schedule]

The shortcode accepts two options:

  • notbefore is the date before which the contained content should not be displayed.

  • notafter is the date after which the contained content should not be displayed.

The dates are parsed by PHP's strtotime (docs), so the dates can be in any format that function understands.

Here are a few sample codes:

  • [scheduler notbefore="2016-01-01"] (date without a time stamp; midnight assumed)
  • [scheduler notafter="2016-01-01T09:00:00"] (ISO format)
  • [scheduler notbefore="2016-01-01 09:00:00"] (almost ISO format)
  • [scheduler notafter="1 December 2016"] (text date)

A live demo is available on my website.

NOTE: This plugin uses regular expressions and is relatively fragile. The matching is case insensitive, but extraneous spaces at the beginning and end of tags will cause problems.

Credits

This plugin was developed as a proof of concept for issue #1176.

Todo

  • Add nesting support

grav-plugin-scheduler's People

Contributors

perlkonig avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

sshyran

grav-plugin-scheduler's Issues

Scheduler not working with Grav Email plugin?

I am trying to use the email plugin https://github.com/getgrav/grav-plugin-email I know the queue works because I can observe the emails getting added in the file system, and flushing the queue sends the emails correctly.

Which leads me to believe the scheduler is not correctly being populated. I believe I can confirm this because I do not see anything inside /user/data/scheduler when i send an email that is added to queue.

Grav: v1.6.6
Admin Panel: v1.9.2
Email: v3.0.1
Scheduler: v1.0.0
Php: 7.2

Any thoughts?

Doesn't work

Tried this plugin but haven't got it to work ???
The bracets always appear as if the plugin would not read them.

The following code block should appear until January 1, 2017.

[scheduler notafter="2016-12-31"]

Can you see me?

[/scheduler]

The following code block should not appear until December 1, 2016.

[scheduler notbefore="1 December 2016"]

Can you see me?

[/scheduler]

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.