From aa3d9b8fe2ab87454599024718ec7b266d35f4e9 Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Tue, 24 Apr 2012 14:58:31 +0100 Subject: [PATCH] Create info pages --- hosting-app/routes/index.js | 3 ++ hosting-app/routes/info.js | 20 +++++++++++++ hosting-app/views/info/layout.jade | 3 ++ hosting-app/views/info/privacy.jade | 8 +++++ hosting-app/views/layout.jade | 2 +- tests/hosting-app-info-pages.js | 46 +++++++++++++++++++++++++++++ 6 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 hosting-app/routes/info.js create mode 100644 hosting-app/views/info/layout.jade create mode 100644 hosting-app/views/info/privacy.jade create mode 100644 tests/hosting-app-info-pages.js diff --git a/hosting-app/routes/index.js b/hosting-app/routes/index.js index 723f49e4..3fa84846 100644 --- a/hosting-app/routes/index.js +++ b/hosting-app/routes/index.js @@ -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()); diff --git a/hosting-app/routes/info.js b/hosting-app/routes/info.js new file mode 100644 index 00000000..096c60c3 --- /dev/null +++ b/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()); + } + }); + + }); +}; + + diff --git a/hosting-app/views/info/layout.jade b/hosting-app/views/info/layout.jade new file mode 100644 index 00000000..8fe4416c --- /dev/null +++ b/hosting-app/views/info/layout.jade @@ -0,0 +1,3 @@ +extends ../layout + +// info page specific layout changes can go here \ No newline at end of file diff --git a/hosting-app/views/info/privacy.jade b/hosting-app/views/info/privacy.jade new file mode 100644 index 00000000..6edf024c --- /dev/null +++ b/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 \ No newline at end of file diff --git a/hosting-app/views/layout.jade b/hosting-app/views/layout.jade index d460bca5..5d296a11 100644 --- a/hosting-app/views/layout.jade +++ b/hosting-app/views/layout.jade @@ -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. diff --git a/tests/hosting-app-info-pages.js b/tests/hosting-app-info-pages.js new file mode 100644 index 00000000..16d53934 --- /dev/null +++ b/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(); + }); + }, + +}; +