From 5ea94d06e679f41faf86fb9344010c55bf426f46 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 29 Nov 2015 20:58:41 +0100 Subject: [PATCH 01/19] Catch YAML parse errors --- lib/Pico.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/Pico.php b/lib/Pico.php index 7f4b1c3..3ea121b 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -753,6 +753,8 @@ class Pico * @param string $rawContent the raw file contents * @param string[] $headers known meta headers * @return array parsed meta data + * @throws \Symfony\Component\Yaml\Exception\ParseException thrown when the + * meta data is invalid */ public function parseFileMeta($rawContent, array $headers) { @@ -955,12 +957,23 @@ class Pico $url = $this->getPageUrl($id); if ($file != $this->requestFile) { $rawContent = file_get_contents($file); - $meta = $this->parseFileMeta($rawContent, $this->getMetaHeaders()); + + $headers = $this->getMetaHeaders(); + try { + $meta = $this->parseFileMeta($rawContent, $headers); + } catch (\Symfony\Component\Yaml\Exception\ParseException $e) { + $meta = array_fill_keys(array_keys($headers), ''); + $meta['time'] = $meta['date_formatted'] = ''; + $meta['YAML_ParseError'] = $e->getMessage(); + } } else { $rawContent = &$this->rawContent; $meta = &$this->meta; } + // fallback to page id if page title is empty + $meta['title'] = (!empty($meta['title'])) ? $meta['title'] : $id; + // build page data // title, description, author and date are assumed to be pretty basic data // everything else is accessible through $page['meta'] From fa4e095bdf8b5adcf46619e5c2cf4e796d373df3 Mon Sep 17 00:00:00 2001 From: theshka Date: Tue, 1 Dec 2015 15:12:20 -0600 Subject: [PATCH 02/19] Move LICENSE to LICENSE.md --- .travis.yml | 2 +- CHANGELOG.md | 1 + LICENSE => LICENSE.md | 0 README.md | 2 +- 4 files changed, 3 insertions(+), 2 deletions(-) rename LICENSE => LICENSE.md (100%) diff --git a/.travis.yml b/.travis.yml index 90b27d2..ff01cd1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ before_deploy: - composer install --no-dev --optimize-autoloader - find vendor/ -type d -path 'vendor/*/*/.git' -print0 | xargs -0 rm -rf - mv index.php.dist index.php - - tar -czf "pico-release-$TRAVIS_TAG.tar.gz" README.md LICENSE CONTRIBUTING.md CHANGELOG.md composer.json composer.lock config content-sample lib plugins themes vendor .htaccess index.php + - tar -czf "pico-release-$TRAVIS_TAG.tar.gz" README.md LICENSE.md CONTRIBUTING.md CHANGELOG.md composer.json composer.lock config content-sample lib plugins themes vendor .htaccess index.php deploy: provider: releases diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bb2310..fe5acbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Released: - ``` * [New] This is Picos first stable release! The Pico Community wants to thank all contributors and users which made this possible! +* [Changed] Moving `LICENSE` to `LICENSE.md` ``` ### Version 1.0.0-beta.2 diff --git a/LICENSE b/LICENSE.md similarity index 100% rename from LICENSE rename to LICENSE.md diff --git a/README.md b/README.md index 2fc8768..ca1356a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Pico ==== -[![License](https://img.shields.io/github/license/picocms/Pico.svg)](https://github.com/picocms/Pico/blob/master/LICENSE) +[![License](https://img.shields.io/github/license/picocms/Pico.svg)](https://github.com/picocms/Pico/blob/master/LICENSE.md) [![Version](https://img.shields.io/github/release/picocms/Pico.svg)](https://github.com/picocms/Pico/releases/latest) [![Build Status](https://img.shields.io/travis/picocms/Pico.svg)](https://travis-ci.org/picocms/Pico) [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/theshka/pico.svg)](https://scrutinizer-ci.com/g/theshka/Pico/?branch=master) From d8c16d974fecd8617dce1eb0c95eb2d8a24202a2 Mon Sep 17 00:00:00 2001 From: smcdougall Date: Sun, 6 Dec 2015 14:35:39 -0500 Subject: [PATCH 03/19] Changed content to match docs changes. --- content-sample/index.md | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/content-sample/index.md b/content-sample/index.md index 2796420..06b852b 100644 --- a/content-sample/index.md +++ b/content-sample/index.md @@ -10,18 +10,11 @@ Congratulations, you have successfully installed [Pico](http://picocms.org/). ## Creating Content -Pico is a flat file CMS, this means there is no administration backend or -database to deal with. You simply create `.md` files in the `content-sample` -folder and that becomes a page. For example, this file is called `index.md` -and is shown as the main landing page. +Pico is a flat file CMS. This means there is no administration backend or database to deal with. You simply create `.md` files in the `content` folder and those files become your pages. For example, this file is called `index.md` and is shown as the main landing page. -If you create a folder within the content folder (e.g. `content-sample/sub`) -and put an `index.md` inside it, you can access that folder at the URL -`http://example.com/pico/?sub`. If you want another page within the sub folder, -simply create a text file with the corresponding name and you will be able to -access it (e.g. `content-sample/sub/page.md` is accessible from the URL -`http://example.com/pico/?sub/page`). Below we've shown some examples of -locations and their corresponding URLs: +When you install Pico, it comes with a `content-sample` folder. Inside this folder is a sample website that will display until you add your own content. You should create your own `content` folder in Pico's root directory and place your files there. No configuration is required, Pico will automatically use the `content` folder if it exists. + +If you create a folder within the content folder (e.g. `content/sub`) and put an `index.md` inside it, you can access that folder at the URL `http://example.com/?sub`. If you want another page within the sub folder, simply create a text file with the corresponding name and you will be able to access it (e.g. `content/sub/page.md` is accessible from the URL `http://example.com/?sub/page`). Below we've shown some examples of locations and their corresponding URLs: @@ -32,41 +25,31 @@ locations and their corresponding URLs: - + - + - + - + - +
content-sample/index.mdcontent/index.md /
content-sample/sub.mdcontent/sub.md ?sub (not accessible, see below)
content-sample/sub/index.mdcontent/sub/index.md ?sub (same as above)
content-sample/sub/page.mdcontent/sub/page.md ?sub/page
content-sample/a/very/long/url.mdcontent/a/very/long/url.md ?a/very/long/url (doesn't exist)
-If a file cannot be found, the file `content-sample/404.md` will be shown. You -can add `404.md` files to any directory, so if you want to use a special error -page for your blog, simply create `content-sample/blog/404.md`. +If a file cannot be found, the file `content/404.md` will be shown. You can add `404.md` files to any directory. So, for example, if you wanted to use a special error page for your blog, you could simply create `content/blog/404.md`. -Instead of adding your own content to the `content-sample` folder, you should -create your own `content` directory in Pico's root directory. You can then add -and access your contents as described above. - -As a common practice, we recommend you to separate your contents and assets -(like images, downloads etc.). We even deny access to your `content` directory -by default. So if you want to use a asset (e.g. a image) in one of your content -files, upload it to the (to be created) directory `assets` and use it as -follows: !\[Image Title\](%base_url%/assets/image.png) +As a common practice, we recommend you to separate your contents and assets (like images, downloads, etc.). We even deny access to your `content` directory by default. If you want to use some assets (e.g. a image) in one of your content files, you should create an `assets` folder in Pico's root directory and upload your assets there. You can then access them in your markdown using %base_url%/assets/ for example: !\[Image Title\](%base_url%/assets/image.png) ### Text File Markup @@ -93,7 +76,7 @@ There are also certain variables that you can use in your text files: * %base_url% - The URL to your Pico site; internal links can be specified using %base_url%?sub/page * %theme_url% - The URL to the currently used theme -* %meta.*% - Access any meta variable of the current page, +* %meta.*% - Access any meta variable of the current page, e.g. %meta.author% is replaced with `Joe Bloggs` ### Blogging From 1e2d500bfaafaad5f1b6b33eb16554d3d39ed42c Mon Sep 17 00:00:00 2001 From: smcdougall Date: Sun, 6 Dec 2015 19:28:37 -0500 Subject: [PATCH 04/19] Formatted lines to 80 characters --- content-sample/index.md | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/content-sample/index.md b/content-sample/index.md index 06b852b..0931c45 100644 --- a/content-sample/index.md +++ b/content-sample/index.md @@ -10,11 +10,24 @@ Congratulations, you have successfully installed [Pico](http://picocms.org/). ## Creating Content -Pico is a flat file CMS. This means there is no administration backend or database to deal with. You simply create `.md` files in the `content` folder and those files become your pages. For example, this file is called `index.md` and is shown as the main landing page. +Pico is a flat file CMS. This means there is no administration backend or +database to deal with. You simply create `.md` files in the `content` folder and +those files become your pages. For example, this file is called `index.md` and +is shown as the main landing page. -When you install Pico, it comes with a `content-sample` folder. Inside this folder is a sample website that will display until you add your own content. You should create your own `content` folder in Pico's root directory and place your files there. No configuration is required, Pico will automatically use the `content` folder if it exists. +When you install Pico, it comes with a `content-sample` folder. Inside this +folder is a sample website that will display until you add your own content. +You should create your own `content` folder in Pico's root directory and place +your files there. No configuration is required, Pico will automatically use the +`content` folder if it exists. -If you create a folder within the content folder (e.g. `content/sub`) and put an `index.md` inside it, you can access that folder at the URL `http://example.com/?sub`. If you want another page within the sub folder, simply create a text file with the corresponding name and you will be able to access it (e.g. `content/sub/page.md` is accessible from the URL `http://example.com/?sub/page`). Below we've shown some examples of locations and their corresponding URLs: +If you create a folder within the content folder (e.g. `content/sub`) and put an +`index.md` inside it, you can access that folder at the URL +`http://example.com/?sub`. If you want another page within the sub folder, +simply create a text file with the corresponding name and you will be able to +access it (e.g. `content/sub/page.md` is accessible from the URL +`http://example.com/?sub/page`). Below we've shown some examples of locations +and their corresponding URLs: @@ -42,14 +55,25 @@ If you create a folder within the content folder (e.g. `content/sub`) and put an - +
content/a/very/long/url.md?a/very/long/url (doesn't exist) + ?a/very/long/url + (doesn't exist) +
-If a file cannot be found, the file `content/404.md` will be shown. You can add `404.md` files to any directory. So, for example, if you wanted to use a special error page for your blog, you could simply create `content/blog/404.md`. +If a file cannot be found, the file `content/404.md` will be shown. You can add +`404.md` files to any directory. So, for example, if you wanted to use a special +error page for your blog, you could simply create `content/blog/404.md`. -As a common practice, we recommend you to separate your contents and assets (like images, downloads, etc.). We even deny access to your `content` directory by default. If you want to use some assets (e.g. a image) in one of your content files, you should create an `assets` folder in Pico's root directory and upload your assets there. You can then access them in your markdown using %base_url%/assets/ for example: !\[Image Title\](%base_url%/assets/image.png) +As a common practice, we recommend you to separate your contents and assets +(like images, downloads, etc.). We even deny access to your `content` directory +by default. If you want to use some assets (e.g. a image) in one of your content +files, you should create an `assets` folder in Pico's root directory and upload +your assets there. You can then access them in your markdown using +%base_url%/assets/ for example: +!\[Image Title\](%base_url%/assets/image.png) ### Text File Markup @@ -76,8 +100,8 @@ There are also certain variables that you can use in your text files: * %base_url% - The URL to your Pico site; internal links can be specified using %base_url%?sub/page * %theme_url% - The URL to the currently used theme -* %meta.*% - Access any meta variable of the current page, - e.g. %meta.author% is replaced with `Joe Bloggs` +* %meta.*% - Access any meta variable of the current +page, e.g. %meta.author% is replaced with `Joe Bloggs` ### Blogging From 93f7aaad8bfd6498dd8d9fa3129609b9100fdee9 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Mon, 7 Dec 2015 15:17:39 +0100 Subject: [PATCH 05/19] Class docs: Use default markdown table format --- lib/Pico.php | 7 ++----- plugins/00-PicoDeprecated.php | 7 ++----- plugins/DummyPlugin.php | 7 ++----- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/lib/Pico.php b/lib/Pico.php index 334d792..bcdb5e6 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -909,10 +909,9 @@ class Pico * Reads the data of all pages known to Pico * * The page data will be an array containing the following values: - *
-     * +----------------+--------+------------------------------------------+
+     *
      * | Array key      | Type   | Description                              |
-     * +----------------+--------+------------------------------------------+
+     * | -------------- | ------ | ---------------------------------------- |
      * | id             | string | relative path to the content file        |
      * | url            | string | URL to the page                          |
      * | title          | string | title of the page (YAML header)          |
@@ -923,8 +922,6 @@ class Pico
      * | date_formatted | string | formatted date of the page               |
      * | raw_content    | string | raw, not yet parsed contents of the page |
      * | meta           | string | parsed meta data of the page             |
-     * +----------------+--------+------------------------------------------+
-     * 
* * @see Pico::sortPages() * @see Pico::getPages() diff --git a/plugins/00-PicoDeprecated.php b/plugins/00-PicoDeprecated.php index 5240160..a9a272d 100644 --- a/plugins/00-PicoDeprecated.php +++ b/plugins/00-PicoDeprecated.php @@ -11,10 +11,9 @@ * can disable this plugin by calling {@link PicoDeprecated::setEnabled()}. * * The following deprecated events are triggered by this plugin: - *
- * +---------------------+-----------------------------------------------------------+
+ *
  * | Event               | ... triggers the deprecated event                         |
- * +---------------------+-----------------------------------------------------------+
+ * | ------------------- | --------------------------------------------------------- |
  * | onPluginsLoaded     | plugins_loaded()                                          |
  * | onConfigLoaded      | config_loaded($config)                                    |
  * | onRequestUrl        | request_url($url)                                         |
@@ -32,8 +31,6 @@
  * | onTwigRegistration  | before_twig_register()                                    |
  * | onPageRendering     | before_render($twigVariables, $twig, $templateName)       |
  * | onPageRendered      | after_render($output)                                     |
- * +---------------------+-----------------------------------------------------------+
- * 
* * Since Pico 1.0 the config is stored in {@path "config/config.php"}. This * plugin tries to read {@path "config.php"} in Pico's root dir and overwrites diff --git a/plugins/DummyPlugin.php b/plugins/DummyPlugin.php index f8ebb01..b1588eb 100644 --- a/plugins/DummyPlugin.php +++ b/plugins/DummyPlugin.php @@ -228,10 +228,9 @@ final class DummyPlugin extends AbstractPicoPlugin * Triggered when Pico reads a single page from the list of all known pages * * The `$pageData` parameter consists of the following values: - *
-     * +----------------+--------+------------------------------------------+
+     *
      * | Array key      | Type   | Description                              |
-     * +----------------+--------+------------------------------------------+
+     * | -------------- | ------ | ---------------------------------------- |
      * | id             | string | relative path to the content file        |
      * | url            | string | URL to the page                          |
      * | title          | string | title of the page (YAML header)          |
@@ -242,8 +241,6 @@ final class DummyPlugin extends AbstractPicoPlugin
      * | date_formatted | string | formatted date of the page               |
      * | raw_content    | string | raw, not yet parsed contents of the page |
      * | meta           | string | parsed meta data of the page             |
-     * +----------------+--------+------------------------------------------+
-     * 
* * @see DummyPlugin::onPagesLoaded() * @param array &$pageData data of the loaded page From d9788c12e4b63e0c1ca8de3b2acaf1ddb107c7ec Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Mon, 7 Dec 2015 15:57:00 +0100 Subject: [PATCH 06/19] _build/generate-phpdoc.sh: Fix output formatting --- _build/generate-phpdoc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_build/generate-phpdoc.sh b/_build/generate-phpdoc.sh index 2408ac2..0728ca6 100755 --- a/_build/generate-phpdoc.sh +++ b/_build/generate-phpdoc.sh @@ -18,7 +18,7 @@ echo # update a separate phpDoc cache if [ "$PHPDOC_CACHE_DIR" != "-" ]; then # parse phpDoc files (i.e. update cache) - printf "\nUpdate phpDoc cache...\n" + printf "Update phpDoc cache...\n" phpdoc project:parse --config "$PHPDOC_CONFIG" \ --target "$PHPDOC_CACHE_DIR" From 0c85d708204c72fc80dcfc07344036eaf10e4d08 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 13 Dec 2015 22:01:25 +0100 Subject: [PATCH 07/19] Adding $queryData parameter to Pico::getPageUrl() method This allows developers to easily add custom query data to an page URL without the need to check enabled URL rewriting on their own. Since Twigs `link` filter is just an alias for Pico::getPageUrl(), theme designers can do the same with e.g. `{{ "index"|link("foo=bar&baz=42") }}`. Theme designers, heads up! Don't forget that the result of the `link` filter is never escaped, so the result could contain unescaped ampersands when passing custom query data. You should pass the result to Twigs `escape` filter when using custom query data. --- CHANGELOG.md | 1 + lib/Pico.php | 27 +++++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe5acbc..3b0877a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Released: - ``` * [New] This is Picos first stable release! The Pico Community wants to thank all contributors and users which made this possible! +* [New] Adding `$queryData` parameter to `Pico::getPageUrl()` method * [Changed] Moving `LICENSE` to `LICENSE.md` ``` diff --git a/lib/Pico.php b/lib/Pico.php index bcdb5e6..30de7be 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -1234,17 +1234,32 @@ class Pico /** * Returns the URL to a given page * - * @param string $page identifier of the page to link to - * @return string URL + * @param string $page identifier of the page to link to + * @param array|string $queryData either an array containing properties to + * create a URL-encoded query string from, or a already encoded string + * @return string URL */ - public function getPageUrl($page) + public function getPageUrl($page, $queryData = null) { + if (is_array($queryData)) { + $queryData = http_build_query($queryData, '', '&'); + } elseif (($queryData !== null) && !is_string($queryData)) { + throw new InvalidArgumentException( + 'Argument 2 passed to ' . get_called_class() . '::getPageUrl() must be of the type array or string, ' + . (is_object($queryData) ? get_class($queryData) : gettype($queryData)) . ' given' + ); + } + if (!empty($queryData)) { + $page = (!empty($page) || $this->isUrlRewritingEnabled()) ? $page : 'index'; + $queryData = $this->isUrlRewritingEnabled() ? '?' . $queryData : '&' . $queryData; + } + if (empty($page)) { - return $this->getBaseUrl(); + return $this->getBaseUrl() . $queryData; } elseif (!$this->isUrlRewritingEnabled()) { - return $this->getBaseUrl() . '?' . rawurlencode($page); + return $this->getBaseUrl() . '?' . rawurlencode($page) . $queryData; } else { - return $this->getBaseUrl() . implode('/', array_map('rawurlencode', explode('/', $page))); + return $this->getBaseUrl() . implode('/', array_map('rawurlencode', explode('/', $page))) . $queryData; } } From a138d23dafee5a72bcbd471960897ac6269742af Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 13 Dec 2015 22:19:02 +0100 Subject: [PATCH 08/19] Throw LogicException instead of RuntimeException in Pico::setConfig() --- CHANGELOG.md | 2 ++ lib/Pico.php | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b0877a..e56c290 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ Released: - all contributors and users which made this possible! * [New] Adding `$queryData` parameter to `Pico::getPageUrl()` method * [Changed] Moving `LICENSE` to `LICENSE.md` +* [Changed] Throw `LogicException` instead of `RuntimeException` when calling + `Pico::setConfig()` after processing has started ``` ### Version 1.0.0-beta.2 diff --git a/lib/Pico.php b/lib/Pico.php index 30de7be..afe78b8 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -267,7 +267,7 @@ class Pico * the rendered contents. * * @return string rendered Pico contents - * @throws RuntimeException thrown when a not recoverable error occurs + * @throws Exception thrown when a not recoverable error occurs */ public function run() { @@ -518,12 +518,12 @@ class Pico * @see Pico::getConfig() * @param mixed[] $config array with config variables * @return void - * @throws RuntimeException thrown if Pico already started processing + * @throws LogicException thrown if Pico already started processing */ public function setConfig(array $config) { if ($this->locked) { - throw new RuntimeException("You cannot modify Pico's config after processing has started"); + throw new LogicException("You cannot modify Pico's config after processing has started"); } $this->config = $config; From dc6ac516a8ca65fd725e1f807d352af6a02401f4 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 13 Dec 2015 22:27:27 +0100 Subject: [PATCH 09/19] Fix Pico::getPageUrl() --- lib/Pico.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Pico.php b/lib/Pico.php index afe78b8..9f83674 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -1250,7 +1250,7 @@ class Pico ); } if (!empty($queryData)) { - $page = (!empty($page) || $this->isUrlRewritingEnabled()) ? $page : 'index'; + $page = !empty($page) ? $page : 'index'; $queryData = $this->isUrlRewritingEnabled() ? '?' . $queryData : '&' . $queryData; } From 693d8ae4facf6b9072cfed00229eb48d47e4ceac Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 16 Dec 2015 21:51:23 +0100 Subject: [PATCH 10/19] Update default theme footer --- themes/default/index.twig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/themes/default/index.twig b/themes/default/index.twig index 25d8b19..32650fb 100644 --- a/themes/default/index.twig +++ b/themes/default/index.twig @@ -39,9 +39,9 @@ From 5694cda14e8e122d487cf630584794d8402b8d82 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 20 Dec 2015 19:44:59 +0100 Subject: [PATCH 11/19] Update website URLs --- CONTRIBUTING.md | 4 ++-- README.md | 10 +++++----- content-sample/index.md | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ca6f0d8..67f1618 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,7 +19,7 @@ Please describe your issue as clear as possible and always include the *Pico ver Contributing code ----------------- -Once you decide you want to contribute to *Pico's core* (which we really appreciate!) you can fork the project from https://github.com/picocms/Pico. If you're interested in developing a *plugin* or *theme* for Pico, please refer to the [development section](http://picocms.org/plugin-dev.html) of our website. +Once you decide you want to contribute to *Pico's core* (which we really appreciate!) you can fork the project from https://github.com/picocms/Pico. If you're interested in developing a *plugin* or *theme* for Pico, please refer to the [development section](http://picocms.org/development/) of our website. ### Prevent `merge-hell` @@ -49,7 +49,7 @@ With this command you can specify a file or folder to limit which files it will Pico accepts the problems of having redundant documentation on different places (concretely Pico's inline user docs, the `README.md` and the website) for the sake of a better user experience. When updating the docs, please make sure to keep them in sync. -If you update the [`README.md`](https://github.com/picocms/Pico/blob/master/README.md) or [`content-sample/index.md`](https://github.com/picocms/Pico/blob/master/content-sample/index.md), please make sure to update the corresponding files in the [`_docs`](https://github.com/picocms/Pico/tree/gh-pages/_docs/) folder of the `gh-pages` branch (i.e. [Pico's website](http://picocms.org/docs.html)) and vice versa. Unfortunately this involves three (!) different markdown parsers. If you're experiencing problems, use Pico's [`erusev/parsedown-extra`](https://github.com/erusev/parsedown-extra) as a reference. You can try to make the contents compatible to [Redcarpet](https://github.com/vmg/redcarpet) by yourself, otherwise please address the issues in your pull request message and we'll take care of it. +If you update the [`README.md`](https://github.com/picocms/Pico/blob/master/README.md) or [`content-sample/index.md`](https://github.com/picocms/Pico/blob/master/content-sample/index.md), please make sure to update the corresponding files in the [`_docs`](https://github.com/picocms/Pico/tree/gh-pages/_docs/) folder of the `gh-pages` branch (i.e. [Pico's website](http://picocms.org/docs/)) and vice versa. Unfortunately this involves three (!) different markdown parsers. If you're experiencing problems, use Pico's [`erusev/parsedown-extra`](https://github.com/erusev/parsedown-extra) as a reference. You can try to make the contents compatible to [Redcarpet](https://github.com/vmg/redcarpet) by yourself, otherwise please address the issues in your pull request message and we'll take care of it. Versioning ---------- diff --git a/README.md b/README.md index ca1356a..ad0ca63 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ Contributing You want to contribute to Pico? We really appreciate that! You can help make Pico better by [contributing code][PullRequests] or [reporting issues][Issues], but please take note of our [contribution guidelines][ContributionGuidelines]. In general you can contribute in three different areas: -1. Plugins & Themes: You're a plugin developer or theme designer? We love you guys! You can find tons of information about how to develop plugins and themes at http://picocms.org/plugin-dev.html. If you have created a plugin or theme, please add it to our [Wiki][], either on the [plugins][WikiPlugins] or [themes page][WikiThemes]. Doing so, we may select and promote your plugin or theme on [our website][OfficialPlugins] as officially supported! +1. Plugins & Themes: You're a plugin developer or theme designer? We love you guys! You can find tons of information about how to develop plugins and themes at http://picocms.org/development/. If you have created a plugin or theme, please add it to our [Wiki][], either on the [plugins][WikiPlugins] or [themes page][WikiThemes]. Doing so, we may select and promote your plugin or theme on [our website][OfficialPlugins] as officially supported! 2. Documentation: We always appreciate people improving our documentation. You can either improve the [inline user docs][EditInlineDocs] or the more extensive [user docs on our website][EditUserDocs]. You can also improve the [docs for plugin and theme developers][EditDevDocs]. Simply fork Pico from https://github.com/picocms/Pico, change the Markdown files and open a [pull request][PullRequests]. @@ -109,10 +109,10 @@ You want to contribute to Pico? We really appreciate that! You can help make Pic [composer]: https://getcomposer.org/ [SemVer]: http://semver.org [PHPServer]: http://php.net/manual/en/features.commandline.webserver.php -[HelpUpgrade]: http://picocms.org/upgrade.html -[HelpUserDocs]: http://picocms.org/docs.html -[HelpDevDocs]: http://picocms.org/plugin-dev.html -[OfficialPlugins]: http://picocms.org/plugins.html +[HelpUpgrade]: http://picocms.org/upgrade/ +[HelpUserDocs]: http://picocms.org/docs/ +[HelpDevDocs]: http://picocms.org/development/ +[OfficialPlugins]: http://picocms.org/customization/ [Wiki]: https://github.com/picocms/Pico/wiki [WikiPlugins]: https://github.com/picocms/Pico/wiki/Pico-Plugins [WikiThemes]: https://github.com/picocms/Pico/wiki/Pico-Themes diff --git a/content-sample/index.md b/content-sample/index.md index 2796420..b487ca6 100644 --- a/content-sample/index.md +++ b/content-sample/index.md @@ -230,9 +230,9 @@ and designers created in the past. As with plugins, you can find themes in #### Plugins for users -Officially tested plugins can be found at http://picocms.org/plugins.html, but -there are many awesome third-party plugins out there! A good start point for -discovery is [our Wiki][WikiPlugins]. +Officially tested plugins can be found at http://picocms.org/customization/, +but there are many awesome third-party plugins out there! A good start point +for discovery is [our Wiki][WikiPlugins]. Pico makes it very easy for you to add new features to your website. Simply upload the files of the plugin to the `plugins/` directory and you're done. @@ -249,7 +249,7 @@ replace `false` with `true`. #### Plugins for developers You're a plugin developer? We love you guys! You can find tons of information -about how to develop plugins at http://picocms.org/plugin-dev.html. If you've +about how to develop plugins at http://picocms.org/development/. If you've developed a plugin for Pico 0.9 or older, you probably want to upgrade it to the brand new plugin system introduced with Pico 1.0. Please refer to the [upgrade section of the docs][PluginUpgrade]. @@ -294,5 +294,5 @@ For more help have a look at the Pico documentation at http://picocms.org/docs. [Twig]: http://twig.sensiolabs.org/documentation [WikiThemes]: https://github.com/picocms/Pico/wiki/Pico-Themes [WikiPlugins]: https://github.com/picocms/Pico/wiki/Pico-Plugins -[PluginUpgrade]: http://picocms.org/plugin-dev.html#upgrade +[PluginUpgrade]: http://picocms.org/development/#upgrade [ModRewrite]: https://httpd.apache.org/docs/current/mod/mod_rewrite.html From b7fbf95b9d0de343a459c3af41f61ff2dc4e1297 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Mon, 21 Dec 2015 02:38:05 +0100 Subject: [PATCH 12/19] README.md: Fix EditDevDocs URL --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ad0ca63..da1fb7b 100644 --- a/README.md +++ b/README.md @@ -122,4 +122,4 @@ You want to contribute to Pico? We really appreciate that! You can help make Pic [ContributionGuidelines]: https://github.com/picocms/Pico/blob/master/CONTRIBUTING.md [EditInlineDocs]: https://github.com/picocms/Pico/edit/master/content-sample/index.md [EditUserDocs]: https://github.com/picocms/Pico/tree/gh-pages/_docs -[EditDevDocs]: https://github.com/picocms/Pico/tree/gh-pages/_plugin-dev +[EditDevDocs]: https://github.com/picocms/Pico/tree/gh-pages/_development From fdf81672a836700fba4a24fd7513d7d072849586 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Mon, 21 Dec 2015 03:24:32 +0100 Subject: [PATCH 13/19] content-sample/index.md: Fix syntax --- content-sample/index.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/content-sample/index.md b/content-sample/index.md index 9a85330..4a86b07 100644 --- a/content-sample/index.md +++ b/content-sample/index.md @@ -11,18 +11,18 @@ Congratulations, you have successfully installed [Pico](http://picocms.org/). ## Creating Content Pico is a flat file CMS. This means there is no administration backend or -database to deal with. You simply create `.md` files in the `content` folder and -those files become your pages. For example, this file is called `index.md` and -is shown as the main landing page. +database to deal with. You simply create `.md` files in the `content` folder +and those files become your pages. For example, creating a file called +`index.md` will make it show as your main landing page. -When you install Pico, it comes with a `content-sample` folder. Inside this +When you install Pico, it comes with a `content-sample` folder. Inside this folder is a sample website that will display until you add your own content. You should create your own `content` folder in Pico's root directory and place -your files there. No configuration is required, Pico will automatically use the +your files there. No configuration is required, Pico will automatically use the `content` folder if it exists. -If you create a folder within the content folder (e.g. `content/sub`) and put an -`index.md` inside it, you can access that folder at the URL +If you create a folder within the content folder (e.g. `content/sub`) and put +an `index.md` inside it, you can access that folder at the URL `http://example.com/?sub`. If you want another page within the sub folder, simply create a text file with the corresponding name and you will be able to access it (e.g. `content/sub/page.md` is accessible from the URL @@ -71,7 +71,7 @@ As a common practice, we recommend you to separate your contents and assets (like images, downloads, etc.). We even deny access to your `content` directory by default. If you want to use some assets (e.g. a image) in one of your content files, you should create an `assets` folder in Pico's root directory and upload -your assets there. You can then access them in your markdown using +your assets there. You can then access them in your markdown using %base_url%/assets/ for example: !\[Image Title\](%base_url%/assets/image.png) @@ -101,7 +101,7 @@ There are also certain variables that you can use in your text files: can be specified using %base_url%?sub/page * %theme_url% - The URL to the currently used theme * %meta.*% - Access any meta variable of the current -page, e.g. %meta.author% is replaced with `Joe Bloggs` + page, e.g. %meta.author% is replaced with `Joe Bloggs` ### Blogging From 67e1e8a8ead236a34f4f4dcad492074deb0413c8 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Mon, 21 Dec 2015 03:31:34 +0100 Subject: [PATCH 14/19] Default theme: Highlight active page + hide untitled pages Related to #302 --- CHANGELOG.md | 2 ++ themes/default/index.twig | 6 ++++-- themes/default/style.css | 9 +++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e56c290..f6c1142 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ Released: - * [Changed] Moving `LICENSE` to `LICENSE.md` * [Changed] Throw `LogicException` instead of `RuntimeException` when calling `Pico::setConfig()` after processing has started +* [Changed] Default theme now highlights the current page and only lists pages + with a title in the navigation ``` ### Version 1.0.0-beta.2 diff --git a/themes/default/index.twig b/themes/default/index.twig index 32650fb..37f8f16 100644 --- a/themes/default/index.twig +++ b/themes/default/index.twig @@ -23,8 +23,10 @@ diff --git a/themes/default/style.css b/themes/default/style.css index d26f65a..a8c0030 100644 --- a/themes/default/style.css +++ b/themes/default/style.css @@ -222,9 +222,14 @@ blockquote { margin-bottom: 80px; color: #afe1da; } -#header a { color: #afe1da; } +#header a { + color: #afe1da; +} #header h1 a, -#header a:hover { color: #fff; } +#header a:hover, +#header .active a { + color: #fff; +} #header h1 { font-weight: bold; margin: 0; From 329049bd18a2c76b21d3646ae58169932f807ebc Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Mon, 21 Dec 2015 03:42:59 +0100 Subject: [PATCH 15/19] Fix empty meta header --- CHANGELOG.md | 1 + lib/Pico.php | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6c1142..cc99b57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Released: - `Pico::setConfig()` after processing has started * [Changed] Default theme now highlights the current page and only lists pages with a title in the navigation +* [Fixed] Support empty meta header ``` ### Version 1.0.0-beta.2 diff --git a/lib/Pico.php b/lib/Pico.php index 9f83674..76fed91 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -758,11 +758,11 @@ class Pico { $meta = array(); $pattern = "/^(\/(\*)|---)[[:blank:]]*(?:\r)?\n" - . "(.*?)(?:\r)?\n(?(2)\*\/|---)[[:blank:]]*(?:(?:\r)?\n|$)/s"; - if (preg_match($pattern, $rawContent, $rawMetaMatches)) { + . "(?:(.*?)(?:\r)?\n)?(?(2)\*\/|---)[[:blank:]]*(?:(?:\r)?\n|$)/s"; + if (preg_match($pattern, $rawContent, $rawMetaMatches) && isset($rawMetaMatches[3])) { $yamlParser = new \Symfony\Component\Yaml\Parser(); $meta = $yamlParser->parse($rawMetaMatches[3]); - $meta = array_change_key_case($meta, CASE_LOWER); + $meta = ($meta !== null) ? array_change_key_case($meta, CASE_LOWER) : array(); foreach ($headers as $fieldId => $fieldName) { $fieldName = strtolower($fieldName); @@ -840,7 +840,7 @@ class Pico { // remove meta header $metaHeaderPattern = "/^(\/(\*)|---)[[:blank:]]*(?:\r)?\n" - . "(.*?)(?:\r)?\n(?(2)\*\/|---)[[:blank:]]*(?:(?:\r)?\n|$)/s"; + . "(?:(.*?)(?:\r)?\n)?(?(2)\*\/|---)[[:blank:]]*(?:(?:\r)?\n|$)/s"; $content = preg_replace($metaHeaderPattern, '', $rawContent, 1); // replace %site_title% From 3798cbe478b3bc3d4f8fdd9af3bf5a2b42e5545e Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Mon, 21 Dec 2015 04:05:25 +0100 Subject: [PATCH 16/19] Remove page title fallback --- lib/Pico.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/Pico.php b/lib/Pico.php index 3ea121b..6b0ef95 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -971,9 +971,6 @@ class Pico $meta = &$this->meta; } - // fallback to page id if page title is empty - $meta['title'] = (!empty($meta['title'])) ? $meta['title'] : $id; - // build page data // title, description, author and date are assumed to be pretty basic data // everything else is accessible through $page['meta'] From 43f953b67af22b084501b337010e0421a8745313 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Mon, 21 Dec 2015 04:08:35 +0100 Subject: [PATCH 17/19] Pico::readPages(): Call Pico::parseFileMeta() again when a exception is thrown --- lib/Pico.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/Pico.php b/lib/Pico.php index 6b0ef95..62174bf 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -962,8 +962,7 @@ class Pico try { $meta = $this->parseFileMeta($rawContent, $headers); } catch (\Symfony\Component\Yaml\Exception\ParseException $e) { - $meta = array_fill_keys(array_keys($headers), ''); - $meta['time'] = $meta['date_formatted'] = ''; + $meta = $this->parseFileMeta('', $headers); $meta['YAML_ParseError'] = $e->getMessage(); } } else { From d2842956b29f5b7722a5d29b95f7c7633e39bb8a Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Mon, 21 Dec 2015 04:19:27 +0100 Subject: [PATCH 18/19] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc99b57..0364e0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Released: - `Pico::setConfig()` after processing has started * [Changed] Default theme now highlights the current page and only lists pages with a title in the navigation +* [Changed] #292: Ignore YAML parse errors (meta data) in `Pico::readPages()` * [Fixed] Support empty meta header ``` From 14e5f3236c87b56a9677f7a820039774ae97d62d Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Mon, 21 Dec 2015 12:50:31 +0100 Subject: [PATCH 19/19] Partially revert fdf8167 Thanks @smcdougall for spotting --- content-sample/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content-sample/index.md b/content-sample/index.md index 4a86b07..5202565 100644 --- a/content-sample/index.md +++ b/content-sample/index.md @@ -12,8 +12,8 @@ Congratulations, you have successfully installed [Pico](http://picocms.org/). Pico is a flat file CMS. This means there is no administration backend or database to deal with. You simply create `.md` files in the `content` folder -and those files become your pages. For example, creating a file called -`index.md` will make it show as your main landing page. +and those files become your pages. For example, this file is called `index.md` +and is shown as the main landing page. When you install Pico, it comes with a `content-sample` folder. Inside this folder is a sample website that will display until you add your own content.