Commit graph

75 commits

Author SHA1 Message Date
Daniel Rudolf
6c746fabb6
Fix DummyPlugin declaring API version 3 2020-04-10 23:14:33 +02:00
Daniel Rudolf
c99f3cbbdf
Update @version phpDoc class docs 2019-11-11 19:02:11 +01:00
Daniel Rudolf
87ced8c8bd
Improve phpDoc class docs 2019-10-01 13:29:16 +02:00
Daniel Rudolf
b27b4f388a
🎉 Add Pico theme API versioning and add pico-theme.yml
- Add pico-theme.yml with a theme's API version, theme-specific default Twig config, registering theme-specific custom meta headers and defaults for Pico's `theme_config` config
- Add new `onThemeLoading(&$theme)` and `onThemeLoaded($theme, $themeApiVersion, &$themeConfig)` events
- Enable Twig autoescaping by default
2019-09-22 18:49:37 +02:00
Daniel Rudolf
17aba01513
Various small improvements 2019-09-12 12:42:01 +02:00
Daniel Rudolf
eca06a38a9
phpDoc class docs: Remove superflous @return void 2019-09-12 12:38:59 +02:00
Daniel Rudolf
bb1b8639bd
Add Pico::getUrlFromPath() and Pico::getAbsoluteUrl(), replacing Pico::getBaseThemeUrl() 2019-04-30 15:26:31 +02:00
Daniel Rudolf
afd0a4d7a3
Change AbstractPicoPlugin::$enabled's behavior
AbstractPicoPlugin::$enabled now defaults to NULL what leaves the decision whether a plugin should be enabled or disabled by default up to Pico (precisely AbstractPicoPlugin::triggerEvent()). If all dependencies of a plugin are fulfilled, Pico enables the plugin by default. Otherwise the plugin is silently disabled (this was the behavior when AbstractPicoPlugin::$enabled was set to TRUE previously).

If a plugin should never be disabled *silently* (e.g. when dealing with security-relevant stuff like access control, or similar), set AbstractPicoPlugin::$enabled to TRUE. If Pico can't fulfill all the plugin's dependencies, it will throw an RuntimeException.

If a plugin rather does some "crazy stuff" a user should really be aware of before using it, you can set AbstractPicoPlugin::$enabled to FALSE. The user will then have to enable the plugin manually. However, if another plugin depends on this plugin, it might get enabled silently nevertheless.

No matter what, the user can always explicitly enable or disable a plugin in Pico's config.
2017-12-27 21:36:08 +01:00
Daniel Rudolf
28d2648ba0
Add Pico::buildPageTree()
Pico's page tree is a list of all the tree's branches (no matter the depth). Thus, by iterating a array element, you get the nodes of a given branch. All leaf nodes do represent a page, but inner nodes may or may not represent a page (e.g. if there's a `sub/page.md`, but neither a `sub/index.md` nor a `sub.md`, the inner node `sub`, that is the parent of the `sub/page` node, represents no page itself).

A page's file path describes its node's path in the tree (e.g. the page `sub/page.md` is represented by the `sub/page` node, thus a child of the `sub` node and a element of the `sub` branch). However, the index page of a folder (e.g. `sub/index.md`), is *not* a node of the `sub` branch, but rather of the `/` branch. The page's node is not `sub/index`, but `sub`. If two pages are described by the same node (e.g. if both a `sub/index.md` and a `sub.md` exist), the index page takes precedence. Pico's main index page (i.e. `index.md`) is represented by the tree's root node `/` and a special case: it is the only node of the `` (i.e. the empty string) branch.

A node is represented by an array with the keys `id`, `page` and `children`. The `id` key contains a string with the node's name. If the node represents a page, the `page` key is a reference to the page's data array. If the node is a inner node, the `children` key is a reference to its matching branch (i.e. a list of the node's children). The order of a node's children matches the order in Pico's pages array.

If you want to walk the whole page tree, start with the tree's root node at `$pageTree[""]["/"]`. The root node's `children` key is a reference to the `/` branch at `$pageTree["/"]`, that is a list of the root node's direct child nodes and their siblings.

You MUST NOT iterate the page tree itself (i.e. the list of the tree's branches), its order is undefined and the array will be replaced by a non-iterable data structure with Pico 3.0.
2017-11-18 18:34:57 +01:00
Daniel Rudolf
f5f38a7b0b
DummyPlugin: Improve phpDoc class docs 2017-11-18 18:27:20 +01:00
Daniel Rudolf
61319b011e
Add license/copyright file header; improve phpDoc class docs 2017-10-19 21:55:41 +02:00
Daniel Rudolf
d8a649e6f7
Don't lower meta data unsolicited and flip meta headers array
Don't lower unregistered meta headers on the first level unsolicited (e.g. `SomeNotRegisteredKey: foobar` in the YAML Frontmatter should result in `['SomeNotRegisteredKey']`, not `['somenotregisteredkey']`). Furthermore, Pico no longer compares registered meta headers in a case-insensitive manner. However, you can now register multiple search strings that are used to find a registered meta header. This is achieved by flipping the meta headers array: Pico 2.0 uses the array key to search for a meta value and the array value to store the found meta value. Previously it was the other way round (what didn't make much sense...).
2017-10-14 23:12:16 +02:00
Daniel Rudolf
151908fbad
Remove various event params that are a bit out of place 2017-10-14 22:08:11 +02:00
Daniel Rudolf
de74e7d867
Improve class docs 2017-07-14 20:50:38 +02:00
Daniel Rudolf
b098e22033
Various small improvements 2017-05-14 01:26:38 +02:00
Daniel Rudolf
d26da62bf1
Add onSinglePageContent event 2017-05-14 01:26:29 +02:00
Daniel Rudolf
80c88f2a7d
Refactor onMetaHeaders event 2017-05-14 01:25:10 +02:00
Daniel Rudolf
624310bbe7
Various small improvements 2017-05-13 18:17:58 +02:00
Daniel Rudolf
191f6edbe9
Don't pass the $plugins argument of the onPluginsLoaded event by reference
This is a BC breaking change!

Manipulating Pico's $plugins array is a really bad idea. We've introduced the Pico::loadPlugin() method to safely load plugins at any time, however, Pico might do unexpected things when loading plugins too late. See the class docs of Pico::loadPlugin() for more details. Nevertheless, this change breaks BC to Pico 1.0. However, I don't know a single plugin that relies on manipulating the $plugins array. If you just want to load a plugin manually, use Pico::loadPlugin() instead.
2017-05-13 18:17:19 +02:00
Daniel Rudolf
6e28a51080
Refactor onPages… and onPage… core events
Add new onPagesDiscovered event passing the unsorted pages array, move the $currentPage, $previousPage and $nextPage arguments from the onPagesLoaded event to the new onCurrentPageDiscovered event, remove the $twig argument from the onPageRendering event and rather trigger the new onTwigRegistered event for this. Also add the new onYamlParserRegistered and onParsedownRegistered events passing the YAML parser resp. the Parsedown instance. Allow plugin's to skip a page by setting the $id argument of the onSinglePageLoading event to NULL.
2017-05-13 18:08:54 +02:00
Daniel Rudolf
7b222b03e4
Add Pico::API_VERSION 2017-05-10 17:00:48 +02:00
Daniel Rudolf
e8e60f49e5
Update DummyPlugin 2017-05-07 14:15:24 +02:00
Daniel Rudolf
cbb8ece579
Move PicoDeprecated plugin and default theme to separate repos
See https://github.com/picocms/pico-theme for Pico's default theme and https://github.com/picocms/pico-deprecated for the PicoDeprecated plugin.
2017-05-01 22:12:18 +02:00
Daniel Rudolf
82a342ba44
Various small improvements 2017-05-01 15:12:13 +02:00
Daniel Rudolf
9b7523b9e8
Use .yml files to configure Pico
Instead of using `*.config.php` files, use `*.yml` files to configure Pico. YAML is much easier to understand, more user friendly and (at least a bit) more error-tolerant, but still very powerful. Don't break BC by letting `PicoDeprecated` still read `config/config.php`.
2017-02-05 16:52:18 +01:00
Daniel Rudolf
8f7e4da53d
Rename Pico 1.1 to Pico 2.0 2016-12-12 15:31:06 +01:00
Daniel Rudolf
9a2dd4f078
Mark Twig variables rewrite_url and is_front_page as deprecated 2016-12-06 20:52:27 +01:00
Daniel Rudolf
ea2146b2db
Remove default plugins PicoParsePagesContent and PicoExcerpt
As previously announced (see [Upgrade to Pico 1.0 page](http://picocms.org/in-depth/upgrade/)) we'll remove the default plugins `PicoParsePagesContent` and `PicoExcerpt` with the next Pico milestone. Needless to say, that you can still install both plugins without any problem - we'll add them to Pico's official [Plugins collection](http://picocms.org/plugins/) by then. Please note that the disadvantages of these plugins are still critical and we strongly advise to not use them. Please refer to the [Upgrade to Pico 1.0 page](http://picocms.org/in-depth/upgrade/) for details.
2016-12-06 19:31:29 +01:00
Daniel Rudolf
5cf47e65de
Various small improvements 2016-12-06 19:03:58 +01:00
Daniel Rudolf
ddf3da0391
Merge branch 'master' into pico-1.1
Conflicts:
	.htaccess
	config/config.php.template
	content-sample/index.md
	lib/Pico.php
2016-06-18 20:23:23 +02:00
Daniel Rudolf
94279c57f8
Improve phpDocs class docs 2016-05-23 15:13:56 +02:00
Daniel Rudolf
3d11b8a979 Replace is_a() function calls with instanceof operator 2016-03-11 19:07:45 +01:00
Daniel Rudolf
cd74b681f5 Fix scope isolated config includes 2016-03-06 20:47:25 +01:00
Daniel Rudolf
75d5081bfb Use scope isolated includes for plugins & config 2016-03-06 20:06:24 +01:00
Daniel Rudolf
1c2f6a1b23 Update class docs 2016-01-25 19:31:53 +01:00
Daniel Rudolf
c3af40c3b9 PicoDeprecated: Fix LIB_DIR constant 2015-12-23 16:17:33 +01:00
Daniel Rudolf
5be2f8e597 Fix path handling on Windows
Fixes #307; thank you @bpgs for reporting!
2015-12-23 16:17:06 +01:00
Daniel Rudolf
93f7aaad8b Class docs: Use default markdown table format 2015-12-07 15:17:39 +01:00
Daniel Rudolf
913cf3816f Plugins: Improve onPagesLoaded() code styling 2015-11-27 19:31:22 +01:00
Daniel Rudolf
364b9066d9 PicoDeprecated: Use $GLOBALS superglobal instead of global keyword 2015-11-27 19:30:25 +01:00
Daniel Rudolf
20387e0bf9 Make DummyPlugin class final
Plugin developers MUST NOT extend from DummyPlugin, they SHOULD extend from AbstractPicoPlugin
2015-11-25 04:10:22 +01:00
Daniel Rudolf
840d41bca5 Improve type hinting 2015-11-25 04:07:46 +01:00
Daniel Rudolf
c0d30d20f8 Follow-up to c72ea0e
Don't use Pico::getAbsolutePath() for $config['content_dir'], just make sure the trailing slash exists. The config.php in Picos root dir should be interpreted exactly like in Pico 0.9 (the option didn't exist in Pico 0.8), thus the path isn't necessarily relative to Picos root dir
2015-11-14 16:50:32 +01:00
Daniel Rudolf
c72ea0ecec PicoDeprecated: Sanitize content_dir and base_url options when reading config.php in Picos root dir 2015-11-13 19:10:30 +01:00
Daniel Rudolf
cd7cd374bb Add content filter to get the parsed contents of a page (lazy loading) 2015-11-06 01:08:31 +01:00
Daniel Rudolf
af8de56512 Fix typos 2015-11-04 19:50:44 +01:00
Daniel Rudolf
2a43b21bae Enable PicoDeprecated if no plugins are loaded 2015-11-04 19:44:20 +01:00
Daniel Rudolf
8da62f4aad PicoDeprecated: Making $config globally accessible again
This was dropped without a replacement with Pico 0.9. I checked all changes since Pico 0.8 manually, as far as I can tell there should be no more surprises regarding BC... Thanks @Lomanic for rubbing our nose in the fact that we should check this! I also added the missing changes of Pico 0.9 to changelog.txt
2015-10-31 01:03:24 +01:00
Daniel Rudolf
9a702415fb Remove return $config in config/config.php
I always thought that doing this is pretty unusual... But now it simply breaks BC - please refer to @Lomanic's [comment](https://github.com/picocms/Pico/pull/260#issuecomment-152610857). Using a return statement has no advantages, but increases the probability that something goes wrong (e.g. a clueless user removes the return statement). It was introduced with 23b90e2, but we never released it ([v0.9.1](4cb2b24fae/lib/pico.php (L188-L189))). Removing the return statement shouldn't cause any problems even for users which installed Pico in the meantime. As a result we don't break BC and moreover remove a prior BC break 😃
2015-10-31 00:32:08 +01:00
Daniel Rudolf
afb55b9cb6 Improve class docs 2015-10-29 18:13:35 +01:00