diff --git a/.htaccess b/.htaccess index 54cbc9b..ac2c3b8 100644 --- a/.htaccess +++ b/.htaccess @@ -1,11 +1,11 @@ RewriteEngine On - # May be required to access sub-directories + # May be required to access sub directories #RewriteBase / # Deny access to internal dirs and files by passing the URL to Pico RewriteRule ^(\.git|config|content|content-sample|lib|vendor)(/|$) index.php [L] - RewriteRule ^(CHANGELOG.md|composer.(json|lock)) index.php [L] + RewriteRule ^(CHANGELOG\.md|composer\.(json|lock)) index.php [L] # Enable URL rewriting RewriteCond %{REQUEST_FILENAME} !-f diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c478c4..4245dcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,15 @@ Pico Changelog ============== ### Version 1.0.3 -Released: - +Released: 2016-05-11 ``` * [Changed] Improve documentation +* [Changed] Heavily extend nginx configuration docs * [Changed] Add CSS rules for definition lists to default theme * [Changed] Always use `on404Content...` execution path when serving a `404.md` -* [Changed] Deny access to `.git` directory (`.htaccess` file) +* [Changed] Deny access to `.git` directory, `CHANGELOG.md`, `composer.json` + and `composer.lock` (`.htaccess` file) * [Changed] Use Pico's `404.md` to deny access to `.git`, `config`, `content`, * `content-sample`, `lib` and `vendor` dirs (`.htaccess` file) * [Fixed] #342: Fix responsiveness in default theme diff --git a/README.md b/README.md index 148538c..2d833d5 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ You want to contribute to Pico? We really appreciate that! You can help make Pic [composer]: https://getcomposer.org/ [SemVer]: http://semver.org [PHPServer]: http://php.net/manual/en/features.commandline.webserver.php -[HelpUpgrade]: http://picocms.org/upgrade/ +[HelpUpgrade]: http://picocms.org/in-depth/upgrade/ [HelpUserDocs]: http://picocms.org/docs/ [HelpDevDocs]: http://picocms.org/development/ [OfficialPlugins]: http://picocms.org/customization/ diff --git a/_build/deploy-phpdoc-branch.sh b/_build/deploy-phpdoc-branch.sh index 720ee15..4e3cbe8 100755 --- a/_build/deploy-phpdoc-branch.sh +++ b/_build/deploy-phpdoc-branch.sh @@ -41,12 +41,20 @@ generate-phpdoc.sh \ [ $? -eq 0 ] || exit 1 [ -n "$(git status --porcelain "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID.cache")" ] || exit 0 +# update phpDoc list +update-phpdoc-list.sh \ + "$DEPLOYMENT_DIR/_data/phpDoc.yml" \ + "$TRAVIS_BRANCH" "branch" "$TRAVIS_BRANCH branch" "$(date +%s)" + # commit phpDocs echo "Committing changes..." -git add "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID.cache" "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" +git add \ + "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID.cache" "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" \ + "$DEPLOYMENT_DIR/_data/phpDoc.yml" git commit \ --message="Update phpDocumentor class docs for $TRAVIS_BRANCH branch @ $TRAVIS_COMMIT" \ - "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID.cache" "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" + "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID.cache" "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" \ + "$DEPLOYMENT_DIR/_data/phpDoc.yml" [ $? -eq 0 ] || exit 1 echo diff --git a/_build/deploy-phpdoc-release.sh b/_build/deploy-phpdoc-release.sh index 6ab1042..9651df5 100755 --- a/_build/deploy-phpdoc-release.sh +++ b/_build/deploy-phpdoc-release.sh @@ -39,13 +39,18 @@ if [ "$DEPLOY_PHPDOC_RELEASES" == "true" ]; then "$MILESTONE API Documentation ($TRAVIS_TAG)" [ $? -eq 0 ] || exit 1 - # commit phpDocs if [ -n "$(git status --porcelain "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID")" ]; then + # update phpDoc list + update-phpdoc-list.sh \ + "$DEPLOYMENT_DIR/_data/phpDoc.yml" \ + "$TRAVIS_TAG" "version" "Pico ${TRAVIS_TAG#v}" "$(date +%s)" + + # commit phpDocs echo "Committing phpDoc changes..." - git add "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" + git add "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" "$DEPLOYMENT_DIR/_data/phpDoc.yml" git commit \ --message="Update phpDocumentor class docs for $TRAVIS_TAG" \ - "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" + "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" "$DEPLOYMENT_DIR/_data/phpDoc.yml" [ $? -eq 0 ] || exit 1 echo fi @@ -69,7 +74,7 @@ fi # update version file if [ "$DEPLOY_VERSION_FILE" == "true" ]; then - generate-version.sh \ + update-version-file.sh \ "$DEPLOYMENT_DIR/_data/version.yml" \ "${TRAVIS_TAG#v}" diff --git a/_build/update-phpdoc-list.sh b/_build/update-phpdoc-list.sh new file mode 100755 index 0000000..c6f48c2 --- /dev/null +++ b/_build/update-phpdoc-list.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash + +## +# Updates the phpDoc list +# +# @author Daniel Rudolf +# @link http://picocms.org +# @license http://opensource.org/licenses/MIT +# + +set -e + +# parameters +LIST_FILE_PATH="$1" # target file path +LIST_ID="$2" # phpDoc ID +LIST_TYPE="$3" # phpDoc type +LIST_TITLE="$4" # phpDoc title +LIST_LAST_UPDATE="$5" # phpDoc last update + +# print parameters +echo "Updating phpDoc list..." +printf 'LIST_FILE_PATH="%s"\n' "$LIST_FILE_PATH" +printf 'LIST_ID="%s"\n' "$LIST_ID" +printf 'LIST_TYPE="%s"\n' "$LIST_TYPE" +printf 'LIST_TITLE="%s"\n' "$LIST_TITLE" +printf 'LIST_LAST_UPDATE="%s"\n' "$LIST_LAST_UPDATE" +echo + +# create temporary file +printf 'Creating temporary file...\n' +LIST_TMP_FILE="$(mktemp)" +[ -n "$LIST_TMP_FILE" ] || exit 1 + +exec 3> "$LIST_TMP_FILE" + +# walk through phpDoc list +printf 'Walking through phpDoc list...\n' + +DO_REPLACE="no" +DID_REPLACE="no" +while IFS='' read -r LINE || [[ -n "$LINE" ]]; do + if [ "$DO_REPLACE" == "yes" ]; then + # skip lines until next entry is reached + [ "${LINE:0:2}" == " " ] && continue + DO_REPLACE="no" + + elif [ "$LINE" == "- id: $LIST_ID" ]; then + # update existing entry + printf 'Updating existing entry...\n' + printf -- '- id: %s\n' "$LIST_ID" >&3 + printf -- ' type: %s\n' "$LIST_TYPE" >&3 + printf -- ' title: %s\n' "$LIST_TITLE" >&3 + printf -- ' last_update: %s\n' "$LIST_LAST_UPDATE" >&3 + + DO_REPLACE="yes" + DID_REPLACE="yes" + continue + fi + + echo "$LINE" >&3 +done < "$LIST_FILE_PATH" + +# add new entry +if [ "$DID_REPLACE" == "no" ]; then + printf 'Adding new entry...\n' + printf -- '- id: %s\n' "$LIST_ID" >&3 + printf -- ' type: %s\n' "$LIST_TYPE" >&3 + printf -- ' title: %s\n' "$LIST_TITLE" >&3 + printf -- ' last_update: %s\n' "$LIST_LAST_UPDATE" >&3 +fi + +exec 3>&- + +# move temporary file +printf 'Replacing phpDoc list...\n' +mv "$LIST_TMP_FILE" "$LIST_FILE_PATH" + +echo diff --git a/_build/generate-version.sh b/_build/update-version-file.sh similarity index 100% rename from _build/generate-version.sh rename to _build/update-version-file.sh diff --git a/config/config.php.template b/config/config.php.template index f04a4bc..bd8c182 100644 --- a/config/config.php.template +++ b/config/config.php.template @@ -11,7 +11,7 @@ * save your changes. * * @link http://picocms.org - * @license http://opensource.org/licenses/MIT + * @license http://opensource.org/licenses/MIT The MIT License * @version 1.1 */ diff --git a/content-sample/index.md b/content-sample/index.md index b498bc0..edbfcc8 100644 --- a/content-sample/index.md +++ b/content-sample/index.md @@ -283,15 +283,25 @@ you get an error message from your web server, please make sure to enable the still shows no rewritten URLs, force URL rewriting by setting `$config['rewrite_url'] = true;` in your `config/config.php`. -If you're using Nginx, you can use the following configuration to enable -URL rewriting. Don't forget to adjust the path (`/pico/`; line `1` and `3`) -to match your installation directory. You can then enable URL rewriting by -setting `$config['rewrite_url'] = true;` in your `config/config.php`. +If you're using Nginx, you can use the following configuration to enable URL +rewriting (lines `5` to `8`) and denying access to Pico's internal files +(lines `1` to `3`). You'll need to adjust the path (`/pico` on lines `1`, `5` +and `7`) to match your installation directory. Additionally, you'll need to +enable URL rewriting by setting `$config['rewrite_url'] = true;` in your +`config/config.php`. The Nginx configuration should provide the *bare minimum* +you need for Pico. Nginx is a very extensive subject. If you have any trouble, +please read through our [Nginx configuration docs][NginxConfig]. - location /pico/ { - index index.php; - try_files $uri $uri/ /pico/$is_args$args; - } +``` +location ~ /pico/(\.htaccess|\.git|config|content|content-sample|lib|vendor|CHANGELOG\.md|composer\.(json|lock)) { + return 404; +} + +location /pico/ { + index index.php; + try_files $uri $uri/ /pico/index.php$is_args$args; +} +``` ## Documentation @@ -305,3 +315,4 @@ For more help have a look at the Pico documentation at http://picocms.org/docs. [WikiPlugins]: https://github.com/picocms/Pico/wiki/Pico-Plugins [PluginUpgrade]: http://picocms.org/development/#upgrade [ModRewrite]: https://httpd.apache.org/docs/current/mod/mod_rewrite.html +[NginxConfig]: http://picocms.org/in-depth/nginx/ diff --git a/lib/AbstractPicoPlugin.php b/lib/AbstractPicoPlugin.php index 2b7a56c..b0506dc 100644 --- a/lib/AbstractPicoPlugin.php +++ b/lib/AbstractPicoPlugin.php @@ -7,7 +7,7 @@ * * @author Daniel Rudolf * @link http://picocms.org - * @license http://opensource.org/licenses/MIT + * @license http://opensource.org/licenses/MIT The MIT License * @version 1.0 */ abstract class AbstractPicoPlugin implements PicoPluginInterface diff --git a/lib/Pico.php b/lib/Pico.php index bcea0f2..86c2c1b 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -22,8 +22,8 @@ * * @author Gilbert Pellegrom * @author Daniel Rudolf - * @link - * @license The MIT License + * @link http://picocms.org + * @license http://opensource.org/licenses/MIT The MIT License * @version 1.1 */ class Pico @@ -896,7 +896,7 @@ class Pico * for users and pure (!) theme developers ONLY. * * @see Pico::getFileMeta() - * @see + * @see http://symfony.com/doc/current/components/yaml/introduction.html * @param string $rawContent the raw file contents * @param string[] $headers known meta headers * @return array parsed meta data diff --git a/lib/PicoPluginInterface.php b/lib/PicoPluginInterface.php index 8ea3ab6..ffa839b 100644 --- a/lib/PicoPluginInterface.php +++ b/lib/PicoPluginInterface.php @@ -22,7 +22,7 @@ * * @author Daniel Rudolf * @link http://picocms.org - * @license http://opensource.org/licenses/MIT + * @license http://opensource.org/licenses/MIT The MIT License * @version 1.0 */ interface PicoPluginInterface diff --git a/lib/PicoTwigExtension.php b/lib/PicoTwigExtension.php index 5bb0b9f..0ed4008 100644 --- a/lib/PicoTwigExtension.php +++ b/lib/PicoTwigExtension.php @@ -5,7 +5,7 @@ * * @author Daniel Rudolf * @link http://picocms.org - * @license http://opensource.org/licenses/MIT + * @license http://opensource.org/licenses/MIT The MIT License * @version 1.0 */ class PicoTwigExtension extends Twig_Extension diff --git a/plugins/00-PicoDeprecated.php b/plugins/00-PicoDeprecated.php index e2db93a..6095ecc 100644 --- a/plugins/00-PicoDeprecated.php +++ b/plugins/00-PicoDeprecated.php @@ -38,7 +38,7 @@ * * @author Daniel Rudolf * @link http://picocms.org - * @license http://opensource.org/licenses/MIT + * @license http://opensource.org/licenses/MIT The MIT License * @version 1.0 */ class PicoDeprecated extends AbstractPicoPlugin diff --git a/plugins/01-PicoParsePagesContent.php b/plugins/01-PicoParsePagesContent.php index db4ed10..6611c90 100644 --- a/plugins/01-PicoParsePagesContent.php +++ b/plugins/01-PicoParsePagesContent.php @@ -13,7 +13,7 @@ * * @author Daniel Rudolf * @link http://picocms.org - * @license http://opensource.org/licenses/MIT + * @license http://opensource.org/licenses/MIT The MIT License * @version 1.0 */ class PicoParsePagesContent extends AbstractPicoPlugin diff --git a/plugins/02-PicoExcerpt.php b/plugins/02-PicoExcerpt.php index 7d0c449..00cae14 100644 --- a/plugins/02-PicoExcerpt.php +++ b/plugins/02-PicoExcerpt.php @@ -15,7 +15,7 @@ * * @author Daniel Rudolf * @link http://picocms.org - * @license http://opensource.org/licenses/MIT + * @license http://opensource.org/licenses/MIT The MIT License * @version 1.0 */ class PicoExcerpt extends AbstractPicoPlugin diff --git a/plugins/DummyPlugin.php b/plugins/DummyPlugin.php index fbdeb06..667de54 100644 --- a/plugins/DummyPlugin.php +++ b/plugins/DummyPlugin.php @@ -8,7 +8,7 @@ * * @author Daniel Rudolf * @link http://picocms.org - * @license http://opensource.org/licenses/MIT + * @license http://opensource.org/licenses/MIT The MIT License * @version 1.0 */ final class DummyPlugin extends AbstractPicoPlugin