Give pages starting with a underscore (_) a special treatment
Follow-up to b493ebdb84e0da20e73ee21992ff36868be0008f
This commit is contained in:
parent
9a2dd4f078
commit
9b72b5c316
12
content-sample/_meta.md
Normal file
12
content-sample/_meta.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
social:
|
||||||
|
- title: Visit us on GitHub
|
||||||
|
url: https://github.com/picocms/Pico
|
||||||
|
icon: octocat
|
||||||
|
- title: Check us out on Twitter
|
||||||
|
url: https://twitter.com/gitpicocms
|
||||||
|
icon: birdy
|
||||||
|
- title: Join us on Freenode IRC Webchat
|
||||||
|
url: https://webchat.freenode.net/?channels=%23picocms
|
||||||
|
icon: chat
|
||||||
|
---
|
@ -1,16 +1,6 @@
|
|||||||
---
|
---
|
||||||
Title: Welcome
|
Title: Welcome
|
||||||
Description: Pico is a stupidly simple, blazing fast, flat file CMS.
|
Description: Pico is a stupidly simple, blazing fast, flat file CMS.
|
||||||
social:
|
|
||||||
- title: Visit us on GitHub
|
|
||||||
url: https://github.com/picocms/Pico
|
|
||||||
icon: octocat
|
|
||||||
- title: Check us out on Twitter
|
|
||||||
url: https://twitter.com/gitpicocms
|
|
||||||
icon: birdy
|
|
||||||
- title: Join us on Freenode IRC Webchat
|
|
||||||
url: https://webchat.freenode.net/?channels=%23picocms
|
|
||||||
icon: chat
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Welcome to Pico
|
## Welcome to Pico
|
||||||
|
20
lib/Pico.php
20
lib/Pico.php
@ -344,8 +344,11 @@ class Pico
|
|||||||
// load raw file content
|
// load raw file content
|
||||||
$this->triggerEvent('onContentLoading', array(&$this->requestFile));
|
$this->triggerEvent('onContentLoading', array(&$this->requestFile));
|
||||||
|
|
||||||
$notFoundFile = '404' . $this->getConfig('content_ext');
|
if (
|
||||||
if (file_exists($this->requestFile) && (basename($this->requestFile) !== $notFoundFile)) {
|
file_exists($this->requestFile)
|
||||||
|
&& (basename($this->requestFile) !== '404' . $this->getConfig('content_ext'))
|
||||||
|
&& !preg_match('/(?:^|\/)_/', $this->requestFile)
|
||||||
|
) {
|
||||||
$this->rawContent = $this->loadFileContent($this->requestFile);
|
$this->rawContent = $this->loadFileContent($this->requestFile);
|
||||||
} else {
|
} else {
|
||||||
$this->triggerEvent('on404ContentLoading', array(&$this->requestFile));
|
$this->triggerEvent('on404ContentLoading', array(&$this->requestFile));
|
||||||
@ -1294,6 +1297,7 @@ class Pico
|
|||||||
'time' => &$meta['time'],
|
'time' => &$meta['time'],
|
||||||
'date' => &$meta['date'],
|
'date' => &$meta['date'],
|
||||||
'date_formatted' => &$meta['date_formatted'],
|
'date_formatted' => &$meta['date_formatted'],
|
||||||
|
'hidden' => (bool) preg_match('/(?:^|\/)_/', $id),
|
||||||
'raw_content' => &$rawContent,
|
'raw_content' => &$rawContent,
|
||||||
'meta' => &$meta
|
'meta' => &$meta
|
||||||
);
|
);
|
||||||
@ -1331,6 +1335,10 @@ class Pico
|
|||||||
}
|
}
|
||||||
|
|
||||||
$alphaSortClosure = function ($a, $b) use ($order) {
|
$alphaSortClosure = function ($a, $b) use ($order) {
|
||||||
|
if ($a['hidden'] xor $b['hidden']) {
|
||||||
|
return (!!$a['hidden'] - !!$b['hidden']) * (($order === 'desc') ? -1 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
$aSortKey = (basename($a['id']) === 'index') ? dirname($a['id']) : $a['id'];
|
$aSortKey = (basename($a['id']) === 'index') ? dirname($a['id']) : $a['id'];
|
||||||
$bSortKey = (basename($b['id']) === 'index') ? dirname($b['id']) : $b['id'];
|
$bSortKey = (basename($b['id']) === 'index') ? dirname($b['id']) : $b['id'];
|
||||||
|
|
||||||
@ -1341,8 +1349,12 @@ class Pico
|
|||||||
if ($orderBy === 'date') {
|
if ($orderBy === 'date') {
|
||||||
// sort by date
|
// sort by date
|
||||||
uasort($this->pages, function ($a, $b) use ($alphaSortClosure, $order) {
|
uasort($this->pages, function ($a, $b) use ($alphaSortClosure, $order) {
|
||||||
if (empty($a['time']) || empty($b['time'])) {
|
if ($a['hidden'] xor $b['hidden']) {
|
||||||
$cmp = (empty($a['time']) - empty($b['time']));
|
return $alphaSortClosure($a, $b);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$a['time'] || !$b['time']) {
|
||||||
|
$cmp = (!$a['time'] - !$b['time']);
|
||||||
} else {
|
} else {
|
||||||
$cmp = ($b['time'] - $a['time']);
|
$cmp = ($b['time'] - $a['time']);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
</h1>
|
</h1>
|
||||||
<div id="nav" role="region" tabindex="-1">
|
<div id="nav" role="region" tabindex="-1">
|
||||||
<ul>
|
<ul>
|
||||||
{% for page in pages if page.title and not (page.id starts with "_") %}
|
{% for page in pages if page.title and not page.hidden %}
|
||||||
{% set pageDepth = page.id|split('/')|length %}
|
{% set pageDepth = page.id|split('/')|length %}
|
||||||
{% if (pageDepth == 2) and (page.id ends with "/index") or (pageDepth == 1) %}
|
{% if (pageDepth == 2) and (page.id ends with "/index") or (pageDepth == 1) %}
|
||||||
<li{% if page.id == current_page.id %} class="active"{% endif %}>
|
<li{% if page.id == current_page.id %} class="active"{% endif %}>
|
||||||
@ -50,7 +50,7 @@
|
|||||||
<div id="footer">
|
<div id="footer">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="social">
|
<div class="social">
|
||||||
{% for social in meta.social %}
|
{% for social in pages._meta.meta.social %}
|
||||||
<a href="{{ social.url }}" title="{{ social.title }}" role="button">
|
<a href="{{ social.url }}" title="{{ social.title }}" role="button">
|
||||||
<span class="icon-{{ social.icon }}" aria-hidden="true"></span>
|
<span class="icon-{{ social.icon }}" aria-hidden="true"></span>
|
||||||
<span class="sr-only">{{ social.title }}</span>
|
<span class="sr-only">{{ social.title }}</span>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user