Skip to content
Browse files

Bumped version

  • Loading branch information...
1 parent c020f41 commit 6d3280c8f852f7b7449db27ab1035993c3ba1e89 @kolber committed Oct 5, 2010
Showing with 21 additions and 21 deletions.
  1. +5 −5 README.md
  2. +16 −16 app/stacey.inc.php
View
10 README.md
@@ -1,7 +1,7 @@
-# Stacey 2.1.0
+# Stacey 2.2.0
## Overview
-Stacey takes content from `.txt` files, image files and implied directory structure and generates a website.
+Stacey takes content from `.txt` files, image files and implied directory structure and generates a website.
It is a no-database, dynamic website generator.
If you look in the `/content` and `/templates` folders, you should get the general idea of how it all works.
@@ -14,8 +14,8 @@ If you want clean urls, `mv htaccess .htaccess`
## Templates
-There are an additional two sets of templates which can be found at:
-<http://github.com/kolber/stacey-template2> &
+There are an additional two sets of templates which can be found at:
+<http://github.com/kolber/stacey-template2> &
<http://github.com/kolber/stacey-template3>
## Read More
@@ -24,5 +24,5 @@ See <http://staceyapp.com> for more detailed usage information.
## Copyright/License
-Copyright (c) 2009 Anthony Kolber. See `LICENSE` for details.
+Copyright (c) 2009 Anthony Kolber. See `LICENSE` for details.
Except PHP Markdown Extra which is (c) Michel Fortin (see `/app/parsers/markdown-parser.inc.php` for details).
View
32 app/stacey.inc.php
@@ -1,9 +1,9 @@
<?php
Class Stacey {
-
- static $version = '2.1.0';
-
+
+ static $version = '2.2.0';
+
function handle_redirects() {
# rewrite any calls to /index or /app back to /
if(preg_match('/^\/?(index|app)\/?$/', $_SERVER['REQUEST_URI'])) {
@@ -19,16 +19,16 @@ function handle_redirects() {
}
return false;
}
-
+
function php_fixes() {
# in PHP/5.3.0 they added a requisite for setting a default timezone, this should be handled via the php.ini, but as we cannot rely on this, we have to set a default timezone ourselves
if(function_exists('date_default_timezone_set')) date_default_timezone_set('Australia/Melbourne');
}
-
+
function set_content_type($template_file) {
# split by file extension
preg_match('/\.([\w\d]+?)$/', $template_file, $split_path);
-
+
switch ($split_path[1]) {
case 'txt':
# set text/utf-8 charset header
@@ -62,7 +62,7 @@ function set_content_type($template_file) {
header("Content-type: text/html; charset=utf-8");
}
}
-
+
function etag_expired($cache) {
header('Etag: "'.$cache->hash.'"');
if(isset($_SERVER['HTTP_IF_NONE_MATCH']) && stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) == '"'.$cache->hash.'"') {
@@ -74,7 +74,7 @@ function etag_expired($cache) {
return true;
}
}
-
+
function render($page) {
$cache = new Cache($page);
# set any custom headers
@@ -89,9 +89,9 @@ function render($page) {
# render the existing cache
echo $cache->render();
}
-
+
}
-
+
function create_page($file_path, $route) {
# return a 404 if a matching folder doesn't exist
if(!file_exists($file_path)) throw new Exception('404');
@@ -106,23 +106,23 @@ function create_page($file_path, $route) {
# register global for the template for the page which is currently being viewed
global $current_page_template_file;
$current_page_template_file = $page->template_file;
-
+
# error out if template file doesn't exist (or glob returns an error)
if(empty($page->template_name)) throw new Exception('404');
-
+
if(!$page->template_file) {
throw new Exception('A template named \''.$page->template_name.'\' could not be found in the \'/templates\' folder');
}
# render page
$this->render($page);
}
-
+
function __construct($get) {
# sometimes when PHP release a new version, they do silly things - this function is here to fix them
$this->php_fixes();
# it's easier to handle some redirection through php rather than relying on a more complex .htaccess file to do all the work
if($this->handle_redirects()) return;
-
+
# strip any leading or trailing slashes from the passed url
$key = preg_replace(array('/\/$/', '/^\//'), '', key($get));
# store file path for this current page
@@ -145,13 +145,13 @@ function __construct($get) {
else {
echo '<h1>404</h1><h2>Page could not be found.</h2><p>Unfortunately, the page you were looking for does not exist here.</p>';
}
-
+
} else {
echo '<h3>'.$e->getMessage().'</h3>';
}
}
}
-
+
}
?>

0 comments on commit 6d3280c

Please sign in to comment.
Something went wrong with that request. Please try again.