Skip to content
This repository has been archived by the owner on Mar 8, 2018. It is now read-only.

Commit

Permalink
Create info pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Edmund von der Burg committed Apr 24, 2012
1 parent 0a19f48 commit aa3d9b8
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 1 deletion.
3 changes: 3 additions & 0 deletions hosting-app/routes/index.js
Expand Up @@ -213,6 +213,9 @@ exports.route = function (app) {

});


require('./info').route(app);

// Throw a 404 error
app.all('/*', function(req, res, next) {
next(new Error404());
Expand Down
20 changes: 20 additions & 0 deletions hosting-app/routes/info.js
@@ -0,0 +1,20 @@
var path = require('path'),
Error404 = require('../../lib/errors').Error404;

exports.route = function (app) {
app.get('/info/:page', function(req, res, next){

var template_file = req.app.set('views') + '/info/' + req.param('page') + '.jade';

path.exists(template_file, function (exists) {
if (exists) {
res.render( 'info/' + req.param('page') );
} else {
next(new Error404());
}
});

});
};


3 changes: 3 additions & 0 deletions hosting-app/views/info/layout.jade
@@ -0,0 +1,3 @@
extends ../layout

// info page specific layout changes can go here
8 changes: 8 additions & 0 deletions hosting-app/views/info/privacy.jade
@@ -0,0 +1,8 @@
extend layout

block title
| Privacy

block content
h1 Privacy
p FIXME: privacy text goes here
2 changes: 1 addition & 1 deletion hosting-app/views/layout.jade
Expand Up @@ -71,7 +71,7 @@ body#popit-united_kingdom.brand_page
li
a(href='/FIXME') Self Hosting
li
a(href='/FIXME') Terms & Privacy Policy
a(href='/info/privacy') Terms & Privacy Policy
#about-mysociety
p
| PopIt is a project from mySociety, a charitable project which builds websites that give people simple, tangible benefits in the civic and community, and teaches through demonstration, how to use the internet most efficiently to improve lives.
Expand Down
46 changes: 46 additions & 0 deletions tests/hosting-app-info-pages.js
@@ -0,0 +1,46 @@
// switch to testing mode
process.env.NODE_ENV = 'testing';

var utils = require('../lib/utils'),
selenium_helpers = require('../lib/testing/selenium'),
config = require('config'),
async = require('async');



module.exports = {

setUp: function (setUp_done) {

utils.delete_all_testing_databases( function () {
selenium_helpers.start_servers( function () {
setUp_done();
});
});
},

tearDown: function (tearDown_done) {
selenium_helpers.stop_servers(tearDown_done);
},

"Check info pages": function (test) {

var browser = selenium_helpers.new_hosting_browser();

test.expect(2);

browser
.open('/info/does_not_exist')
.assertTextPresent('Page not found')
.open('/info/privacy')
.assertTextPresent('privacy text goes here')
.testComplete()
.end(function (err) {
test.ifError(err);
test.ok(true, "end of tests");
test.done();
});
},

};

0 comments on commit aa3d9b8

Please sign in to comment.