Browse Source

Merge branch 'master' into enhancement/build-release

Conflicts:
	.travis.yml
Daniel Rudolf 9 years ago
parent
commit
18fc928797
10 changed files with 64 additions and 46 deletions
  1. 11 11
      .gitignore
  2. 1 0
      .travis.yml
  3. 1 0
      CHANGELOG.md
  4. 2 2
      README.md
  5. 16 5
      composer.json
  6. 9 4
      lib/Pico.php
  7. 8 8
      plugins/00-PicoDeprecated.php
  8. 1 1
      plugins/01-PicoParsePagesContent.php
  9. 2 2
      plugins/02-PicoExcerpt.php
  10. 13 13
      plugins/DummyPlugin.php

+ 11 - 11
.gitignore

@@ -15,22 +15,22 @@ desktop.ini
 /build/phpdoc-*.git/
 
 # Composer
-composer.lock
-composer.phar
-vendor/*
+/composer.lock
+/composer.phar
+/vendor
 
 # User config
-config/config.php
+/config/config.php
 
 # User themes
-themes/*
-!themes/default/*
+/themes/*
+!/themes/default
 
 # User plugins
-plugins/*
-!plugins/0?-*
-!plugins/1?-*
-!plugins/DummyPlugin.php
+/plugins/*
+!/plugins/0?-*
+!/plugins/1?-*
+!/plugins/DummyPlugin.php
 
 # User content
-content/*
+/content

+ 1 - 0
.travis.yml

@@ -16,6 +16,7 @@ before_deploy:
   - ./vendor/bin/phpdoc -d . -i 'vendor/*' -i 'plugins/*' -f 'plugins/DummyPlugin.php' -t "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" --title "Pico 1.0 API Documentation ($TRAVIS_TAG)"
   - ./build/deploy-phpdoc.sh "picocms/Pico" "gh-pages" "$GITHUB_OAUTH_TOKEN" "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "phpDoc/$TRAVIS_TAG"
   - composer install --no-dev
+  - composer dump-autoload --optimize
   - 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
 
 deploy:

+ 1 - 0
CHANGELOG.md

@@ -11,6 +11,7 @@ Released: -
         want to parse the contents of a page, use the `content` filter instead
 * [Changed] Improve documentation
 * [Changed] Improve table styling in default theme
+* [Changed] Throw a RuntimeException when the `content` dir isn't accessible
 * [Changed] Reuse `ParsedownExtra` object; new `onParsedownRegistration` event
 * [Fixed] `PicoDeprecated`: Sanitize `content_dir` and `base_url` options when
           reading `config.php` in Picos root dir

+ 2 - 2
README.md

@@ -46,11 +46,11 @@ Upgrading Pico is very easy: You just have to replace all of Pico's files - that
 
 Pico follows [Semantic Versioning 2.0][SemVer] and uses version numbers like `MAJOR`.`MINOR`.`PATCH`. When we update...
 
-- the `PATCH` version (e.g. `1.0.0` to `1.0.1`), we made backwards-compatible bug fixes. It's then sufficient to extract [Pico's latest release][LatestRelease] to your existing installation directory and overwriting all files.
+- the `PATCH` version (e.g. `1.0.0` to `1.0.1`), we made backwards-compatible bug fixes. It's then sufficient to extract [Pico's latest release][LatestRelease] to your existing installation directory and overwriting all files. Alternatively you can either use the [*source code* of Pico's latest release][LatestRelease] or pull from Pico's Git repository, but are then required to update Pico's [composer][] dependencies manually by running `php composer.phar update`.
 
 - the `MINOR` version (e.g. `1.0` to `1.1`), we added functionality in a backwards-compatible manner, but anyway recommend you to "install" Pico newly. Backup all of your files, empty your installation directory and install Pico as elucidated above. You can then copy your `config/config.php` and `content` directory without any change. If applicable, you can also copy the folder of your custom theme within the `themes` directory. Provided that you're using plugins, also copy all of your plugins from the `plugins` directory.
 
-- the `MAJOR` version (e.g. `1.0` to `2.0`), a appropriate upgrade tutorial will be provided.
+- the `MAJOR` version (e.g. `1.0` to `2.0`), we made incompatible API changes. We will then provide a appropriate upgrade tutorial.
 
 Upgrading Pico 0.8 or 0.9 to Pico 1.0 is a special case. The new `PicoDeprecated` plugin ensures backwards compatibility, so you basically can follow the above upgrade instructions as if we updated the `MINOR` version. However, we recommend you to take some further steps to confine the necessity of `PicoDeprecated` as far as possible. For more information about what has changed with Pico 1.0 and a step-by-step upgrade tutorial, please refer to the [upgrade page of our website][HelpUpgrade].
 

+ 16 - 5
composer.json

@@ -2,20 +2,31 @@
     "name": "picocms/pico",
     "type": "library",
     "description": "Pico is a flat file CMS, this means there is no administration backend and database to deal with. You simply create .md files in the \"content\" folder and that becomes a page.",
-    "keywords": ["cms"],
+    "keywords": ["flat-file","cms","php","twig","markdown"],
     "homepage": "http://picocms.org/",
     "license": "MIT",
     "authors": [
         {
             "name": "Gilbert Pellegrom",
-            "email": "gilbert@pellegrom.me"
+            "email": "gilbert@pellegrom.me",
+            "role": "Project Founder"
+        },
+        {
+            "name": "The Pico Community",
+            "homepage": "https://github.com/picocms/Pico/graphs/contributors",
+            "role": "Contributors"
         }
     ],
+    "support": {
+        "docs": "http://picocms.org/docs",
+        "issues": "https://github.com/picocms/Pico/issues",
+        "source": "https://github.com/picocms/Pico"
+    },
     "require": {
         "php": ">=5.3.6",
-        "twig/twig": "1.18.*",
-        "erusev/parsedown-extra": "0.7.*",
-        "symfony/yaml" : "2.3"
+        "twig/twig": "^1.18",
+        "erusev/parsedown-extra": "^0.7",
+        "symfony/yaml" : "^2.3"
     },
     "require-dev" : {
         "phpdocumentor/phpdocumentor": "^2.8"

+ 9 - 4
lib/Pico.php

@@ -266,7 +266,8 @@ class Pico
      * meta headers, processes Markdown, does Twig processing and returns
      * the rendered contents.
      *
-     * @return string rendered Pico contents
+     * @return string           rendered Pico contents
+     * @throws RuntimeException thrown when a not recoverable error occurs
      */
     public function run()
     {
@@ -281,6 +282,11 @@ class Pico
         $this->loadConfig();
         $this->triggerEvent('onConfigLoaded', array(&$this->config));
 
+        // check content dir
+        if (!is_dir($this->getConfig('content_dir'))) {
+            throw new RuntimeException('Invalid content directory "' . $this->getConfig('content_dir') . '"');
+        }
+
         // evaluate request url
         $this->evaluateRequestUrl();
         $this->triggerEvent('onRequestUrl', array(&$this->requestUrl));
@@ -1025,7 +1031,7 @@ class Pico
      *
      * @see    Pico::readPages()
      * @see    Pico::sortPages()
-     * @return array|null the data of all pages
+     * @return array[]|null the data of all pages
      */
     public function getPages()
     {
@@ -1333,8 +1339,7 @@ class Pico
         if (!empty($this->plugins)) {
             foreach ($this->plugins as $plugin) {
                 // only trigger events for plugins that implement PicoPluginInterface
-                // deprecated events (plugins for Pico 0.9 and older) will be
-                // triggered by the `PicoPluginDeprecated` plugin
+                // deprecated events (plugins for Pico 0.9 and older) will be triggered by `PicoDeprecated`
                 if (is_a($plugin, 'PicoPluginInterface')) {
                     $plugin->handleEvent($eventName, $params);
                 }

+ 8 - 8
plugins/00-PicoDeprecated.php

@@ -67,7 +67,7 @@ class PicoDeprecated extends AbstractPicoPlugin
      *
      * @see DummyPlugin::onPluginsLoaded()
      */
-    public function onPluginsLoaded(&$plugins)
+    public function onPluginsLoaded(array &$plugins)
     {
         if (!empty($plugins)) {
             foreach ($plugins as $plugin) {
@@ -110,7 +110,7 @@ class PicoDeprecated extends AbstractPicoPlugin
      * @param  mixed[] &$realConfig array of config variables
      * @return void
      */
-    public function onConfigLoaded(&$realConfig)
+    public function onConfigLoaded(array &$realConfig)
     {
         global $config;
 
@@ -167,7 +167,7 @@ class PicoDeprecated extends AbstractPicoPlugin
      * @param  mixed[] &$realConfig array of config variables
      * @return void
      */
-    protected function loadRootDirConfig(&$realConfig)
+    protected function loadRootDirConfig(array &$realConfig)
     {
         if (file_exists($this->getRootDir() . 'config.php')) {
             // config.php in Pico::$rootDir is deprecated
@@ -284,7 +284,7 @@ class PicoDeprecated extends AbstractPicoPlugin
      *
      * @see DummyPlugin::onMetaHeaders()
      */
-    public function onMetaHeaders(&$headers)
+    public function onMetaHeaders(array &$headers)
     {
         $this->triggerEvent('before_read_file_meta', array(&$headers));
     }
@@ -294,7 +294,7 @@ class PicoDeprecated extends AbstractPicoPlugin
      *
      * @see DummyPlugin::onMetaParsed()
      */
-    public function onMetaParsed(&$meta)
+    public function onMetaParsed(array &$meta)
     {
         $this->triggerEvent('file_meta', array(&$meta));
     }
@@ -328,7 +328,7 @@ class PicoDeprecated extends AbstractPicoPlugin
      *
      * @see DummyPlugin::onSinglePageLoaded()
      */
-    public function onSinglePageLoaded(&$pageData)
+    public function onSinglePageLoaded(array &$pageData)
     {
         $this->triggerEvent('get_page_data', array(&$pageData, $pageData['meta']));
     }
@@ -344,7 +344,7 @@ class PicoDeprecated extends AbstractPicoPlugin
      *
      * @see DummyPlugin::onPagesLoaded()
      */
-    public function onPagesLoaded(&$pages, &$currentPage, &$previousPage, &$nextPage)
+    public function onPagesLoaded(array &$pages, array &$currentPage = null, array &$previousPage = null, array &$nextPage = null)
     {
         // remove keys of pages array
         $plainPages = array();
@@ -391,7 +391,7 @@ class PicoDeprecated extends AbstractPicoPlugin
      *
      * @see DummyPlugin::onPageRendering()
      */
-    public function onPageRendering(&$twig, &$twigVariables, &$templateName)
+    public function onPageRendering(Twig_Environment &$twig, array &$twigVariables, &$templateName)
     {
         // template name contains file extension since Pico 1.0
         $fileExtension = '';

+ 1 - 1
plugins/01-PicoParsePagesContent.php

@@ -30,7 +30,7 @@ class PicoParsePagesContent extends AbstractPicoPlugin
      *
      * @see DummyPlugin::onSinglePageLoaded()
      */
-    public function onSinglePageLoaded(&$pageData)
+    public function onSinglePageLoaded(array &$pageData)
     {
         if (!isset($pageData['content'])) {
             $pageData['content'] = $this->prepareFileContent($pageData['raw_content'], $pageData['meta']);

+ 2 - 2
plugins/02-PicoExcerpt.php

@@ -40,7 +40,7 @@ class PicoExcerpt extends AbstractPicoPlugin
      *
      * @see DummyPlugin::onConfigLoaded()
      */
-    public function onConfigLoaded(&$config)
+    public function onConfigLoaded(array &$config)
     {
         if (!isset($config['excerpt_length'])) {
             $config['excerpt_length'] = 50;
@@ -53,7 +53,7 @@ class PicoExcerpt extends AbstractPicoPlugin
      * @see PicoExcerpt::createExcerpt()
      * @see DummyPlugin::onSinglePageLoaded()
      */
-    public function onSinglePageLoaded(&$pageData)
+    public function onSinglePageLoaded(array &$pageData)
     {
         if (!isset($pageData['excerpt'])) {
             $pageData['excerpt'] = $this->createExcerpt(

+ 13 - 13
plugins/DummyPlugin.php

@@ -11,7 +11,7 @@
  * @license http://opensource.org/licenses/MIT
  * @version 1.0
  */
-class DummyPlugin extends AbstractPicoPlugin
+final class DummyPlugin extends AbstractPicoPlugin
 {
     /**
      * This plugin is enabled by default?
@@ -40,7 +40,7 @@ class DummyPlugin extends AbstractPicoPlugin
      * @param  object[] &$plugins loaded plugin instances
      * @return void
      */
-    public function onPluginsLoaded(&$plugins)
+    public function onPluginsLoaded(array &$plugins)
     {
         // your code
     }
@@ -52,7 +52,7 @@ class DummyPlugin extends AbstractPicoPlugin
      * @param  mixed[] &$config array of config variables
      * @return void
      */
-    public function onConfigLoaded(&$config)
+    public function onConfigLoaded(array &$config)
     {
         // your code
     }
@@ -141,7 +141,7 @@ class DummyPlugin extends AbstractPicoPlugin
      *     array key is later used to access the found value
      * @return void
      */
-    public function onMetaHeaders(&$headers)
+    public function onMetaHeaders(array &$headers)
     {
         // your code
     }
@@ -155,7 +155,7 @@ class DummyPlugin extends AbstractPicoPlugin
      * @param  string[] &$headers    known meta header fields
      * @return void
      */
-    public function onMetaParsing(&$rawContent, &$headers)
+    public function onMetaParsing(&$rawContent, array &$headers)
     {
         // your code
     }
@@ -167,7 +167,7 @@ class DummyPlugin extends AbstractPicoPlugin
      * @param  string[] &$meta parsed meta data
      * @return void
      */
-    public function onMetaParsed(&$meta)
+    public function onMetaParsed(array &$meta)
     {
         // your code
     }
@@ -249,7 +249,7 @@ class DummyPlugin extends AbstractPicoPlugin
      * @param  array &$pageData data of the loaded page
      * @return void
      */
-    public function onSinglePageLoaded(&$pageData)
+    public function onSinglePageLoaded(array &$pageData)
     {
         // your code
     }
@@ -264,13 +264,13 @@ class DummyPlugin extends AbstractPicoPlugin
      * @see    Pico::getCurrentPage()
      * @see    Pico::getPreviousPage()
      * @see    Pico::getNextPage()
-     * @param  array &$pages        data of all known pages
-     * @param  array &$currentPage  data of the page being served
-     * @param  array &$previousPage data of the previous page
-     * @param  array &$nextPage     data of the next page
+     * @param  array[]    &$pages        data of all known pages
+     * @param  array|null &$currentPage  data of the page being served
+     * @param  array|null &$previousPage data of the previous page
+     * @param  array|null &$nextPage     data of the next page
      * @return void
      */
-    public function onPagesLoaded(&$pages, &$currentPage, &$previousPage, &$nextPage)
+    public function onPagesLoaded(array &$pages, array &$currentPage = null, array &$previousPage = null, array &$nextPage = null)
     {
         // your code
     }
@@ -295,7 +295,7 @@ class DummyPlugin extends AbstractPicoPlugin
      * @param  string           &$templateName  file name of the template
      * @return void
      */
-    public function onPageRendering(&$twig, &$twigVariables, &$templateName)
+    public function onPageRendering(Twig_Environment &$twig, array &$twigVariables, &$templateName)
     {
         // your code
     }