Skip to content

Commit

Permalink
Changed extension for 'html' format views to '.html.php'. Added 'xhtm…
Browse files Browse the repository at this point in the history
…l' format separate from 'html'.
  • Loading branch information
KrisJordan committed Jul 8, 2009
1 parent ab78977 commit aa72313
Show file tree
Hide file tree
Showing 29 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion recess/recess/Recess.class.php
Expand Up @@ -44,7 +44,7 @@ public static function main(Request $request, IPolicy $policy, array $apps, RtNo
if(isset($response->context)) {
$forwardRequest->get = $response->context;
}

$forwardRequest->accepts = $response->request->accepts;
$forwardRequest->cookies = $response->request->cookies;
$forwardRequest->username = $response->request->username;
$forwardRequest->password = $response->request->password;
Expand Down
Expand Up @@ -96,7 +96,7 @@ private function generateApp() {
$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('Home Template', $this->application->codeTemplatesDir . 'scaffolding/views/home/index.template.php', $appDir . '/views/home/index.html.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');
Expand Down Expand Up @@ -345,10 +345,10 @@ 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/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('index view', $this->application->codeTemplatesDir . 'scaffolding/views/resource/index.template.php', $viewsDir . 'index.html.php', $replacements);
$this->messages[] = $this->tryGeneratingFile('editForm view', $this->application->codeTemplatesDir . 'scaffolding/views/resource/editForm.template.php', $viewsDir . 'editForm.html.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);
$this->messages[] = $this->tryGeneratingFile('static details', $this->application->codeTemplatesDir . 'scaffolding/views/resource/details.template.php', $viewsDir . 'details.php', $replacements);
$this->messages[] = $this->tryGeneratingFile('static details', $this->application->codeTemplatesDir . 'scaffolding/views/resource/details.template.php', $viewsDir . 'details.html.php', $replacements);
$this->messages[] = $this->tryGeneratingFile('details part', $this->application->codeTemplatesDir . 'scaffolding/views/resource/details.part.template.php', $viewsDir . 'details.part.php', $replacements);
$this->appName = get_class($app);
$this->modelName = $model;
Expand Down
File renamed without changes.
Expand Up @@ -7,14 +7,13 @@
<?php foreach($sources as $name => $source): ?>
<h2 class="bottom"><?php echo $name; ?> (<?php echo $sourceInfo[$name]['driver']; ?>)</h2>
<div style="margin: 0 0 0 2em">
<p>DSN: <?php echo $sourceInfo[$name]['dsn']; ?>
<p>DSN: <?php echo $sourceInfo[$name]['dsn']; ?></p>
<h3 class="bottom">Tables:</h3>
<ul style="font-size: 1.8em">
<?php foreach($sourceInfo[$name]['tables'] as $table): ?>
<li><a href="<?php echo $controller->urlTo('showTable',$name,$table); ?>"><?php echo $table; ?></a></li>
<?php endforeach; ?>
</ul>
</p>
</div>
<hr />
<?php endforeach; ?>
Expand Down
13 changes: 8 additions & 5 deletions recess/recess/framework/views/NativeView.class.php
Expand Up @@ -4,24 +4,27 @@
class NativeView extends AbstractView {
protected function getTemplateFor($response) {
$format = $response->request->accepts->format();
if($format == 'html' || $format == '') {
$extension = '.php';
} else {

if(is_string($format)) {
$extension = ".$format.php";
} else {
$extension = '.php';
}

$template =
$response->meta->app->getViewsDir()
. $response->meta->viewsPrefix
. $response->meta->viewName
. $extension;

return $template;
}

public function canRespondWith(Response $response) {
// TODO: Cache in production mode
return file_exists($this->getTemplateFor($response));
}

protected function render(Response $response) {
$context = $response->data;
$context['viewsDir'] = $response->meta->app->getViewsDir();
Expand Down
3 changes: 2 additions & 1 deletion recess/recess/http/MimeTypes.class.php
Expand Up @@ -8,7 +8,8 @@ static function init() {
// TODO: Cache the MIME Type Data Structure
MimeTypes::registerMany(
array(
array('html', array('text/html', 'application/xhtml+xml')),
array('html', 'text/html'),
array('xhtml', 'application/xhtml+xml'),
array('xml', array('application/xml', 'text/xml', 'application/x-xml')),
array('json', array('application/json', 'text/x-json','application/jsonrequest')),
array('js', array('text/javascript', 'application/javascript', 'application/x-javascript')),
Expand Down
2 changes: 2 additions & 0 deletions recess/recess/http/Request.class.php
Expand Up @@ -65,6 +65,8 @@ public function data($name) {
return $this->put[$name];
} else if (isset($this->get[$name])) {
return $this->get[$name];
} else {
return '';
}
}
}
Expand Down

0 comments on commit aa72313

Please sign in to comment.