Navigation Menu

Skip to content

Commit

Permalink
Wrapping up new Layouts, Parts, & Blocks system. This is a major comm…
Browse files Browse the repository at this point in the history
…it that is not backwards compatible with the previous GitHub Edge Layouts.

Major components of the new view system in place. Still need comments.

Added documentation for Part and Buffer as well as regression tests.

AssertiveTemplate commented.

Layout commented and tested.

PartBlock and Buffer documented and tested.

Updated WelcomeApp

Updated default resource scaffolding.
  • Loading branch information
KrisJordan committed Jun 29, 2009
1 parent 8ede42a commit ab78977
Show file tree
Hide file tree
Showing 110 changed files with 2,086 additions and 510 deletions.
2 changes: 2 additions & 0 deletions apps/welcome/WelcomeApplication.class.php
Expand Up @@ -14,6 +14,8 @@ public function __construct() {

$this->routingPrefix = '/';

$this->assetUrl = 'recess/recess/apps/tools/public/';

}
}
?>
7 changes: 0 additions & 7 deletions apps/welcome/controllers/WelcomeHomeController.class.php
Expand Up @@ -12,12 +12,5 @@ class WelcomeHomeController extends Controller {
function index() {
$this->flash = 'Welcome to your new Recess app!';
}

/**
* !Route GET, foo
*/
function foo() {

}
}
?>
4 changes: 0 additions & 4 deletions apps/welcome/views/common/footer.php

This file was deleted.

6 changes: 2 additions & 4 deletions apps/welcome/views/home/index.php
@@ -1,6 +1,6 @@
<?php
Layout::extend('master');
$title = 'Welcome to Recess!';
include_once($viewsDir . 'common/header.php');
?>
<div class="span-24 last">
<div class="span-12 notice">
Expand All @@ -16,6 +16,4 @@
</div>
</div>

<h3>For more information visit <a href="http://www.recessframework.org/">http://www.recessframework.org/</a></h3>

<?php include_once($viewsDir . 'common/footer.php'); ?>
<h3>For more information visit <a href="http://www.recessframework.org/">http://www.recessframework.org/</a></h3>
@@ -1,15 +1,16 @@
<?php
Layout::input($title, 'string');
Layout::input($body, 'Block');
?>
<html>
<head>
<!-- Blue Print -->
<link rel="stylesheet" href="<?php echo $_ENV['url.content']; ?>css/blueprint/screen.css" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="<?php echo $_ENV['url.content']; ?>css/blueprint/print.css" type="text/css" media="print" />
<?php echo Html::css('blueprint/screen', 'screen') ?>
<?php echo Html::css('blueprint/print', 'print') ?>
<!--[if IE]>
<link rel="stylesheet" href="/css/blueprint/ie.css" type="text/css" media="screen, projection" />
<?php echo Html::css('blueprint/ie', 'screen') ?>
<![endif]-->
<!-- Syntax Highlighter -->
<link type="text/css" rel="stylesheet" href="<?php echo $_ENV['url.content']; ?>css/SyntaxHighlighter.css"></link>
<title><?php if(isset($title)) echo $title; else echo 'Recess!'; ?></title>

<style type="text/css">
.error,.notice,.success{ margin: 0 0 1em 0; padding: 0.8em; border: 2px solid #000; }
.error{ background: #FBE3E4; border-color: #FBC2C4; }
Expand Down Expand Up @@ -38,6 +39,10 @@
<body>
<div class="container">
<div class="span-24">
<h1>Welcome to Recess!</h1>
<h1><?php echo $title ?></h1>
</div>
<div class="span-24 last">
<div class="span-24 last">
<?php echo $body ?>
</div>
</body>
</html>
3 changes: 3 additions & 0 deletions recess/recess/apps/tools/RecessToolsApplication.class.php
@@ -1,5 +1,6 @@
<?php
Library::import('recess.framework.Application');
Library::import('recess.framework.helpers.AssertiveTemplate');

class RecessToolsApplication extends Application {

Expand All @@ -23,6 +24,8 @@ public function __construct() {

$this->routingPrefix = 'recess/';

AssertiveTemplate::addPath($_ENV['dir.recess'] . 'recess/framework/parts/');

}
}

Expand Down
Expand Up @@ -95,8 +95,9 @@ private function generateApp() {
$this->messages[] = $this->tryGeneratingFile('Navigation Part', $this->application->codeTemplatesDir . 'scaffolding/views/parts/navigation.part.template.php', $appDir . '/views/parts/navigation.part.php', $appReplacements);
$this->messages[] = $this->tryGeneratingFile('Style Part', $this->application->codeTemplatesDir . 'scaffolding/views/parts/style.part.template.php', $appDir . '/views/parts/style.part.php', $appReplacements);
$this->messages[] = $this->tryCreatingDirectory($appDir . '/views/home', 'home views');
$this->messages[] = $this->tryCreatingDirectory($appDir . '/views/layouts', 'layouts');
$this->messages[] = $this->tryGeneratingFile('Home Template', $this->application->codeTemplatesDir . 'scaffolding/views/home/index.template.php', $appDir . '/views/home/index.php', $appReplacements);
$this->messages[] = $this->tryGeneratingFile('Master Layout', $this->application->codeTemplatesDir . 'scaffolding/views/master.template.php', $appDir . '/views/master.php', $appReplacements);
$this->messages[] = $this->tryGeneratingFile('Master Layout', $this->application->codeTemplatesDir . 'scaffolding/views/master.layout.template.php', $appDir . '/views/layouts/master.layout.php', $appReplacements);

$this->messages[] = $this->tryCreatingDirectory($appDir . '/public', 'public');
$this->messages[] = $this->tryCreatingDirectory($appDir . '/public/css', 'css');
Expand Down Expand Up @@ -343,7 +344,7 @@ public function generateScaffolding($app, $model) {

$viewsDir = $app->viewsDir . $replacements['viewsPrefix'] . '/';
$this->messages[] = $this->tryCreatingDirectory($viewsDir, $model . ' views dir');
$this->messages[] = $this->tryGeneratingFile('resource layout', $this->application->codeTemplatesDir . 'scaffolding/views/resource/layout.template.php', $viewsDir . 'layout.php', $replacements);
$this->messages[] = $this->tryGeneratingFile('resource layout', $this->application->codeTemplatesDir . 'scaffolding/views/resource/resource.layout.template.php', $viewsDir . '../layouts/' . $replacements['viewsPrefix'] . '.layout.php', $replacements);
$this->messages[] = $this->tryGeneratingFile('index view', $this->application->codeTemplatesDir . 'scaffolding/views/resource/index.template.php', $viewsDir . 'index.php', $replacements);
$this->messages[] = $this->tryGeneratingFile('editForm view', $this->application->codeTemplatesDir . 'scaffolding/views/resource/editForm.template.php', $viewsDir . 'editForm.php', $replacements, true);
$this->messages[] = $this->tryGeneratingFile('form part', $this->application->codeTemplatesDir . 'scaffolding/views/resource/form.part.template.php', $viewsDir . 'form.part.php', $replacements, true);
Expand Down
Expand Up @@ -15,7 +15,7 @@ public function __construct() {
$this->controllersPrefix = '{{camelProgrammaticName}}.controllers.';

$this->routingPrefix = '{{routesPrefix}}';

}
}
?>
@@ -1,6 +1,6 @@
<?php
Layout::extend('master');
Layout::blockAssign('title', 'Home');
Layout::extend('layouts/master');
$title = 'Home';
?>
<h1>Hello Kick-ass Developer!</h1>
<h2 class="highlight"><?php echo $flash; ?></h2>
Expand Down
@@ -1,11 +1,17 @@
<?php
Layout::input($title, 'string');
Layout::input($body, 'Block');
Layout::input($navigation, 'Block', new HtmlBlock());
Layout::input($style, 'Block', new HtmlBlock());
?>
<html>
<head>
<?php
Layout::slot('style');
Part::render('parts/style');
Layout::slotEnd();
<?php
if(!$style->draw()) {
Part::draw('parts/style');
}
?>
<title>{{appName}} - <?php Layout::slot('title'); Layout::slotEnd() ?></title>
<title>{{appName}} - <?php echo $title; ?></title>
</head>
<body>
<div class="container">
Expand All @@ -14,15 +20,9 @@
</div>
<div class="span-24 last">
<div class="navigation">
<?php
Layout::slot('navigation');
Layout::slotEnd();
?>
<?php echo $navigation; ?>
</div>
<?php
Layout::slot('body');
Layout::slotEnd();
?>
<?php echo $body; ?>
</div>
<div class="span-24 footer">
<p class="quiet bottom">
Expand Down
@@ -1,5 +1,5 @@
<?php
assert(${{modelNameLower}} instanceof {{modelName}});
Part::input(${{modelNameLower}}, '{{modelName}}');
?>
<form method="POST" action="<?php echo Url::action('{{modelName}}Controller::delete', ${{modelNameLower}}->{{primaryKey}}) ?>">
<fieldset>
Expand Down
@@ -1,9 +1,9 @@
<?php
Layout::extend('{{modelNameLower}}/layout');
Layout::blockAssign('title', 'Details of {{modelName}} #' . ${{modelNameLower}}->{{primaryKey}} );
Layout::extend('layouts/{{modelNameLower}}');
$title = 'Details of {{modelName}} #' . ${{modelNameLower}}->{{primaryKey}} ;
?>

<?php Part::render('{{modelNameLower}}/details', ${{modelNameLower}}) ?>
<?php Part::draw('{{modelNameLower}}/details', ${{modelNameLower}}) ?>

<?php echo Html::anchor(Url::action('{{modelName}}Controller::index'), 'Back to list of {{modelNameLower}}s') ?>
<hr />
@@ -1,13 +1,13 @@
<?php
Layout::extend('{{modelNameLower}}/layout');
Layout::extend('layouts/{{modelNameLower}}');
if(isset(${{modelNameLower}}->{{primaryKey}})) {
$title = 'Edit {{modelName}} #' . ${{modelNameLower}}->{{primaryKey}};
} else {
$title = 'Create New {{modelName}}';
}
Layout::blockAssign('title', $title);
$title = $title;
?>

<?php Part::render('{{modelNameLower}}/form', $_form, $title) ?>
<?php Part::draw('{{modelNameLower}}/form', $_form, $title) ?>

<?php echo Html::anchor(Url::action('{{modelName}}Controller::index'), '{{modelName}} List') ?>
@@ -1,6 +1,6 @@
<?php
assert($form instanceof ModelForm);
assert(is_string($title));
Part::input($form, 'ModelForm');
Part::input($title, 'string');
?>
<?php $form->begin(); ?>
<fieldset>
Expand Down
@@ -1,6 +1,6 @@
<?php
Layout::extend('{{modelNameLower}}/layout');
Layout::blockAssign('title', 'Index');
Layout::extend('layouts/{{modelNameLower}}');
$title = 'Index';
?>

<h3><?php echo Html::anchor(Url::action('{{modelName}}Controller::newForm'), 'Create New {{modelName}}') ?></h3>
Expand All @@ -12,6 +12,6 @@
<?php endif; ?>

<?php foreach(${{modelNameLower}}Set as ${{modelNameLower}}): ?>
<?php Part::render('{{modelNameLower}}/details', ${{modelNameLower}}) ?>
<?php Part::draw('{{modelNameLower}}/details', ${{modelNameLower}}) ?>
<hr />
<?php endforeach; ?>

This file was deleted.

@@ -0,0 +1,9 @@
<?php
Layout::extend('layouts/master');
Layout::input($title, 'string');
Layout::input($body, 'Block');

$title .= '{{modelName}} - ';

$navigation = Part::block('parts/navigation');
?>
27 changes: 9 additions & 18 deletions recess/recess/apps/tools/views/apps/app.php
@@ -1,42 +1,33 @@
<?php
Layout::extend('layouts/apps');
Layout::blockAssign('title', $app->name);

Library::import('recess.apps.tools.controllers.RecessToolsCodeController');
$codeController = new RecessToolsCodeController($response->request->meta->app);
$title = $app->name;
?>
<h1><?php echo $app->name; ?></h1>
<p>Class:
<a href="<?php
echo $codeController
->urlTo(
'classInfo',
Library::getFullyQualifiedClassName(
get_class($app)
)
); ?>"><?php echo get_class($app); ?></a></p>
echo Url::action('RecessToolsCodeController::classInfo', Library::getFullyQualifiedClassName(get_class($app))) ?>"><?php echo get_class($app); ?></a></p>
<div class="span-6">
<h2 class="bottom">Models (<a href="<?php echo $controller->urlTo('createModel',get_class($app)); ?>">new</a>)</h2>
<p>Location: <a href="<?php echo $codeController->urlTo('packageInfo', substr($app->modelsPrefix,0,-1)); ?>"><?php echo $app->modelsPrefix; ?></a></p>
<p>Location: <?php echo Html::anchor(Url::action('RecessToolsCodeController::packageInfo',substr($app->modelsPrefix,0,-1)), $app->modelsPrefix ) ?> </p>
<?php
function printClassesInNamespace($namespace, $codeController) {
function printClassesInNamespace($namespace) {
$classes = Library::findClassesIn($namespace);
if(!empty($classes)) {
echo '<ul>';
foreach($classes as $class) {
echo '<li><a href="' . $codeController->urlTo('classInfo',$namespace . $class) . '">' . $class . '</a></li>';
echo '<li>' . Html::anchor(Url::action('RecessToolsCodeController::classInfo', $namespace . $class), $class) . '</li>';
}
echo '</ul>';
}
}
printClassesInNamespace($app->modelsPrefix, $codeController);
printClassesInNamespace($app->modelsPrefix);
?>
</div>
<div class="span-6">
<h2 class="bottom">Controllers (<a href="<?php echo $controller->urlTo('createController', get_class($app)); ?>">new</a>)</h2>
<p>Location: <a href="<?php echo $codeController->urlTo('packageInfo', substr($app->controllersPrefix,0,-1)); ?>"><?php echo $app->controllersPrefix; ?></a></p>
<p>Location: <?php echo Html::anchor(Url::action('RecessToolsCodeController::packageInfo',substr($app->controllersPrefix,0,-1)), $app->controllersPrefix ) ?></p>
<?php
printClassesInNamespace($app->controllersPrefix, $codeController);
printClassesInNamespace($app->controllersPrefix);
?>
</div>

Expand All @@ -52,7 +43,7 @@ function printClassesInNamespace($namespace, $codeController) {
$routes = new RtNode();
$app->addRoutesToRouter($routes);
// include_once($viewsDir . 'common/printRoutes.php');
Part::render('routes/table', $routes, $codeController, '');
Part::draw('routes/table', $routes, '');
?>

<hr />
Expand Down
8 changes: 4 additions & 4 deletions recess/recess/apps/tools/views/apps/createModel.php
@@ -1,10 +1,10 @@
<?php
Layout::extend('layouts/apps');
Layout::blockAssign('title', $app);
$title = $app;

Layout::block('scripts');
include_once($viewsDir . 'apps/newModelJQuery.php');
Layout::blockEnd();
Buffer::to($scripts);
include 'newModelJQuery.php';
Buffer::end();
?>

<h1>New <strong>Model</strong> Helper</h1>
Expand Down
@@ -1,6 +1,6 @@
<?php
Layout::extend('layouts/apps');
Layout::blockAssign('title', 'Model Created');
$title = 'Model Created';
?>
<h1>Creating <strong><?php echo $modelName; ?></strong> Model...</h1>

Expand Down
2 changes: 1 addition & 1 deletion recess/recess/apps/tools/views/apps/genController.php
@@ -1,6 +1,6 @@
<?php
Layout::extend('layouts/apps');
Layout::blockAssign('title', 'Scaffolding Generation');
$title = 'Scaffolding Generation';
?>

<h1>Select the Model to Generate Scaffolding for:</h1>
Expand Down
@@ -1,6 +1,6 @@
<?php
Layout::extend('layouts/apps');
Layout::blockAssign('title', 'Scaffolding Generation');
$title = 'Scaffolding Generation';
?>

<h1>Generating Scaffolding for <?php echo $modelName; ?>...</h1>
Expand Down
2 changes: 1 addition & 1 deletion recess/recess/apps/tools/views/apps/home.php
@@ -1,6 +1,6 @@
<?php
Layout::extend('layouts/apps');
Layout::blockAssign('Title', 'Home');
$title = 'Home';
?>

<h1>Applications</h1>
Expand Down
2 changes: 1 addition & 1 deletion recess/recess/apps/tools/views/apps/newAppInstructions.php
@@ -1,6 +1,6 @@
<?php
Layout::extend('layouts/apps');
Layout::blockAssign('title', 'New App Instructions');
$title = 'New App Instructions';
?>

<h1>Your apps dir isn't writeable...</h1>
Expand Down
2 changes: 1 addition & 1 deletion recess/recess/apps/tools/views/apps/newAppWizard.php
@@ -1,6 +1,6 @@
<?php
Layout::extend('layouts/apps');
Layout::blockAssign('title', 'New Application Instructions');
$title = 'New Application Instructions';
?>


Expand Down
@@ -1,6 +1,6 @@
<?php
Layout::extend('layouts/apps');
Layout::blockAssign('title', 'New Application Instructions');
$title = 'New Application Instructions';
?>

<h1>Creating New Application...</h1>
Expand Down

0 comments on commit ab78977

Please sign in to comment.