Skip to content

Commit

Permalink
More improvements to Tools
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisJordan committed Dec 1, 2008
1 parent d99821f commit 7621dad
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 53 deletions.
1 change: 1 addition & 0 deletions content/css/recess.css
Expand Up @@ -3,6 +3,7 @@ body { margin: 1em 0 0 0; }
h3 { }
thead { background-color: #eef; font-size: 1.2em; }

.light { background: #f5f5f5; }
.input-flash { background: yellow; padding: 0 0 0 1em; }

.header { background-image: url('/content/images/recess/logo.gif'); background-repeat: no-repeat; background-position: -5px -5px;}
Expand Down
4 changes: 1 addition & 3 deletions recess-config.php
Expand Up @@ -2,7 +2,7 @@

/* RECESS FRAMEWORK CONFIGURATION SETTINGS */

Config::$mode = Config::DEVELOPMENT; // Config::PRODUCTION
Config::$mode = Config::DEVELOPMENT; // or Config::PRODUCTION

// Paths to the recess and apps directories
Config::$recessDir = $_ENV['dir.documentRoot'] . 'recess/';
Expand Down Expand Up @@ -32,8 +32,6 @@
// = array( 'recess.framework.plugins.ContentCaching'
// );



//Config::$namedDataSources
// = array( 'name' => array('dsn'),
// 'name' => array('dsn','user','pass','options')
Expand Down
Expand Up @@ -17,7 +17,8 @@ public function home() {

/** !Route GET, uninstall/$appClass */
public function uninstall($appClass) {
echo $appClass; exit;
//Library::getFullyQualifiedClassName($appClass);
$this->app = new $appClass;
}

/** !Route GET, new */
Expand Down Expand Up @@ -74,6 +75,7 @@ private function generateApp() {
$this->appName = $appName;

$routesPrefix = $this->request->post['routingPrefix'];
if(substr($routesPrefix,-1) != '/') { $routesPrefix .= '/'; }
$appDir = $_ENV['dir.apps'] . $camelProgrammaticName;

$this->messages = array();
Expand Down
4 changes: 1 addition & 3 deletions recess/lib/recess/apps/tools/templates/home.template.php
Expand Up @@ -4,8 +4,6 @@
?>
<h2>Welcome!</h2>

<h2>Next Steps</h2>

<h2>Need Help?</h2>
<p class="highlight"><?php echo $flash; ?></p>

<?php include_once($viewsDir . 'common/footer.php'); ?>
45 changes: 4 additions & 41 deletions recess/lib/recess/apps/tools/views/apps/app.php
Expand Up @@ -17,8 +17,7 @@
)
); ?>"><?php echo get_class($app); ?></a></p>
<div class="span-6">
<h2 class="bottom">Models</h2>
<a href="<?php echo $controller->urlToMethod('createModel'); ?>">Create New Model</a>
<h2 class="bottom">Models (<a href="<?php echo $controller->urlToMethod('createModel'); ?>">new</a>)</h2>
<p>Location: <a href="<?php echo $codeController->urlToMethod('packageInfo', substr($app->modelsPrefix,0,-1)); ?>"><?php echo $app->modelsPrefix; ?></a></p>
<?php
function printClassesInNamespace($namespace, $codeController) {
Expand All @@ -35,8 +34,7 @@ function printClassesInNamespace($namespace, $codeController) {
?>
</div>
<div class="span-6">
<h2 class="bottom">Controllers</h2>
<a href="<?php echo $controller->urlToMethod('createController'); ?>">Create New Controller</a>
<h2 class="bottom">Controllers (<a href="<?php echo $controller->urlToMethod('createController'); ?>">new</a>)</h2>
<p>Location: <a href="<?php echo $codeController->urlToMethod('packageInfo', substr($app->controllersPrefix,0,-1)); ?>"><?php echo $app->controllersPrefix; ?></a></p>
<?php
printClassesInNamespace($app->controllersPrefix, $codeController);
Expand All @@ -54,43 +52,8 @@ function printClassesInNamespace($namespace, $codeController) {
<?php
$routes = new RoutingNode();
$app->addRoutesToRouter($routes);
$routes = $routes->getStaticPaths();

echo '<table>';
echo '<thead><td>HTTP</td><td>Route</td><td>Controller</td><td>Method</td></thead>';
echo '<tbody>';
$fullPath = $_ENV['url.base'];
if(strrpos($fullPath, '/') == strlen($fullPath) - 1) $fullPath = substr($fullPath,0,-1);
printRoutes($codeController, array_shift($routes), $fullPath);
echo '</tbody>';
echo '</table>';

function printRoutes($codeController, $routingNode, $fullPath) {
if($routingNode == null) return;
$staticPaths = $routingNode->getStaticPaths();
$parametricPaths = $routingNode->getParametricPaths();
$methods = $routingNode->getMethods();
if(!empty($methods)) {
foreach($methods as $method => $route) {
echo '<tr><td>' . $method . '</td>';
echo '<td>' . $fullPath . '</td>';
echo '<td><a href="' . $codeController->urlToMethod('classInfo',$route->class) . '">' . Library::getClassName($route->class) . '</a></td>';
echo '<td><a href="' . $codeController->urlToMethod('classInfo',$route->class) . '#method_' . $route->function . '">'. $route->function . '</a></td>';
echo '</tr>';
}
}

if(!empty($staticPaths) || !empty($parametricPaths)) {
ksort($staticPaths);
ksort($parametricPaths);
foreach($staticPaths as $path => $node) {
printRoutes($codeController, $node, $fullPath . '/' . $path);
}
foreach($parametricPaths as $path => $node) {
printRoutes($codeController, $node, $fullPath . '/$' . $path);
}
}
}
include_once($viewsDir . 'common/printRoutes.php');
printRoutes($routes, $codeController);
?>

<hr />
Expand Down
Expand Up @@ -25,7 +25,8 @@
);
</pre>

<h2>Now, have fun building <a href="<?php echo $controller->urlToMethod('app', $applicationClass); ?>"><?php echo $appName; ?></a>!</h2>
<h2><span class="highlight">Did you add that line?</span> Great! Have fun building <a href="<?php echo $controller->urlToMethod('app', $applicationClass); ?>"><?php echo $appName; ?></a>!</h2>

<?php
include_once($viewsDir . 'common/footer.php');
?>
17 changes: 17 additions & 0 deletions recess/lib/recess/apps/tools/views/apps/uninstall.php
@@ -0,0 +1,17 @@
<?php
$title = 'Uninstall';
$selectedNav = 'apps';
include_once($viewsDir . 'common/header.php');
?>
<h1>To <span class="removed">Uninstall</span> <?php echo $app->name; ?>...</h1>
<ol>
<li><span class="highlight">Open <?php echo $_ENV['dir.documentRoot']; ?>recess-config.php</span></li>
<li>Find the <span class="highlight">Config::$applications</span> array.</li>
<?php
$appClass = Library::getFullyQualifiedClassName(get_class($app));
?>
<li><span class="highlight">Remove the string '<?php echo $appClass; ?>'</span></li>
<li>[Optional] Delete the directory <?php echo $_ENV['dir.apps'] . substr($appClass,0,strpos($appClass,'.')); ?></li>
</ol>
<h2>Th-Th-Th-Th-That's all folks. <a href="<?php echo $controller->urlToMethod('home'); ?>">Head back to apps.</a></h2>
<?php include_once($viewsDir . 'common/footer.php'); ?>
5 changes: 3 additions & 2 deletions recess/lib/recess/apps/tools/views/common/header.php
Expand Up @@ -7,8 +7,9 @@
'Because it\'s no fun playing hide-and-seek alone.',
'Because it\'s no fun finding booty without a treasure map.',
'Because it\'s no fun fighting evil without a sling shot.',
'Because it\'s no fun being chased by girls without a cooties shot.'
);
'Because it\'s no fun being chased by girls without a cooties shot.',
'Because it\'s no fun playing slip \'n slide without a hose.'
);
?>

<html>
Expand Down
46 changes: 46 additions & 0 deletions recess/lib/recess/apps/tools/views/common/printRoutes.php
@@ -0,0 +1,46 @@
<?php
function printRoutes($routes, $codeController) {
echo '<table>';
echo '<thead><td>HTTP</td><td>Route</td><td>Controller</td><td>Method</td></thead>';
echo '<tbody>';
$fullPath = $_ENV['url.base'];
if(strrpos($fullPath, '/') == strlen($fullPath) - 1) $fullPath = substr($fullPath,0,-1);
printRoutesRecursive($codeController, $routes, $fullPath);
echo '</tbody>';
echo '</table>';
}

function printRoutesRecursive($codeController, $routingNode, $fullPath) {
static $i = 0;
if($routingNode == null) return;
$staticPaths = $routingNode->getStaticPaths();
$parametricPaths = $routingNode->getParametricPaths();
$methods = $routingNode->getMethods();
if(!empty($methods)) {
foreach($methods as $method => $route) {
$i++;
if($i % 2 == 0) {
echo '<tr class="light">';
} else {
echo '<tr>';
}
echo '<td>' . $method . '</td>';
echo '<td>' . $fullPath . '</td>';
echo '<td><a href="' . $codeController->urlToMethod('classInfo',$route->class) . '">' . Library::getClassName($route->class) . '</a></td>';
echo '<td><a href="' . $codeController->urlToMethod('classInfo',$route->class) . '#method_' . $route->function . '">'. $route->function . '</a></td>';
echo '</tr>';
}
}

if(!empty($staticPaths) || !empty($parametricPaths)) {
ksort($staticPaths);
ksort($parametricPaths);
foreach($staticPaths as $path => $node) {
printRoutesRecursive($codeController, $node, $fullPath . '/' . $path);
}
foreach($parametricPaths as $path => $node) {
printRoutesRecursive($codeController, $node, $fullPath . '/$' . $path);
}
}
}
?>
9 changes: 8 additions & 1 deletion recess/lib/recess/apps/tools/views/routes/home.php
Expand Up @@ -3,7 +3,14 @@
$selectedNav = 'routes';
include_once($viewsDir . 'common/header.php');
?>
<h2 class="bottom">Routes</h2>
<?php
include_once($viewsDir . 'common/printRoutes.php');
$routes = Config::getRouter();

<h1>Routes Browser</h1>
Library::import('recess.apps.tools.controllers.RecessToolsCodeController');
$codeController = new RecessToolsCodeController($response->request->meta->app);

printRoutes($routes, $codeController);
?>
<?php include_once($viewsDir . 'common/footer.php'); ?>
8 changes: 7 additions & 1 deletion recess/lib/recess/framework/routing/RoutingNode.class.php
Expand Up @@ -42,10 +42,16 @@ class RoutingNode {
public function addRoute($app, Route $route, $prefix) {
if($route->path == '') return;

$route = clone $route;

$route->app = $app;

if($route->path[0] != '/') {
$route->path = $prefix . '/' . trim($route->path);
if(substr($route->path,-1) != '/') {
$route->path = $prefix . '/' . trim($route->path);
}else{
$route->path = $prefix . trim($route->path);
}
}

$pathParts = $this->getRevesedPathParts($route->path);
Expand Down
Binary file modified recess/sqlite/default.db
Binary file not shown.

0 comments on commit 7621dad

Please sign in to comment.