Sfoglia il codice sorgente

Merge 4b519a7cf341c39075aceb7b9369c907e89ba3e9 into 6acc979655db80e947c84a5ea4dd42ea594d269b

Frank Nägler 11 anni fa
parent
commit
23abe7954f
4 ha cambiato i file con 43 aggiunte e 9 eliminazioni
  1. 1 0
      .gitignore
  2. 11 2
      content/index.md
  3. 20 5
      lib/pico.php
  4. 11 2
      themes/default/index.html

+ 1 - 0
.gitignore

@@ -17,6 +17,7 @@ Thumbs.db
 # User themes
 # User themes
 themes/*
 themes/*
 !themes/index.html
 !themes/index.html
+!themes/default
 !themes/default/*
 !themes/default/*
 
 
 # User config
 # User config

+ 11 - 2
content/index.md

@@ -3,6 +3,9 @@ Title: Welcome
 Description: This description will go in the meta description tag
 Description: This description will go in the meta description tag
 */
 */
 
 
+
+{column:content}
+
 ## Welcome to Pico
 ## Welcome to Pico
 
 
 Congratulations, you have successfully installed [Pico](http://pico.dev7studios.com). Pico is a stupidly simple, blazing fast, flat file CMS.
 Congratulations, you have successfully installed [Pico](http://pico.dev7studios.com). Pico is a stupidly simple, blazing fast, flat file CMS.
@@ -10,9 +13,9 @@ Congratulations, you have successfully installed [Pico](http://pico.dev7studios.
 ### Creating Content
 ### Creating Content
 
 
 Pico is a flat file CMS, this means there is no administration backend and database to deal with. You simply create `.md` files in the "content"
 Pico is a flat file CMS, this means there is no administration backend and database to deal with. You simply create `.md` files in the "content"
-folder and that becomes a page. For example, this file is called `index.md` and is shown as the main landing page. 
+folder and that becomes a page. For example, this file is called `index.md` and is shown as the main landing page.
 
 
-If you create a folder within the content folder (e.g. `content/sub`) and put an `index.md` inside it, you can access that folder at the URL 
+If you create a folder within the content folder (e.g. `content/sub`) and put an `index.md` 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.md`)
 `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.md`)
 and you 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:
 and you 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:
 
 
@@ -106,3 +109,9 @@ lists all of the settings and their defaults. To override a setting, simply unco
 ### Documentation
 ### Documentation
 
 
 For more help have a look at the Pico documentation at [http://pico.dev7studios.com/docs](http://pico.dev7studios.com/docs)
 For more help have a look at the Pico documentation at [http://pico.dev7studios.com/docs](http://pico.dev7studios.com/docs)
+
+{/column:content}
+
+{column:sidebar}
+sidebar content goes here
+{/column:sidebar}

+ 20 - 5
lib/pico.php

@@ -11,6 +11,7 @@ use \Michelf\MarkdownExtra;
  */
  */
 class Pico {
 class Pico {
 
 
+	private $columns = array();
 	private $plugins;
 	private $plugins;
 
 
 	/**
 	/**
@@ -22,7 +23,11 @@ class Pico {
 		// Load plugins
 		// Load plugins
 		$this->load_plugins();
 		$this->load_plugins();
 		$this->run_hooks('plugins_loaded');
 		$this->run_hooks('plugins_loaded');
-		
+
+		// Load the settings
+		$settings = $this->get_config();
+		$this->run_hooks('config_loaded', array(&$settings));
+
 		// Get request url and script url
 		// Get request url and script url
 		$url = '';
 		$url = '';
 		$request_url = (isset($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : '';
 		$request_url = (isset($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : '';
@@ -51,10 +56,6 @@ class Pico {
 			$this->run_hooks('after_404_load_content', array(&$file, &$content));
 			$this->run_hooks('after_404_load_content', array(&$file, &$content));
 		}
 		}
 		$this->run_hooks('after_load_content', array(&$file, &$content));
 		$this->run_hooks('after_load_content', array(&$file, &$content));
-		
-		// Load the settings
-		$settings = $this->get_config();
-		$this->run_hooks('config_loaded', array(&$settings));
 
 
 		$meta = $this->read_file_meta($content);
 		$meta = $this->read_file_meta($content);
 		$this->run_hooks('file_meta', array(&$meta));
 		$this->run_hooks('file_meta', array(&$meta));
@@ -98,6 +99,9 @@ class Pico {
 			'next_page' => $next_page,
 			'next_page' => $next_page,
 			'is_front_page' => $url ? false : true,
 			'is_front_page' => $url ? false : true,
 		);
 		);
+		foreach ($this->columns as $var => $code) {
+			$twig_vars["column_{$var}"] = $code;
+		}
 		$this->run_hooks('before_render', array(&$twig_vars, &$twig));
 		$this->run_hooks('before_render', array(&$twig_vars, &$twig));
 		$output = $twig->render('index.html', $twig_vars);
 		$output = $twig->render('index.html', $twig_vars);
 		$this->run_hooks('after_render', array(&$output));
 		$this->run_hooks('after_render', array(&$output));
@@ -133,6 +137,17 @@ class Pico {
 	{
 	{
 		$content = preg_replace('#/\*.+?\*/#s', '', $content); // Remove comments and meta
 		$content = preg_replace('#/\*.+?\*/#s', '', $content); // Remove comments and meta
 		$content = str_replace('%base_url%', $this->base_url(), $content);
 		$content = str_replace('%base_url%', $this->base_url(), $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++;
+		}
+
 		$content = MarkdownExtra::defaultTransform($content);
 		$content = MarkdownExtra::defaultTransform($content);
 
 
 		return $content;
 		return $content;

+ 11 - 2
themes/default/index.html

@@ -29,9 +29,18 @@
 	</header>
 	</header>
 
 
 	<section id="content">
 	<section id="content">
-		<div class="inner">
+        <!-- old {{ content }} variable works also -->
+		<!-- div class="inner">
 			{{ content }}
 			{{ content }}
-		</div>
+		</div -->
+        <div class="inner">
+            <div class="col_content">
+                {{ column_content }}
+            </div>
+            <div class="col_sidebar">
+                {{ column_sidebar }}
+            </div>
+        </div>
 	</section>
 	</section>
 	
 	
 	<footer id="footer">
 	<footer id="footer">