Skip to content

mabadir/kirby_publisher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Kirby Publisher

Kirby Publisher a PHP publishing script for Kirby.

Introduction

Kirby Publisher is a PHP class that scans the Kirby content directory, and looks inside each article directory for the blogarticle.txt file, if the file contains a specific YAML variable published with value Publish, Kirby Publisher will ensure the article is published (i.e. precedes the directory name with a number). On the other hand, if the variable value is Draft the article directory is drafted (i.e. the number preceding the article name is removed if exists).

Features

The initial version hosts some basic features to streamline the process:

  1. Automatic article numbering; Kirby Publisher will detect the latest article ID used, and assign an incremented ID to the next published article.
  2. Reserve IDs across articles, once an ID is reserved to an article, it will not be assigned to another article.
  3. Configurable YAML variables, if you are already using a similar YAML variable, no need to configure a new one.
  4. Backward compatible with old posts, even if the YAML variable is not defined for old articles, it can still process new ones.

Configuration

In order to run Kirby Publisher, a helper script is developed on PHP as well. Kirby Publisher can be used within any application, it required the following configuration parameters:

$CONTENT_PATH // This is the Kirby content directory, where the articles are hosted. $TOOLKIT_PATH // This is the Kirby toolkit path. $DIRECTORY_DIGITS = 4 // This is the number of digits used in directory names, for example, 0012-kirby-publisher (Default = 4). $YAML_DIRECTIVE="published" //This is the YAML variable name to be used (Default = published) $PUBLIHSED_VALUE="Publish" //This is the value Kirby Publisher will check to Publish the article (Default = Publish). $DRAFT_VALUE="Draft" // This is the value Kirby Publisher will check to Draft the article (Default = Draft).

In order to run Kirby Publisher, from any PHP script initialize an object passing all the configuration parameters above.

$kirby_publisher = new kirby_publisher($CONTENT_PATH,$TOOLKIT_PATH,$DIRECTORY_DIGITS,$YAML_DIRECTIVE,$PUBLISHED_VALUE,$DRAFT_VALUE);

Only the first two parameters are mandatory, the rest are optional, and the object will be initialized with their default values.

Run Kirby Publisher

In order to do the magic, just call the update_published_status() method.

$kirby_publisher->update_published_status();

About

PHP script to publish new posts as needed for Kirby.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages