Commit 7317b585 authored by Taylor Otwell's avatar Taylor Otwell

refactored welcome pages.

parent d0771493
......@@ -37,16 +37,8 @@ return array(
| //
| })
|
| The "shared" composer is called for every view. This allows the
| convenient binding of global data or assets.
|
*/
'shared' => function($view)
{
// This composer is called for every view.
},
'home.index' => array('name' => 'home', function($view)
{
// This composer is called for the "home.index" view.
......
......@@ -49,18 +49,11 @@ return array(
'handler' => function($exception, $severity, $message, $config)
{
if ($config['detail'])
{
$data = compact('exception', 'severity', 'message');
$data = compact('exception', 'severity', 'message');
$response = Response::view('error.exception', $data)->status(500);
}
else
{
$response = Response::error('500');
}
$data['detailed'] = $config['detail'];
$response->send();
Response::error('500', $data)->send();
},
/*
......
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Error 404 - Not Found</title>
<style>
@import url(http://fonts.googleapis.com/css?family=Ubuntu);
body {
background:#eee;
color: #6d6d6d;
font: normal normal normal 16px/1.253 Ubuntu, sans-serif;
margin:0;
min-width:800px;
padding:0;
}
#main {
background-clip: padding-box;
background-color: #fff;
border:1px solid #ccc;
border-radius: 5px;
box-shadow: 0 0 10px #cdcdcd;
margin: 50px auto 0;
padding: 30px;
width: 700px;
}
#main h1 {
font-family: 'Ubuntu';
font-size: 34px;
margin: 0 0 20px 0;
padding: 0;
}
#main h2,h3 {
margin-top: 25px;
padding: 0 0 0 0;
}
#main h3 {
font-size: 18px;
}
#main p {
line-height: 25px;
margin: 10px 0;
}
</style>
</head>
<body>
<div id="main">
<?php $messages = array('We need a map.', 'I think we\'re lost.', 'We took a wrong turn.'); ?>
<h1><?php echo $messages[mt_rand(0, 2)]; ?></h1>
<p>We're really sorry, but we couldn't find the resource you requested.</p>
<p>Perhaps you would like to go to our <?php echo HTML::link('/', 'home page'); ?> instead?</p>
</div>
</body>
</html>
\ No newline at end of file
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Error 500 - Internal Server Error</title>
<style>
@import url(http://fonts.googleapis.com/css?family=Ubuntu);
body {
background:#eee;
color: #6d6d6d;
font: normal normal normal 14px/1.253 Ubuntu, sans-serif;
margin:0;
min-width:800px;
padding:0;
}
#main {
background-clip: padding-box;
background-color: #fff;
border:1px solid #ccc;
border-radius: 5px;
box-shadow: 0 0 10px #cdcdcd;
margin: 50px auto 0;
padding: 30px;
width: 700px;
}
#main h1 {
font-family: 'Ubuntu';
font-size: 34px;
margin: 0 0 20px 0;
padding: 0;
}
#main p {
line-height: 25px;
margin: 10px 0;
}
</style>
</head>
<body>
<div id="main">
<?php $messages = array('Something bad has happened.', 'We messed up.', 'Whoops!'); ?>
<h1><?php echo $messages[mt_rand(0, 2)]; ?></h1>
<p>We're really sorry, but something went wrong while we were processing your request.</p>
<p>Perhaps you would like to go to our <?php echo HTML::link('/', 'home page'); ?> instead?</p>
</div>
</body>
</html>
\ No newline at end of file
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Laravel - <?php echo $severity; ?></title>
<style>
@import url(http://fonts.googleapis.com/css?family=Ubuntu);
body {
background:#eee;
color: #6d6d6d;
font: normal normal normal 14px/1.253 Ubuntu, sans-serif;
margin:0;
min-width:1000px;
padding:0;
}
#main {
background-clip: padding-box;
background-color: #fff;
border:1px solid #ccc;
border-radius: 5px;
box-shadow: 0 0 10px #cdcdcd;
margin: 50px auto 0;
padding: 30px;
width: 900px;
}
#main h1 {
font-family: 'Ubuntu';
font-size: 34px;
margin: 0 0 20px 0;
padding: 0;
}
#main h2,h3 {
margin-top: 25px;
padding: 0 0 0 0;
}
#main h3 {
font-size: 18px;
}
#main p {
line-height: 25px;
margin: 10px 0;
}
</style>
</head>
<body>
<div id="main">
<h1><?php echo $severity; ?></h1>
<h3>Message</h3>
<pre><?php echo $message; ?></pre>
<h3>Stack Trace</h3>
<pre><?php echo $exception->getTraceAsString(); ?></pre>
</div>
</body>
</html>
\ No newline at end of file
......@@ -6,70 +6,16 @@
<title>Laravel - A Framework For Web Artisans</title>
<style>
@import url(http://fonts.googleapis.com/css?family=Ubuntu);
body {
background:#eee;
color: #6d6d6d;
font: normal normal normal 14px/1.253 Ubuntu, sans-serif;
margin:0;
min-width:800px;
padding:0;
}
#main {
background-clip: padding-box;
background-color: #fff;
border:1px solid #ccc;
border-radius: 5px;
box-shadow: 0 0 10px #cdcdcd;
margin: 50px auto 0;
padding: 30px;
width: 700px;
}
#main h1 {
font-family: 'Ubuntu';
font-size: 34px;
margin: 0 0 20px 0;
padding: 0;
}
#main h2,h3 {
margin-top: 25px;
padding: 0 0 0 0;
}
#main h3 {
font-size: 18px;
}
#main p {
line-height: 25px;
margin: 10px 0;
}
#main pre {
background-color: #f0f0f0;
border-left: 1px solid #d8d8d8;
border-top: 1px solid #d8d8d8;
border-radius: 5px;
padding: 10px;
}
#main ul {
margin: 10px 0;
padding: 0 30px;
}
#main li {
margin: 5px 0;
}
<?php echo file_get_contents(PUBLIC_PATH.'css/laravel.css'); ?>
</style>
</head>
<body>
<div id="main">
<h1>Welcome to Laravel</h1>
<img src="http://laravel.com/img/splash/check.png" class="marker">
<h1>Welcome To Laravel</h1>
<h2>A Framework For Web Artisans</h2>
<p>
You have successfully installed the Laravel framework. Laravel is a simple framework
......
......@@ -20,6 +20,7 @@ define('ROUTE_PATH', APP_PATH.'routes/');
define('SESSION_PATH', STORAGE_PATH.'sessions/');
define('SYS_CONFIG_PATH', SYS_PATH.'config/');
define('SYS_LANG_PATH', SYS_PATH.'language/');
define('SYS_VIEW_PATH', SYS_PATH.'views/');
define('VIEW_PATH', APP_PATH.'views/');
define('EXT', '.php');
......
......@@ -109,11 +109,45 @@ class Connection {
*/
public function query($sql, $bindings = array())
{
$sql = $this->transform($sql, $bindings);
$this->queries[] = compact('sql', 'bindings');
return $this->execute($this->pdo->prepare(trim($sql)), $bindings);
}
/**
* Transform an SQL query into an executable query.
*
* Laravel provides a convenient short-cut when writing raw queries for
* handling cumbersome "where in" statements. This method will transform
* those segments into their full SQL counterparts.
*
* @param string $sql
* @param array $bindings
* @return string
*/
protected function transform($sql, $bindings)
{
if (strpos($sql, '(...)') === false) return $sql;
for ($i = 0; $i < count($bindings); $i++)
{
// If the binding is an array, we can assume it is being used to fill
// a "where in" condition, so we will replace the next place-holder
// in the query with the correct number of parameters based on the
// number of elements in this binding.
if (is_array($bindings[$i]))
{
$parameters = implode(', ', array_fill(0, count($bindings[$i]), '?'));
$sql = preg_replace('~\(\.\.\.\)~', "({$parameters})", $sql, 1);
}
}
return $sql;
}
/**
* Execute a prepared PDO statement and return the appropriate results.
*
......
......@@ -19,9 +19,9 @@ class Grammar {
/**
* Compile a SQL SELECT statement from a Query instance.
*
* The query will be compiled according to the order of the elements specified
* in the "components" property. The entire query is pased into each component
* compiler for convenience.
* The query will be compiled according to the order of the elements
* specified in the "components" property. The entire query is passed
* into each component compiler for convenience.
*
* @param Query $query
* @return string
......@@ -30,11 +30,15 @@ class Grammar {
{
$sql = array();
// Iterate through each query component, calling the compiler for that
// component, and passing the query instance into the compiler.
// Iterate through each query component, calling the compiler
// for that component, and passing the query instance into
// the compiler.
foreach ($this->components as $component)
{
if ( ! is_null($query->$component)) $sql[] = call_user_func(array($this, $component), $query);
if ( ! is_null($query->$component))
{
$sql[] = call_user_func(array($this, $component), $query);
}
}
return implode(' ', Arr::without($sql, array(null, '')));
......@@ -59,9 +63,7 @@ class Grammar {
*/
protected function aggregate(Query $query)
{
list($aggregator, $column) = array($query->aggregate['aggregator'], $query->aggregate['column']);
return 'SELECT '.$aggregator.'('.$this->wrap($column).')';
return 'SELECT '.$query->aggregate['aggregator'].'('.$this->wrap($query->aggregate['column']).')';
}
/**
......@@ -83,15 +85,18 @@ class Grammar {
*/
protected function joins(Query $query)
{
// Since creating a JOIN clause using string concatenation is a little cumbersome,
// we will create a format we can pass to "sprintf" to make things cleaner.
// Since creating a JOIN clause using string concatenation is a
// little cumbersome, we will create a format we can pass to
// "sprintf" to make things cleaner.
$format = '%s JOIN %s ON %s %s %s';
foreach ($query->joins as $join)
{
extract($join, EXTR_SKIP);
list($column1, $column2) = array($this->wrap($column1), $this->wrap($column2));
$column1 = $this->wrap($column1);
$column2 = $this->wrap($column2);
$sql[] = sprintf($format, $type, $this->wrap($table), $column1, $operator, $column2);
}
......@@ -107,15 +112,16 @@ class Grammar {
*/
final protected function wheres(Query $query)
{
// Each WHERE clause array has a "type" that is assigned by the query builder, and
// each type has its own compiler function. For example, "where in" queries are
// compiled by the "where_in" function.
//
// The only exception to this rule are "raw" where clauses, which are simply
// appended to the query as-is, without any further compiling.
// Each WHERE clause array has a "type" that is assigned by the
// query builder, and each type has its own compiler function.
// The only exception to this rule are "raw" where clauses,
// which are simply appended to the query as-is, without
// any further compiling.
foreach ($query->wheres as $where)
{
$sql[] = ($where['type'] == 'raw') ? $where['sql'] : $where['connector'].' '.$this->{$where['type']}($where);
$sql[] = ($where['type'] !== 'raw')
? $where['connector'].' '.$this->{$where['type']}($where)
: $where['sql'];
}
if (isset($sql)) return implode(' ', array_merge(array('WHERE 1 = 1'), $sql));
......@@ -207,20 +213,20 @@ class Grammar {
*/
public function insert(Query $query, $values)
{
// Force every insert to be treated like a batch insert. This simply makes creating
// the SQL syntax a little easier on us since we can always treat the values as if
// is an array containing multiple inserts.
// Force every insert to be treated like a batch insert.
// This simply makes creating the SQL syntax a little
// easier on us since we can always treat the values
// as if is an array containing multiple inserts.
if ( ! is_array(reset($values))) $values = array($values);
// Since we only care about the column names, we can pass any of the insert arrays
// into the "columnize" method. The names should be the same for every insert.
// Since we only care about the column names, we can pass
// any of the insert arrays into the "columnize" method.
// The names should be the same for every insert.
$columns = $this->columnize(array_keys(reset($values)));
// We need to create a string of comma-delimited insert segments. Each segment contains
// PDO place-holders for each value being inserted into the table. So, if we are inserting
// into three columns, the string should look like this:
//
// (?, ?, ?), (?, ?, ?), (?, ?, ?)
// We need to create a string of comma-delimited insert
// segments. Each segment contains PDO place-holders for
// each value being inserted into the table.
$parameters = implode(', ', array_fill(0, count($values), '('.$this->parameterize(reset($values)).')'));
return 'INSERT INTO '.$this->wrap($query->from).' ('.$columns.') VALUES '.$parameters;
......@@ -229,8 +235,9 @@ class Grammar {
/**
* Compile a SQL UPDATE statment from a Query instance.
*
* Note: Since UPDATE statements can be limited by a WHERE clause, this method will
* use the same WHERE clause compilation functions as the "select" method.
* Note: Since UPDATE statements can be limited by a WHERE clause,
* this method will use the same WHERE clause compilation
* functions as the "select" method.
*
* @param Query $query
* @param array $values
......@@ -255,17 +262,16 @@ class Grammar {
}
/**
* The following functions primarily serve as utility functions for the grammar.
* They perform tasks such as wrapping values in keyword identifiers or creating
* variable lists of bindings. Most likely, they will not need to change across
* various database systems.
* The following functions primarily serve as utility functions
* for the grammar. They perform tasks such as wrapping values
* in keyword identifiers or creating variable lists of bindings.
*/
/**
* Create a comma-delimited list of wrapped column names.
*
* Optionally, an "append" value may be passed to the method. This value will be
* appended to every wrapped column name.
* Optionally, an "append" value may be passed to the method.
* This value will be appended to every wrapped column name.
*
* @param array $columns
* @param string $append
......@@ -284,9 +290,9 @@ class Grammar {
/**
* Wrap a value in keyword identifiers.
*
* They keyword identifier used by the method is specified as a property on
* the grammar class so it can be conveniently overriden without changing
* the wrapping logic itself.
* They keyword identifier used by the method is specified as
* a property on the grammar class so it can be conveniently
* overriden without changing the wrapping logic itself.
*
* @param string $value
* @return string
......
......@@ -98,6 +98,55 @@ class Str {
return strlen($value);
}
/**
* Limit the number of chars in a string
*
* <code>
* // Limit the characters
* echo Str::limit_chars('taylor otwell', 3);
* results in 'tay...'
* </code>
*
* @param string $value
* @param int $length
* @param string $end
* @return string
*/
public static function limit($value, $length = 100, $end = '...')
{
if (static::length($value) <= $length) return $value;
if (function_exists('mb_substr'))
{
return mb_substr($value, 0, $length).$end;
}
return substr($value, 0, $length).$end;
}
/**
* Limit the number of words in a string
*
* <code>
* // Limit the words
* echo Str::limit_chars('This is a sentence.', 3);
* results in 'This is a...'
* </code>
*
* @param string $value
* @param int $length
* @param string $end
* @return string
*/
public static function limit_words($value, $length = 100, $end = '...')
{
$count = str_word_count($value,1);
if ($count <= $length) return $value;
return implode(' ',array_slice($count,0,$length)).$end;
}
/**
* Convert a string to 7-bit ASCII.
*
......
......@@ -59,7 +59,14 @@ class View {
foreach (array(EXT, BLADE_EXT) as $extension)
{
if (file_exists($path = VIEW_PATH.$view.$extension)) return $path;
if (file_exists($path = VIEW_PATH.$view.$extension))
{
return $path;
}
elseif (file_exists($path = SYS_VIEW_PATH.$view.$extension))
{
return $path;
}
}
throw new \Exception("View [$view] does not exist.");
......@@ -145,10 +152,6 @@ class View {
{
if (is_null(static::$composers)) static::$composers = require APP_PATH.'composers'.EXT;
// The shared composer is called for every view instance. This allows the
// convenient binding of global view data or partials within a single method.
if (isset(static::$composers['shared'])) call_user_func(static::$composers['shared'], $view);
if (isset(static::$composers[$view->view]))
{
foreach ((array) static::$composers[$view->view] as $key => $value)
......
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Error 404 - Not Found</title>
<style>
<?php echo file_get_contents(PUBLIC_PATH.'css/laravel.css'); ?>
</style>
</head>
<body>
<div id="main">
<img src="http://laravel.com/img/splash/error.png" class="marker">
<?php $messages = array('We need a map.', 'I think we\'re lost.', 'We took a wrong turn.'); ?>
<h1><?php echo $messages[mt_rand(0, 2)]; ?></h1>
<h2>Server Error: 404 (Not Found)</h2>
<h3>What does this mean?</h3>
<p>
We couldn't find the page you requested on our servers. We're really sorry about that.
It's our fault, not yours. We'll work hard to get this page back online as soon as possible.
</p>
<p>
Perhaps you would like to go to our <?php echo HTML::link('/', 'home page'); ?>?
</p>
</div>
</body>
</html>
\ No newline at end of file
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Error 500 - Internal Server Error</title>
<style>
<?php echo file_get_contents(PUBLIC_PATH.'css/laravel.css'); ?>
</style>
</head>
<body>
<div id="main">
<img src="http://laravel.com/img/splash/error.png" class="marker">
<?php $messages = array('Ouch.', 'Oh no!', 'Whoops!'); ?>
<h1><?php echo $messages[mt_rand(0, 2)]; ?></h1>
<h2>Server Error: 500 (Internal Server Error)</h2>
<h3>What does this mean?</h3>
<p>
Something went wrong on our servers while we were processing your request.
We're really sorry about this, and will work hard to get this resolved as
soon as possible.
</p>
<p>
Perhaps you would like to go to our <?php echo HTML::link('/', 'home page'); ?>?
</p>
<?php if (isset($detailed) and $detailed): ?>
<h3>Error Message:</h3>
<pre style="word-wrap: break-word;"><?php echo $message; ?></pre>
<h3>Stack Trace:</h3>
<?php
$search = array(APP_PATH, SYS_PATH);
$replace = array('APP_PATH/', 'SYS_PATH/');
$trace = str_replace($search, $replace, $exception->getTraceAsString());
?>
<pre style="word-wrap: break-word;"><?php echo $trace; ?></pre>
<?php endif; ?>
</div>
</body>
</html>
\ No newline at end of file
@import url(http://fonts.googleapis.com/css?family=Ubuntu);
body {
background: #eee;
color: #6d6d6d;
font: normal normal normal 14px/1.253 Ubuntu, sans-serif;
margin:0;
min-width: 800px;
padding:0;
}
#main {
background-clip: padding-box;
background-color: #fff;
border:1px solid #ccc;
border-radius: 5px;
box-shadow: 0 0 10px #cdcdcd;
margin: 50px auto 0;
padding: 30px;
width: 700px;
position: relative;
}
#main h1 {
font-family: 'Ubuntu';
font-size: 38px;
margin: 0 0 10px 0;
padding: 0;
}
#main h2 {
color: #999;
font-size: 18px;
letter-spacing: 3px;
margin: 0 0 25px 0;
padding: 0 0 0 0;
}
#main h3 {
color: #999;
margin-top: 24px;
padding: 0 0 0 0;
}
#main h3 {
font-size: 18px;
}
#main p {
line-height: 25px;
margin: 10px 0;
}
#main pre {
background-color: #333;
border-left: 1px solid #d8d8d8;
border-top: 1px solid #d8d8d8;
border-radius: 5px;
color: #eee;
padding: 10px;
}
#main ul {
margin: 10px 0;
padding: 0 30px;
}
#main li {
margin: 5px 0;
}
#main .marker {
float: left;
left: -24px; top: -24px;
position: absolute;
}
\ No newline at end of file
......@@ -45,4 +45,4 @@ $public = __DIR__;
*/
require $laravel.'/laravel.php';
echo number_format((microtime(true) - START_TIME) * 1000, 2);
\ No newline at end of file
//echo number_format((microtime(true) - START_TIME) * 1000, 2);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment