瀏覽代碼

Merge bcb3f7062653516f26a466c83cca5c8616657e25 into aa59661ff81dd52c3a2596988372a214b0fc31b9

Frank Nägler 11 年之前
父節點
當前提交
d7458ecad5
共有 6 個文件被更改,包括 108 次插入2 次删除
  1. 3 0
      .gitignore
  2. 11 1
      content/404.md
  3. 11 0
      content/index.md
  4. 20 1
      lib/pico.php
  5. 50 0
      themes/default/content-sidebar.html
  6. 13 0
      themes/default/style.css

+ 3 - 0
.gitignore

@@ -14,6 +14,9 @@ Icon?
 Thumbs.db
 *.swp
 
+# PHPStorm settings
+.idea
+
 # User themes
 themes/*
 !themes/index.html

+ 11 - 1
content/404.md

@@ -1,9 +1,19 @@
 /*
 Title: Error 404
 Robots: noindex,nofollow
+Template: content-sidebar
 */
 
+
+{column:content}
+
 Error 404
 =========
 
-Woops. Looks like this page doesn't exist.
+Woops. Looks like this page doesn't exist.
+
+{/column:content}
+
+{column:sidebar}
+<div class="big">404</div>
+{/column:sidebar}

+ 11 - 0
content/index.md

@@ -3,6 +3,7 @@ Title: Welcome
 Description: This description will go in the meta description tag
 */
 
+
 ## Welcome to Pico
 
 Congratulations, you have successfully installed [Pico](http://pico.dev7studios.com). Pico is a stupidly simple, blazing fast, flat file CMS.
@@ -73,6 +74,7 @@ All themes must include an `index.html` file to define the HTML structure of the
 	* `{{ meta.date_formatted }}`
 	* `{{ meta.robots }}`
 * `{{ content }}` - The content of the current page (after it has been processed through Markdown)
+* `{{ column_<name> }}` - The column name of the content of the current page (after it has been processed through Markdown) [more information](#columns)
 * `{{ pages }}` - A collection of all the content in your site
 	* `{{ page.title }}`
 	* `{{ page.url }}`
@@ -94,6 +96,15 @@ Pages can be used like:
 	{% endfor %}
 &lt;/ul&gt;</pre>
 
+### <a name="columns"></a> Columns
+
+You can use multiple columns within the templates. A good example is the 404 error page. The basic logic is very simple. In the template you can use twig variables like `{{ column_content }}`.
+To define which content should be displayed in which column, you have to wrap the content (in the *.md files) with markers like this:
+
+<pre>{column:content}
+  my content for column content
+{/column:content}</pre>
+
 ### Plugins
 
 See [http://pico.dev7studios.com/plugins](http://pico.dev7studios.com/plugins)

+ 20 - 1
lib/pico.php

@@ -11,6 +11,7 @@ use \Michelf\MarkdownExtra;
  */
 class Pico {
 
+	protected $columns = array();
 	private $plugins;
 
 	/**
@@ -59,6 +60,10 @@ class Pico {
 		$meta = $this->read_file_meta($content);
 		$this->run_hooks('file_meta', array(&$meta));
 
+		$this->run_hooks('before_parse_columns', array(&$content, $this->columns));
+		$this->parse_columns($content);
+		$this->run_hooks('after_parse_columns', array(&$content, $this->columns));
+
 		$this->run_hooks('before_parse_content', array(&$content));
 		$content = $this->parse_content($content);
 		$this->run_hooks('after_parse_content', array(&$content));
@@ -101,7 +106,9 @@ class Pico {
 			'next_page' => $next_page,
 			'is_front_page' => $url ? false : true,
 		);
-
+		foreach ($this->columns as $var => $code) {
+			$twig_vars["column_{$var}"] = $code;
+		}
 		$template = (isset($meta['template']) && $meta['template']) ? $meta['template'] : 'index';
 		$this->run_hooks('before_render', array(&$twig_vars, &$twig, &$template));
 		$output = $twig->render($template .'.html', $twig_vars);
@@ -128,6 +135,18 @@ class Pico {
 		}
 	}
 
+	protected function parse_columns($content) {
+		// pattern to find {column:xyz} {/column:xyz} column marker
+		$pattern = '#({column:(.*?)})(.+?)({/column:\\2})#ims';
+		preg_match_all($pattern, $content, $matches);
+
+		$counter = 0;
+		foreach ($matches[2] as $var) {
+			$this->columns[$var] = MarkdownExtra::defaultTransform($matches[3][$counter]);
+			$counter++;
+		}
+	}
+
 	/**
 	 * Parses the content using Markdown
 	 *

+ 50 - 0
themes/default/content-sidebar.html

@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<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="http://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>
+</head>
+<body>
+
+	<header id="header">
+		<div class="inner clearfix">
+			<h1><a href="{{ base_url }}">{{ site_title }}</a></h1>
+			<ul class="nav">
+				{% for page in pages %}
+				<li><a href="{{ page.url }}">{{ page.title }}</a></li>
+				{% endfor %}
+			</ul>
+		</div>
+	</header>
+
+	<section id="content">
+		<div class="inner clearfix">
+            <div class="col_sidebar">
+                {{ column_sidebar }}
+            </div>
+            <div class="col_content">
+                {{ column_content }}
+            </div>
+		</div>
+	</section>
+	
+	<footer id="footer">
+		<div class="inner">
+			<a href="http://pico.dev7studios.com">Pico</a> was made by <a href="http://gilbert.pellegrom.me">Gilbert Pellegrom</a> 
+			from <a href="http://dev7studios.com">Dev7studios</a>.
+		</div>
+	</footer>
+    
+</body>
+</html>

+ 13 - 0
themes/default/style.css

@@ -240,6 +240,19 @@ blockquote {
 #footer a { color: #ddd; }
 #footer a:hover { color: #fff; }
 
+.col_sidebar {
+    float: left;
+    width: 200px;
+    background: #C0C0C0;
+    margin: 0 10px 10px 0;
+}
+.col_sidebar .big {
+    font-size: 121px;
+    color: #fff;
+    font-weight: bold;
+    margin-left: -3px;
+    line-height: 79px;
+}
 /* Misc Styles
 /*---------------------------------------------*/
 .clearfix:before,