Skip to content

Commit

Permalink
v0.7
Browse files Browse the repository at this point in the history
 * [New] Added before_read_file_meta and get_page_data plugin hooks to
customize page meta data
 * [Changed] Make get_files() ignore dotfiles
 * [Changed] Make get_pages() ignore Emacs and temp files
 * [Changed] Use composer version of Markdown
 * [Changed] Other small tweaks
 * [Fixed] Date warnings and other small bugs
  • Loading branch information
gilbitron committed Sep 4, 2013
1 parent 69d67b2 commit 45cd4ca
Show file tree
Hide file tree
Showing 19 changed files with 3,637 additions and 45 deletions.
20 changes: 19 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Composer
composer.lock
composer.phar

# Twig
vendor/twig/twig/doc/*
vendor/twig/twig/ext/*
vendor/twig/twig/test/*
vendor/twig/twig/test/*

# OS Generated
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
*.swp

# User themes
themes/*
!themes/index.html
!themes/default/*

# User config
config.php
8 changes: 8 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
*** Pico Changelog ***

2013.09.04 - version 0.7
* [New] Added before_read_file_meta and get_page_data plugin hooks to customize page meta data
* [Changed] Make get_files() ignore dotfiles
* [Changed] Make get_pages() ignore Emacs and temp files
* [Changed] Use composer version of Markdown
* [Changed] Other small tweaks
* [Fixed] Date warnings and other small bugs

2013.05.07 - version 0.6.2
* [Changed] Replaced glob_recursive with get_files

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": {
"twig/twig": "1.12.*",
"michelf/php-markdown": "1.3"
"michelf/php-markdown": "1.3"
}
}
4 changes: 1 addition & 3 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@
$config['custom_setting'] = 'Hello'; // Can be accessed by {{ config.custom_setting }} in a theme
*/

?>
*/
8 changes: 8 additions & 0 deletions content/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,15 @@ Pages can be used like:
{% endfor %}
&lt;/ul&gt;</pre>

### Plugins

See [http://pico.dev7studios.com/plugins](http://pico.dev7studios.com/plugins)

### Config

You can override the default Pico settings (and add your own custom settings) by editing config.php in the root Pico directory. The config.php file
lists all of the settings and their defaults. To override a setting, simply uncomment it in config.php and set your custom value.

### Documentation

For more help have a look at the Pico documentation at [http://pico.dev7studios.com/docs](http://pico.dev7studios.com/docs)
23 changes: 10 additions & 13 deletions lib/pico.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php
use \Michelf\MarkdownExtra;

/**
* Pico
*
* @author Gilbert Pellegrom
* @link http://pico.dev7studios.com
* @license http://opensource.org/licenses/MIT
* @version 0.6.2
* @version 0.7
*/
class Pico {

Expand Down Expand Up @@ -66,7 +67,7 @@ public function __construct()
$current_page = array();
$next_page = array();
while($current_page = current($pages)){
if($meta['title'] == $current_page['title']){
if((isset($meta['title'])) && ($meta['title'] == $current_page['title'])){
break;
}
next($pages);
Expand Down Expand Up @@ -166,7 +167,7 @@ private function read_file_meta($content)
}
}

if($headers['date']) $headers['date_formatted'] = date($config['date_format'], strtotime($headers['date']));
if(isset($headers['date'])) $headers['date_formatted'] = date($config['date_format'], strtotime($headers['date']));

return $headers;
}
Expand All @@ -178,10 +179,8 @@ private function read_file_meta($content)
*/
private function get_config()
{
if(!file_exists(ROOT_DIR .'config.php')) return array();

global $config;
require_once(ROOT_DIR .'config.php');
@include_once(ROOT_DIR .'config.php');

$defaults = array(
'site_title' => 'Pico',
Expand Down Expand Up @@ -235,19 +234,19 @@ private function get_pages($base_url, $order_by = 'alpha', $order = 'asc', $exce
$url = str_replace('index'. CONTENT_EXT, '', $url);
$url = str_replace(CONTENT_EXT, '', $url);
$data = array(
'title' => $page_meta['title'],
'title' => isset($page_meta['title']) ? $page_meta['title'] : '',
'url' => $url,
'author' => $page_meta['author'],
'date' => $page_meta['date'],
'date_formatted' => date($config['date_format'], strtotime($page_meta['date'])),
'author' => isset($page_meta['author']) ? $page_meta['author'] : '',
'date' => isset($page_meta['date']) ? $page_meta['date'] : '',
'date_formatted' => isset($page_meta['date']) ? date($config['date_format'], strtotime($page_meta['date'])) : '',
'content' => $page_content,
'excerpt' => $this->limit_words(strip_tags($page_content), $excerpt_length)
);

// Extend the data provided with each page by hooking into the data array
$this->run_hooks('get_page_data', array(&$data, $page_meta));

if($order_by == 'date'){
if($order_by == 'date' && isset($page_meta['date'])){
$sorted_pages[$page_meta['date'].$date_id] = $data;
$date_id++;
}
Expand Down Expand Up @@ -347,5 +346,3 @@ private function limit_words($string, $word_limit)
}

}

?>
10 changes: 10 additions & 0 deletions plugins/pico_plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public function config_loaded(&$settings)

}

public function before_read_file_meta(&$headers)
{

}

public function file_meta(&$meta)
{

Expand All @@ -54,6 +59,11 @@ public function content_parsed(&$content)

}

public function get_page_data(&$data, $page_meta)
{

}

public function get_pages(&$pages, &$current_page, &$prev_page, &$next_page)
{

Expand Down
4 changes: 2 additions & 2 deletions vendor/autoload.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

// autoload.php generated by Composer
// autoload.php @generated by Composer

require_once __DIR__ . '/composer' . '/autoload_real.php';

return ComposerAutoloaderInit5115ee54a7a3f173d564b433db6d791a::getLoader();
return ComposerAutoloaderInit68d29614b81b64051229769b084d96b6::getLoader();
40 changes: 23 additions & 17 deletions vendor/composer/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ClassLoader

public function getPrefixes()
{
return $this->prefixes;
return call_user_func_array('array_merge', $this->prefixes);
}

public function getFallbackDirs()
Expand Down Expand Up @@ -98,19 +98,21 @@ public function add($prefix, $paths, $prepend = false)

return;
}
if (!isset($this->prefixes[$prefix])) {
$this->prefixes[$prefix] = (array) $paths;

$first = $prefix[0];
if (!isset($this->prefixes[$first][$prefix])) {
$this->prefixes[$first][$prefix] = (array) $paths;

return;
}
if ($prepend) {
$this->prefixes[$prefix] = array_merge(
$this->prefixes[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixes[$prefix]
$this->prefixes[$first][$prefix]
);
} else {
$this->prefixes[$prefix] = array_merge(
$this->prefixes[$prefix],
$this->prefixes[$first][$prefix] = array_merge(
$this->prefixes[$first][$prefix],
(array) $paths
);
}
Expand All @@ -119,8 +121,8 @@ public function add($prefix, $paths, $prepend = false)
/**
* Registers a set of classes, replacing any others previously set.
*
* @param string $prefix The classes prefix
* @param array|string $paths The location(s) of the classes
* @param string $prefix The classes prefix
* @param array|string $paths The location(s) of the classes
*/
public function set($prefix, $paths)
{
Expand All @@ -129,7 +131,7 @@ public function set($prefix, $paths)

return;
}
$this->prefixes[$prefix] = (array) $paths;
$this->prefixes[substr($prefix, 0, 1)][$prefix] = (array) $paths;
}

/**
Expand Down Expand Up @@ -195,6 +197,7 @@ public function loadClass($class)
*/
public function findFile($class)
{
// work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
if ('\\' == $class[0]) {
$class = substr($class, 1);
}
Expand All @@ -205,21 +208,24 @@ public function findFile($class)

if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)) . DIRECTORY_SEPARATOR;
$classPath = strtr(substr($class, 0, $pos), '\\', DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
$className = substr($class, $pos + 1);
} else {
// PEAR-like class name
$classPath = null;
$className = $class;
}

$classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
$classPath .= strtr($className, '_', DIRECTORY_SEPARATOR) . '.php';

foreach ($this->prefixes as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) {
return $dir . DIRECTORY_SEPARATOR . $classPath;
$first = $class[0];
if (isset($this->prefixes[$first])) {
foreach ($this->prefixes[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) {
return $dir . DIRECTORY_SEPARATOR . $classPath;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

// autoload_classmap.php generated by Composer
// autoload_classmap.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
Expand Down
5 changes: 3 additions & 2 deletions vendor/composer/autoload_namespaces.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

// autoload_namespaces.php generated by Composer
// autoload_namespaces.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
'Twig_' => $vendorDir . '/twig/twig/lib',
'Twig_' => array($vendorDir . '/twig/twig/lib'),
'Michelf' => array($vendorDir . '/michelf/php-markdown'),
);
10 changes: 5 additions & 5 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

// autoload_real.php generated by Composer
// autoload_real.php @generated by Composer

class ComposerAutoloaderInit5115ee54a7a3f173d564b433db6d791a
class ComposerAutoloaderInit68d29614b81b64051229769b084d96b6
{
private static $loader;

Expand All @@ -19,16 +19,16 @@ public static function getLoader()
return self::$loader;
}

spl_autoload_register(array('ComposerAutoloaderInit5115ee54a7a3f173d564b433db6d791a', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit68d29614b81b64051229769b084d96b6', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit5115ee54a7a3f173d564b433db6d791a', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit68d29614b81b64051229769b084d96b6', 'loadClassLoader'));

$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);

$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->add($namespace, $path);
$loader->set($namespace, $path);
}

$classMap = require __DIR__ . '/autoload_classmap.php';
Expand Down
53 changes: 53 additions & 0 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,58 @@
"keywords": [
"templating"
]
},
{
"name": "michelf/php-markdown",
"version": "1.3",
"version_normalized": "1.3.0.0",
"source": {
"type": "git",
"url": "https://github.com/michelf/php-markdown.git",
"reference": "fcdd3e0781ae40c2b9847874e0755ff4f5559688"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/michelf/php-markdown/zipball/fcdd3e0781ae40c2b9847874e0755ff4f5559688",
"reference": "fcdd3e0781ae40c2b9847874e0755ff4f5559688",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"time": "2013-04-11 18:53:11",
"type": "library",
"extra": {
"branch-alias": {
"dev-lib": "1.3.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Michelf": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Michel Fortin",
"email": "[email protected]",
"homepage": "http://michelf.ca/",
"role": "Developer"
},
{
"name": "John Gruber",
"homepage": "http://daringfireball.net/"
}
],
"description": "PHP Markdown",
"homepage": "http://michelf.ca/projects/php-markdown/",
"keywords": [
"markdown"
]
}
]
Loading

0 comments on commit 45cd4ca

Please sign in to comment.