From c72ea0ececdbee3c03453ef83d34c7e051067aa0 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 13 Nov 2015 19:10:30 +0100 Subject: [PATCH 01/80] PicoDeprecated: Sanitize content_dir and base_url options when reading config.php in Picos root dir --- CHANGELOG.md | 2 ++ lib/Pico.php | 11 +++++------ plugins/00-PicoDeprecated.php | 18 +++++++++++++++++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d211dc2..2b62150 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ Released: - * [New] New `markdown` filter for Twig to parse markdown strings; Note: If you want to parse the contents of a page, use the `content` filter instead * [Changed] Reuse `ParsedownExtra` object; new `onParsedownRegistration` event +* [Fixed] `PicoDeprecated`: Sanitize `content_dir` and `base_url` options when + reading `config.php` in Picos root dir * [Fixed] Replace `urldecode()` (deprecated RFC 1738) with `rawurldecode()` (RFC 3986) in `Page::evaluateRequestUrl()` * [Fixed] #272: Encode URLs using `rawurlencode()` in `Pico::getPageUrl()` diff --git a/lib/Pico.php b/lib/Pico.php index be75671..9c94c4a 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -446,6 +446,10 @@ class Pico protected function loadConfig() { $config = null; + if (file_exists($this->getConfigDir() . 'config.php')) { + require($this->getConfigDir() . 'config.php'); + } + $defaultConfig = array( 'site_title' => 'Pico', 'base_url' => '', @@ -460,11 +464,6 @@ class Pico 'timezone' => '' ); - $configFile = $this->getConfigDir() . 'config.php'; - if (file_exists($configFile)) { - require $configFile; - } - $this->config = is_array($this->config) ? $this->config : array(); $this->config += is_array($config) ? $config + $defaultConfig : $defaultConfig; @@ -1308,7 +1307,7 @@ class Pico * @param string $path relative or absolute path * @return string absolute path */ - protected function getAbsolutePath($path) + public function getAbsolutePath($path) { if (substr($path, 0, 1) !== '/') { $path = $this->getRootDir() . $path; diff --git a/plugins/00-PicoDeprecated.php b/plugins/00-PicoDeprecated.php index 53bfff2..a246547 100644 --- a/plugins/00-PicoDeprecated.php +++ b/plugins/00-PicoDeprecated.php @@ -170,11 +170,27 @@ class PicoDeprecated extends AbstractPicoPlugin protected function loadRootDirConfig(&$realConfig) { if (file_exists($this->getRootDir() . 'config.php')) { - // config.php in Pico::$rootDir is deprecated; use Pico::$configDir instead + // config.php in Pico::$rootDir is deprecated + // use config.php in Pico::$configDir instead $config = null; require($this->getRootDir() . 'config.php'); if (is_array($config)) { + if (array_key_exists('base_url', $config)) { + if (!empty($config['base_url'])) { + $config['base_url'] = rtrim($config['base_url'], '/') . '/'; + } else { + unset($config['base_url']); + } + } + if (array_key_exists('content_dir', $config)) { + if (!empty($config['content_dir'])) { + $config['content_dir'] = $this->getAbsolutePath($config['content_dir']); + } else { + unset($config['content_dir']); + } + } + $realConfig = $config + $realConfig; } } From f5006c036a03ee6a6ae7c909fa9f6669ebb489cc Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 13 Nov 2015 22:29:58 +0100 Subject: [PATCH 02/80] Prevent double slashes in base_url when installed to document root Fixes #274 --- lib/Pico.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Pico.php b/lib/Pico.php index 9c94c4a..443e557 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -1220,7 +1220,7 @@ class Pico $this->config['base_url'] = $protocol . "://" . $_SERVER['HTTP_HOST'] - . dirname($_SERVER['SCRIPT_NAME']) . '/'; + . rtrim(dirname($_SERVER['SCRIPT_NAME']), '/') . '/'; return $this->getConfig('base_url'); } From aa68cfaa459c3de245b2329bcf2de9af96324828 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 13 Nov 2015 22:34:47 +0100 Subject: [PATCH 03/80] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b62150..8a88039 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Released: - * [Fixed] Replace `urldecode()` (deprecated RFC 1738) with `rawurldecode()` (RFC 3986) in `Page::evaluateRequestUrl()` * [Fixed] #272: Encode URLs using `rawurlencode()` in `Pico::getPageUrl()` +* [Fixed] #274: Prevent double slashes in `base_url` ``` ### Version 1.0.0-beta.1 From 636f27ae2fdecbad56f5a79fc4f89c8696094362 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sat, 14 Nov 2015 00:26:26 +0100 Subject: [PATCH 04/80] Add asset handling recommendations to inline user docs Thanks @smcdougall for giving the hint about this --- content-sample/index.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/content-sample/index.md b/content-sample/index.md index 074ded8..55d385d 100644 --- a/content-sample/index.md +++ b/content-sample/index.md @@ -62,6 +62,12 @@ 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) + ### Text File Markup Text files are marked up using [Markdown][]. They can also contain regular HTML. From e0c1e068fb189fdaab4cf63b4db73de9d33ef312 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sat, 14 Nov 2015 00:26:45 +0100 Subject: [PATCH 05/80] Default theme: Improve table styling --- themes/default/style.css | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/themes/default/style.css b/themes/default/style.css index b1f3ca9..5fce108 100644 --- a/themes/default/style.css +++ b/themes/default/style.css @@ -32,7 +32,7 @@ body { } table { - border-collapse: separate; + border-collapse: collapse; border-spacing: 0; } @@ -137,7 +137,7 @@ h3 { margin-top: 2em; } -p { +p, table { margin-bottom: 1em; } @@ -167,6 +167,17 @@ td, td img { vertical-align: top; } +td, th { + border: solid 1px #999; + padding: 0.25em 0.5em; +} + +th { + font-weight: bold; + text-align: center; + background: #eee; +} + sub { vertical-align: sub; font-size: smaller; From 71076e8eba2ab43eec929fd365e100fc5beae27d Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sat, 14 Nov 2015 00:27:49 +0100 Subject: [PATCH 06/80] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a88039..912e766 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ Released: - all contributors and users which made this possible! * [New] New `markdown` filter for Twig to parse markdown strings; Note: If you want to parse the contents of a page, use the `content` filter instead +* [Changed] Improve documentation +* [Changed] Improve table styling in default theme * [Changed] Reuse `ParsedownExtra` object; new `onParsedownRegistration` event * [Fixed] `PicoDeprecated`: Sanitize `content_dir` and `base_url` options when reading `config.php` in Picos root dir From c0d30d20f8984e616a3f2359fc9c78f13adaa76c Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sat, 14 Nov 2015 16:50:32 +0100 Subject: [PATCH 07/80] 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 --- plugins/00-PicoDeprecated.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/plugins/00-PicoDeprecated.php b/plugins/00-PicoDeprecated.php index a246547..4866b9e 100644 --- a/plugins/00-PicoDeprecated.php +++ b/plugins/00-PicoDeprecated.php @@ -176,19 +176,11 @@ class PicoDeprecated extends AbstractPicoPlugin require($this->getRootDir() . 'config.php'); if (is_array($config)) { - if (array_key_exists('base_url', $config)) { - if (!empty($config['base_url'])) { - $config['base_url'] = rtrim($config['base_url'], '/') . '/'; - } else { - unset($config['base_url']); - } + if (isset($config['base_url'])) { + $config['base_url'] = rtrim($config['base_url'], '/') . '/'; } - if (array_key_exists('content_dir', $config)) { - if (!empty($config['content_dir'])) { - $config['content_dir'] = $this->getAbsolutePath($config['content_dir']); - } else { - unset($config['content_dir']); - } + if (isset($config['content_dir'])) { + $config['content_dir'] = rtrim($config['content_dir'], '/') . '/'; } $realConfig = $config + $realConfig; From 3b737aac1abc62bcacc4374bddce48fd8d0b036f Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 18 Nov 2015 00:34:59 +0100 Subject: [PATCH 08/80] Update README.md: Update "edit inline docs" link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 520d937..e4c2642 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,6 @@ You want to contribute to Pico? We really appreciate that! You can help make Pic [IssuesSearch]: https://github.com/picocms/Pico/search?type=Issues [PullRequests]: https://github.com/picocms/Pico/pulls [ContributionGuidelines]: https://github.com/picocms/Pico/blob/master/CONTRIBUTING.md -[EditInlineDocs]: https://github.com/picocms/Pico/blob/master/content-sample/index.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 From 3e4bcd4289b807c4f7dd9b4cb45d1743de78ed4b Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 18 Nov 2015 00:41:38 +0100 Subject: [PATCH 09/80] Update CONTRIBUTING.md: Fix typo --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2aa4241..64e5f52 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,7 +45,7 @@ With this command you can specify a file or folder to limit which files it will ### Keep documentation in sync -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 the keep them in sync. +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. From ba766ea65c2c5b65cc56ebcb72b2eb57ece921ee Mon Sep 17 00:00:00 2001 From: theshka Date: Wed, 18 Nov 2015 13:39:48 -0600 Subject: [PATCH 10/80] Update Build & Release section --- CONTRIBUTING.md | 63 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 64e5f52..5ec7925 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -78,44 +78,63 @@ As soon as development reaches a point where feedback is appreciated, a pull req Build & Release process ----------------------- -This is work in progress. Please refer to [#268](https://github.com/picocms/Pico/issues/268) for details. +> This is work in progress. Please refer to [#268](https://github.com/picocms/Pico/issues/268) for details. - From 8093758b3ed2d98d4b32f2a8723eb1d08fe41a9f Mon Sep 17 00:00:00 2001 From: theshka Date: Wed, 18 Nov 2015 15:26:39 -0600 Subject: [PATCH 11/80] Improve headings and formatting --- CONTRIBUTING.md | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5ec7925..7634a33 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -82,10 +82,10 @@ Build & Release process Defined below is a specification to which the Build and Release process of Pico should follow. We use [travis-ci](https://travis-ci.com) to automate the process, and each commit to `master` should be deployable. Once a `feature/branch` or the `master` branch have reached a point where the need for a version increase is necessary move through these phases to generate a Pico release. -#### Commit phase +### Commit phase - Make/Commit/Merge changes -- Use a formatted commit message +- Use a formatted commit message with contents of changelog Example: ``` @@ -102,7 +102,7 @@ Defined below is a specification to which the Build and Release process of Pico [SemVer](http://semver.org) increase to avoid the need for manual amendments.__ -#### Analysis phase +### Analysis phase Does the commit pass all `travis-ci` checks? @@ -110,31 +110,32 @@ Does the commit pass all `travis-ci` checks? If not, all errors will need to be corrected before the build can complete. -#### Packaging phase -`travis-ci` +### Packaging phase + +###### travis-ci - will run [composer](http://getcomposer.org) locally. - will create a ZIP archive (so vendor/ is included) -`manually` +###### manually - build current documentation using [PhpDocumentor](http://phpdoc.org), -#### Release phase -`travis-ci` +### Release phase + +###### travis-ci - will create new Git release at tag - will include the properly formatted commit message including the changelog of items since the last release. - will include ZIP archive in release -`manually` +###### manually - rename `docs/master` folder in `gh-pages` branch to the name of the previous Pico release. (e.g. `docs/pico-1.0.0`) - upload current documentation to the `gh-pages` branch `/docs/master` - - update release information on GitHub with: - Release title (taken from changelog) - Changelog -`automatically` +###### automatically - Pico will be automatically updated on [Packagist](http://packagist.org/packages/picocms/pico) -#### Announcements -- Where to announce new Pico release? +### Announcements +- Releases will be available at https://github.com/picocms/Pico/releases From 31d611a5077191c1a2dfbdbb67047734d3e78daf Mon Sep 17 00:00:00 2001 From: theshka Date: Wed, 18 Nov 2015 18:55:26 -0600 Subject: [PATCH 12/80] add template for new issues --- CONTRIBUTING.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7634a33..1edef44 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,6 +14,39 @@ If you want to report an *issue* with Pico's core, please create a new [Issue](h Before creating a [new Issue on GitHub](https://github.com/picocms/Pico/issues/new), please make sure the problem wasn't reported yet using [GitHubs search engine](https://github.com/picocms/Pico/search?type=Issues). Please describe your issue as clear as possible and always include steps to reproduce the problem. +This is an example of what information to include with your issue. + + Version + - Operating System and version + - Pico Version + - other installed software, plugins, if applicable + - hardware information, if applicable + + Bug Description + - A concise description of what the problem is. Pure description, no narrative or conversational language. + + Severity + - Trivial, Minor, Major, or Catastrophic + + Steps to Reproduce + - Step by step instructions on how to reproduce this bug. + - Do not assume anything, the more detailed your list of instructions, the easier it is for the developer to track down the problem! + + Actual Behavior + - Type what happens when you follow the instructions. This is the manifestation of the bug. + + Expected Behavior + - Type what you expected to happen when you followed the instructions. + - This is important, because you may have misunderstood something or missed a step, + and knowing what you expected to see will help the developer recognize that. + + Troubleshooting/Testing Steps Attempted + - Describe anything you did to try to fix it on your own. + + Workaround + - If you found a way to make the program work in spite of the bug, describe how you did it here. + + Contributing code ----------------- From d252df4b98c0af82ea76a3ba9abc409138d8cb93 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Thu, 19 Nov 2015 04:48:22 +0100 Subject: [PATCH 13/80] Throw RuntimeException on invalid content dirs --- CHANGELOG.md | 1 + lib/Pico.php | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 912e766..991b2ec 100644 --- a/CHANGELOG.md +++ b/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 diff --git a/lib/Pico.php b/lib/Pico.php index 443e557..3089290 100644 --- a/lib/Pico.php +++ b/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)); From f6d5e8c7f40e101ab4a4367bce5ea5560a9015ce Mon Sep 17 00:00:00 2001 From: theshka Date: Fri, 20 Nov 2015 20:30:56 -0600 Subject: [PATCH 14/80] can phpDoc be automatic? --- CONTRIBUTING.md | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1edef44..827f583 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -113,12 +113,12 @@ Build & Release process > This is work in progress. Please refer to [#268](https://github.com/picocms/Pico/issues/268) for details. -Defined below is a specification to which the Build and Release process of Pico should follow. We use [travis-ci](https://travis-ci.com) to automate the process, and each commit to `master` should be deployable. Once a `feature/branch` or the `master` branch have reached a point where the need for a version increase is necessary move through these phases to generate a Pico release. +Defined below is a specification to which the Build and Release process of Pico should follow. We use [travis-ci](https://travis-ci.com) to automate the process, and each commit to `master` should be deployable. Once a `feature/branch` or the `master` branch have reached a point where the need for a version increase is necessary, move through these phases to generate a Pico release. ### Commit phase - Make/Commit/Merge changes -- Use a formatted commit message with contents of changelog +- Use a formatted commit message with contents of `CHANGELOG.md` since last release. Example: ``` @@ -141,6 +141,10 @@ Does the commit pass all `travis-ci` checks? - We test PHP 5.3, 5.4, 5.5, 5.6, 7, the nighlty build, and HHVM +- should we `allow_failures:` in `.tavis.yml?` + - php: hhvm + - php: 7 + If not, all errors will need to be corrected before the build can complete. ### Packaging phase @@ -151,7 +155,24 @@ If not, all errors will need to be corrected before the build can complete. ###### manually -- build current documentation using [PhpDocumentor](http://phpdoc.org), +- build current documentation using [PhpDocumentor](http://phpdoc.org) + + `phpdoc -d path/to/Pico/ -t path/to/Pico/build/docs/master` + + When running `phpDocumentor` there are three command-line options that are essential: + - `-d`, specifies the directory, or directories, of your project that you want to document. + - `-f`, specifies a specific file, or files, in your project that you want to document. + - `-t`, specifies the location where your documentation will be written (also called ‘target folder’). + +TO-DO: in the future, this should be automatic. +- can `phpDocumentor` be included in Pico's `composer.json`? +- can `travis-ci` run `phpDocumentor`? `php vendor/bin/phpdoc ...` +- can `travis-ci` run a shell script to: + - `git clone`, `git add`, `git commit`, `git push` to `gh-pages`? + e.g. `git clone -b gh-pages "https://github.com/picocms/Pico.git"` + - (below) rename `docs/master` ... + - `git push` +- organize in `build` folder? ### Release phase @@ -161,11 +182,12 @@ If not, all errors will need to be corrected before the build can complete. - will include ZIP archive in release ###### manually +TO-DO: in the future, this should be automatic. (See above) - rename `docs/master` folder in `gh-pages` branch to the name of the previous Pico release. (e.g. `docs/pico-1.0.0`) -- upload current documentation to the `gh-pages` branch `/docs/master` +- upload current documentation to the `gh-pages` branch `/docs/master` - update release information on GitHub with: - - Release title (taken from changelog) - - Changelog + - release title (taken from changelog) + - changelog ###### automatically - Pico will be automatically updated on [Packagist](http://packagist.org/packages/picocms/pico) From f062640bb1e87c82108067d238b47e7289ea11df Mon Sep 17 00:00:00 2001 From: theshka Date: Fri, 20 Nov 2015 23:28:09 -0600 Subject: [PATCH 15/80] test auto docs --- .travis.yml | 11 ++++++++++- build/gh-pages.sh | 31 +++++++++++++++++++++++++++++++ composer.json | 3 +++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 build/gh-pages.sh diff --git a/.travis.yml b/.travis.yml index 01b5c42..04c9e4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,17 @@ script: - find . -type f -name '*.php' -print0 | xargs -0 -I file php -l file > /dev/null before_deploy: + #update composer + - composer self-update + # install dependencies + req-dev - composer install + # Generate API documentation + - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.6' ]; then php vendor/bin/phpdoc -d $TRAVIS_BUILD_DIR -t $TRAVIS_BUILD_DIR/build/docs/$TRAVIS_TAG ; fi" + # Send documentation to Github Pages + - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.6' ]; then cd build/docs; bash ../gh-pages.sh; fi" + # remove req-dev depenedencies + - composer update --no-dev + # package Pico - tar -czf "pico-release-$TRAVIS_TAG.tar.gz" .htaccess README.md CHANGELOG.md CONTRIBUTING.md composer.json composer.lock LICENSE config content-sample lib plugins themes vendor index.php deploy: @@ -26,4 +36,3 @@ deploy: php: 5.3 sudo: false - diff --git a/build/gh-pages.sh b/build/gh-pages.sh new file mode 100644 index 0000000..1e821ff --- /dev/null +++ b/build/gh-pages.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# +# https://gist.github.com/domenic/ec8b0fc8ab45f39403dd +# + +# Exit with nonzero exit code if anything fails +set -e + +# Clone Pico, then create & checkout gh-pages branch +git clone -b gh-pages "https://github.com/theshka/Pico.git" + +# Inside this git repo we'll pretend to be a new user +git config user.name "theshka" +git config user.email "tyler@heshka.com" + +#move old files +mv $TRAVIS_BUILD_DIR/Pico/phpDoc/master $TRAVIS_BUILD_DIR/Pico/phpDoc/old-stable +#move new files +cp $TRAVIS_BUILD_DIR/build/docs/$TRAVIS_TAG $TRAVIS_BUILD_DIR/Pico/phpDoc/master + +# Add the files to our commit +git add $TRAVIS_BUILD_DIR/Pico/phpDoc/* + +# Commit the files with our commit message +git commit -m "update documentation" + +# Force push from the current repo's master branch to the remote +# repo's gh-pages branch.We redirect any output to +# /dev/null to hide any sensitive credential data that might otherwise be exposed. +#git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" master:gh-pages > /dev/null 2>&1 +git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" master:gh-pages > /dev/null 2>&1 diff --git a/composer.json b/composer.json index b0d75e1..b16ab1d 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,9 @@ "erusev/parsedown-extra": "0.7.*", "symfony/yaml" : "2.3" }, + "require-dev" : { + "phpdocumentor/phpdocumentor": "2.*" + }, "autoload": { "psr-0": { "Pico": "lib/", From d59dba0b5faf35ecdca0ae65b8a9a72141f4279a Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sat, 21 Nov 2015 22:13:54 +0100 Subject: [PATCH 16/80] Update README.md: Add update instructions for composer users --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e4c2642..1f32a64 100644 --- a/README.md +++ b/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]. From 60c627c21416d55d0de2a8e3b1e74d4408e10be7 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 22 Nov 2015 14:08:06 +0100 Subject: [PATCH 17/80] Update composer.json: Use latest MINOR versions of Twig/Parsedown/YAML --- composer.json | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index b0d75e1..c8a1355 100644 --- a/composer.json +++ b/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" }, "autoload": { "psr-0": { From c34afad4affb14750ed01abaa9fad7c491ef52f2 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 22 Nov 2015 14:08:35 +0100 Subject: [PATCH 18/80] Fix typo --- lib/Pico.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/Pico.php b/lib/Pico.php index 3089290..2a2a383 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -1339,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); } From 7f910e913f9629828b3535c7979b589bed906bdb Mon Sep 17 00:00:00 2001 From: theshka Date: Mon, 23 Nov 2015 11:59:05 -0600 Subject: [PATCH 19/80] update auto-docs files * [Changed] move everything inside /build/ directory Implement @PhrozenByte 's suggestions. * [Changed] don't change directories, pass the paths * [Removed] unnecessary `composer install`, travis-ci runs this already * [Removed] unnecessary `composer self-update` command * [Removed] unnecessary php version check on script --- .travis.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 04c9e4a..c03cc77 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,14 +12,10 @@ script: - find . -type f -name '*.php' -print0 | xargs -0 -I file php -l file > /dev/null before_deploy: - #update composer - - composer self-update - # install dependencies + req-dev - - composer install # Generate API documentation - - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.6' ]; then php vendor/bin/phpdoc -d $TRAVIS_BUILD_DIR -t $TRAVIS_BUILD_DIR/build/docs/$TRAVIS_TAG ; fi" + - sh -c "php $TRAVIS_BUILD_DIR/vendor/bin/phpdoc -d $TRAVIS_BUILD_DIR -t $TRAVIS_BUILD_DIR/build/docs/pico-$TRAVIS_TAG" # Send documentation to Github Pages - - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.6' ]; then cd build/docs; bash ../gh-pages.sh; fi" + - sh -c "bash $TRAVIS_BUILD_DIR/build/deploy-phpdoc.sh;" # remove req-dev depenedencies - composer update --no-dev # package Pico From e0c63834066c6401bd2cc649a6cc1a6f78b1a20c Mon Sep 17 00:00:00 2001 From: theshka Date: Mon, 23 Nov 2015 12:03:53 -0600 Subject: [PATCH 20/80] rename script --- build/gh-pages.sh | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 build/gh-pages.sh diff --git a/build/gh-pages.sh b/build/gh-pages.sh deleted file mode 100644 index 1e821ff..0000000 --- a/build/gh-pages.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -# -# https://gist.github.com/domenic/ec8b0fc8ab45f39403dd -# - -# Exit with nonzero exit code if anything fails -set -e - -# Clone Pico, then create & checkout gh-pages branch -git clone -b gh-pages "https://github.com/theshka/Pico.git" - -# Inside this git repo we'll pretend to be a new user -git config user.name "theshka" -git config user.email "tyler@heshka.com" - -#move old files -mv $TRAVIS_BUILD_DIR/Pico/phpDoc/master $TRAVIS_BUILD_DIR/Pico/phpDoc/old-stable -#move new files -cp $TRAVIS_BUILD_DIR/build/docs/$TRAVIS_TAG $TRAVIS_BUILD_DIR/Pico/phpDoc/master - -# Add the files to our commit -git add $TRAVIS_BUILD_DIR/Pico/phpDoc/* - -# Commit the files with our commit message -git commit -m "update documentation" - -# Force push from the current repo's master branch to the remote -# repo's gh-pages branch.We redirect any output to -# /dev/null to hide any sensitive credential data that might otherwise be exposed. -#git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" master:gh-pages > /dev/null 2>&1 -git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" master:gh-pages > /dev/null 2>&1 From bf2a9622db3c35b94eceaeb32d9e919dd18f36bf Mon Sep 17 00:00:00 2001 From: theshka Date: Mon, 23 Nov 2015 12:04:08 -0600 Subject: [PATCH 21/80] Update deploy script * [Changed] move everything inside /build/ directory * [Changed] use absolute file paths in script * [Changed] copy docs to both the release number and master dirs Implement @PhrozenByte 's suggestions. * [Changed] use `$GITHUB_OAUTH_TOKEN` instead of `$GITHUB_TOKEN` --- build/deploy-phpdoc.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 build/deploy-phpdoc.sh diff --git a/build/deploy-phpdoc.sh b/build/deploy-phpdoc.sh new file mode 100644 index 0000000..921fc7b --- /dev/null +++ b/build/deploy-phpdoc.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# Modified from: https://gist.github.com/domenic/ec8b0fc8ab45f39403dd + +# Exit with nonzero exit code if anything fails +set -e + +# Clone Pico, then create & checkout gh-pages branch +git clone -b gh-pages "https://github.com/picocms/Pico.git $TRAVIS_BUILD_DIR/build/Pico" + +# Inside this git repo we'll pretend to be a new user +git config user.name "Travis CI" +git config user.email "travis-ci@picocms.org" + +#copy new files to release number +cp -a $TRAVIS_BUILD_DIR/build/docs/pico-$TRAVIS_TAG $TRAVIS_BUILD_DIR/build/Pico/phpDoc/pico-$TRAVIS_TAG +#move old files +mv -f $TRAVIS_BUILD_DIR/build/Pico/phpDoc/master $TRAVIS_BUILD_DIR/build/Pico/phpDoc/old-stable +#copy new files to master +cp -a $TRAVIS_BUILD_DIR/build/docs/pico-$TRAVIS_TAG $TRAVIS_BUILD_DIR/build/Pico/phpDoc/master + +# Add the files to our commit +git add $TRAVIS_BUILD_DIR/build/Pico/phpDoc/* + +# Commit the files with our commit message +git commit -m "Update Documentation for Pico $TRAVIS_TAG" + +# Force push from the current repo's master branch to the remote +# repo's gh-pages branch.We redirect any output to +# /dev/null to hide any sensitive credential data that might otherwise be exposed. +git push --force --quiet "https://${GITHUB_OAUTH_TOKEN}@${GH_REF}" master:gh-pages > /dev/null 2>&1 From edbf9f1747ebaf56a81c76fd673388901c6cebe3 Mon Sep 17 00:00:00 2001 From: theshka Date: Mon, 23 Nov 2015 12:07:54 -0600 Subject: [PATCH 22/80] Implement @PhrozenByte 's suggestions. * [Changed] require phpDocumentor version ^2.8 constraint --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b16ab1d..2787259 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "symfony/yaml" : "2.3" }, "require-dev" : { - "phpdocumentor/phpdocumentor": "2.*" + "phpdocumentor/phpdocumentor": "^2.8" }, "autoload": { "psr-0": { From 04f7140347e2bcb490058502c1fad7c36cbacc3b Mon Sep 17 00:00:00 2001 From: theshka Date: Mon, 23 Nov 2015 13:19:47 -0600 Subject: [PATCH 23/80] update .travis.yml for auto-docs --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c03cc77..2cc0f22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ script: before_deploy: # Generate API documentation - - sh -c "php $TRAVIS_BUILD_DIR/vendor/bin/phpdoc -d $TRAVIS_BUILD_DIR -t $TRAVIS_BUILD_DIR/build/docs/pico-$TRAVIS_TAG" + - sh -c "php $TRAVIS_BUILD_DIR/vendor/bin/phpdoc -d $TRAVIS_BUILD_DIR -t $TRAVIS_BUILD_DIR/build/docs/$TRAVIS_TAG --ignore '*/vendor/*'" # Send documentation to Github Pages - sh -c "bash $TRAVIS_BUILD_DIR/build/deploy-phpdoc.sh;" # remove req-dev depenedencies From c3b908939f2664ad86f06b677ec50fc0757f0fbb Mon Sep 17 00:00:00 2001 From: theshka Date: Mon, 23 Nov 2015 13:26:31 -0600 Subject: [PATCH 24/80] update deploy-phpdoc.sh for auto docs --- build/deploy-phpdoc.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/build/deploy-phpdoc.sh b/build/deploy-phpdoc.sh index 921fc7b..0d447ed 100644 --- a/build/deploy-phpdoc.sh +++ b/build/deploy-phpdoc.sh @@ -12,11 +12,11 @@ git config user.name "Travis CI" git config user.email "travis-ci@picocms.org" #copy new files to release number -cp -a $TRAVIS_BUILD_DIR/build/docs/pico-$TRAVIS_TAG $TRAVIS_BUILD_DIR/build/Pico/phpDoc/pico-$TRAVIS_TAG -#move old files +cp -a $TRAVIS_BUILD_DIR/build/docs/$TRAVIS_TAG $TRAVIS_BUILD_DIR/build/Pico/phpDoc/$TRAVIS_TAG +#move old master files to old-stable mv -f $TRAVIS_BUILD_DIR/build/Pico/phpDoc/master $TRAVIS_BUILD_DIR/build/Pico/phpDoc/old-stable #copy new files to master -cp -a $TRAVIS_BUILD_DIR/build/docs/pico-$TRAVIS_TAG $TRAVIS_BUILD_DIR/build/Pico/phpDoc/master +cp -a $TRAVIS_BUILD_DIR/build/docs/$TRAVIS_TAG $TRAVIS_BUILD_DIR/build/Pico/phpDoc/master # Add the files to our commit git add $TRAVIS_BUILD_DIR/build/Pico/phpDoc/* @@ -24,7 +24,6 @@ git add $TRAVIS_BUILD_DIR/build/Pico/phpDoc/* # Commit the files with our commit message git commit -m "Update Documentation for Pico $TRAVIS_TAG" -# Force push from the current repo's master branch to the remote -# repo's gh-pages branch.We redirect any output to -# /dev/null to hide any sensitive credential data that might otherwise be exposed. -git push --force --quiet "https://${GITHUB_OAUTH_TOKEN}@${GH_REF}" master:gh-pages > /dev/null 2>&1 +# Force push from the current repo's gh-pages branch to the remote repo's gh-pages branch. +# We redirect output to /dev/null to hide any sensitive data that might otherwise be exposed. +git push --force --quiet "https://${GITHUB_OAUTH_TOKEN}@github.com/picocms/Pico.git" master:gh-pages > /dev/null 2>&1 From bd24d518f20b9568aa9625bec27fc93b4db01cf0 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Mon, 23 Nov 2015 21:33:57 +0100 Subject: [PATCH 25/80] Update .gitignore --- .gitignore | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 01cdfee..825c513 100644 --- a/.gitignore +++ b/.gitignore @@ -11,22 +11,22 @@ desktop.ini ._* # 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 From 7f4ad752454278a1a5ee50259737b1f4534a0778 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Mon, 23 Nov 2015 21:46:36 +0100 Subject: [PATCH 26/80] Refactor phpDoc auto-deployment --- .gitignore | 4 ++++ .travis.yml | 13 +++++-------- build/deploy-phpdoc.sh | 40 ++++++++++++++++++++-------------------- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 01cdfee..25d5f39 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,10 @@ desktop.ini .DS_Store ._* +# Travis +/build/phpdoc-*/ +/build/phpdoc-*.git/ + # Composer composer.lock composer.phar diff --git a/.travis.yml b/.travis.yml index 2cc0f22..5a0544f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,14 +12,11 @@ script: - find . -type f -name '*.php' -print0 | xargs -0 -I file php -l file > /dev/null before_deploy: - # Generate API documentation - - sh -c "php $TRAVIS_BUILD_DIR/vendor/bin/phpdoc -d $TRAVIS_BUILD_DIR -t $TRAVIS_BUILD_DIR/build/docs/$TRAVIS_TAG --ignore '*/vendor/*'" - # Send documentation to Github Pages - - sh -c "bash $TRAVIS_BUILD_DIR/build/deploy-phpdoc.sh;" - # remove req-dev depenedencies - - composer update --no-dev - # package Pico - - tar -czf "pico-release-$TRAVIS_TAG.tar.gz" .htaccess README.md CHANGELOG.md CONTRIBUTING.md composer.json composer.lock LICENSE config content-sample lib plugins themes vendor index.php + - composer install + - ./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 + - 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: provider: releases diff --git a/build/deploy-phpdoc.sh b/build/deploy-phpdoc.sh index 0d447ed..6a5d0b8 100644 --- a/build/deploy-phpdoc.sh +++ b/build/deploy-phpdoc.sh @@ -1,29 +1,29 @@ #!/usr/bin/env bash -# Modified from: https://gist.github.com/domenic/ec8b0fc8ab45f39403dd - -# Exit with nonzero exit code if anything fails set -e -# Clone Pico, then create & checkout gh-pages branch -git clone -b gh-pages "https://github.com/picocms/Pico.git $TRAVIS_BUILD_DIR/build/Pico" +# parameters +GITHUB_PROJECT="$1" # GitHub repo (e.g. picocms/Pico) +GITHUB_BRANCH="$2" # branch to use (e.g. gh-pages) +GITHUB_OAUTH_TOKEN="$3" # see https://github.com/settings/tokens +SOURCE_DIR="$4" # absolute path to phpDocs target directory +TARGET_DIR="$5" # relative path within the specified GitHub repo -# Inside this git repo we'll pretend to be a new user +# clone repo +GIT_DIR="$(dirname "$0")/$(basename "$SOURCE_DIR").git" +git clone -b "$GITHUB_BRANCH" "https://github.com/$GITHUB_PROJECT.git" "$GIT_DIR" + +# setup git +cd "$GIT_DIR" git config user.name "Travis CI" git config user.email "travis-ci@picocms.org" -#copy new files to release number -cp -a $TRAVIS_BUILD_DIR/build/docs/$TRAVIS_TAG $TRAVIS_BUILD_DIR/build/Pico/phpDoc/$TRAVIS_TAG -#move old master files to old-stable -mv -f $TRAVIS_BUILD_DIR/build/Pico/phpDoc/master $TRAVIS_BUILD_DIR/build/Pico/phpDoc/old-stable -#copy new files to master -cp -a $TRAVIS_BUILD_DIR/build/docs/$TRAVIS_TAG $TRAVIS_BUILD_DIR/build/Pico/phpDoc/master +# copy phpdoc +[ -e "$TARGET_DIR" ] && echo "FATAL: $(basename "$0") target directory exists" && exit 1 +cp -R "$SOURCE_DIR" "$TARGET_DIR" -# Add the files to our commit -git add $TRAVIS_BUILD_DIR/build/Pico/phpDoc/* +# commit changes +git add "$TARGET_DIR" +git commit -m "Add phpDocumentor class docs for Pico $TRAVIS_TAG" -# Commit the files with our commit message -git commit -m "Update Documentation for Pico $TRAVIS_TAG" - -# Force push from the current repo's gh-pages branch to the remote repo's gh-pages branch. -# We redirect output to /dev/null to hide any sensitive data that might otherwise be exposed. -git push --force --quiet "https://${GITHUB_OAUTH_TOKEN}@github.com/picocms/Pico.git" master:gh-pages > /dev/null 2>&1 +# push changes +git push --force --quiet "https://${GITHUB_OAUTH_TOKEN}@github.com/$GITHUB_PROJECT.git" "$GITHUB_BRANCH:$GITHUB_BRANCH" > /dev/null 2>&1 From 9712ae2a97dc9adb52f029631669f1367328a91b Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Mon, 23 Nov 2015 21:52:23 +0100 Subject: [PATCH 27/80] Fix permissions of build/deploy-phpdoc.sh --- build/deploy-phpdoc.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 build/deploy-phpdoc.sh diff --git a/build/deploy-phpdoc.sh b/build/deploy-phpdoc.sh old mode 100644 new mode 100755 From 80049ed9666bdc96d0bdad7f31057b3c7b2a653b Mon Sep 17 00:00:00 2001 From: theshka Date: Mon, 23 Nov 2015 15:51:12 -0600 Subject: [PATCH 28/80] update build & release section for auto-docs --- CONTRIBUTING.md | 50 ++++++++++++------------------------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 827f583..aa812cb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -141,56 +141,30 @@ Does the commit pass all `travis-ci` checks? - We test PHP 5.3, 5.4, 5.5, 5.6, 7, the nighlty build, and HHVM -- should we `allow_failures:` in `.tavis.yml?` - - php: hhvm - - php: 7 - If not, all errors will need to be corrected before the build can complete. ### Packaging phase ###### travis-ci -- will run [composer](http://getcomposer.org) locally. +- will run [composer](http://getcomposer.org) locally with `req-dev` dependencies. +- will generate [PhpDocumentor](http://phpdoc.org) class docs automatically +- will run our `deploy-phpdoc.sh` script - will create a ZIP archive (so vendor/ is included) -###### manually - -- build current documentation using [PhpDocumentor](http://phpdoc.org) - - `phpdoc -d path/to/Pico/ -t path/to/Pico/build/docs/master` - - When running `phpDocumentor` there are three command-line options that are essential: - - `-d`, specifies the directory, or directories, of your project that you want to document. - - `-f`, specifies a specific file, or files, in your project that you want to document. - - `-t`, specifies the location where your documentation will be written (also called ‘target folder’). - -TO-DO: in the future, this should be automatic. -- can `phpDocumentor` be included in Pico's `composer.json`? -- can `travis-ci` run `phpDocumentor`? `php vendor/bin/phpdoc ...` -- can `travis-ci` run a shell script to: - - `git clone`, `git add`, `git commit`, `git push` to `gh-pages`? - e.g. `git clone -b gh-pages "https://github.com/picocms/Pico.git"` - - (below) rename `docs/master` ... - - `git push` -- organize in `build` folder? - ### Release phase ###### travis-ci +- will remove phpDocumentor from dependencies - will create new Git release at tag -- will include the properly formatted commit message including the changelog of items since the last release. +- will include the properly formatted commit message including the changelog of items since the last release. - will include ZIP archive in release -###### manually -TO-DO: in the future, this should be automatic. (See above) -- rename `docs/master` folder in `gh-pages` branch to the name of the previous Pico release. (e.g. `docs/pico-1.0.0`) -- upload current documentation to the `gh-pages` branch `/docs/master` -- update release information on GitHub with: - - release title (taken from changelog) - - changelog - -###### automatically -- Pico will be automatically updated on [Packagist](http://packagist.org/packages/picocms/pico) +###### Note: +If a properly formatted commit message was not provided, you may have to update release information on GitHub with: +- release title (taken from changelog) +- changelog ### Announcements -- Releases will be available at https://github.com/picocms/Pico/releases +- Releases will be available at: [https://github.com/picocms/Pico/releases](https://github.com/picocms/Pico/releases) + +- Pico will be automatically updated on [Packagist](http://packagist.org/packages/picocms/pico) From 9e752c1d293272a9a10fcbbe48c670c7652b3ac0 Mon Sep 17 00:00:00 2001 From: Diogo Oliveira de Melo Date: Mon, 23 Nov 2015 20:11:42 -0200 Subject: [PATCH 29/80] It works when Pico is installed as a dependency --- index.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index 40b811a..5920eb4 100644 --- a/index.php +++ b/index.php @@ -1,6 +1,14 @@ Date: Mon, 23 Nov 2015 20:29:33 -0200 Subject: [PATCH 30/80] update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 991b2ec..b6810a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Released: - (RFC 3986) in `Page::evaluateRequestUrl()` * [Fixed] #272: Encode URLs using `rawurlencode()` in `Pico::getPageUrl()` * [Fixed] #274: Prevent double slashes in `base_url` +* [Fixed] #285: Make `index.php` work when installed as a composer dependency ``` ### Version 1.0.0-beta.1 From 2982f5deb9565e87c2236f25d0521fb4c8e3100a Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Tue, 24 Nov 2015 19:49:16 +0100 Subject: [PATCH 31/80] Optimize composer autoloader before deploying This converts PSR-0/PSR-4 autoloading to classmap to get a faster autoloader (up to 20% performance increase) --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 01b5c42..331173c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ script: before_deploy: - composer install + - composer dump-autoload --optimize - tar -czf "pico-release-$TRAVIS_TAG.tar.gz" .htaccess README.md CHANGELOG.md CONTRIBUTING.md composer.json composer.lock LICENSE config content-sample lib plugins themes vendor index.php deploy: From 840d41bca5b35ddcb24d5b4cdd3fc14a61c5496e Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 25 Nov 2015 04:07:46 +0100 Subject: [PATCH 32/80] Improve type hinting --- lib/Pico.php | 2 +- plugins/00-PicoDeprecated.php | 16 ++++++++-------- plugins/01-PicoParsePagesContent.php | 2 +- plugins/02-PicoExcerpt.php | 4 ++-- plugins/DummyPlugin.php | 24 ++++++++++++------------ 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/Pico.php b/lib/Pico.php index 2a2a383..ccc0d55 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -1031,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() { diff --git a/plugins/00-PicoDeprecated.php b/plugins/00-PicoDeprecated.php index 4866b9e..f646b03 100644 --- a/plugins/00-PicoDeprecated.php +++ b/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 = ''; diff --git a/plugins/01-PicoParsePagesContent.php b/plugins/01-PicoParsePagesContent.php index fd36f0a..db4ed10 100644 --- a/plugins/01-PicoParsePagesContent.php +++ b/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']); diff --git a/plugins/02-PicoExcerpt.php b/plugins/02-PicoExcerpt.php index 4ada382..7d0c449 100644 --- a/plugins/02-PicoExcerpt.php +++ b/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( diff --git a/plugins/DummyPlugin.php b/plugins/DummyPlugin.php index 9ecd411..60f2f35 100644 --- a/plugins/DummyPlugin.php +++ b/plugins/DummyPlugin.php @@ -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 } From 876a500ecfda382a3a3362f4093403372eed8407 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 25 Nov 2015 04:07:57 +0100 Subject: [PATCH 33/80] Improve .gitignore --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 825c513..f77c917 100644 --- a/.gitignore +++ b/.gitignore @@ -19,11 +19,11 @@ desktop.ini /config/config.php # User themes -/themes +/themes/* !/themes/default # User plugins -/plugins +/plugins/* !/plugins/0?-* !/plugins/1?-* !/plugins/DummyPlugin.php From 20387e0bf980196e3ac1afb61c954062ed14e7dd Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 25 Nov 2015 04:10:22 +0100 Subject: [PATCH 34/80] Make DummyPlugin class final Plugin developers MUST NOT extend from DummyPlugin, they SHOULD extend from AbstractPicoPlugin --- plugins/DummyPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/DummyPlugin.php b/plugins/DummyPlugin.php index 60f2f35..6c2a85b 100644 --- a/plugins/DummyPlugin.php +++ b/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? From b198ad48c6edb7f62c1560cc28809d638f5dd48c Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 25 Nov 2015 20:04:46 +0100 Subject: [PATCH 35/80] Travis: Allow PHP nightly builds to fail --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 331173c..a080916 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,11 @@ php: - hhvm - nightly +matrix: + allow_failures: + - php: nightly + fast-finish: true + script: - find . -type f -name '*.php' -print0 | xargs -0 -I file php -l file > /dev/null From d503cea95495d6a7b8eedc90dde37a8b440663c8 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 25 Nov 2015 20:37:45 +0100 Subject: [PATCH 36/80] Travis: Don't test vendor PHP files --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a080916..1751308 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ matrix: fast-finish: true script: - - find . -type f -name '*.php' -print0 | xargs -0 -I file php -l file > /dev/null + - find . -not \( -path './vendor' -prune \) -type f -name '*.php' -print0 | xargs -0 -I file php -l file > /dev/null before_deploy: - composer install From 4ddde6b9fb0fa68a5a70aef0a8842cf17a00c242 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 25 Nov 2015 20:38:27 +0100 Subject: [PATCH 37/80] Travis: Deploy on every repo, forks usually don't setup Travis --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1751308..8a0a57f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,6 @@ deploy: file: pico-release-$TRAVIS_TAG.tar.gz skip_cleanup: true on: - repo: picocms/Pico tags: true php: 5.3 From c9387610f3372ac62596cfc8b049985f488005d1 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 25 Nov 2015 20:39:49 +0100 Subject: [PATCH 38/80] Auto-generate phpDoc when committing to master --- .travis.yml | 26 +++++++++++--- build/deploy-phpdoc.sh | 75 ++++++++++++++++++++++++++++++++++------ build/generate-phpdoc.sh | 14 ++++++++ 3 files changed, 99 insertions(+), 16 deletions(-) create mode 100644 build/generate-phpdoc.sh diff --git a/.travis.yml b/.travis.yml index 06f34e8..71359de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,15 +13,31 @@ matrix: - php: nightly fast-finish: true +install: + - composer install + +before_script: + - export PATH="$TRAVIS_BUILD_DIR/vendor/bin:$PATH" + script: - find . -not \( -path './vendor' -prune \) -type f -name '*.php' -print0 | xargs -0 -I file php -l file > /dev/null +after_success: + - | + [ "$DEPLOY_PHPDOC" == "yes" ] && ( + [ "$TRAVIS_BRANCH" == "master" ] && [ -z "$TRAVIS_TAG" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && ( + ./build/generate-phpdoc.sh . "$TRAVIS_BUILD_DIR/build/phpdoc-master" "Pico 1.0 API Documentation (master@$TRAVIS_COMMIT)" + ./build/deploy-phpdoc.sh "$TRAVIS_BUILD_DIR/build/phpdoc-master" "$TRAVIS_REPO_SLUG" "gh-pages" "master@$TRAVIS_COMMIT" + ) + ) + before_deploy: - - composer install - - ./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 + - | + [ "$DEPLOY_PHPDOC" == "yes" ] && ( + ./build/generate-phpdoc.sh . "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "Pico 1.0 API Documentation ($TRAVIS_TAG)" + ./build/deploy-phpdoc.sh "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "$TRAVIS_REPO_SLUG" "gh-pages" "$TRAVIS_TAG" + ) + - composer install --no-dev --optimize-autoloader - 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: diff --git a/build/deploy-phpdoc.sh b/build/deploy-phpdoc.sh index 6a5d0b8..f7420b0 100755 --- a/build/deploy-phpdoc.sh +++ b/build/deploy-phpdoc.sh @@ -1,29 +1,82 @@ #!/usr/bin/env bash +APP_NAME="$(basename "$0")" +BASE_PWD="$PWD" set -e +# environment variables +# GITHUB_OAUTH_TOKEN GitHub authentication token, see https://github.com/settings/tokens + # parameters -GITHUB_PROJECT="$1" # GitHub repo (e.g. picocms/Pico) -GITHUB_BRANCH="$2" # branch to use (e.g. gh-pages) -GITHUB_OAUTH_TOKEN="$3" # see https://github.com/settings/tokens -SOURCE_DIR="$4" # absolute path to phpDocs target directory -TARGET_DIR="$5" # relative path within the specified GitHub repo +SOURCE_DIR="$1" # absolute local source path +TARGET_REPO_SLUG="$2" # target repo (e.g. picocms/Pico) +TARGET_BRANCH="$3" # target branch (e.g. gh-pages) +TARGET_REF="$4" # target reference (either [branch]@[commit], [branch] or [tag]) + +# evaluate target reference +if git check-ref-format "tags/$TARGET_REF"; then + TARGET_REF_TYPE="tag" + TARGET_REF_TAG="$TARGET_REF" + TARGET_DIR="$TARGET_REF_TAG" +elif [[ "$TARGET_REF" == *@* ]]; then + TARGET_REF_TYPE="commit" + TARGET_REF_BRANCH="${TARGET_REF%@*}" + TARGET_REF_COMMIT="${TARGET_REF##*@}" + TARGET_DIR="$TARGET_REF_BRANCH" + + if ! git check-ref-format "heads/$TARGET_REF_BRANCH"; then + echo "FATAL: $APP_NAME target reference '$TARGET_REF' is invalid" >&2 + exit 1 + fi +elif git check-ref-format "heads/$TARGET_REF"; then + TARGET_REF_TYPE="branch" + TARGET_REF_BRANCH="$TARGET_REF" + TARGET_DIR="$TARGET_REF_BRANCH" +else + echo "FATAL: $APP_NAME target reference '$TARGET_REF' is invalid" >&2 + exit 1 +fi # clone repo -GIT_DIR="$(dirname "$0")/$(basename "$SOURCE_DIR").git" -git clone -b "$GITHUB_BRANCH" "https://github.com/$GITHUB_PROJECT.git" "$GIT_DIR" +GIT_DIR="$SOURCE_DIR.git" +git clone -b "$TARGET_BRANCH" "https://github.com/$TARGET_REPO_SLUG.git" "$GIT_DIR" # setup git cd "$GIT_DIR" git config user.name "Travis CI" git config user.email "travis-ci@picocms.org" +[ -n "$GITHUB_OAUTH_TOKEN" ] && git config credential.https://github.com.username "$GITHUB_OAUTH_TOKEN" # copy phpdoc -[ -e "$TARGET_DIR" ] && echo "FATAL: $(basename "$0") target directory exists" && exit 1 -cp -R "$SOURCE_DIR" "$TARGET_DIR" +[ -e "$TARGET_DIR" ] && echo "FATAL: $(basename "$0") target directory '$TARGET_DIR' exists" >&2 && exit 1 +[ "${SOURCE_DIR:0:1}" == "/" ] || SOURCE_DIR="$BASE_PWD/$SOURCE_DIR" +cp -R "$SOURCE_DIR" "phpDoc/$TARGET_DIR" # commit changes git add "$TARGET_DIR" -git commit -m "Add phpDocumentor class docs for Pico $TRAVIS_TAG" +git commit -m "Add phpDocumentor class docs for $TARGET_REF" + +# very simple race condition protection for concurrent Travis builds +# this is no definite protection (race conditions are still possible during `git push`), +# but it should give a basic protection without disabling concurrent builds completely +if [ "$TARGET_REF_TYPE" == "commit" ]; then + # get latest commit + LATEST_COMMIT="$(wget -O- "https://api.github.com/repos/$TARGET_REPO_SLUG/git/refs/heads/$TARGET_REF_BRANCH" 2> /dev/null | php -r " + \$json = json_decode(stream_get_contents(STDIN), true); + if (\$json !== null) { + if (isset(\$json['ref']) && (\$json['ref'] === 'refs/heads/$TARGET_REF_BRANCH')) { + if (isset(\$json['object']) && isset(\$json['object']['sha'])) { + echo \$json['object']['sha']; + } + } + } + ")" + + # compare target reference against the latest commit + if [ "$LATEST_COMMIT" != "$TARGET_REF_COMMIT" ]; then + echo "WARNING: $APP_NAME target reference '$TARGET_REF' doesn't match the latest commit '$LATEST_COMMIT'" >&2 + exit 0 + fi +fi # push changes -git push --force --quiet "https://${GITHUB_OAUTH_TOKEN}@github.com/$GITHUB_PROJECT.git" "$GITHUB_BRANCH:$GITHUB_BRANCH" > /dev/null 2>&1 +git push "https://github.com/$TARGET_REPO_SLUG.git" "$TARGET_BRANCH:$TARGET_BRANCH" diff --git a/build/generate-phpdoc.sh b/build/generate-phpdoc.sh new file mode 100644 index 0000000..5a01653 --- /dev/null +++ b/build/generate-phpdoc.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -e + +# parameters +PHPDOC_SOURCE_DIR="$1" +PHPDOC_TARGET_DIR="$2" +PHPDOC_TITLE="$3" + +# generate phpdoc +phpdoc -d "$PHPDOC_SOURCE_DIR" \ + -i 'build/*' -i 'vendor/*' -i 'plugins/*' \ + -f 'plugins/DummyPlugin.php' \ + -t "$PHPDOC_TARGET_DIR" \ + --title "$PHPDOC_TITLE" From 586282526595ba6d8502fe430cfee212612adb77 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 25 Nov 2015 20:56:13 +0100 Subject: [PATCH 39/80] Travis: Deploy phpDocs on PHP 5.3 only and allow multiple branches --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 71359de..da54042 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,8 +24,8 @@ script: after_success: - | - [ "$DEPLOY_PHPDOC" == "yes" ] && ( - [ "$TRAVIS_BRANCH" == "master" ] && [ -z "$TRAVIS_TAG" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && ( + [[ ",$DEPLOY_PHPDOC_BRANCHES," == *,"$TRAVIS_BRANCH",* ]] && [ "$TRAVIS_PHP_VERSION" == "5.3" ] ( + [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ -z "$TRAVIS_TAG" ] ( ./build/generate-phpdoc.sh . "$TRAVIS_BUILD_DIR/build/phpdoc-master" "Pico 1.0 API Documentation (master@$TRAVIS_COMMIT)" ./build/deploy-phpdoc.sh "$TRAVIS_BUILD_DIR/build/phpdoc-master" "$TRAVIS_REPO_SLUG" "gh-pages" "master@$TRAVIS_COMMIT" ) @@ -33,7 +33,7 @@ after_success: before_deploy: - | - [ "$DEPLOY_PHPDOC" == "yes" ] && ( + [ "$DEPLOY_PHPDOC_TAGS" == "true" ] && ( ./build/generate-phpdoc.sh . "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "Pico 1.0 API Documentation ($TRAVIS_TAG)" ./build/deploy-phpdoc.sh "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "$TRAVIS_REPO_SLUG" "gh-pages" "$TRAVIS_TAG" ) From e4165d35b17581464868ed867e74bc7c6e57c2e8 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 25 Nov 2015 20:59:29 +0100 Subject: [PATCH 40/80] Fix .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index da54042..0f4f888 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,8 +24,8 @@ script: after_success: - | - [[ ",$DEPLOY_PHPDOC_BRANCHES," == *,"$TRAVIS_BRANCH",* ]] && [ "$TRAVIS_PHP_VERSION" == "5.3" ] ( - [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ -z "$TRAVIS_TAG" ] ( + [[ ",$DEPLOY_PHPDOC_BRANCHES," == *,"$TRAVIS_BRANCH",* ]] && [ "$TRAVIS_PHP_VERSION" == "5.3" ] && ( + [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ -z "$TRAVIS_TAG" ] && ( ./build/generate-phpdoc.sh . "$TRAVIS_BUILD_DIR/build/phpdoc-master" "Pico 1.0 API Documentation (master@$TRAVIS_COMMIT)" ./build/deploy-phpdoc.sh "$TRAVIS_BUILD_DIR/build/phpdoc-master" "$TRAVIS_REPO_SLUG" "gh-pages" "master@$TRAVIS_COMMIT" ) From 32120e5bbc198b4f49a954c3d0316bf2ec279e97 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 25 Nov 2015 21:02:43 +0100 Subject: [PATCH 41/80] Fix build/generate-phpdoc.sh permissions --- build/generate-phpdoc.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 build/generate-phpdoc.sh diff --git a/build/generate-phpdoc.sh b/build/generate-phpdoc.sh old mode 100644 new mode 100755 From 9a46033141ca77e64f8cc95bb4bec382edd0f785 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 25 Nov 2015 21:36:56 +0100 Subject: [PATCH 42/80] Improve phpDocs auto-generation --- .travis.yml | 8 +++-- build/deploy-phpdoc.sh | 65 +++++++++++++++++++++------------------- build/generate-phpdoc.sh | 1 + 3 files changed, 41 insertions(+), 33 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0f4f888..9212024 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,9 +25,10 @@ script: after_success: - | [[ ",$DEPLOY_PHPDOC_BRANCHES," == *,"$TRAVIS_BRANCH",* ]] && [ "$TRAVIS_PHP_VERSION" == "5.3" ] && ( - [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ -z "$TRAVIS_TAG" ] && ( + [ "$TRAVIS_SECURE_ENV_VARS" == "true" ] && [ -z "$TRAVIS_TAG" ] && ( ./build/generate-phpdoc.sh . "$TRAVIS_BUILD_DIR/build/phpdoc-master" "Pico 1.0 API Documentation (master@$TRAVIS_COMMIT)" - ./build/deploy-phpdoc.sh "$TRAVIS_BUILD_DIR/build/phpdoc-master" "$TRAVIS_REPO_SLUG" "gh-pages" "master@$TRAVIS_COMMIT" + printf '\n' + ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-master" "master@$TRAVIS_COMMIT" "phpDoc/master" "gh-pages" ) ) @@ -35,7 +36,8 @@ before_deploy: - | [ "$DEPLOY_PHPDOC_TAGS" == "true" ] && ( ./build/generate-phpdoc.sh . "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "Pico 1.0 API Documentation ($TRAVIS_TAG)" - ./build/deploy-phpdoc.sh "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "$TRAVIS_REPO_SLUG" "gh-pages" "$TRAVIS_TAG" + printf '\n' + ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "$TRAVIS_TAG" "phpDoc/$TRAVIS_TAG" "gh-pages" ) - composer install --no-dev --optimize-autoloader - 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 diff --git a/build/deploy-phpdoc.sh b/build/deploy-phpdoc.sh index f7420b0..44d7424 100755 --- a/build/deploy-phpdoc.sh +++ b/build/deploy-phpdoc.sh @@ -7,38 +7,39 @@ set -e # GITHUB_OAUTH_TOKEN GitHub authentication token, see https://github.com/settings/tokens # parameters -SOURCE_DIR="$1" # absolute local source path -TARGET_REPO_SLUG="$2" # target repo (e.g. picocms/Pico) -TARGET_BRANCH="$3" # target branch (e.g. gh-pages) -TARGET_REF="$4" # target reference (either [branch]@[commit], [branch] or [tag]) +GITHUB_SLUG="$1" # GitHub repo (e.g. picocms/Pico) +SOURCE_DIR="$2" # absolute source path +SOURCE_REF="$3" # source reference (either [branch]@[commit], [branch] or [tag]) +TARGET_DIR="$4" # relative target path +TARGET_BRANCH="$5" # target branch (e.g. gh-pages) + +printf 'Deploying phpDocs (%s (%s) --> %s:%s/%s)...\n' "$SOURCE_DIR" "$SOURCE_REF" "$GITHUB_SLUG" "$TARGET_BRANCH" "$TARGET_DIR" # evaluate target reference -if git check-ref-format "tags/$TARGET_REF"; then - TARGET_REF_TYPE="tag" - TARGET_REF_TAG="$TARGET_REF" - TARGET_DIR="$TARGET_REF_TAG" -elif [[ "$TARGET_REF" == *@* ]]; then - TARGET_REF_TYPE="commit" - TARGET_REF_BRANCH="${TARGET_REF%@*}" - TARGET_REF_COMMIT="${TARGET_REF##*@}" - TARGET_DIR="$TARGET_REF_BRANCH" +if git check-ref-format "tags/$SOURCE_REF"; then + SOURCE_REF_TYPE="tag" + SOURCE_REF_TAG="$SOURCE_REF" +elif [[ "$SOURCE_REF" == *@* ]]; then + SOURCE_REF_TYPE="commit" + SOURCE_REF_BRANCH="${SOURCE_REF%@*}" + SOURCE_REF_COMMIT="${SOURCE_REF##*@}" - if ! git check-ref-format "heads/$TARGET_REF_BRANCH"; then - echo "FATAL: $APP_NAME target reference '$TARGET_REF' is invalid" >&2 + if ! git check-ref-format "heads/$SOURCE_REF_BRANCH"; then + echo "FATAL: $APP_NAME target reference '$SOURCE_REF' is invalid" >&2 exit 1 fi -elif git check-ref-format "heads/$TARGET_REF"; then - TARGET_REF_TYPE="branch" - TARGET_REF_BRANCH="$TARGET_REF" - TARGET_DIR="$TARGET_REF_BRANCH" +elif git check-ref-format "heads/$SOURCE_REF"; then + SOURCE_REF_TYPE="branch" + SOURCE_REF_BRANCH="$SOURCE_REF" else - echo "FATAL: $APP_NAME target reference '$TARGET_REF' is invalid" >&2 + echo "FATAL: $APP_NAME target reference '$SOURCE_REF' is invalid" >&2 exit 1 fi # clone repo +printf '\nCloning %s branch of %s...\n' "$TARGET_BRANCH" "https://github.com/$GITHUB_SLUG.git" GIT_DIR="$SOURCE_DIR.git" -git clone -b "$TARGET_BRANCH" "https://github.com/$TARGET_REPO_SLUG.git" "$GIT_DIR" +git clone -b "$TARGET_BRANCH" "https://github.com/$GITHUB_SLUG.git" "$GIT_DIR" # setup git cd "$GIT_DIR" @@ -47,23 +48,26 @@ git config user.email "travis-ci@picocms.org" [ -n "$GITHUB_OAUTH_TOKEN" ] && git config credential.https://github.com.username "$GITHUB_OAUTH_TOKEN" # copy phpdoc -[ -e "$TARGET_DIR" ] && echo "FATAL: $(basename "$0") target directory '$TARGET_DIR' exists" >&2 && exit 1 +[ ! -d "$TARGET_DIR" ] || rm -rf "$TARGET_DIR" [ "${SOURCE_DIR:0:1}" == "/" ] || SOURCE_DIR="$BASE_PWD/$SOURCE_DIR" -cp -R "$SOURCE_DIR" "phpDoc/$TARGET_DIR" +printf '\nCopying phpDoc (%s --> %s)...\n' "$SOURCE_DIR" "$GIT_DIR/$TARGET_DIR" +cp -R "$SOURCE_DIR" "$TARGET_DIR" # commit changes +printf '\nCommiting changes...\n' git add "$TARGET_DIR" -git commit -m "Add phpDocumentor class docs for $TARGET_REF" +git commit -m "Add phpDocumentor class docs for $SOURCE_REF" # very simple race condition protection for concurrent Travis builds # this is no definite protection (race conditions are still possible during `git push`), # but it should give a basic protection without disabling concurrent builds completely -if [ "$TARGET_REF_TYPE" == "commit" ]; then +if [ "$SOURCE_REF_TYPE" == "commit" ]; then # get latest commit - LATEST_COMMIT="$(wget -O- "https://api.github.com/repos/$TARGET_REPO_SLUG/git/refs/heads/$TARGET_REF_BRANCH" 2> /dev/null | php -r " + printf '\nRetrieving latest commit of %s:%s' "$GITHUB_SLUG" "$SOURCE_REF_BRANCH" + LATEST_COMMIT="$(wget -O- "https://api.github.com/repos/$GITHUB_SLUG/git/refs/heads/$SOURCE_REF_BRANCH" 2> /dev/null | php -r " \$json = json_decode(stream_get_contents(STDIN), true); if (\$json !== null) { - if (isset(\$json['ref']) && (\$json['ref'] === 'refs/heads/$TARGET_REF_BRANCH')) { + if (isset(\$json['ref']) && (\$json['ref'] === 'refs/heads/$SOURCE_REF_BRANCH')) { if (isset(\$json['object']) && isset(\$json['object']['sha'])) { echo \$json['object']['sha']; } @@ -72,11 +76,12 @@ if [ "$TARGET_REF_TYPE" == "commit" ]; then ")" # compare target reference against the latest commit - if [ "$LATEST_COMMIT" != "$TARGET_REF_COMMIT" ]; then - echo "WARNING: $APP_NAME target reference '$TARGET_REF' doesn't match the latest commit '$LATEST_COMMIT'" >&2 + if [ "$LATEST_COMMIT" != "$SOURCE_REF_COMMIT" ]; then + echo "WARNING: $APP_NAME target reference '$SOURCE_REF' doesn't match the latest commit '$LATEST_COMMIT'" >&2 exit 0 fi fi # push changes -git push "https://github.com/$TARGET_REPO_SLUG.git" "$TARGET_BRANCH:$TARGET_BRANCH" +printf '\nPushing changes...\n' +git push "https://github.com/$GITHUB_SLUG.git" "$TARGET_BRANCH:$TARGET_BRANCH" diff --git a/build/generate-phpdoc.sh b/build/generate-phpdoc.sh index 5a01653..0cbad7b 100755 --- a/build/generate-phpdoc.sh +++ b/build/generate-phpdoc.sh @@ -7,6 +7,7 @@ PHPDOC_TARGET_DIR="$2" PHPDOC_TITLE="$3" # generate phpdoc +printf 'Generating phpDocs (%s --> %s; "%s")...\n' "$PHPDOC_SOURCE_DIR" "$PHPDOC_TARGET_DIR" "$PHPDOC_TITLE" phpdoc -d "$PHPDOC_SOURCE_DIR" \ -i 'build/*' -i 'vendor/*' -i 'plugins/*' \ -f 'plugins/DummyPlugin.php' \ From 3852585ba0b1b4b6bee95217b261c1ddfc5e73b8 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 25 Nov 2015 21:55:28 +0100 Subject: [PATCH 43/80] Improve phpDocs auto-generation --- .travis.yml | 10 ++++------ build/deploy-phpdoc.sh | 16 ++++++++++++---- build/generate-phpdoc.sh | 9 ++++++++- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9212024..a613974 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,18 +26,16 @@ after_success: - | [[ ",$DEPLOY_PHPDOC_BRANCHES," == *,"$TRAVIS_BRANCH",* ]] && [ "$TRAVIS_PHP_VERSION" == "5.3" ] && ( [ "$TRAVIS_SECURE_ENV_VARS" == "true" ] && [ -z "$TRAVIS_TAG" ] && ( - ./build/generate-phpdoc.sh . "$TRAVIS_BUILD_DIR/build/phpdoc-master" "Pico 1.0 API Documentation (master@$TRAVIS_COMMIT)" - printf '\n' - ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-master" "master@$TRAVIS_COMMIT" "phpDoc/master" "gh-pages" + ./build/generate-phpdoc.sh . "build/phpdoc-master" "Pico 1.0 API Documentation (master)" + ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "build/phpdoc-master" "master@$TRAVIS_COMMIT" "phpDoc/master" "gh-pages" ) ) before_deploy: - | [ "$DEPLOY_PHPDOC_TAGS" == "true" ] && ( - ./build/generate-phpdoc.sh . "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "Pico 1.0 API Documentation ($TRAVIS_TAG)" - printf '\n' - ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "$TRAVIS_TAG" "phpDoc/$TRAVIS_TAG" "gh-pages" + ./build/generate-phpdoc.sh . "build/phpdoc-$TRAVIS_TAG" "Pico 1.0 API Documentation ($TRAVIS_TAG)" + ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "build/phpdoc-$TRAVIS_TAG" "$TRAVIS_TAG" "phpDoc/$TRAVIS_TAG" "gh-pages" ) - composer install --no-dev --optimize-autoloader - 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 diff --git a/build/deploy-phpdoc.sh b/build/deploy-phpdoc.sh index 44d7424..f68d1dd 100755 --- a/build/deploy-phpdoc.sh +++ b/build/deploy-phpdoc.sh @@ -13,7 +13,13 @@ SOURCE_REF="$3" # source reference (either [branch]@[commit], [branc TARGET_DIR="$4" # relative target path TARGET_BRANCH="$5" # target branch (e.g. gh-pages) -printf 'Deploying phpDocs (%s (%s) --> %s:%s/%s)...\n' "$SOURCE_DIR" "$SOURCE_REF" "$GITHUB_SLUG" "$TARGET_BRANCH" "$TARGET_DIR" +# print parameters +echo "Deploying phpDocs..." +printf 'GITHUB_SLUG="%s"\n' "$GITHUB_SLUG" +printf 'SOURCE_DIR="%s"\n' "$SOURCE_DIR" +printf 'SOURCE_REF="%s"\n' "$SOURCE_REF" +printf 'TARGET_DIR="%s"\n' "$TARGET_DIR" +printf 'TARGET_BRANCH="%s"\n' "$TARGET_BRANCH" # evaluate target reference if git check-ref-format "tags/$SOURCE_REF"; then @@ -24,7 +30,7 @@ elif [[ "$SOURCE_REF" == *@* ]]; then SOURCE_REF_BRANCH="${SOURCE_REF%@*}" SOURCE_REF_COMMIT="${SOURCE_REF##*@}" - if ! git check-ref-format "heads/$SOURCE_REF_BRANCH"; then + if ! git check-ref-format "heads/$SOURCE_REF_BRANCH" || ! git rev-parse --verify "$SOURCE_REF_COMMIT"; then echo "FATAL: $APP_NAME target reference '$SOURCE_REF' is invalid" >&2 exit 1 fi @@ -37,7 +43,7 @@ else fi # clone repo -printf '\nCloning %s branch of %s...\n' "$TARGET_BRANCH" "https://github.com/$GITHUB_SLUG.git" +printf '\nCloning repo...\n' GIT_DIR="$SOURCE_DIR.git" git clone -b "$TARGET_BRANCH" "https://github.com/$GITHUB_SLUG.git" "$GIT_DIR" @@ -48,9 +54,9 @@ git config user.email "travis-ci@picocms.org" [ -n "$GITHUB_OAUTH_TOKEN" ] && git config credential.https://github.com.username "$GITHUB_OAUTH_TOKEN" # copy phpdoc +printf '\nCopying phpDocs...\n' [ ! -d "$TARGET_DIR" ] || rm -rf "$TARGET_DIR" [ "${SOURCE_DIR:0:1}" == "/" ] || SOURCE_DIR="$BASE_PWD/$SOURCE_DIR" -printf '\nCopying phpDoc (%s --> %s)...\n' "$SOURCE_DIR" "$GIT_DIR/$TARGET_DIR" cp -R "$SOURCE_DIR" "$TARGET_DIR" # commit changes @@ -85,3 +91,5 @@ fi # push changes printf '\nPushing changes...\n' git push "https://github.com/$GITHUB_SLUG.git" "$TARGET_BRANCH:$TARGET_BRANCH" + +echo diff --git a/build/generate-phpdoc.sh b/build/generate-phpdoc.sh index 0cbad7b..83fef3f 100755 --- a/build/generate-phpdoc.sh +++ b/build/generate-phpdoc.sh @@ -6,10 +6,17 @@ PHPDOC_SOURCE_DIR="$1" PHPDOC_TARGET_DIR="$2" PHPDOC_TITLE="$3" +# print parameters +echo "Generating phpDocs..." +printf 'PHPDOC_SOURCE_DIR="%s"\n' "$PHPDOC_SOURCE_DIR" +printf 'PHPDOC_TARGET_DIR="%s"\n' "$PHPDOC_TARGET_DIR" +printf 'PHPDOC_TITLE="%s"\n' "$PHPDOC_TITLE" + # generate phpdoc -printf 'Generating phpDocs (%s --> %s; "%s")...\n' "$PHPDOC_SOURCE_DIR" "$PHPDOC_TARGET_DIR" "$PHPDOC_TITLE" phpdoc -d "$PHPDOC_SOURCE_DIR" \ -i 'build/*' -i 'vendor/*' -i 'plugins/*' \ -f 'plugins/DummyPlugin.php' \ -t "$PHPDOC_TARGET_DIR" \ --title "$PHPDOC_TITLE" + +echo From 3c6809507537f945585f3589eda4e4da2c21ac40 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 25 Nov 2015 22:04:16 +0100 Subject: [PATCH 44/80] Improve phpDocs auto-generation --- build/deploy-phpdoc.sh | 7 ++++--- build/generate-phpdoc.sh | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build/deploy-phpdoc.sh b/build/deploy-phpdoc.sh index f68d1dd..bc3e2fb 100755 --- a/build/deploy-phpdoc.sh +++ b/build/deploy-phpdoc.sh @@ -20,6 +20,7 @@ printf 'SOURCE_DIR="%s"\n' "$SOURCE_DIR" printf 'SOURCE_REF="%s"\n' "$SOURCE_REF" printf 'TARGET_DIR="%s"\n' "$TARGET_DIR" printf 'TARGET_BRANCH="%s"\n' "$TARGET_BRANCH" +echo # evaluate target reference if git check-ref-format "tags/$SOURCE_REF"; then @@ -43,9 +44,9 @@ else fi # clone repo -printf '\nCloning repo...\n' +printf 'Cloning repo...\n' GIT_DIR="$SOURCE_DIR.git" -git clone -b "$TARGET_BRANCH" "https://github.com/$GITHUB_SLUG.git" "$GIT_DIR" +git clone --branch="$TARGET_BRANCH" "https://github.com/$GITHUB_SLUG.git" "$GIT_DIR" # setup git cd "$GIT_DIR" @@ -61,7 +62,7 @@ cp -R "$SOURCE_DIR" "$TARGET_DIR" # commit changes printf '\nCommiting changes...\n' -git add "$TARGET_DIR" +git add --all "$TARGET_DIR" git commit -m "Add phpDocumentor class docs for $SOURCE_REF" # very simple race condition protection for concurrent Travis builds diff --git a/build/generate-phpdoc.sh b/build/generate-phpdoc.sh index 83fef3f..5e11255 100755 --- a/build/generate-phpdoc.sh +++ b/build/generate-phpdoc.sh @@ -11,6 +11,7 @@ echo "Generating phpDocs..." printf 'PHPDOC_SOURCE_DIR="%s"\n' "$PHPDOC_SOURCE_DIR" printf 'PHPDOC_TARGET_DIR="%s"\n' "$PHPDOC_TARGET_DIR" printf 'PHPDOC_TITLE="%s"\n' "$PHPDOC_TITLE" +echo # generate phpdoc phpdoc -d "$PHPDOC_SOURCE_DIR" \ From 728873c5a4e13e7f4b7fc60f1d8c61db18416886 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 25 Nov 2015 22:26:51 +0100 Subject: [PATCH 45/80] build/deploy-phpdoc.sh: Fix credentials --- build/deploy-phpdoc.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build/deploy-phpdoc.sh b/build/deploy-phpdoc.sh index bc3e2fb..39bc0ec 100755 --- a/build/deploy-phpdoc.sh +++ b/build/deploy-phpdoc.sh @@ -52,7 +52,11 @@ git clone --branch="$TARGET_BRANCH" "https://github.com/$GITHUB_SLUG.git" "$GIT_ cd "$GIT_DIR" git config user.name "Travis CI" git config user.email "travis-ci@picocms.org" -[ -n "$GITHUB_OAUTH_TOKEN" ] && git config credential.https://github.com.username "$GITHUB_OAUTH_TOKEN" + +if [ -n "$GITHUB_OAUTH_TOKEN" ]; then + git config credential.helper 'store --file=.git/credentials' + (umask 077 && echo "https://GitHub:$GITHUB_OAUTH_TOKEN@github.com" > .git/credentials) +fi # copy phpdoc printf '\nCopying phpDocs...\n' From c198333de783c9d1e51fd795731d9c4427af9442 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 25 Nov 2015 22:55:21 +0100 Subject: [PATCH 46/80] Improve phpDocs auto-generation --- .travis.yml | 15 +++++++-------- build/deploy-phpdoc.sh | 8 ++++---- build/generate-phpdoc.sh | 5 +++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index a613974..34e8774 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,18 +24,17 @@ script: after_success: - | - [[ ",$DEPLOY_PHPDOC_BRANCHES," == *,"$TRAVIS_BRANCH",* ]] && [ "$TRAVIS_PHP_VERSION" == "5.3" ] && ( - [ "$TRAVIS_SECURE_ENV_VARS" == "true" ] && [ -z "$TRAVIS_TAG" ] && ( - ./build/generate-phpdoc.sh . "build/phpdoc-master" "Pico 1.0 API Documentation (master)" - ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "build/phpdoc-master" "master@$TRAVIS_COMMIT" "phpDoc/master" "gh-pages" - ) - ) + [ "$TRAVIS_PHP_VERSION" != "5.3" ] && echo "Skipping phpDoc deployment because this is not on the required runtime" && exit + [[ ",$DEPLOY_PHPDOC_BRANCHES," != *,"$TRAVIS_BRANCH",* ]] && echo "Skipping phpDoc deployment because this branch is not permitted to deploy" && exit + [ "$TRAVIS_SECURE_ENV_VARS" != "true" ] && echo "Skipping phpDoc deployment because this is no environment with write access to the repository" && exit + ./build/generate-phpdoc.sh "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-master" "Pico 1.0 API Documentation (master)" + ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-master" "master @ $TRAVIS_COMMIT" "phpDoc/master" "gh-pages" before_deploy: - | [ "$DEPLOY_PHPDOC_TAGS" == "true" ] && ( - ./build/generate-phpdoc.sh . "build/phpdoc-$TRAVIS_TAG" "Pico 1.0 API Documentation ($TRAVIS_TAG)" - ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "build/phpdoc-$TRAVIS_TAG" "$TRAVIS_TAG" "phpDoc/$TRAVIS_TAG" "gh-pages" + ./build/generate-phpdoc.sh "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "Pico 1.0 API Documentation ($TRAVIS_TAG)" + ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "$TRAVIS_TAG" "phpDoc/$TRAVIS_TAG" "gh-pages" ) - composer install --no-dev --optimize-autoloader - 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 diff --git a/build/deploy-phpdoc.sh b/build/deploy-phpdoc.sh index 39bc0ec..4c13044 100755 --- a/build/deploy-phpdoc.sh +++ b/build/deploy-phpdoc.sh @@ -26,10 +26,10 @@ echo if git check-ref-format "tags/$SOURCE_REF"; then SOURCE_REF_TYPE="tag" SOURCE_REF_TAG="$SOURCE_REF" -elif [[ "$SOURCE_REF" == *@* ]]; then +elif [[ "$SOURCE_REF" == *" @ "* ]]; then SOURCE_REF_TYPE="commit" - SOURCE_REF_BRANCH="${SOURCE_REF%@*}" - SOURCE_REF_COMMIT="${SOURCE_REF##*@}" + SOURCE_REF_BRANCH="${SOURCE_REF% @ *}" + SOURCE_REF_COMMIT="${SOURCE_REF##* @ }" if ! git check-ref-format "heads/$SOURCE_REF_BRANCH" || ! git rev-parse --verify "$SOURCE_REF_COMMIT"; then echo "FATAL: $APP_NAME target reference '$SOURCE_REF' is invalid" >&2 @@ -67,7 +67,7 @@ cp -R "$SOURCE_DIR" "$TARGET_DIR" # commit changes printf '\nCommiting changes...\n' git add --all "$TARGET_DIR" -git commit -m "Add phpDocumentor class docs for $SOURCE_REF" +git commit -m "Update phpDocumentor class docs for $SOURCE_REF" # very simple race condition protection for concurrent Travis builds # this is no definite protection (race conditions are still possible during `git push`), diff --git a/build/generate-phpdoc.sh b/build/generate-phpdoc.sh index 5e11255..bd11e7e 100755 --- a/build/generate-phpdoc.sh +++ b/build/generate-phpdoc.sh @@ -15,8 +15,9 @@ echo # generate phpdoc phpdoc -d "$PHPDOC_SOURCE_DIR" \ - -i 'build/*' -i 'vendor/*' -i 'plugins/*' \ - -f 'plugins/DummyPlugin.php' \ + -i 'build/*' \ + -i 'vendor/*' \ + -i 'plugins/*' -f 'plugins/DummyPlugin.php' \ -t "$PHPDOC_TARGET_DIR" \ --title "$PHPDOC_TITLE" From 236ae43dabb08eb4861b09863978aeb30d421190 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 25 Nov 2015 23:09:15 +0100 Subject: [PATCH 47/80] phpDocs auto deployment: Fix deployment of branches --- .travis.yml | 8 ++++---- build/deploy-phpdoc.sh | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 34e8774..25c939c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,14 +27,14 @@ after_success: [ "$TRAVIS_PHP_VERSION" != "5.3" ] && echo "Skipping phpDoc deployment because this is not on the required runtime" && exit [[ ",$DEPLOY_PHPDOC_BRANCHES," != *,"$TRAVIS_BRANCH",* ]] && echo "Skipping phpDoc deployment because this branch is not permitted to deploy" && exit [ "$TRAVIS_SECURE_ENV_VARS" != "true" ] && echo "Skipping phpDoc deployment because this is no environment with write access to the repository" && exit - ./build/generate-phpdoc.sh "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-master" "Pico 1.0 API Documentation (master)" - ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-master" "master @ $TRAVIS_COMMIT" "phpDoc/master" "gh-pages" + ./build/generate-phpdoc.sh "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_BRANCH" "Pico 1.0 API Documentation ($TRAVIS_BRANCH)" || exit 1 + ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_BRANCH" "$TRAVIS_BRANCH @ $TRAVIS_COMMIT" "phpDoc/$TRAVIS_BRANCH" "gh-pages" || exit 1 before_deploy: - | [ "$DEPLOY_PHPDOC_TAGS" == "true" ] && ( - ./build/generate-phpdoc.sh "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "Pico 1.0 API Documentation ($TRAVIS_TAG)" - ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "$TRAVIS_TAG" "phpDoc/$TRAVIS_TAG" "gh-pages" + ./build/generate-phpdoc.sh "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "Pico 1.0 API Documentation ($TRAVIS_TAG)" || exit 1 + ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "$TRAVIS_TAG" "phpDoc/$TRAVIS_TAG" "gh-pages" || exit 1 ) - composer install --no-dev --optimize-autoloader - 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 diff --git a/build/deploy-phpdoc.sh b/build/deploy-phpdoc.sh index 4c13044..bede6f0 100755 --- a/build/deploy-phpdoc.sh +++ b/build/deploy-phpdoc.sh @@ -31,7 +31,7 @@ elif [[ "$SOURCE_REF" == *" @ "* ]]; then SOURCE_REF_BRANCH="${SOURCE_REF% @ *}" SOURCE_REF_COMMIT="${SOURCE_REF##* @ }" - if ! git check-ref-format "heads/$SOURCE_REF_BRANCH" || ! git rev-parse --verify "$SOURCE_REF_COMMIT"; then + if ! git check-ref-format "heads/$SOURCE_REF_BRANCH" || ! git rev-parse --verify "$SOURCE_REF_COMMIT" > /dev/null; then echo "FATAL: $APP_NAME target reference '$SOURCE_REF' is invalid" >&2 exit 1 fi @@ -74,7 +74,7 @@ git commit -m "Update phpDocumentor class docs for $SOURCE_REF" # but it should give a basic protection without disabling concurrent builds completely if [ "$SOURCE_REF_TYPE" == "commit" ]; then # get latest commit - printf '\nRetrieving latest commit of %s:%s' "$GITHUB_SLUG" "$SOURCE_REF_BRANCH" + printf '\nRetrieving latest commit...\n' LATEST_COMMIT="$(wget -O- "https://api.github.com/repos/$GITHUB_SLUG/git/refs/heads/$SOURCE_REF_BRANCH" 2> /dev/null | php -r " \$json = json_decode(stream_get_contents(STDIN), true); if (\$json !== null) { @@ -88,7 +88,7 @@ if [ "$SOURCE_REF_TYPE" == "commit" ]; then # compare target reference against the latest commit if [ "$LATEST_COMMIT" != "$SOURCE_REF_COMMIT" ]; then - echo "WARNING: $APP_NAME target reference '$SOURCE_REF' doesn't match the latest commit '$LATEST_COMMIT'" >&2 + echo "WARNING: $APP_NAME source reference '$SOURCE_REF' doesn't match the latest commit '$LATEST_COMMIT'" >&2 exit 0 fi fi From 137b2ba3a6d335f2159e91dd276bc4e080dd0904 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 25 Nov 2015 23:35:42 +0100 Subject: [PATCH 48/80] phpDocs auto deployment: Fix deployment of branches with slashes --- .travis.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 25c939c..3273b4e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,14 +27,16 @@ after_success: [ "$TRAVIS_PHP_VERSION" != "5.3" ] && echo "Skipping phpDoc deployment because this is not on the required runtime" && exit [[ ",$DEPLOY_PHPDOC_BRANCHES," != *,"$TRAVIS_BRANCH",* ]] && echo "Skipping phpDoc deployment because this branch is not permitted to deploy" && exit [ "$TRAVIS_SECURE_ENV_VARS" != "true" ] && echo "Skipping phpDoc deployment because this is no environment with write access to the repository" && exit - ./build/generate-phpdoc.sh "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_BRANCH" "Pico 1.0 API Documentation ($TRAVIS_BRANCH)" || exit 1 - ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_BRANCH" "$TRAVIS_BRANCH @ $TRAVIS_COMMIT" "phpDoc/$TRAVIS_BRANCH" "gh-pages" || exit 1 + PHPDOC_ID="${TRAVIS_BRANCH//\//_}" + ./build/generate-phpdoc.sh "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" "Pico 1.0 API Documentation ($TRAVIS_BRANCH)" || exit 1 + ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" "$TRAVIS_BRANCH @ $TRAVIS_COMMIT" "phpDoc/$PHPDOC_ID" "gh-pages" || exit 1 before_deploy: - | [ "$DEPLOY_PHPDOC_TAGS" == "true" ] && ( - ./build/generate-phpdoc.sh "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "Pico 1.0 API Documentation ($TRAVIS_TAG)" || exit 1 - ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "$TRAVIS_TAG" "phpDoc/$TRAVIS_TAG" "gh-pages" || exit 1 + PHPDOC_ID="${TRAVIS_BRANCH//\//_}" + ./build/generate-phpdoc.sh "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" "Pico 1.0 API Documentation ($TRAVIS_TAG)" || exit 1 + ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" "$TRAVIS_TAG" "phpDoc/$PHPDOC_ID" "gh-pages" || exit 1 ) - composer install --no-dev --optimize-autoloader - 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 From 38d2dd2e202bfdcad373ba4bdf55ade9bfb213c9 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 25 Nov 2015 23:38:22 +0100 Subject: [PATCH 49/80] Travis: Remove .git dirs from vendor/ dir when deploying See https://github.com/picocms/Pico/issues/289#issuecomment-159722672 - thanks to @joshas for spotting --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 8a0a57f..ad46b87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,7 @@ script: before_deploy: - composer install - composer dump-autoload --optimize + - find vendor/ -type d -path 'vendor/*/*/.git' -print0 | xargs -0 rm -rf - tar -czf "pico-release-$TRAVIS_TAG.tar.gz" .htaccess README.md CHANGELOG.md CONTRIBUTING.md composer.json composer.lock LICENSE config content-sample lib plugins themes vendor index.php deploy: From 3ac53d2b4cb0a041e1d9f0296e5e903af83665bd Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 25 Nov 2015 23:44:11 +0100 Subject: [PATCH 50/80] phpDocs auto deployment: Improve title of class docs for branches --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3273b4e..bdd1e82 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,7 @@ after_success: [[ ",$DEPLOY_PHPDOC_BRANCHES," != *,"$TRAVIS_BRANCH",* ]] && echo "Skipping phpDoc deployment because this branch is not permitted to deploy" && exit [ "$TRAVIS_SECURE_ENV_VARS" != "true" ] && echo "Skipping phpDoc deployment because this is no environment with write access to the repository" && exit PHPDOC_ID="${TRAVIS_BRANCH//\//_}" - ./build/generate-phpdoc.sh "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" "Pico 1.0 API Documentation ($TRAVIS_BRANCH)" || exit 1 + ./build/generate-phpdoc.sh "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" "Pico 1.0 API Documentation ($TRAVIS_BRANCH branch)" || exit 1 ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" "$TRAVIS_BRANCH @ $TRAVIS_COMMIT" "phpDoc/$PHPDOC_ID" "gh-pages" || exit 1 before_deploy: From 2306010ba79670807bb754433e5098ccb8a596ad Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Wed, 25 Nov 2015 23:53:58 +0100 Subject: [PATCH 51/80] phpDocs auto deployment: Fix phpDocs generation phpDocumentor acts very strange when relative paths are involved... --- build/generate-phpdoc.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/generate-phpdoc.sh b/build/generate-phpdoc.sh index bd11e7e..c2fe334 100755 --- a/build/generate-phpdoc.sh +++ b/build/generate-phpdoc.sh @@ -15,9 +15,9 @@ echo # generate phpdoc phpdoc -d "$PHPDOC_SOURCE_DIR" \ - -i 'build/*' \ - -i 'vendor/*' \ - -i 'plugins/*' -f 'plugins/DummyPlugin.php' \ + -i "$PHPDOC_SOURCE_DIR/build/" \ + -i "$PHPDOC_SOURCE_DIR/vendor/" \ + -i "$PHPDOC_SOURCE_DIR/plugins/" -f "$PHPDOC_SOURCE_DIR/plugins/DummyPlugin.php" \ -t "$PHPDOC_TARGET_DIR" \ --title "$PHPDOC_TITLE" From 17dbc4cf186c926625d179ed5611430fc2a265d6 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Thu, 26 Nov 2015 00:29:14 +0100 Subject: [PATCH 52/80] phpDocs auto deployment: Cleanup --- .travis.yml | 17 +++-------------- build/deploy-phpdoc-branch.sh | 28 ++++++++++++++++++++++++++++ build/deploy-phpdoc-release.sh | 15 +++++++++++++++ build/deploy-phpdoc.sh | 28 ++++++++++++++++------------ 4 files changed, 62 insertions(+), 26 deletions(-) create mode 100755 build/deploy-phpdoc-branch.sh create mode 100755 build/deploy-phpdoc-release.sh diff --git a/.travis.yml b/.travis.yml index bdd1e82..8e87356 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,27 +17,16 @@ install: - composer install before_script: - - export PATH="$TRAVIS_BUILD_DIR/vendor/bin:$PATH" + - export PATH="$TRAVIS_BUILD_DIR/build:$TRAVIS_BUILD_DIR/vendor/bin:$PATH" script: - find . -not \( -path './vendor' -prune \) -type f -name '*.php' -print0 | xargs -0 -I file php -l file > /dev/null after_success: - - | - [ "$TRAVIS_PHP_VERSION" != "5.3" ] && echo "Skipping phpDoc deployment because this is not on the required runtime" && exit - [[ ",$DEPLOY_PHPDOC_BRANCHES," != *,"$TRAVIS_BRANCH",* ]] && echo "Skipping phpDoc deployment because this branch is not permitted to deploy" && exit - [ "$TRAVIS_SECURE_ENV_VARS" != "true" ] && echo "Skipping phpDoc deployment because this is no environment with write access to the repository" && exit - PHPDOC_ID="${TRAVIS_BRANCH//\//_}" - ./build/generate-phpdoc.sh "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" "Pico 1.0 API Documentation ($TRAVIS_BRANCH branch)" || exit 1 - ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" "$TRAVIS_BRANCH @ $TRAVIS_COMMIT" "phpDoc/$PHPDOC_ID" "gh-pages" || exit 1 + - deploy-phpdoc-branch.sh before_deploy: - - | - [ "$DEPLOY_PHPDOC_TAGS" == "true" ] && ( - PHPDOC_ID="${TRAVIS_BRANCH//\//_}" - ./build/generate-phpdoc.sh "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" "Pico 1.0 API Documentation ($TRAVIS_TAG)" || exit 1 - ./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" "$TRAVIS_TAG" "phpDoc/$PHPDOC_ID" "gh-pages" || exit 1 - ) + - deploy-phpdoc-release.sh - composer install --no-dev --optimize-autoloader - 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 diff --git a/build/deploy-phpdoc-branch.sh b/build/deploy-phpdoc-branch.sh new file mode 100755 index 0000000..2a401a4 --- /dev/null +++ b/build/deploy-phpdoc-branch.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +if [ "$TRAVIS_PHP_VERSION" != "5.3" ]; then + echo "Skipping phpDoc deployment because this is not on the required runtime" + exit +fi + +if [[ ",$DEPLOY_PHPDOC_BRANCHES," != *,"$TRAVIS_BRANCH",* ]]; then + echo "Skipping phpDoc deployment because this branch is not permitted to deploy" + exit +fi + +if [ "$TRAVIS_SECURE_ENV_VARS" != "true" ]; then + echo "Skipping phpDoc deployment because this is no environment with write access to the repository" + exit +fi + +PHPDOC_ID="${TRAVIS_BRANCH//\//_}" + +generate-phpdoc.sh \ + "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \ + "Pico 1.0 API Documentation ($TRAVIS_BRANCH branch)" +[ $? -eq 0 ] || exit 1 + +deploy-phpdoc.sh \ + "$TRAVIS_REPO_SLUG" "$TRAVIS_BRANCH @ $TRAVIS_COMMIT" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \ + "$TRAVIS_REPO_SLUG" "gh-pages" "phpDoc/$PHPDOC_ID" +[ $? -eq 0 ] || exit 1 diff --git a/build/deploy-phpdoc-release.sh b/build/deploy-phpdoc-release.sh new file mode 100755 index 0000000..6604ba6 --- /dev/null +++ b/build/deploy-phpdoc-release.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +[ "$DEPLOY_PHPDOC_RELEASES" == "true" ] || exit + +PHPDOC_ID="${TRAVIS_BRANCH//\//_}" + +generate-phpdoc.sh \ + "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \ + "Pico 1.0 API Documentation ($TRAVIS_TAG)" +[ $? -eq 0 ] || exit 1 + +deploy-phpdoc.sh \ + "$TRAVIS_REPO_SLUG" "$TRAVIS_TAG" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \ + "$TRAVIS_REPO_SLUG" "gh-pages" "phpDoc/$PHPDOC_ID" +[ $? -eq 0 ] || exit 1 diff --git a/build/deploy-phpdoc.sh b/build/deploy-phpdoc.sh index bede6f0..85dcddb 100755 --- a/build/deploy-phpdoc.sh +++ b/build/deploy-phpdoc.sh @@ -1,25 +1,29 @@ #!/usr/bin/env bash +set -e + +# base variables APP_NAME="$(basename "$0")" BASE_PWD="$PWD" -set -e # environment variables # GITHUB_OAUTH_TOKEN GitHub authentication token, see https://github.com/settings/tokens # parameters -GITHUB_SLUG="$1" # GitHub repo (e.g. picocms/Pico) -SOURCE_DIR="$2" # absolute source path -SOURCE_REF="$3" # source reference (either [branch]@[commit], [branch] or [tag]) -TARGET_DIR="$4" # relative target path +SOURCE_REPO_SLUG="$1" # source GitHub repo (e.g. picocms/Pico) +SOURCE_REF="$2" # source reference (either [branch]@[commit], [branch] or [tag]) +SOURCE_DIR="$3" # absolute source path +TARGET_REPO_SLUG="$4" # target GitHub repo (e.g. picocms/Pico) TARGET_BRANCH="$5" # target branch (e.g. gh-pages) +TARGET_DIR="$6" # relative target path # print parameters echo "Deploying phpDocs..." -printf 'GITHUB_SLUG="%s"\n' "$GITHUB_SLUG" -printf 'SOURCE_DIR="%s"\n' "$SOURCE_DIR" +printf 'SOURCE_REPO_SLUG="%s"\n' "$SOURCE_REPO_SLUG" printf 'SOURCE_REF="%s"\n' "$SOURCE_REF" -printf 'TARGET_DIR="%s"\n' "$TARGET_DIR" +printf 'SOURCE_DIR="%s"\n' "$SOURCE_DIR" +printf 'TARGET_REPO_SLUG="%s"\n' "$TARGET_REPO_SLUG" printf 'TARGET_BRANCH="%s"\n' "$TARGET_BRANCH" +printf 'TARGET_DIR="%s"\n' "$TARGET_DIR" echo # evaluate target reference @@ -46,7 +50,7 @@ fi # clone repo printf 'Cloning repo...\n' GIT_DIR="$SOURCE_DIR.git" -git clone --branch="$TARGET_BRANCH" "https://github.com/$GITHUB_SLUG.git" "$GIT_DIR" +git clone --branch="$TARGET_BRANCH" "https://github.com/$TARGET_REPO_SLUG.git" "$GIT_DIR" # setup git cd "$GIT_DIR" @@ -67,7 +71,7 @@ cp -R "$SOURCE_DIR" "$TARGET_DIR" # commit changes printf '\nCommiting changes...\n' git add --all "$TARGET_DIR" -git commit -m "Update phpDocumentor class docs for $SOURCE_REF" +git commit --message="Update phpDocumentor class docs for $SOURCE_REF" # very simple race condition protection for concurrent Travis builds # this is no definite protection (race conditions are still possible during `git push`), @@ -75,7 +79,7 @@ git commit -m "Update phpDocumentor class docs for $SOURCE_REF" if [ "$SOURCE_REF_TYPE" == "commit" ]; then # get latest commit printf '\nRetrieving latest commit...\n' - LATEST_COMMIT="$(wget -O- "https://api.github.com/repos/$GITHUB_SLUG/git/refs/heads/$SOURCE_REF_BRANCH" 2> /dev/null | php -r " + LATEST_COMMIT="$(wget -O- "https://api.github.com/repos/$SOURCE_REPO_SLUG/git/refs/heads/$SOURCE_REF_BRANCH" 2> /dev/null | php -r " \$json = json_decode(stream_get_contents(STDIN), true); if (\$json !== null) { if (isset(\$json['ref']) && (\$json['ref'] === 'refs/heads/$SOURCE_REF_BRANCH')) { @@ -95,6 +99,6 @@ fi # push changes printf '\nPushing changes...\n' -git push "https://github.com/$GITHUB_SLUG.git" "$TARGET_BRANCH:$TARGET_BRANCH" +git push "https://github.com/$TARGET_REPO_SLUG.git" "$TARGET_BRANCH:$TARGET_BRANCH" echo From 5af160c31d6a725520121f27375bc61c2afda954 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Thu, 26 Nov 2015 01:13:37 +0100 Subject: [PATCH 53/80] phpDocs auto deployment: Use $GITHUB_OAUTH_TOKEN to determine latest commit --- build/deploy-phpdoc.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/build/deploy-phpdoc.sh b/build/deploy-phpdoc.sh index 85dcddb..57b5c6b 100755 --- a/build/deploy-phpdoc.sh +++ b/build/deploy-phpdoc.sh @@ -77,9 +77,17 @@ git commit --message="Update phpDocumentor class docs for $SOURCE_REF" # this is no definite protection (race conditions are still possible during `git push`), # but it should give a basic protection without disabling concurrent builds completely if [ "$SOURCE_REF_TYPE" == "commit" ]; then - # get latest commit + # load branch data via GitHub APIv3 printf '\nRetrieving latest commit...\n' - LATEST_COMMIT="$(wget -O- "https://api.github.com/repos/$SOURCE_REPO_SLUG/git/refs/heads/$SOURCE_REF_BRANCH" 2> /dev/null | php -r " + LATEST_COMMIT_URL="https://api.github.com/repos/$SOURCE_REPO_SLUG/git/refs/heads/$SOURCE_REF_BRANCH" + if [ -n "$GITHUB_OAUTH_TOKEN" ]; then + LATEST_COMMIT_RESPONSE="$(wget -O- --header="Authorization: token $GITHUB_OAUTH_TOKEN" "$LATEST_COMMIT_URL" 2> /dev/null)" + else + LATEST_COMMIT_RESPONSE="$(wget -O- "$LATEST_COMMIT_URL" 2> /dev/null)" + fi + + # evaluate JSON response + LATEST_COMMIT="$(echo "$LATEST_COMMIT_RESPONSE" | php -r " \$json = json_decode(stream_get_contents(STDIN), true); if (\$json !== null) { if (isset(\$json['ref']) && (\$json['ref'] === 'refs/heads/$SOURCE_REF_BRANCH')) { From 6e0b2aab34abdcca40639d244fd51f748e7422c1 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Thu, 26 Nov 2015 01:35:35 +0100 Subject: [PATCH 54/80] phpDocs auto deployment: Disable for pull requests with a safe environment Pull requests with a safe environment are primarly local branches --- build/deploy-phpdoc-branch.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build/deploy-phpdoc-branch.sh b/build/deploy-phpdoc-branch.sh index 2a401a4..0d4335a 100755 --- a/build/deploy-phpdoc-branch.sh +++ b/build/deploy-phpdoc-branch.sh @@ -15,6 +15,11 @@ if [ "$TRAVIS_SECURE_ENV_VARS" != "true" ]; then exit fi +if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then + echo "Skipping phpDoc deployment because this pull request (#$TRAVIS_PULL_REQUEST) is not permitted to deploy" + exit +fi + PHPDOC_ID="${TRAVIS_BRANCH//\//_}" generate-phpdoc.sh \ From 45dcf32fa7ab64b1c722a74079ab80cff38c0f34 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Thu, 26 Nov 2015 02:15:34 +0100 Subject: [PATCH 55/80] phpDocs auto deployment: Support pull requests in a safe environment --- build/deploy-phpdoc-branch.sh | 22 +++++++++++++++------- build/deploy-phpdoc-release.sh | 6 ++++-- build/deploy-phpdoc.sh | 29 +++++++++++++---------------- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/build/deploy-phpdoc-branch.sh b/build/deploy-phpdoc-branch.sh index 0d4335a..1b3e11e 100755 --- a/build/deploy-phpdoc-branch.sh +++ b/build/deploy-phpdoc-branch.sh @@ -15,19 +15,27 @@ if [ "$TRAVIS_SECURE_ENV_VARS" != "true" ]; then exit fi -if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then - echo "Skipping phpDoc deployment because this pull request (#$TRAVIS_PULL_REQUEST) is not permitted to deploy" - exit -fi - PHPDOC_ID="${TRAVIS_BRANCH//\//_}" +PHPDOC_REF="heads/$TRAVIS_BRANCH" +PHPDOC_REF_TEXT="$TRAVIS_BRANCH branch" + +if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then + PHPDOC_ID="pull_$TRAVIS_PULL_REQUEST" + PHPDOC_REF="pull/$TRAVIS_PULL_REQUEST/head" + PHPDOC_REF_TEXT="pull request #$TRAVIS_PULL_REQUEST" + + if [[ ",$DEPLOY_PHPDOC_BRANCHES," != *,"#$TRAVIS_PULL_REQUEST",* ]]; then + echo "Skipping phpDoc deployment because this pull request (#$TRAVIS_PULL_REQUEST) is not permitted to deploy" + exit + fi +fi generate-phpdoc.sh \ "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \ - "Pico 1.0 API Documentation ($TRAVIS_BRANCH branch)" + "Pico 1.0 API Documentation ($PHPDOC_REF_TEXT)" [ $? -eq 0 ] || exit 1 deploy-phpdoc.sh \ - "$TRAVIS_REPO_SLUG" "$TRAVIS_BRANCH @ $TRAVIS_COMMIT" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \ + "$TRAVIS_REPO_SLUG" "$PHPDOC_REF @ $TRAVIS_COMMIT" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \ "$TRAVIS_REPO_SLUG" "gh-pages" "phpDoc/$PHPDOC_ID" [ $? -eq 0 ] || exit 1 diff --git a/build/deploy-phpdoc-release.sh b/build/deploy-phpdoc-release.sh index 6604ba6..f22030c 100755 --- a/build/deploy-phpdoc-release.sh +++ b/build/deploy-phpdoc-release.sh @@ -3,13 +3,15 @@ [ "$DEPLOY_PHPDOC_RELEASES" == "true" ] || exit PHPDOC_ID="${TRAVIS_BRANCH//\//_}" +PHPDOC_REF="tags/$TRAVIS_TAG" +PHPDOC_REF_TEXT="$TRAVIS_TAG" generate-phpdoc.sh \ "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \ - "Pico 1.0 API Documentation ($TRAVIS_TAG)" + "Pico 1.0 API Documentation ($PHPDOC_REF_TEXT)" [ $? -eq 0 ] || exit 1 deploy-phpdoc.sh \ - "$TRAVIS_REPO_SLUG" "$TRAVIS_TAG" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \ + "$TRAVIS_REPO_SLUG" "$PHPDOC_REF" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \ "$TRAVIS_REPO_SLUG" "gh-pages" "phpDoc/$PHPDOC_ID" [ $? -eq 0 ] || exit 1 diff --git a/build/deploy-phpdoc.sh b/build/deploy-phpdoc.sh index 57b5c6b..26d06b8 100755 --- a/build/deploy-phpdoc.sh +++ b/build/deploy-phpdoc.sh @@ -10,7 +10,8 @@ BASE_PWD="$PWD" # parameters SOURCE_REPO_SLUG="$1" # source GitHub repo (e.g. picocms/Pico) -SOURCE_REF="$2" # source reference (either [branch]@[commit], [branch] or [tag]) +SOURCE_REF="$2" # source reference (either "[ref] @ [commit]" or "[ref]", + # [ref] can be e.g. heads/master or tags/v1.0.0) SOURCE_DIR="$3" # absolute source path TARGET_REPO_SLUG="$4" # target GitHub repo (e.g. picocms/Pico) TARGET_BRANCH="$5" # target branch (e.g. gh-pages) @@ -26,24 +27,20 @@ printf 'TARGET_BRANCH="%s"\n' "$TARGET_BRANCH" printf 'TARGET_DIR="%s"\n' "$TARGET_DIR" echo -# evaluate target reference -if git check-ref-format "tags/$SOURCE_REF"; then - SOURCE_REF_TYPE="tag" - SOURCE_REF_TAG="$SOURCE_REF" -elif [[ "$SOURCE_REF" == *" @ "* ]]; then +# evaluate source reference +if [[ "$SOURCE_REF" == *" @ "* ]]; then SOURCE_REF_TYPE="commit" - SOURCE_REF_BRANCH="${SOURCE_REF% @ *}" + SOURCE_REF_HEAD="${SOURCE_REF% @ *}" SOURCE_REF_COMMIT="${SOURCE_REF##* @ }" - if ! git check-ref-format "heads/$SOURCE_REF_BRANCH" || ! git rev-parse --verify "$SOURCE_REF_COMMIT" > /dev/null; then - echo "FATAL: $APP_NAME target reference '$SOURCE_REF' is invalid" >&2 + if ! git check-ref-format "$SOURCE_REF_HEAD" || ! git rev-parse --verify "$SOURCE_REF_COMMIT" > /dev/null; then + echo "FATAL: $APP_NAME source reference '$SOURCE_REF' is invalid" >&2 exit 1 fi -elif git check-ref-format "heads/$SOURCE_REF"; then - SOURCE_REF_TYPE="branch" - SOURCE_REF_BRANCH="$SOURCE_REF" +elif git check-ref-format "$SOURCE_REF"; then + SOURCE_REF_TYPE="ref" else - echo "FATAL: $APP_NAME target reference '$SOURCE_REF' is invalid" >&2 + echo "FATAL: $APP_NAME source reference '$SOURCE_REF' is invalid" >&2 exit 1 fi @@ -79,7 +76,7 @@ git commit --message="Update phpDocumentor class docs for $SOURCE_REF" if [ "$SOURCE_REF_TYPE" == "commit" ]; then # load branch data via GitHub APIv3 printf '\nRetrieving latest commit...\n' - LATEST_COMMIT_URL="https://api.github.com/repos/$SOURCE_REPO_SLUG/git/refs/heads/$SOURCE_REF_BRANCH" + LATEST_COMMIT_URL="https://api.github.com/repos/$SOURCE_REPO_SLUG/git/refs/$SOURCE_REF_HEAD" if [ -n "$GITHUB_OAUTH_TOKEN" ]; then LATEST_COMMIT_RESPONSE="$(wget -O- --header="Authorization: token $GITHUB_OAUTH_TOKEN" "$LATEST_COMMIT_URL" 2> /dev/null)" else @@ -90,7 +87,7 @@ if [ "$SOURCE_REF_TYPE" == "commit" ]; then LATEST_COMMIT="$(echo "$LATEST_COMMIT_RESPONSE" | php -r " \$json = json_decode(stream_get_contents(STDIN), true); if (\$json !== null) { - if (isset(\$json['ref']) && (\$json['ref'] === 'refs/heads/$SOURCE_REF_BRANCH')) { + if (isset(\$json['ref']) && (\$json['ref'] === 'refs/$SOURCE_REF_HEAD')) { if (isset(\$json['object']) && isset(\$json['object']['sha'])) { echo \$json['object']['sha']; } @@ -98,7 +95,7 @@ if [ "$SOURCE_REF_TYPE" == "commit" ]; then } ")" - # compare target reference against the latest commit + # compare source reference against the latest commit if [ "$LATEST_COMMIT" != "$SOURCE_REF_COMMIT" ]; then echo "WARNING: $APP_NAME source reference '$SOURCE_REF' doesn't match the latest commit '$LATEST_COMMIT'" >&2 exit 0 From 8005efdbbb28ada3e5c8aa903ba430024c4ff928 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Thu, 26 Nov 2015 02:38:29 +0100 Subject: [PATCH 56/80] phpDocs auto deployment: Remove latest commit check for pull requests See https://developer.github.com/v3/pulls/#get-a-single-pull-request > Each time the pull request receives new commits, GitHub creates a merge > commit to *test* whether the pull request can be automatically merged into > the base branch. (This *test* commit is not added to the base branch or the > head branch.) The attribute holds the SHA of the *test* > merge commit; however, this attribute is deprecated and is scheduled for > removal in the next version of the API. holds the SHA of the merge commit and not of the latest commit of the head branch, therefore the comparison fails. We could theoretically compare it against this attribute, but as of its deprecation, this is a pretty bad idea. Thus we remove the latest commit check for pull requests. --- build/deploy-phpdoc-branch.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/deploy-phpdoc-branch.sh b/build/deploy-phpdoc-branch.sh index 1b3e11e..b3d4b2f 100755 --- a/build/deploy-phpdoc-branch.sh +++ b/build/deploy-phpdoc-branch.sh @@ -6,7 +6,7 @@ if [ "$TRAVIS_PHP_VERSION" != "5.3" ]; then fi if [[ ",$DEPLOY_PHPDOC_BRANCHES," != *,"$TRAVIS_BRANCH",* ]]; then - echo "Skipping phpDoc deployment because this branch is not permitted to deploy" + echo "Skipping phpDoc deployment because this branch ($TRAVIS_BRANCH) is not permitted to deploy" exit fi @@ -16,7 +16,7 @@ if [ "$TRAVIS_SECURE_ENV_VARS" != "true" ]; then fi PHPDOC_ID="${TRAVIS_BRANCH//\//_}" -PHPDOC_REF="heads/$TRAVIS_BRANCH" +PHPDOC_REF="heads/$TRAVIS_BRANCH @ $TRAVIS_COMMIT" PHPDOC_REF_TEXT="$TRAVIS_BRANCH branch" if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then @@ -36,6 +36,6 @@ generate-phpdoc.sh \ [ $? -eq 0 ] || exit 1 deploy-phpdoc.sh \ - "$TRAVIS_REPO_SLUG" "$PHPDOC_REF @ $TRAVIS_COMMIT" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \ + "$TRAVIS_REPO_SLUG" "$PHPDOC_REF" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \ "$TRAVIS_REPO_SLUG" "gh-pages" "phpDoc/$PHPDOC_ID" [ $? -eq 0 ] || exit 1 From 54305c4d33b88533f55da6364e5881d285bee7fb Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Thu, 26 Nov 2015 04:06:34 +0100 Subject: [PATCH 57/80] phpDocs auto deployment: Remove pull requests support We can deploy phpDocs in safe environments only, but "safe environment" is equivalent to "pull a local branch", therefore we can simply use that local branch to deploy the phpDocs. There's no need for a explicit pull request support. --- build/deploy-phpdoc-branch.sh | 21 ++++----------------- build/deploy-phpdoc-release.sh | 6 ++---- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/build/deploy-phpdoc-branch.sh b/build/deploy-phpdoc-branch.sh index b3d4b2f..f08063d 100755 --- a/build/deploy-phpdoc-branch.sh +++ b/build/deploy-phpdoc-branch.sh @@ -10,32 +10,19 @@ if [[ ",$DEPLOY_PHPDOC_BRANCHES," != *,"$TRAVIS_BRANCH",* ]]; then exit fi -if [ "$TRAVIS_SECURE_ENV_VARS" != "true" ]; then - echo "Skipping phpDoc deployment because this is no environment with write access to the repository" +if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then + echo "Skipping phpDoc deployment because this pull request (#$TRAVIS_PULL_REQUEST) is not permitted to deploy" exit fi PHPDOC_ID="${TRAVIS_BRANCH//\//_}" -PHPDOC_REF="heads/$TRAVIS_BRANCH @ $TRAVIS_COMMIT" -PHPDOC_REF_TEXT="$TRAVIS_BRANCH branch" - -if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then - PHPDOC_ID="pull_$TRAVIS_PULL_REQUEST" - PHPDOC_REF="pull/$TRAVIS_PULL_REQUEST/head" - PHPDOC_REF_TEXT="pull request #$TRAVIS_PULL_REQUEST" - - if [[ ",$DEPLOY_PHPDOC_BRANCHES," != *,"#$TRAVIS_PULL_REQUEST",* ]]; then - echo "Skipping phpDoc deployment because this pull request (#$TRAVIS_PULL_REQUEST) is not permitted to deploy" - exit - fi -fi generate-phpdoc.sh \ "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \ - "Pico 1.0 API Documentation ($PHPDOC_REF_TEXT)" + "Pico 1.0 API Documentation ($TRAVIS_BRANCH branch)" [ $? -eq 0 ] || exit 1 deploy-phpdoc.sh \ - "$TRAVIS_REPO_SLUG" "$PHPDOC_REF" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \ + "$TRAVIS_REPO_SLUG" "heads/$TRAVIS_BRANCH @ $TRAVIS_COMMIT" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \ "$TRAVIS_REPO_SLUG" "gh-pages" "phpDoc/$PHPDOC_ID" [ $? -eq 0 ] || exit 1 diff --git a/build/deploy-phpdoc-release.sh b/build/deploy-phpdoc-release.sh index f22030c..721f3a4 100755 --- a/build/deploy-phpdoc-release.sh +++ b/build/deploy-phpdoc-release.sh @@ -3,15 +3,13 @@ [ "$DEPLOY_PHPDOC_RELEASES" == "true" ] || exit PHPDOC_ID="${TRAVIS_BRANCH//\//_}" -PHPDOC_REF="tags/$TRAVIS_TAG" -PHPDOC_REF_TEXT="$TRAVIS_TAG" generate-phpdoc.sh \ "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \ - "Pico 1.0 API Documentation ($PHPDOC_REF_TEXT)" + "Pico 1.0 API Documentation ($TRAVIS_TAG)" [ $? -eq 0 ] || exit 1 deploy-phpdoc.sh \ - "$TRAVIS_REPO_SLUG" "$PHPDOC_REF" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \ + "$TRAVIS_REPO_SLUG" "tags/$TRAVIS_TAG" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \ "$TRAVIS_REPO_SLUG" "gh-pages" "phpDoc/$PHPDOC_ID" [ $? -eq 0 ] || exit 1 From 70d813eafeeaf313ed59b2ab21ed810626d412f8 Mon Sep 17 00:00:00 2001 From: Diogo Oliveira de Melo Date: Fri, 27 Nov 2015 02:16:06 -0200 Subject: [PATCH 58/80] change the way to call autoload.php. - As suggested by @theshka, this code first verify if Pico is being used as local composer install, then verify if it is being used as a composer library. --- index.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/index.php b/index.php index 5920eb4..24225b8 100644 --- a/index.php +++ b/index.php @@ -1,14 +1,16 @@ Date: Fri, 27 Nov 2015 10:31:17 -0600 Subject: [PATCH 59/80] Consolidate Build & Release section. --- CONTRIBUTING.md | 45 ++++++--------------------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index aa812cb..3d19e57 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -113,12 +113,9 @@ Build & Release process > This is work in progress. Please refer to [#268](https://github.com/picocms/Pico/issues/268) for details. -Defined below is a specification to which the Build and Release process of Pico should follow. We use [travis-ci](https://travis-ci.com) to automate the process, and each commit to `master` should be deployable. Once a `feature/branch` or the `master` branch have reached a point where the need for a version increase is necessary, move through these phases to generate a Pico release. +We're using [Travis CI](https://travis-ci.com) to automate the build & release process of Pico. It generates and deploys [phpDoc](http://phpdoc.org) class docs for new releases and on every commit to the `master` branch. Travis also prepares new releases by generating Pico's pre-built packages and uploading them to GitHub. -### Commit phase - -- Make/Commit/Merge changes -- Use a formatted commit message with contents of `CHANGELOG.md` since last release. +It is important that each commit to `master` is deployable. Once a `feature/branch` or the `master` branch have reached a point where the need for a version increase is necessary, you can trigger this process by pushing a new Git Tag. The tag references a (usually empty) commit which message follows the following template: Example: ``` @@ -129,42 +126,12 @@ Defined below is a specification to which the Build and Release process of Pico * [Security] ... ``` -- Tagging a commit on the `master` branch will trigger an automatic build.. + -- __Please submit pull-requests with a properly formatted commit message and -[SemVer](http://semver.org) increase to avoid the need for manual amendments.__ +After deploying a new release, you will need to amend the release information on GitHub with the release title (taken from changelog), and changelog itself. - -### Analysis phase - -Does the commit pass all `travis-ci` checks? - -- We test PHP 5.3, 5.4, 5.5, 5.6, 7, the nighlty build, and HHVM - -If not, all errors will need to be corrected before the build can complete. - -### Packaging phase - -###### travis-ci -- will run [composer](http://getcomposer.org) locally with `req-dev` dependencies. -- will generate [PhpDocumentor](http://phpdoc.org) class docs automatically -- will run our `deploy-phpdoc.sh` script -- will create a ZIP archive (so vendor/ is included) - -### Release phase - -###### travis-ci -- will remove phpDocumentor from dependencies -- will create new Git release at tag -- will include the properly formatted commit message including the changelog of items since the last release. -- will include ZIP archive in release - -###### Note: -If a properly formatted commit message was not provided, you may have to update release information on GitHub with: -- release title (taken from changelog) -- changelog - -### Announcements +__Note__ - Releases will be available at: [https://github.com/picocms/Pico/releases](https://github.com/picocms/Pico/releases) - Pico will be automatically updated on [Packagist](http://packagist.org/packages/picocms/pico) From 917cd6caf3f361fb524f015e37a8d95acea1dafd Mon Sep 17 00:00:00 2001 From: theshka Date: Fri, 27 Nov 2015 10:36:44 -0600 Subject: [PATCH 60/80] Consolidate Issue Template --- CONTRIBUTING.md | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3d19e57..cb3bfde 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,38 +14,15 @@ If you want to report an *issue* with Pico's core, please create a new [Issue](h Before creating a [new Issue on GitHub](https://github.com/picocms/Pico/issues/new), please make sure the problem wasn't reported yet using [GitHubs search engine](https://github.com/picocms/Pico/search?type=Issues). Please describe your issue as clear as possible and always include steps to reproduce the problem. -This is an example of what information to include with your issue. - - Version - - Operating System and version - - Pico Version - - other installed software, plugins, if applicable - - hardware information, if applicable - - Bug Description - - A concise description of what the problem is. Pure description, no narrative or conversational language. - - Severity - - Trivial, Minor, Major, or Catastrophic - - Steps to Reproduce - - Step by step instructions on how to reproduce this bug. - - Do not assume anything, the more detailed your list of instructions, the easier it is for the developer to track down the problem! - - Actual Behavior - - Type what happens when you follow the instructions. This is the manifestation of the bug. - - Expected Behavior - - Type what you expected to happen when you followed the instructions. - - This is important, because you may have misunderstood something or missed a step, - and knowing what you expected to see will help the developer recognize that. - - Troubleshooting/Testing Steps Attempted - - Describe anything you did to try to fix it on your own. - - Workaround - - If you found a way to make the program work in spite of the bug, describe how you did it here. +This is an example of what type of information to include with your issue. +- Pico Version +- Installed plugins, if applicable +- Bug Description +- Steps to Reproduce +- Actual/Expected Behavior +- Troubleshooting/Testing Steps Attempted +- Workarounds? Contributing code ----------------- From 1fae7ab3df34e953389c623cab2d682051d54046 Mon Sep 17 00:00:00 2001 From: theshka Date: Fri, 27 Nov 2015 12:27:45 -0600 Subject: [PATCH 61/80] * [New] added PHP_VERSION check to Pico::run() --- lib/Pico.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Pico.php b/lib/Pico.php index ccc0d55..0073a7e 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -271,6 +271,11 @@ class Pico */ public function run() { + // check PHP version + if (version_compare(PHP_VERSION, '5.3.6', '<')) { + die('Sorry, Pico requires PHP 5.3.6 or above to run!'); + } + // lock Pico $this->locked = true; From 81821e781124d37eb6e376116cb216511fa9531b Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 27 Nov 2015 19:28:48 +0100 Subject: [PATCH 62/80] Improve Pico::getBaseUrl() code styling --- lib/Pico.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/Pico.php b/lib/Pico.php index ccc0d55..8714345 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -1214,14 +1214,13 @@ class Pico return $baseUrl; } - if ( - (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') - || ($_SERVER['SERVER_PORT'] == 443) - || (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') - ) { + $protocol = 'http'; + if (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] !== 'off')) { + $protocol = 'https'; + } elseif ($_SERVER['SERVER_PORT'] == 443) { + $protocol = 'https'; + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && ($_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')) { $protocol = 'https'; - } else { - $protocol = 'http'; } $this->config['base_url'] = From 364b9066d9c8defc10e0f36f2fa3fbb530edcf33 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 27 Nov 2015 19:30:25 +0100 Subject: [PATCH 63/80] PicoDeprecated: Use $GLOBALS superglobal instead of global keyword --- plugins/00-PicoDeprecated.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/plugins/00-PicoDeprecated.php b/plugins/00-PicoDeprecated.php index f646b03..5ea9f1f 100644 --- a/plugins/00-PicoDeprecated.php +++ b/plugins/00-PicoDeprecated.php @@ -107,19 +107,17 @@ class PicoDeprecated extends AbstractPicoPlugin * @see PicoDeprecated::loadRootDirConfig() * @see PicoDeprecated::enablePlugins() * @see DummyPlugin::onConfigLoaded() - * @param mixed[] &$realConfig array of config variables + * @param mixed[] &$config array of config variables * @return void */ - public function onConfigLoaded(array &$realConfig) + public function onConfigLoaded(array &$config) { - global $config; - $this->defineConstants(); - $this->loadRootDirConfig($realConfig); + $this->loadRootDirConfig($config); $this->enablePlugins(); - $config = &$realConfig; + $GLOBALS['config'] = &$config; - $this->triggerEvent('config_loaded', array(&$realConfig)); + $this->triggerEvent('config_loaded', array(&$config)); } /** From 913cf3816f16e9bf0f781dae5cc79aa95a8d90f8 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 27 Nov 2015 19:31:22 +0100 Subject: [PATCH 64/80] Plugins: Improve onPagesLoaded() code styling --- plugins/00-PicoDeprecated.php | 8 ++++++-- plugins/DummyPlugin.php | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/plugins/00-PicoDeprecated.php b/plugins/00-PicoDeprecated.php index 5ea9f1f..5240160 100644 --- a/plugins/00-PicoDeprecated.php +++ b/plugins/00-PicoDeprecated.php @@ -342,8 +342,12 @@ class PicoDeprecated extends AbstractPicoPlugin * * @see DummyPlugin::onPagesLoaded() */ - public function onPagesLoaded(array &$pages, array &$currentPage = null, array &$previousPage = null, array &$nextPage = null) - { + public function onPagesLoaded( + array &$pages, + array &$currentPage = null, + array &$previousPage = null, + array &$nextPage = null + ) { // remove keys of pages array $plainPages = array(); foreach ($pages as &$pageData) { diff --git a/plugins/DummyPlugin.php b/plugins/DummyPlugin.php index 6c2a85b..f8ebb01 100644 --- a/plugins/DummyPlugin.php +++ b/plugins/DummyPlugin.php @@ -270,8 +270,12 @@ final class DummyPlugin extends AbstractPicoPlugin * @param array|null &$nextPage data of the next page * @return void */ - public function onPagesLoaded(array &$pages, array &$currentPage = null, array &$previousPage = null, array &$nextPage = null) - { + public function onPagesLoaded( + array &$pages, + array &$currentPage = null, + array &$previousPage = null, + array &$nextPage = null + ) { // your code } From e14c007789e9486fcdc92f004e98eeb7759bd08d Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 27 Nov 2015 19:32:12 +0100 Subject: [PATCH 65/80] Default theme: Replace tabs with 4-space-indentation --- themes/default/style.css | 737 +++++++++++++++++++-------------------- 1 file changed, 367 insertions(+), 370 deletions(-) diff --git a/themes/default/style.css b/themes/default/style.css index 5fce108..d26f65a 100644 --- a/themes/default/style.css +++ b/themes/default/style.css @@ -1,370 +1,367 @@ -/*=================================*/ -/* Pico Default Theme -/* By: Gilbert Pellegrom -/* http: //dev7studios.com -/*=================================*/ - -/* Reset Styles -/*---------------------------------------------*/ -html, body, div, span, applet, object, iframe, -h1, h2, h3, h4, h5, h6, p, blockquote, pre, -a, abbr, acronym, address, big, cite, code, -del, dfn, em, font, img, ins, kbd, q, s, samp, -small, strike, strong, sub, sup, tt, var, -dl, dt, dd, ol, ul, li, -fieldset, form, label, legend, -table, caption, tbody, tfoot, thead, tr, th, td { - margin: 0; - padding: 0; - border: 0; - outline: 0; - font-weight: inherit; - font-style: inherit; - font-size: 100%; - font-family: inherit; - vertical-align: baseline; -} - -body { - line-height: 1; - color: black; - background: white; -} - -table { - border-collapse: collapse; - border-spacing: 0; -} - -caption, th, td { - text-align: left; - font-weight: normal; -} - -blockquote:before, blockquote:after, -q:before, q:after { - content: ""; -} - -blockquote, q { - quotes: "" ""; -} - -/* HTML5 tags */ -header, section, footer, -aside, nav, article, figure { - display: block; -} - -/* hand cursor on clickable input elements */ -label, input[type=button], input[type=submit], button { - cursor: pointer; -} - -/* make buttons play nice in IE: - www.viget.com/inspire/styling-the-button-element-in-internet-explorer/ */ -button { - width: auto; - overflow: visible; -} - -/* Sharper Thumbnails */ -img { - -ms-interpolation-mode: bicubic; -} - -/* Input Styles -/*---------------------------------------------*/ -input, -textarea, -select { - padding: 5px; - font: 400 1em Verdana, Sans-serif; - color: #666; - background: #fff; - border: 1px solid #999999; - margin: 0 0 1em 0; -} - -input:focus, -textarea:focus, -select:focus { - color: #000; - background: #fff; - border: 1px solid #666666; -} - -/* Main Styles -/*---------------------------------------------*/ -body { - font: 14px/1.8em 'Open Sans', Helvetica, Arial, Helvetica, sans-serif; - color: #444; - background: #fff; - -webkit-font-smoothing: antialiased; -} - -a, a:visited { - color: #2EAE9B; - text-decoration: none; - -webkit-transition: all 0.2s linear; - -moz-transition: all 0.2s linear; - -ms-transition: all 0.2s linear; - -o-transition: all 0.2s linear; - transition: all 0.2s linear; -} - -a:hover, a:active { - color: #000; - text-decoration: none; -} - -h1, h2, h3, h4, h5, h6 { - color: #000; - line-height: 1.2em; - margin-bottom: 0.6em; -} - -h1 { - font-size: 2em; -} - -h2 { - font-size: 1.7em; -} - -h3 { - font-size: 1.5em; - margin-top: 2em; -} - -p, table { - margin-bottom: 1em; -} - -ol, ul { - padding-left: 30px; - margin-bottom: 1em; -} - -b, strong { - font-weight: bold; -} - -i, em { - font-style: italic; -} - -u { - text-decoration: underline; -} - -abbr, acronym { - cursor: help; - border-bottom: 0.1em dotted; -} - -td, td img { - vertical-align: top; -} - -td, th { - border: solid 1px #999; - padding: 0.25em 0.5em; -} - -th { - font-weight: bold; - text-align: center; - background: #eee; -} - -sub { - vertical-align: sub; - font-size: smaller; -} - -sup { - vertical-align: super; - font-size: smaller; -} - -code { - font-family: Courier, "Courier New", Monaco, Tahoma; - background: #eee; - color: #333; - padding: 0px 2px; -} - -pre { - background: #eee; - padding: 20px; - margin-bottom: 1em; - overflow: auto; -} - -blockquote { - font-style: italic; - margin: 0 0 1em 15px; - padding-left: 10px; - border-left: 5px solid #dddddd; -} - -/* Structure Styles -/*---------------------------------------------*/ -.inner { - width: 850px; - margin: 0 auto; -} - -#header { - background: #2EAE9B; - padding: 60px 0; - margin-bottom: 80px; - color: #afe1da; -} -#header a { color: #afe1da; } -#header h1 a, -#header a:hover { color: #fff; } -#header h1 { - font-weight: bold; - margin: 0; - float: left; -} -#header .menu-icon { - display: none; - width: 35px; - height: 35px; - background: #afe1da url(menu-icon.png) center; -} -#header nav { - float: right; - list-style: none; - margin: 0; - padding: 0; -} -#header nav a { - font-weight: bold; - margin-left: 20px; -} -#header a:hover#menu-icon { - background-color: #444; - border-radius: 4px 4px 0 0; -} -#header ul { - list-style: none; -} -#header li { - display: inline-block; - float: left; -} -#footer { - background: #707070; - padding: 60px 0; - margin-top: 80px; - color: #C0C0C0; -} -#footer a { color: #ddd; } -#footer a:hover { color: #fff; } - -/* Misc Styles -/*---------------------------------------------*/ -.clearfix:before, -.clearfix:after { - content: " "; - display: table; -} -.clearfix:after { - clear: both; -} -.clearfix { - *zoom: 1; -} - -/* Media Queries -/*---------------------------------------------*/ - -/* Small Devices, Tablets */ -@media only screen and (max-width : 768px) { - - .inner { - width: 85%; - } - .inner img { - width:100%; - } - #header { - margin-bottom: 40px; - } - #header h1 a { - font-size:1em; - } - #header .menu-icon { - display:inline-block; - } - #header nav a { color: #000; } - #header nav a:hover { color: #afe1da; } - #header nav ul, nav:active ul { - display: none; - position: absolute; - padding: 20px; - background: #fff; - border: 5px solid #444; - right: 2.7em; - top: 100px; - width: 80%; - border-radius: 4px 0 4px 4px; - z-index: 9999; - } - #header nav li { - text-align: center; - width: 100%; - padding: 10px 0; - margin: 0; - } - #header nav:hover ul { - display: block; - } - -} - -/* Extra Small Devices, Phones */ -@media only screen and (max-width : 480px) { - - .inner { - width: 85%; - } - .inner img { - width:100%; - } - #header { - margin-bottom: 30px; - } - #header h1 a { - font-size:1em; - } - #header .menu-icon { - display:inline-block; - } - #header nav a { color: #000; } - #header nav a:hover { color: #afe1da; } - #header nav ul, nav:active ul { - display: none; - position: absolute; - padding: 20px; - background: #fff; - border: 5px solid #444; - right: 0em; - top: 100px; - width: auto; - border-radius: 4px 0 4px 4px; - } - #header nav li { - text-align: center; - width: 100%; - padding: 10px 0; - margin: 0; - } - #header nav:hover ul { - display: block; - } -} \ No newline at end of file +/*=================================*/ +/* Pico Default Theme +/* By: Gilbert Pellegrom +/* http: //dev7studios.com +/*=================================*/ + +/* Reset Styles +/*---------------------------------------------*/ +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, font, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td { + margin: 0; + padding: 0; + border: 0; + outline: 0; + font-weight: inherit; + font-style: inherit; + font-size: 100%; + font-family: inherit; + vertical-align: baseline; +} + +body { + line-height: 1; + color: black; + background: white; +} + +table { + border-collapse: collapse; + border-spacing: 0; +} + +caption, th, td { + text-align: left; + font-weight: normal; +} + +blockquote:before, blockquote:after, +q:before, q:after { + content: ""; +} + +blockquote, q { + quotes: "" ""; +} + +/* HTML5 tags */ +header, section, footer, +aside, nav, article, figure { + display: block; +} + +/* hand cursor on clickable input elements */ +label, input[type=button], input[type=submit], button { + cursor: pointer; +} + +/* make buttons play nice in IE: + www.viget.com/inspire/styling-the-button-element-in-internet-explorer/ */ +button { + width: auto; + overflow: visible; +} + +/* Sharper Thumbnails */ +img { + -ms-interpolation-mode: bicubic; +} + +/* Input Styles +/*---------------------------------------------*/ +input, +textarea, +select { + padding: 5px; + font: 400 1em Verdana, Sans-serif; + color: #666; + background: #fff; + border: 1px solid #999999; + margin: 0 0 1em 0; +} + +input:focus, +textarea:focus, +select:focus { + color: #000; + background: #fff; + border: 1px solid #666666; +} + +/* Main Styles +/*---------------------------------------------*/ +body { + font: 14px/1.8em 'Open Sans', Helvetica, Arial, Helvetica, sans-serif; + color: #444; + background: #fff; + -webkit-font-smoothing: antialiased; +} + +a, a:visited { + color: #2EAE9B; + text-decoration: none; + -webkit-transition: all 0.2s linear; + -moz-transition: all 0.2s linear; + -ms-transition: all 0.2s linear; + -o-transition: all 0.2s linear; + transition: all 0.2s linear; +} + +a:hover, a:active { + color: #000; + text-decoration: none; +} + +h1, h2, h3, h4, h5, h6 { + color: #000; + line-height: 1.2em; + margin-bottom: 0.6em; +} + +h1 { + font-size: 2em; +} + +h2 { + font-size: 1.7em; +} + +h3 { + font-size: 1.5em; + margin-top: 2em; +} + +p, table { + margin-bottom: 1em; +} + +ol, ul { + padding-left: 30px; + margin-bottom: 1em; +} + +b, strong { + font-weight: bold; +} + +i, em { + font-style: italic; +} + +u { + text-decoration: underline; +} + +abbr, acronym { + cursor: help; + border-bottom: 0.1em dotted; +} + +td, td img { + vertical-align: top; +} + +td, th { + border: solid 1px #999; + padding: 0.25em 0.5em; +} + +th { + font-weight: bold; + text-align: center; + background: #eee; +} + +sub { + vertical-align: sub; + font-size: smaller; +} + +sup { + vertical-align: super; + font-size: smaller; +} + +code { + font-family: Courier, "Courier New", Monaco, Tahoma; + background: #eee; + color: #333; + padding: 0px 2px; +} + +pre { + background: #eee; + padding: 20px; + margin-bottom: 1em; + overflow: auto; +} + +blockquote { + font-style: italic; + margin: 0 0 1em 15px; + padding-left: 10px; + border-left: 5px solid #dddddd; +} + +/* Structure Styles +/*---------------------------------------------*/ +.inner { + width: 850px; + margin: 0 auto; +} + +#header { + background: #2EAE9B; + padding: 60px 0; + margin-bottom: 80px; + color: #afe1da; +} +#header a { color: #afe1da; } +#header h1 a, +#header a:hover { color: #fff; } +#header h1 { + font-weight: bold; + margin: 0; + float: left; +} +#header .menu-icon { + display: none; + width: 35px; + height: 35px; + background: #afe1da url(menu-icon.png) center; +} +#header nav { + float: right; + list-style: none; + margin: 0; + padding: 0; +} +#header nav a { + font-weight: bold; + margin-left: 20px; +} +#header a:hover#menu-icon { + background-color: #444; + border-radius: 4px 4px 0 0; +} +#header ul { + list-style: none; +} +#header li { + display: inline-block; + float: left; +} +#footer { + background: #707070; + padding: 60px 0; + margin-top: 80px; + color: #C0C0C0; +} +#footer a { color: #ddd; } +#footer a:hover { color: #fff; } + +/* Misc Styles +/*---------------------------------------------*/ +.clearfix:before, +.clearfix:after { + content: " "; + display: table; +} +.clearfix:after { + clear: both; +} +.clearfix { + *zoom: 1; +} + +/* Media Queries +/*---------------------------------------------*/ + +/* Small Devices, Tablets */ +@media only screen and (max-width : 768px) { + .inner { + width: 85%; + } + .inner img { + width:100%; + } + #header { + margin-bottom: 40px; + } + #header h1 a { + font-size:1em; + } + #header .menu-icon { + display:inline-block; + } + #header nav a { color: #000; } + #header nav a:hover { color: #afe1da; } + #header nav ul, nav:active ul { + display: none; + position: absolute; + padding: 20px; + background: #fff; + border: 5px solid #444; + right: 2.7em; + top: 100px; + width: 80%; + border-radius: 4px 0 4px 4px; + z-index: 9999; + } + #header nav li { + text-align: center; + width: 100%; + padding: 10px 0; + margin: 0; + } + #header nav:hover ul { + display: block; + } +} + +/* Extra Small Devices, Phones */ +@media only screen and (max-width : 480px) { + .inner { + width: 85%; + } + .inner img { + width:100%; + } + #header { + margin-bottom: 30px; + } + #header h1 a { + font-size:1em; + } + #header .menu-icon { + display:inline-block; + } + #header nav a { color: #000; } + #header nav a:hover { color: #afe1da; } + #header nav ul, nav:active ul { + display: none; + position: absolute; + padding: 20px; + background: #fff; + border: 5px solid #444; + right: 0em; + top: 100px; + width: auto; + border-radius: 4px 0 4px 4px; + } + #header nav li { + text-align: center; + width: 100%; + padding: 10px 0; + margin: 0; + } + #header nav:hover ul { + display: block; + } +} From 31acaffa67228dae1c022ad4b078b163cc98434f Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 27 Nov 2015 19:40:26 +0100 Subject: [PATCH 66/80] Add PHP_CodeSniffer --- .travis.yml | 2 +- composer.json | 3 ++- index.php | 4 +++- phpcs.xml | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 phpcs.xml diff --git a/.travis.yml b/.travis.yml index 7815b08..2fb9600 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ before_script: - export PATH="$TRAVIS_BUILD_DIR/build:$TRAVIS_BUILD_DIR/vendor/bin:$PATH" script: - - find . -not \( -path './vendor' -prune \) -type f -name '*.php' -print0 | xargs -0 -I file php -l file > /dev/null + - phpcs --standard=phpcs.xml "$TRAVIS_BUILD_DIR" after_success: - deploy-phpdoc-branch.sh diff --git a/composer.json b/composer.json index 14f174d..5894970 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,8 @@ "symfony/yaml" : "^2.3" }, "require-dev" : { - "phpdocumentor/phpdocumentor": "^2.8" + "phpdocumentor/phpdocumentor": "^2.8", + "squizlabs/php_codesniffer": "^2.4" }, "autoload": { "psr-0": { diff --git a/index.php b/index.php index 40b811a..a4e0fb0 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,6 @@ setConfig(array()); +//$pico->setConfig(array()); // run application echo $pico->run(); diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..6e8d640 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,39 @@ + + + + Pico's coding standards mainly base on the PHP-FIG PSR-2 standard, + but without the MissingNamespace sniff. + + + + ^build/ + ^vendor/ + *.min.js + + + + + + + + + + + + + + + + \ No newline at end of file From 86d1f713f24ea8c59d4bdc5647e9393d7a76ac1c Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 27 Nov 2015 19:45:21 +0100 Subject: [PATCH 67/80] Move PHP version check to index.php --- index.php | 5 +++++ lib/Pico.php | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/index.php b/index.php index 24225b8..2532c31 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,10 @@ locked = true; From cb15ea74935090243eb730f42f50fcb86125df63 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 27 Nov 2015 19:49:53 +0100 Subject: [PATCH 68/80] Amend #286 --- index.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/index.php b/index.php index 2532c31..625c725 100644 --- a/index.php +++ b/index.php @@ -6,15 +6,14 @@ if (version_compare(PHP_VERSION, '5.3.6', '<')) { } // load dependencies -if(is_file($f = __DIR__ . '/vendor/autoload.php')) { - // local composer install - require_once($f); -} elseif(is_file($f = __DIR__ . '/../../../vendor/autoload.php')) { - // root composer install - require_once($f); +if(is_file(__DIR__ . '/vendor/autoload.php')) { + // composer root package + require_once(__DIR__ . '/vendor/autoload.php'); +} elseif(is_file(__DIR__ . '/../../../vendor/autoload.php')) { + // composer dependency package + require_once(__DIR__ . '/../../../vendor/autoload.php'); } else { - // composer needs install... - die('Cannot find composer `/vendor/autoload.php` -- try `composer install`'); + die("Cannot find `vendor/autoload.php`. Run `composer install`."); } // instance Pico From 2761f8b7516ea323004ad696c4303d3ce7769bca Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 27 Nov 2015 20:13:17 +0100 Subject: [PATCH 69/80] Refactor Pico::isUrlRewritingEnabled() --- lib/Pico.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/Pico.php b/lib/Pico.php index 8714345..610d66e 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -479,6 +479,10 @@ class Pico $this->config['base_url'] = rtrim($this->config['base_url'], '/') . '/'; } + if ($this->config['rewrite_url'] === null) { + $this->config['rewrite_url'] = $this->isUrlRewritingEnabled(); + } + if (empty($this->config['content_dir'])) { // try to guess the content directory if (is_dir($this->getRootDir() . 'content')) { @@ -1237,13 +1241,13 @@ class Pico */ public function isUrlRewritingEnabled() { - if (($this->getConfig('rewrite_url') === null) && isset($_SERVER['PICO_URL_REWRITING'])) { - return (bool) $_SERVER['PICO_URL_REWRITING']; - } elseif ($this->getConfig('rewrite_url')) { - return true; + $urlRewritingEnabled = $this->getConfig('rewrite_url'); + if ($urlRewritingEnabled !== null) { + return $urlRewritingEnabled; } - return false; + $this->config['rewrite_url'] = (isset($_SERVER['PICO_URL_REWRITING']) && $_SERVER['PICO_URL_REWRITING']); + return $this->getConfig('rewrite_url'); } /** From 98022a5a8ff6a13d07431c8dc371ac868fa84522 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 27 Nov 2015 20:21:13 +0100 Subject: [PATCH 70/80] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6810a0..d3642ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,10 +9,16 @@ Released: - all contributors and users which made this possible! * [New] New `markdown` filter for Twig to parse markdown strings; Note: If you want to parse the contents of a page, use the `content` filter instead +* [New] New PHP version check in `index.php` * [Changed] Improve documentation * [Changed] Improve table styling in default theme +* [Changed] Update composer version constraints; almost all dependencies will + have pending updates, run `composer update` * [Changed] Throw a RuntimeException when the `content` dir isn't accessible * [Changed] Reuse `ParsedownExtra` object; new `onParsedownRegistration` event +* [Changed] `$config['rewrite_url']` is now always available +* [Changed] `DummyPlugin` class is now final +* [Changed] Various small improvements and changes... * [Fixed] `PicoDeprecated`: Sanitize `content_dir` and `base_url` options when reading `config.php` in Picos root dir * [Fixed] Replace `urldecode()` (deprecated RFC 1738) with `rawurldecode()` From 2535df7cfe778dfb7993f66a81d3738cce93b84f Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 27 Nov 2015 19:56:28 +0100 Subject: [PATCH 71/80] Add index.php.dist See https://github.com/picocms/Pico/issues/285#issuecomment-160130798 --- .travis.yml | 1 + index.php | 8 +------- index.php.dist | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 index.php.dist diff --git a/.travis.yml b/.travis.yml index 2fb9600..aa0af02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,7 @@ before_deploy: - deploy-phpdoc-release.sh - 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 deploy: diff --git a/index.php b/index.php index b8fdff6..7e7cdf0 100644 --- a/index.php +++ b/index.php @@ -1,10 +1,4 @@ -run(); From e088f6c6fafef094f04e02db57367c01bf06bfa1 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 27 Nov 2015 20:31:17 +0100 Subject: [PATCH 72/80] Update phpcs.xml --- phpcs.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpcs.xml b/phpcs.xml index 6e8d640..93b9ebb 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -36,4 +36,4 @@ - \ No newline at end of file + From 2eed14103a052b6ff0b39eabb0d0f47d88b1f431 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 27 Nov 2015 20:36:40 +0100 Subject: [PATCH 73/80] Add @codingStandardsIgnoreFile to index.php.dist The comments of the "instance Pico" section violate PSR-2, but we want to keep them anyway --- index.php.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php.dist b/index.php.dist index 73d8330..2186072 100644 --- a/index.php.dist +++ b/index.php.dist @@ -1,4 +1,4 @@ - Date: Fri, 27 Nov 2015 22:52:15 +0100 Subject: [PATCH 74/80] Force Pico::$requestUrl to have no leading/trailing slash Fixes #291 --- CHANGELOG.md | 1 + lib/Pico.php | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3642ee..8a3fe95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ Released: - * [Fixed] #272: Encode URLs using `rawurlencode()` in `Pico::getPageUrl()` * [Fixed] #274: Prevent double slashes in `base_url` * [Fixed] #285: Make `index.php` work when installed as a composer dependency +* [Fixed] #291: Force `Pico::$requestUrl` to have no leading/trailing slash ``` ### Version 1.0.0-beta.1 diff --git a/lib/Pico.php b/lib/Pico.php index 610d66e..2a5aa65 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -567,9 +567,9 @@ class Pico * * We recommend you to use the `link` filter in templates to create * internal links, e.g. `{{ "sub/page"|link }}` is equivalent to - * `{{ base_url }}sub/page`. In content files you can still use the - * `%base_url%` variable; e.g. `%base_url%?sub/page` will be automatically - * replaced accordingly. + * `{{ base_url }}/sub/page` and `{{ base_url }}?sub/page`, depending on + * enabled URL rewriting. In content files you can use the `%base_url%` + * variable; e.g. `%base_url%?sub/page` will be replaced accordingly. * * @see Pico::getRequestUrl() * @return void @@ -587,6 +587,7 @@ class Pico $pathComponent = substr($pathComponent, 0, $pathComponentLength); } $this->requestUrl = (strpos($pathComponent, '=') === false) ? rawurldecode($pathComponent) : ''; + $this->requestUrl = trim($this->requestUrl, '/'); } /** From 2d9b5aa1a20b5e8d1ed943367b8576fed681fb0e Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 29 Nov 2015 16:39:03 +0100 Subject: [PATCH 75/80] Fix operators --- lib/Pico.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/Pico.php b/lib/Pico.php index 2a5aa65..7f4b1c3 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -939,7 +939,7 @@ class Pico $files = $this->getFiles($this->getConfig('content_dir'), $this->getConfig('content_ext'), Pico::SORT_NONE); foreach ($files as $i => $file) { // skip 404 page - if (basename($file) == '404' . $this->getConfig('content_ext')) { + if (basename($file) === '404' . $this->getConfig('content_ext')) { unset($files[$i]); continue; } @@ -977,7 +977,7 @@ class Pico 'meta' => &$meta ); - if ($file == $this->requestFile) { + if ($file === $this->requestFile) { $page['content'] = &$this->content; } @@ -1006,10 +1006,10 @@ class Pico $bSortKey = (basename($b['id']) === 'index') ? dirname($b['id']) : $b['id']; $cmp = strcmp($aSortKey, $bSortKey); - return $cmp * (($order == 'desc') ? -1 : 1); + return $cmp * (($order === 'desc') ? -1 : 1); }; - if ($this->getConfig('pages_order_by') == 'date') { + if ($this->getConfig('pages_order_by') === 'date') { // sort by date uasort($this->pages, function ($a, $b) use ($alphaSortClosure, $order) { if (empty($a['time']) || empty($b['time'])) { @@ -1023,7 +1023,7 @@ class Pico return $alphaSortClosure($a, $b); } - return $cmp * (($order == 'desc') ? 1 : -1); + return $cmp * (($order === 'desc') ? 1 : -1); }); } else { // sort alphabetically @@ -1063,7 +1063,7 @@ class Pico if ($currentPageIndex !== false) { $this->currentPage = &$this->pages[$currentPageId]; - if (($this->getConfig('order_by') == 'date') && ($this->getConfig('order') == 'desc')) { + if (($this->getConfig('order_by') === 'date') && ($this->getConfig('order') === 'desc')) { $previousPageOffset = 1; $nextPageOffset = -1; } else { @@ -1203,7 +1203,7 @@ class Pico 'prev_page' => $this->previousPage, 'current_page' => $this->currentPage, 'next_page' => $this->nextPage, - 'is_front_page' => ($this->requestFile == $frontPage), + 'is_front_page' => ($this->requestFile === $frontPage), ); } From b18464adba15b81f862774aeab99b3b170255b0d Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 29 Nov 2015 17:00:05 +0100 Subject: [PATCH 76/80] CONTRIBUTING.md: Convert Issues template to continuous text --- CONTRIBUTING.md | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cb3bfde..945417c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,17 +12,9 @@ Issues If you want to report an *issue* with Pico's core, please create a new [Issue](https://github.com/picocms/Pico/issues) on GitHub. Concerning problems with plugins or themes, please refer to the website of the developer of this plugin or theme. -Before creating a [new Issue on GitHub](https://github.com/picocms/Pico/issues/new), please make sure the problem wasn't reported yet using [GitHubs search engine](https://github.com/picocms/Pico/search?type=Issues). Please describe your issue as clear as possible and always include steps to reproduce the problem. +Before creating a [new Issue on GitHub](https://github.com/picocms/Pico/issues/new), please make sure the problem wasn't reported yet using [GitHubs search engine](https://github.com/picocms/Pico/search?type=Issues). -This is an example of what type of information to include with your issue. - -- Pico Version -- Installed plugins, if applicable -- Bug Description -- Steps to Reproduce -- Actual/Expected Behavior -- Troubleshooting/Testing Steps Attempted -- Workarounds? +Please describe your issue as clear as possible and always include the *Pico version* you're using. Provided that you're using *plugins*, include a list of them. We need information about the *actual and expected behavior* and *steps to reproduce* the problem. What steps have you taken to resolve the problem by yourself (i.e. *your own troubleshooting*)? Contributing code ----------------- From 372979e45b58c63b5fff1bc37e34e3f76b58cfc2 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 29 Nov 2015 17:18:46 +0100 Subject: [PATCH 77/80] CONTRIBUTING.md: Update build & release process --- CONTRIBUTING.md | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 945417c..92e8af0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -80,27 +80,18 @@ As soon as development reaches a point where feedback is appreciated, a pull req Build & Release process ----------------------- -> This is work in progress. Please refer to [#268](https://github.com/picocms/Pico/issues/268) for details. +We're using [Travis CI](https://travis-ci.com) to automate the build & release process of Pico. It generates and deploys [phpDoc](http://phpdoc.org) class docs for new releases and on every commit to the `master` branch. Travis also prepares new releases by generating Pico's pre-built packages and uploading them to GitHub. Please refer to [our `.travis.yml`](https://github.com/picocms/Pico/blob/master/.travis.yml) for details. -We're using [Travis CI](https://travis-ci.com) to automate the build & release process of Pico. It generates and deploys [phpDoc](http://phpdoc.org) class docs for new releases and on every commit to the `master` branch. Travis also prepares new releases by generating Pico's pre-built packages and uploading them to GitHub. +As elucidated above, it's important that each commit to `master` is deployable. Once development of a new Pico release is finished, trigger Pico's build & release process by pushing a new Git tag. This tag should reference a (usually empty) commit on `master`, which message should follow the following template: -It is important that each commit to `master` is deployable. Once a `feature/branch` or the `master` branch have reached a point where the need for a version increase is necessary, you can trigger this process by pushing a new Git Tag. The tag references a (usually empty) commit which message follows the following template: +``` +Version 1.0.0 - Example: - ``` - Pico Version 1.0.1 - * [New] ... - * [Changed] ... - * [Removed] ... - * [Security] ... - ``` +* [Security] ... +* [New] ... +* [Changed] ... +* [Fixed] ... +* [Removed] ... +``` - - -After deploying a new release, you will need to amend the release information on GitHub with the release title (taken from changelog), and changelog itself. - -__Note__ -- Releases will be available at: [https://github.com/picocms/Pico/releases](https://github.com/picocms/Pico/releases) - -- Pico will be automatically updated on [Packagist](http://packagist.org/packages/picocms/pico) +Travis CI will draft the new [release on GitHub](https://github.com/picocms/Pico/releases) automatically, but will require you to manually amend the descriptions formatting. The latest Pico version is always available at https://github.com/picocms/Pico/releases/latest, so please make sure to publish this URL rather than version-specific URLs. [Packagist](http://packagist.org/packages/picocms/pico) will be updated automatically. From bef150221b3755e9f0fbe2d8c42bdedfb9691717 Mon Sep 17 00:00:00 2001 From: theshka Date: Sun, 29 Nov 2015 11:11:26 -0600 Subject: [PATCH 78/80] CONTRIBUTING.md: Final tocuhes on Build & Release section. --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 92e8af0..b849472 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,7 +14,7 @@ If you want to report an *issue* with Pico's core, please create a new [Issue](h Before creating a [new Issue on GitHub](https://github.com/picocms/Pico/issues/new), please make sure the problem wasn't reported yet using [GitHubs search engine](https://github.com/picocms/Pico/search?type=Issues). -Please describe your issue as clear as possible and always include the *Pico version* you're using. Provided that you're using *plugins*, include a list of them. We need information about the *actual and expected behavior* and *steps to reproduce* the problem. What steps have you taken to resolve the problem by yourself (i.e. *your own troubleshooting*)? +Please describe your issue as clear as possible and always include the *Pico version* you're using. Provided that you're using *plugins*, include a list of them too. We need information about the *actual and expected behavior*, the *steps to reproduce* the problem, and what steps have you taken to resolve the problem by yourself (i.e. *your own troubleshooting*)? Contributing code ----------------- @@ -82,7 +82,7 @@ Build & Release process We're using [Travis CI](https://travis-ci.com) to automate the build & release process of Pico. It generates and deploys [phpDoc](http://phpdoc.org) class docs for new releases and on every commit to the `master` branch. Travis also prepares new releases by generating Pico's pre-built packages and uploading them to GitHub. Please refer to [our `.travis.yml`](https://github.com/picocms/Pico/blob/master/.travis.yml) for details. -As elucidated above, it's important that each commit to `master` is deployable. Once development of a new Pico release is finished, trigger Pico's build & release process by pushing a new Git tag. This tag should reference a (usually empty) commit on `master`, which message should follow the following template: +As insinuated above, it is important that each commit to `master` is deployable. Once development of a new Pico release is finished, trigger Pico's build & release process by pushing a new Git tag. This tag should reference a (usually empty) commit on `master`, which message should adhere to the following template: ``` Version 1.0.0 From 6cb378e83fe152ad0d3e052bb49e01bca896b646 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 29 Nov 2015 20:26:43 +0100 Subject: [PATCH 79/80] Inline docs: Add link to YAML wikipedia article Official resources about YAML are ... - impossible to understand for a ordinary user. --- content-sample/index.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/content-sample/index.md b/content-sample/index.md index 55d385d..40abb8b 100644 --- a/content-sample/index.md +++ b/content-sample/index.md @@ -72,8 +72,8 @@ follows: !\[Image Title\](%base_url%/assets/image.png) Text files are marked up using [Markdown][]. They can also contain regular HTML. -At the top of text files you can place a block comment and specify certain -attributes of the page. For example: +At the top of text files you can place a block comment and specify certain meta +attributes of the page using [YAML][] (the "YAML header"). For example: --- Title: Welcome @@ -285,6 +285,7 @@ setting `$config['rewrite_url'] = true;` in your `config/config.php`. For more help have a look at the Pico documentation at http://picocms.org/docs. [Markdown]: http://daringfireball.net/projects/markdown/syntax +[YAML]: https://en.wikipedia.org/wiki/YAML [Twig]: http://twig.sensiolabs.org/documentation [WikiThemes]: https://github.com/picocms/Pico/wiki/Pico-Themes [WikiPlugins]: https://github.com/picocms/Pico/wiki/Pico-Plugins From 9aaab5de1a8277dfd58e5c5410622925e0ce8492 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 29 Nov 2015 21:58:30 +0100 Subject: [PATCH 80/80] Refactor Pico::parseFileMeta() --- lib/Pico.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/Pico.php b/lib/Pico.php index 7f4b1c3..9f64b3e 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -772,7 +772,7 @@ class Pico $meta[$fieldId] = $meta[$fieldName]; unset($meta[$fieldName]); } - } else { + } elseif (!isset($meta[$fieldId])) { // guarantee array key existance $meta[$fieldId] = ''; } @@ -786,10 +786,7 @@ class Pico } } else { // guarantee array key existance - foreach ($headers as $id => $field) { - $meta[$id] = ''; - } - + $meta = array_fill_keys(array_keys($headers), ''); $meta['time'] = $meta['date_formatted'] = ''; }