From 55d44685e94127596601be17714b428d2609745e Mon Sep 17 00:00:00 2001 From: Rowan Manning Date: Fri, 15 Nov 2013 15:58:49 +0000 Subject: [PATCH] Disable search engine indexing by default --- README.md | 3 +++ app.js | 12 +++++++++++- config/development.sample.json | 3 ++- config/production.sample.json | 3 ++- view/layout/default.html | 2 ++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3fb9a92..ae36a45 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,9 @@ The boot configurations for pa11y-dashboard are as follows. Look at the sample J ### port *(number)* The port to run the application on. +### noindex +*(boolean)* If set to `true` (default), the dashboard will not be indexed by search engines. Set to `false` to allow indexing. + Development ----------- diff --git a/app.js b/app.js index e3b7535..004178c 100644 --- a/app.js +++ b/app.js @@ -11,6 +11,7 @@ module.exports = initApp; // Initialise the application function initApp (config, callback) { + config = defaultConfig(config); var app = new EventEmitter(); app.address = null; @@ -51,7 +52,8 @@ function initApp (config, callback) { year: (new Date()).getFullYear(), version: pkg.version, repo: pkg.homepage, - bugtracker: pkg.bugs + bugtracker: pkg.bugs, + noindex: config.noindex }); app.express.use(function (req, res, next) { res.locals.isHomePage = (req.path === '/'); @@ -93,3 +95,11 @@ function initApp (config, callback) { }); } + +// Get default configurations +function defaultConfig (config) { + if (typeof config.noindex !== 'boolean') { + config.noindex = true; + } + return config; +} diff --git a/config/development.sample.json b/config/development.sample.json index d4d8316..14a708c 100644 --- a/config/development.sample.json +++ b/config/development.sample.json @@ -1,4 +1,5 @@ { "webservice": "http://localhost:3000/", - "port": 4000 + "port": 4000, + "noindex": true } \ No newline at end of file diff --git a/config/production.sample.json b/config/production.sample.json index d4d8316..14a708c 100644 --- a/config/production.sample.json +++ b/config/production.sample.json @@ -1,4 +1,5 @@ { "webservice": "http://localhost:3000/", - "port": 4000 + "port": 4000, + "noindex": true } \ No newline at end of file diff --git a/view/layout/default.html b/view/layout/default.html index dbfa400..e5a3505 100644 --- a/view/layout/default.html +++ b/view/layout/default.html @@ -9,6 +9,8 @@ {{block "title"}} + {{#if noindex}}{{/if}} +