Browse files

Fix to template view override

  • Loading branch information...
1 parent f8c999f commit 9db1749d01ce6c7f74a67fd3a4b4464e8dae1851 @cliftonc committed Nov 19, 2011
Showing with 7 additions and 182 deletions.
  1. +7 −2 modules/core/content/content.js
  2. +0 −180 test/sanity.test.js
View
9 modules/core/content/content.js
@@ -750,12 +750,17 @@ function showContent(req,res,template,block,next,err,content,format) {
// Set the page layout to the content type
if(format === "html") {
if(content) {
+
// Change the layout
res.layout = content.layout ? content.layout : "default";
+
// Override of the template
- template = calipso.theme.cache.contentTypes[content.contentType].view || template;
+ template = calipso.theme.cache.contentTypes[content.contentType] ? calipso.theme.cache.contentTypes[content.contentType].view : template;
+
}
+
calipso.theme.renderItem(req,res,template,block,{content:content.toObject()},next);
+
}
if(format === "json") {
@@ -875,7 +880,7 @@ function getContentList(query,out,next) {
// Render the item into the response
if(out.format === 'html') {
-
+
var table = {id:'content-list',sort:true,cls:'table-admin',
columns:[{name:'_id',sort:'title',label:'Title',fn:contentLink},
{name:'contentType',label:'Type'},
View
180 test/sanity.test.js
@@ -1,180 +0,0 @@
-/**
- * Sanity test
- * Test must be executed serially as it runs
- * against an app instance, this is typically executed by the make file
- **/
-var assert = require('assert'),
- mongoose = require('mongoose'),
- should = require('should'),
- path = require('path'),
- rootpath = process.cwd() + '/';
-
-/**
- * Simple sanity tests to make sure that calipso will run.
- */
-var adminCookie;
-
-/**
- * Initialise server
- */
-require('../app').boot(function(server) {
-
- app = server;
-
- exports['Get the home page and confirm a 200'] = function(done) {
- assert.response(app, {
- url: '/',
- method: 'GET'
- }, function(res) {
- res.statusCode.should.equal(200);
- done();
- });
- };
-
- exports['Get an invalid page as an anonymous user and get a 404'] = function(done) {
- assert.response(app, {
- url: '/this-is-an-invalid-page.html',
- method: 'GET'
- }, function(res) {
- res.statusCode.should.equal(404);
- done();
- });
- };
-
- exports['Logging in as an invalid user will flash an error and redirect me back to the home page'] = function(done) {
- var data = 'user[username]=invalid&user[password]=login';
- assert.response(app, {
- url: '/user/login',
- method: 'POST',
- headers: {
- 'host': 'dummyhost',
- 'Content-Length': data.length,
- 'Content-Type': 'application/x-www-form-urlencoded'
- },
- data: data
- }, function(res) {
- res.statusCode.should.equal(302);
- res.headers['location'].should.equal('http://dummyhost/');
- done();
- });
- };
-
- exports['I can login to calipso as the default administrator and it will redirect me back to the home page'] = function(done) {
- var data = 'user[username]=admin&user[password]=password';
- assert.response(app, {
- url: '/user/login',
- method: 'POST',
- headers: {
- 'host': 'dummyhost',
- 'Content-Length': data.length,
- 'Content-Type': 'application/x-www-form-urlencoded'
- },
- data: data
- }, function(res) {
- adminCookie = res.headers['set-cookie'];
- res.statusCode.should.equal(302);
- res.headers['location'].should.equal('http://dummyhost/');
- done();
- });
- };
-
- exports['Get an invalid page as an admin user and get a 302 to create a new page'] = function(done) {
- var url = 'this-is-an-invalid-page';
- assert.response(app, {
- url: '/' + url + '.html',
- method: 'GET',
- headers: {
- 'host': 'dummyhost',
- 'Cookie': adminCookie
- }
- }, function(res) {
- res.statusCode.should.equal(302);
- res.headers['location'].should.equal('http://dummyhost/content/new?alias=' + url + '&type=Article');
- done();
- });
- };
-
- exports['My profile page is valid and contains the user name'] = function(done) {
- assert.response(app, {
- url: '/user',
- method: 'GET',
- headers: {
- 'host': 'dummyhost',
- 'Cookie': adminCookie
- }
- }, function(res) {
- res.statusCode.should.equal(200);
- res.body.should.include.string('admin');
- done();
- });
- };
-
- exports['The admin page renders and contains the default modules are enabled'] = function(done) {
- var request = {
- method: 'GET',
- headers: {
- 'host': 'dummyhost',
- 'Cookie': adminCookie
- }
- };
- request.url = '/admin/core/config';
- assert.response(app, request, function(res) {
- res.statusCode.should.equal(200);
- res.body.should.include.string('Modules');
- done();
- });
-
- };
-
- exports['The content admin page renders'] = function(done) {
- var request = {
- method: 'GET',
- headers: {
- 'host': 'dummyhost',
- 'Cookie': adminCookie
- }
- };
- request.url = "/content";
- assert.response(app, request, function(res) {
- res.statusCode.should.equal(200);
- done();
- });
- };
-
-
- exports['The content types page renders'] = function(done) {
- var request = {
- method: 'GET',
- headers: {
- 'host': 'dummyhost',
- 'Cookie': adminCookie
- }
- };
- request.url = "/content/type";
- assert.response(app, request, function(res) {
- res.statusCode.should.equal(200);
- res.body.should.include.string('Article'); // Default content type
- done();
- });
- };
-
- // Ok, now lets test the modules
- calipso = require(path.join(rootpath, 'lib/calipso'));
-
- // Login as some modules may require admin access
- for(var module in calipso.modules) {
-
- var moduleName = calipso.modules[module].name;
- var modulePath = __dirname + "/../" + calipso.modules[module].path;
- var moduleTests = modulePath + "/test";
-
- // TODO ... launch or run, or integrate?
-
- };
-
- exports.tearDown = function(done) {
- mongoose.disconnect();
- done(process.exit());
- }
-
-});

0 comments on commit 9db1749

Please sign in to comment.