Merge 70dbccc911
into df4d37bf13
This commit is contained in:
commit
76554a3133
4 changed files with 20 additions and 13 deletions
|
@ -1,6 +1,8 @@
|
|||
/*
|
||||
Title: Welcome
|
||||
Description: This description will go in the meta description tag
|
||||
Robots: noindex,nofollow
|
||||
Theme: default
|
||||
*/
|
||||
|
||||
Welcome to Pico
|
||||
|
@ -12,9 +14,9 @@ Creating Content
|
|||
----------------
|
||||
|
||||
Pico is a flat file CMS, this means there is no administration backend and database to deal with. You simply create `.txt` files in the "content"
|
||||
folder and that becomes a page. For example this file is called `index.txt` and is shown as the main landing page.
|
||||
folder and that becomes a page. For example this file is called `index.txt` and is shown as the main landing page.
|
||||
|
||||
If you created folder within the content folder (e.g. `content/sub`) and put an `index.txt` inside it, you can access that folder at the URL
|
||||
If you created folder within the content folder (e.g. `content/sub`) and put an `index.txt` inside it, you can access that folder at the URL
|
||||
`http://yousite.com/sub`. If you want another page within the sub folder, simply create a text file with the corresponding name (e.g. `content/sub/page.txt`)
|
||||
and will be able to access it from the URL `http://yousite.com/sub/page`. Below we've shown some examples of content locations and their corresponing URL's:
|
||||
|
||||
|
@ -44,6 +46,7 @@ At the top of text files you can place a block comment and specify certain attri
|
|||
Title: Welcome
|
||||
Description: This description will go in the meta description tag
|
||||
Robots: noindex,nofollow
|
||||
Theme: default
|
||||
*/
|
||||
|
||||
These values will be contained in the `{{ meta }}` variable in themes (see below).
|
||||
|
@ -56,7 +59,7 @@ Themes
|
|||
------
|
||||
|
||||
You can create themes for your Pico installation and in the "themes" folder. Check out the default theme for an example of a theme. Pico uses
|
||||
[Twig](http://twig.sensiolabs.org/documentation) for it's templating engine. You can select your theme by setting the `$config['theme']` variable
|
||||
[Twig](http://twig.sensiolabs.org/documentation) for it's templating engine. You can select your theme by changing the meta `Theme:`-tag or by setting the `$config['theme']` variable
|
||||
in config.php to your theme folder.
|
||||
|
||||
All themes must include an `index.html` file to define the HTML structure of the theme. Below are the Twig variables that are available to use in your theme:
|
||||
|
@ -67,7 +70,7 @@ All themes must include an `index.html` file to define the HTML structure of the
|
|||
* `{{ theme_dir }}` - The path to the Pico active theme direcotry
|
||||
* `{{ theme_url }}` - The URL to the Pico active theme direcotry
|
||||
* `{{ site_title }}` - Shortcut to the site title (defined in config.php)
|
||||
* `{{ meta }}` - Contains the meta values from the current page (e.g. `{{ meta.title }}`, `{{ meta.description }}`, `{{ meta.robots }}`)
|
||||
* `{{ meta }}` - Contains the meta values from the current page (e.g. `{{ meta.title }}`, `{{ meta.description }}`, `{{ meta.robots }}`, `{{meta.theme}}`)
|
||||
* `{{ content }}` - The content of the current page (after it has been processed through Markdown)
|
||||
|
||||
Config
|
||||
|
|
17
lib/pico.php
17
lib/pico.php
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php
|
||||
|
||||
class Pico {
|
||||
|
||||
|
@ -8,7 +8,7 @@ class Pico {
|
|||
$url = '';
|
||||
$request_url = (isset($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : '';
|
||||
$script_url = (isset($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : '';
|
||||
|
||||
|
||||
// Get our url path and trim the / of the left and the right
|
||||
if($request_url != $script_url) $url = trim(preg_replace('/'. str_replace('/', '\/', str_replace('index.php', '', $script_url)) .'/', '', $request_url, 1), '/');
|
||||
|
||||
|
@ -31,17 +31,18 @@ class Pico {
|
|||
$settings = $this->get_config();
|
||||
$env = array('autoescape' => false);
|
||||
if($settings['enable_cache']) $env['cache'] = CACHE_DIR;
|
||||
|
||||
|
||||
// Load the theme
|
||||
$theme = $meta['theme'] ? $meta['theme'] : $settings['theme'];
|
||||
Twig_Autoloader::register();
|
||||
$loader = new Twig_Loader_Filesystem(THEMES_DIR . $settings['theme']);
|
||||
$loader = new Twig_Loader_Filesystem(THEMES_DIR . $theme);
|
||||
$twig = new Twig_Environment($loader, $env);
|
||||
echo $twig->render('index.html', array(
|
||||
'config' => $settings,
|
||||
'base_dir' => rtrim(ROOT_DIR, '/'),
|
||||
'base_url' => $settings['base_url'],
|
||||
'theme_dir' => THEMES_DIR . $settings['theme'],
|
||||
'theme_url' => $settings['base_url'] .'/'. basename(THEMES_DIR) .'/'. $settings['theme'],
|
||||
'theme_dir' => THEMES_DIR . $theme,
|
||||
'theme_url' => $settings['base_url'] .'/'. basename(THEMES_DIR) .'/'. $theme,
|
||||
'site_title' => $settings['site_title'],
|
||||
'meta' => $meta,
|
||||
'content' => $content
|
||||
|
@ -58,10 +59,12 @@ class Pico {
|
|||
|
||||
function read_file_meta($content)
|
||||
{
|
||||
global $headers;
|
||||
$headers = array(
|
||||
'title' => 'Title',
|
||||
'description' => 'Description',
|
||||
'robots' => 'Robots'
|
||||
'robots' => 'Robots',
|
||||
'theme' => 'Theme'
|
||||
);
|
||||
|
||||
foreach ($headers as $field => $regex){
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Copyright (c) 2012 Dev7studios Ltd
|
||||
Further modifications by Yannick Albert
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
<html lang="en" class="no-js">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
|
||||
|
||||
<title>{% if meta.title %}{{ meta.title }} | {% endif %}{{ site_title }}</title>
|
||||
{% if meta.description %}<meta name="description" content="{{ meta.description }}">{% endif %}
|
||||
{% if meta.robots %}<meta name="robots" content="{{ meta.robots }}">{% endif %}
|
||||
|
||||
|
||||
<link rel="stylesheet" href="{{ theme_url }}/style.css" type="text/css" media="screen" />
|
||||
|
||||
<!--[if IE]>
|
||||
|
|
Loading…
Add table
Reference in a new issue