Forráskód Böngészése

Merge branch 'master' into pico-1.1

Conflicts:
	.htaccess
Daniel Rudolf 9 éve
szülő
commit
0e8cd0873d

+ 19 - 1
CHANGELOG.md

@@ -1,11 +1,29 @@
 Pico Changelog
 ==============
 
-### Version 1.0.2
+### Version 1.0.3
 Released: -
 
 ```
+* [Changed] Improve documentation
+* [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] 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
+* [Fixed] #344: Improve HTTPS detection with proxies
+* [Fixed] #346: Force HTTPS to load Google Fonts in default theme
+```
+
+### Version 1.0.2
+Released: 2016-03-16
+
+```
+* [Changed] Various small improvements and changes...
 * [Fixed] Check dependencies when a plugin is enabled by default
+* [Fixed] Allow `Pico::$requestFile` to point to somewhere outside `content_dir`
+* [Fixed] #336: Fix `Date` meta header parsing with ISO-8601 datetime strings
 ```
 
 ### Version 1.0.1

+ 22 - 3
_build/deploy-phpdoc-release.sh

@@ -6,8 +6,11 @@ fi
 if [ "$DEPLOY_VERSION_BADGE" != "true" ]; then
     echo "Skipping version badge deployment because it has been disabled"
 fi
-if [ "$DEPLOY_PHPDOC_RELEASES" != "true" ] || [ "$DEPLOY_VERSION_BADGE" != "true" ]; then
-    [ "$DEPLOY_PHPDOC_RELEASES" != "true" ] && [ "$DEPLOY_VERSION_BADGE" != "true" ] && exit 0 || echo
+if [ "$DEPLOY_VERSION_FILE" != "true" ]; then
+    echo "Skipping version file deployment because it has been disabled"
+fi
+if [ "$DEPLOY_PHPDOC_RELEASES" != "true" ] || [ "$DEPLOY_VERSION_BADGE" != "true" ] || [ "$DEPLOY_VERSION_FILE" != "true" ]; then
+    [ "$DEPLOY_PHPDOC_RELEASES" != "true" ] && [ "$DEPLOY_VERSION_BADGE" != "true" ] && [ "$DEPLOY_VERSION_FILE" != "true" ] && exit 0 || echo
 fi
 
 DEPLOYMENT_ID="${TRAVIS_BRANCH//\//_}"
@@ -51,7 +54,7 @@ if [ "$DEPLOY_VERSION_BADGE" == "true" ]; then
         "release" "$TRAVIS_TAG" "blue"
 
     # commit version badge
-    echo "Committing changes..."
+    echo "Committing version badge..."
     git add "$DEPLOYMENT_DIR/badges/pico-version.svg"
     git commit \
         --message="Update version badge for $TRAVIS_TAG" \
@@ -60,6 +63,22 @@ if [ "$DEPLOY_VERSION_BADGE" == "true" ]; then
     echo
 fi
 
+# update version file
+if [ "$DEPLOY_VERSION_FILE" == "true" ]; then
+    generate-version.sh \
+        "$DEPLOYMENT_DIR/_data/version.yml" \
+        "${TRAVIS_TAG#v}"
+
+    # commit version file
+    echo "Committing version file..."
+    git add "$DEPLOYMENT_DIR/_data/version.yml"
+    git commit \
+        --message="Update version file for $TRAVIS_TAG" \
+        "$DEPLOYMENT_DIR/_data/version.yml"
+    [ $? -eq 0 ] || exit 1
+    echo
+fi
+
 # deploy
 github-deploy.sh "$TRAVIS_REPO_SLUG" "tags/$TRAVIS_TAG" "$TRAVIS_COMMIT"
 [ $? -eq 0 ] || exit 1

+ 57 - 0
_build/generate-version.sh

@@ -0,0 +1,57 @@
+#!/usr/bin/env bash
+
+##
+# Updates the version file
+#
+# @author  Daniel Rudolf
+# @link    http://picocms.org
+# @license http://opensource.org/licenses/MIT
+#
+
+set -e
+
+# parameters
+VERSION_FILE_PATH="$1"  # target file path
+VERSION_FULL="$2"       # full version string (e.g. 1.0.0-beta.1+7b4ad7f)
+
+# print parameters
+echo "Generating version file..."
+printf 'VERSION_FILE_PATH="%s"\n' "$VERSION_FILE_PATH"
+printf 'VERSION_FULL="%s"\n' "$VERSION_FULL"
+echo
+
+# evaluate version constraint (see http://semver.org/)
+printf 'Evaluating version constraint...\n'
+if [[ "$VERSION_FULL" =~ ^([0-9]+)\.([0-9]{1,2})\.([0-9]{1,2})(-([0-9A-Za-z\.\-]+))?(\+([0-9A-Za-z\.\-]+))?$ ]]; then
+    VERSION_MAJOR="${BASH_REMATCH[1]}"
+    VERSION_MINOR="${BASH_REMATCH[2]}"
+    VERSION_PATCH="${BASH_REMATCH[3]}"
+    VERSION_SUFFIX="${BASH_REMATCH[5]}"
+    VERSION_BUILD="${BASH_REMATCH[7]}"
+
+    VERSION_MILESTONE="$VERSION_MAJOR.$VERSION_MINOR"
+    VERSION_NAME="$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH"
+    VERSION_ID="$VERSION_MAJOR$(printf '%02d' "$VERSION_MINOR")$(printf '%02d' "$VERSION_PATCH")"
+else
+    echo "Invalid version constraint; skipping..." >&2
+    exit 1
+fi
+
+# generate version file
+printf 'Updating version file...\n'
+echo -n "" > "$VERSION_FILE_PATH"
+exec 3> "$VERSION_FILE_PATH"
+
+printf 'full: %s\n' "$VERSION_FULL" >&3
+printf 'name: %s\n' "$VERSION_NAME" >&3
+printf 'milestone: %s\n' "$VERSION_MILESTONE" >&3
+printf 'id: %d\n' "$VERSION_ID" >&3
+printf 'major: %d\n' "$VERSION_MAJOR" >&3
+printf 'minor: %d\n' "$VERSION_MINOR" >&3
+printf 'patch: %d\n' "$VERSION_PATCH" >&3
+printf 'suffix: %s\n' "$VERSION_SUFFIX" >&3
+printf 'build: %s\n' "$VERSION_BUILD" >&3
+
+exec 3>&-
+
+echo

+ 6 - 6
content-sample/index.md

@@ -135,10 +135,10 @@ something like the following:
         {% endif %}
     {% endfor %}
    ```
-4. Make sure to exclude the blog articles from your page navigation. You can
-   achieve this by adding `{% if not page starts with "blog/" %}...{% endif %}`
+4. Make sure to exclude blog articles from your page navigation. You can achieve
+   this by adding `{% if not (page.id starts with "blog/") %}...{% endif %}`
    to the navigation loop (`{% for page in pages %}...{% endfor %}`) in your
-   themes `index.twig`.
+   theme's `index.twig`.
 
 ## Customization
 
@@ -284,13 +284,13 @@ 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 `4`)
+URL rewriting. Don't forget to adjust the path (`/pico`; line `1` and `4`)
 to match your installation directory. You can then enable URL rewriting by
 setting `$config['rewrite_url'] = true;` in your `config/config.php`.
 
-    location /pico/ {
+    location ~ ^/pico(.*) {
         index index.php;
-        try_files $uri $uri/ /pico/?$uri&$args;
+        try_files $uri $uri/ /pico/?$1&$args;
     }
 
 ## Documentation

+ 19 - 7
lib/Pico.php

@@ -312,7 +312,8 @@ class Pico
         // load raw file content
         $this->triggerEvent('onContentLoading', array(&$this->requestFile));
 
-        if (file_exists($this->requestFile)) {
+        $notFoundFile = '404' . $this->getConfig('content_ext');
+        if (file_exists($this->requestFile) && (basename($this->requestFile) !== $notFoundFile)) {
             $this->rawContent = $this->loadFileContent($this->requestFile);
         } else {
             $this->triggerEvent('on404ContentLoading', array(&$this->requestFile));
@@ -925,7 +926,17 @@ class Pico
             }
 
             if (!empty($meta['date'])) {
-                $meta['time'] = strtotime($meta['date']);
+                // workaround for issue #336
+                // Symfony YAML interprets ISO-8601 datetime strings and returns timestamps instead of the string
+                // this behavior conforms to the YAML standard, i.e. this is no bug of Symfony YAML
+                if (is_int($meta['date'])) {
+                    $meta['time'] = $meta['date'];
+
+                    $rawDateFormat = (date('H:i:s', $meta['time']) === '00:00:00') ? 'Y-m-d' : 'Y-m-d H:i:s';
+                    $meta['date'] = date($rawDateFormat, $meta['time']);
+                } else {
+                    $meta['time'] = strtotime($meta['date']);
+                }
                 $meta['date_formatted'] = utf8_encode(strftime($this->getConfig('date_format'), $meta['time']));
             } else {
                 $meta['time'] = $meta['date_formatted'] = '';
@@ -1283,8 +1294,8 @@ class Pico
     /**
      * Registers the twig template engine
      *
-     * This method also registers Picos core Twig filters `link` and `content`
-     * as well as Picos {@link PicoTwigExtension} Twig extension.
+     * This method also registers Pico's core Twig filters `link` and `content`
+     * as well as Pico's {@link PicoTwigExtension} Twig extension.
      *
      * @see    Pico::getTwig()
      * @return void
@@ -1371,12 +1382,13 @@ class Pico
         }
 
         $protocol = 'http';
-        if (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] !== 'off')) {
+        if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
+            $secureProxyHeader = strtolower(current(explode(',', $_SERVER['HTTP_X_FORWARDED_PROTO'])));
+            $protocol = in_array($secureProxyHeader, array('https', 'on', 'ssl', '1')) ? 'https' : 'http';
+        } elseif (!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';
         }
 
         $this->config['base_url'] =

+ 2 - 2
lib/PicoTwigExtension.php

@@ -1,7 +1,7 @@
 <?php
 
 /**
- * Picos Twig extension to implement additional filters
+ * Pico's Twig extension to implement additional filters
  *
  * @author  Daniel Rudolf
  * @link    http://picocms.org
@@ -54,7 +54,7 @@ class PicoTwigExtension extends Twig_Extension
      * Returns the Twig filters markdown, map and sort_by
      *
      * @see    Twig_ExtensionInterface::getFilters()
-     * @return Twig_SimpleFilter[] array of Picos Twig filters
+     * @return Twig_SimpleFilter[] array of Pico's Twig filters
      */
     public function getFilters()
     {

+ 1 - 1
themes/default/index.twig

@@ -10,7 +10,7 @@
         <meta name="robots" content="{{ meta.robots }}">
     {% endif %}
 
-    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400,700" type="text/css" />
+    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:400,700" type="text/css" />
     <link rel="stylesheet" href="{{ theme_url }}/style.css" type="text/css" />
 
     <script src="{{ theme_url }}/scripts/modernizr-2.6.1.min.js"></script>

+ 8 - 5
themes/default/style.css

@@ -137,13 +137,12 @@ h3 {
     margin-top: 2em;
 }
 
-p, table {
+p, table, ol, ul, pre, blockquote, dl {
     margin-bottom: 1em;
 }
 
 ol, ul {
     padding-left: 30px;
-    margin-bottom: 1em;
 }
 
 b, strong {
@@ -198,17 +197,20 @@ code {
 pre {
     background: #eee;
     padding: 20px;
-    margin-bottom: 1em;
     overflow: auto;
 }
 
 blockquote {
     font-style: italic;
-    margin: 0 0 1em 15px;
+    margin-left: 15px;
     padding-left: 10px;
     border-left: 5px solid #dddddd;
 }
 
+dd {
+    margin-left: 2em;
+}
+
 /* Structure Styles
 /*---------------------------------------------*/
 body {
@@ -223,7 +225,8 @@ body > * {
 }
 
 .inner {
-    width: 850px;
+    width: 100%;
+    max-width: 850px;
     margin: 0 auto;
 }