Skip to content

Commit

Permalink
1.1.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marty Wallace committed Mar 13, 2015
1 parent f887082 commit 86f8754
Show file tree
Hide file tree
Showing 18 changed files with 174 additions and 142 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ Tempest makes use of various tools to streamline the development process:

## Releases.

* [1.1.0](https://github.com/MartyWallace/Tempest/releases/tag/1.1.0)
* Greatly improved error handling; you can now handle specific HTTP errors buy placing a Twig template with the same name into `/html/_status/`.
* Cleant up templates.
* Cleant up SASS.

* [1.0.0](https://github.com/MartyWallace/Tempest/releases/tag/1.0.0)
* Modern project structure (using `public` for public files).
* Using Twig for templating.
Expand Down
11 changes: 9 additions & 2 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,22 @@
return array(

'*' => array(
'title' => 'New App',
// The application timezone.
'timezone' => 'Australia/Sydney',

// Variables that are accessible within Twig templates via {{ config.<key> }}.
// Do not put sensitive data in this block!
'twig' => array(
'title' => 'New App'
),

// Routes that the application can respond to.
'routes' => array(
'/' => 'AdaptivePage'
)
),

'localhost' => array(
'tempest.local' => array(
// Dev mode shows more verbose errors.
'dev' => true
)
Expand Down
16 changes: 10 additions & 6 deletions html/_layout.html → html/_layouts/doc.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>{{ title }} - Success!</title>
<title>{{ title is defined ? title : config.title }}</title>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
{% block meta %}
<meta charset="utf-8">
{% if meta is defined %}
{% for item in meta %}
<meta name="{{ item.name }}" content="{{ item.content }}" />
{% endfor %}
{% endif %}
{% endblock %}

{% block css %}
<link rel="stylesheet" href="/css/app.css">
{% endblock %}
</head>
<body>
<div id="content">
{% block content %}{% endblock %}
</div>
{% block body %}{% endblock %}

{% block js %}
<script src="/js/vendor.js"></script>
Expand Down
6 changes: 6 additions & 0 deletions html/_layouts/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{# Append additional META tags like description here. #}
{% set meta = [
{ name: 'viewport', content: 'width=device-width, initial-scale=1' }
] %}

{% extends '_layouts/doc.html' %}
8 changes: 8 additions & 0 deletions html/_status/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% set title = config.title ~ ' - Page Not Found' %}

{% extends '_layouts/doc.html' %}

{% block body %}
<h1>404</h1>
<p>This resource does not exist. Go back to our <a href="/">homepage</a>.</p>
{% endblock %}
63 changes: 63 additions & 0 deletions html/_status/500.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{% set title = config.title ~ ' - Internal Server Error' %}

{% set meta = [
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ name: 'robots', context: 'noindex, nofollow' }
] %}

{% extends '_layouts/doc.html' %}

{% block css %}
<link rel="stylesheet" href="/css/tempest.css">
{% endblock %}

{% block body %}
<div id="head">
<div class="grid">
<h1>{{ title }}</h1>
<a href="/">Return</a>
</div>
</div>

<div id="content">
<div class="grid">
<div class="column sixty">
{% block content %}
<ul id="errors">
{% for error in errors %}
<li>
<pre>{{ error.getString() }}</pre>
<p><small><span title="{{ error.getFile() }}">{{ error.getShortFile() }}</span> &middot; Line {{ error.getLine() }}</small></p>
</li>
{% endfor %}
</ul>
{% endblock %}
</div>
<div class="column thirty-five float-right">
<div id="request">
<h2>REQUEST DATA</h2>

<h6>URI</h6>
<p>{{ request.value }}</p>

<h6>GET</h6>
<pre>{{ request.data('get') | json_encode(constant('JSON_PRETTY_PRINT')) }}</pre>

<h6>POST</h6>
<pre>{{ request.data('post') | json_encode(constant('JSON_PRETTY_PRINT')) }}</pre>

<h6>NAMED</h6>
<pre>{{ request.data('named') | json_encode(constant('JSON_PRETTY_PRINT')) }}</pre>
</div>
</div>

<div class="clear"></div>
</div>
</div>

<div id="foot">
<div class="grid">
<p><a target="_blank" href="https://github.com/MartyWallace/Tempest">Tempest Framework</a> &middot; Developed by Marty Wallace.</p>
</div>
</div>
{% endblock %}
6 changes: 4 additions & 2 deletions html/home.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{% extends '_layout.html' %}
{% set title = config.title ~ ' - Success!' %}

{% block content %}
{% extends '_layouts/main.html' %}

{% block body %}
<div id="intro">
<p><img src="/textures/the-tempest.jpg" alt="Ivan Aivazovsky - The Tempest" title="Ivan Aivazovsky - The Tempest" /></p>

Expand Down
52 changes: 0 additions & 52 deletions html/tempest/_layout.html

This file was deleted.

12 changes: 0 additions & 12 deletions html/tempest/errors.html

This file was deleted.

28 changes: 15 additions & 13 deletions sass/tempest.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,24 @@ ul {
list-style: none;
margin: 0 auto;
text-align: left;
}

ul > li + li {
border-top: 1px dotted #DADADA;
margin-top: 20px;
padding-top: 20px;
}
li {
+ li {
border-top: 1px dotted #DADADA;
margin-top: 20px;
padding-top: 20px;
}

ul > li > pre {
background: none;
white-space: normal;
word-wrap: break-word;
}
pre {
background: none;
white-space: normal;
word-wrap: break-word;

ul > li > pre > code {
color: #A00;
code {
color: #A00;
}
}
}
}

small {
Expand Down
1 change: 1 addition & 0 deletions sass/vendor/_base.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO: Get a real CSS reset in here.
* {
margin: 0;
padding: 0;
Expand Down
17 changes: 5 additions & 12 deletions server/app/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

use Tempest\Tempest;
use Tempest\HTTP\Router;
use Tempest\HTTP\Request;
use Tempest\HTTP\Status;


class App extends Tempest
Expand All @@ -16,17 +14,12 @@ protected function setup(Router $router)
}


protected function errorOutput(Request $r, $code)
protected function defineServices()
{
if($code === Status::NOT_FOUND)
{
// You are able to implement a custom 404 page here.
return '404 - Not Found.';
}


// Use default error output if the code hasn't been handled.
return parent::errorOutput($r, $code);
return array(
// Add services here. Services are accessible in Twig via {{ tempest.<serviceName> }}.
// ...
);
}

}
6 changes: 5 additions & 1 deletion server/app/Responses/AdaptivePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ public function setup(Request $r)

public function index(Request $request)
{
trigger_error('fdsfs');
trigger_error('fdsfs');
trigger_error('fdsfs');

$result = tempest()->twig->render($this->name . '.html', array());

if($result === null)
if ($result === null)
{
// NULL is provided if the template could not be loaded.
tempest()->abort(404);
Expand Down
2 changes: 1 addition & 1 deletion server/boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
define('POST', 'post');
define('NAMED', 'named');

define('HOST', $_SERVER['SERVER_NAME']);
define('HOST', strtolower($_SERVER['SERVER_NAME']));
define('REQUEST_CLEAN', preg_replace('/(\?|#)(.+)/', '', $_SERVER["REQUEST_URI"]));
define('REQUEST_URI', Path::create(REQUEST_CLEAN, Path::DELIMITER_LEFT));
14 changes: 7 additions & 7 deletions server/tempest/Tempest/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public function __construct()
{
$data = require_once(APP_ROOT . 'config.php');

if(array_key_exists('*', $data))
if (array_key_exists('*', $data))
{
$this->data = $data['*'];

if(array_key_exists(HOST, $data))
if (array_key_exists(HOST, $data))
{
// Consume host-specific configuration and overwrite where necessary.
$this->data = array_replace_recursive($this->data, $data[HOST]);
Expand All @@ -32,7 +32,7 @@ public function __construct()
}

// General configuration.
date_default_timezone_set($this->data("timezone", "Australia/Sydney"));
if ($this->data('timezone')) date_default_timezone_set($this->data('timezone'));
}


Expand All @@ -46,15 +46,15 @@ public function __construct()
*/
public function data($field = null, $default = null)
{
if($field === null) return $this->data;
if ($field === null) return $this->data;

$path = preg_split('/\.+/', $field);
if(!array_key_exists($path[0], $this->data)) return $default;
if (!array_key_exists($path[0], $this->data)) return $default;

$target = $this->data;
foreach($path as $p)
foreach ($path as $p)
{
if(array_key_exists($p, $target)) $target = $target[$p];
if (array_key_exists($p, $target)) $target = $target[$p];
else return $default;
}

Expand Down
Loading

0 comments on commit 86f8754

Please sign in to comment.