diff --git a/Gruntfile.js b/Gruntfile.js index aeb8a6e8f..8c50ce4a1 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -17,7 +17,10 @@ module.exports = function (grunt) { 'public/stylesheets/prism.css': 'public/sass/prism.scss', }, options: { - includePaths: ['govuk_modules/public/sass'], + includePaths: [ + 'govuk_modules/govuk_template/assets/stylesheets', + 'govuk_modules/govuk_frontend_toolkit/stylesheets' + ], outputStyle: 'expanded', imagePath: '../images' } @@ -26,47 +29,28 @@ module.exports = function (grunt) { // Copies templates and assets from external modules and dirs copy: { - - govuk_template: { - src: 'node_modules/govuk_template_mustache/views/layouts/govuk_template.html', - dest: 'govuk_modules/views/', - expand: true, - flatten: true, - filter: 'isFile' - }, - - govuk_assets: { - files: [ - { - expand: true, - src: '**', - cwd: 'node_modules/govuk_template_mustache/assets', - dest: 'govuk_modules/public/' - } - ] - }, - - govuk_frontend_toolkit_scss: { - expand: true, - src: '**', - cwd: 'node_modules/govuk_frontend_toolkit/stylesheets/', - dest: 'govuk_modules/public/sass/' - }, - - govuk_frontend_toolkit_js: { - expand: true, - src: '**', - cwd: 'node_modules/govuk_frontend_toolkit/javascripts/', - dest: 'govuk_modules/public/javascripts/' + assets: { + files: [{ + expand: true, + cwd: 'app/assets/', + src: ['**/*', '!sass/**'], + dest: 'public/' + }] }, - - govuk_frontend_toolkit_img: { - expand: true, - src: '**', - cwd: 'node_modules/govuk_frontend_toolkit/images/', - dest: 'govuk_modules/public/images/' + govuk: { + files: [{ + expand: true, + cwd: 'node_modules/govuk_frontend_toolkit/', + src: '**', + dest: 'govuk_modules/govuk_frontend_toolkit/' + }, + { + expand: true, + cwd: 'node_modules/govuk_template_mustache/', + src: '**', + dest: 'govuk_modules/govuk_template/' + }] }, - }, // workaround for libsass @@ -93,7 +77,7 @@ module.exports = function (grunt) { // nodemon watches for changes and restarts app nodemon: { dev: { - script: 'app.js', + script: 'server.js', options: { ext: 'html, js' } @@ -145,12 +129,8 @@ module.exports = function (grunt) { ); grunt.registerTask('default', [ - 'copy:govuk_template', - 'copy:govuk_assets', + 'copy', 'convert_template', - 'copy:govuk_frontend_toolkit_scss', - 'copy:govuk_frontend_toolkit_js', - 'copy:govuk_frontend_toolkit_img', 'replace', 'sass', 'concurrent:target' @@ -160,12 +140,8 @@ module.exports = function (grunt) { 'test_default', 'Test that the default task runs the app', [ - 'copy:govuk_template', - 'copy:govuk_assets', + 'copy', 'convert_template', - 'copy:govuk_frontend_toolkit_scss', - 'copy:govuk_frontend_toolkit_js', - 'copy:govuk_frontend_toolkit_img', 'replace', 'sass' ] diff --git a/routes.js b/app/routes.js similarity index 72% rename from routes.js rename to app/routes.js index ce9392397..9f9a0b276 100755 --- a/routes.js +++ b/app/routes.js @@ -13,7 +13,7 @@ module.exports = { // Layout app.get('/layout', function (req, res) { var page_name = "Layout"; - res.render('guide_layout', {'assetPath' : assetPath, 'page_name' : page_name }); + res.render('guide_layout', { 'page_name' : page_name }); }); // Example page: Grid layout @@ -21,7 +21,7 @@ module.exports = { var section = "layout"; var section_name = "Layout"; var page_name = "Example: Grid layout"; - res.render('examples/example_grid_layout', {'assetPath' : assetPath, 'section': section, 'section_name' : section_name, 'page_name' : page_name }); + res.render('examples/example_grid_layout', { 'section': section, 'section_name' : section_name, 'page_name' : page_name }); }); // Redirect examples from /examples/ to /section/example-name-of-example @@ -32,7 +32,7 @@ module.exports = { // Typography app.get('/typography', function (req, res) { var page_name = "Typography"; - res.render('guide_typography', {'assetPath' : assetPath, 'page_name' : page_name }); + res.render('guide_typography', { 'page_name' : page_name }); }); // Example page: Typography @@ -40,7 +40,7 @@ module.exports = { var section = "typography"; var section_name = "Typography"; var page_name = "Example: Typography"; - res.render('examples/example_typography', {'assetPath' : assetPath, 'section': section, 'section_name' : section_name, 'page_name' : page_name }); + res.render('examples/example_typography', { 'section': section, 'section_name' : section_name, 'page_name' : page_name }); }); // Redirect examples from /examples/ to /section/example-name-of-example @@ -53,7 +53,7 @@ module.exports = { var section = "typography"; var section_name = "Typography"; var page_name = "Example: Details summary"; - res.render('examples/example_details_summary', {'assetPath' : assetPath, 'section': section, 'section_name' : section_name, 'page_name' : page_name }); + res.render('examples/example_details_summary', { 'section': section, 'section_name' : section_name, 'page_name' : page_name }); }); // Redirect examples from /patterns/ to /section/example-name-of-example @@ -64,13 +64,13 @@ module.exports = { // Colour app.get('/colour', function (req, res) { var page_name = "Colour"; - res.render('guide_colour', {'assetPath' : assetPath, 'page_name' : page_name }); + res.render('guide_colour', { 'page_name' : page_name }); }); // Icons and images app.get('/icons-images', function (req, res) { var page_name = "Icons and images"; - res.render('guide_icons_images', {'assetPath' : assetPath, 'page_name' : page_name }); + res.render('guide_icons_images', { 'page_name' : page_name }); }); // Example page: Icons @@ -78,25 +78,25 @@ module.exports = { var section = "icons-images"; var section_name = "Icons and images"; var page_name = "Example: Icons"; - res.render('examples/example_icons', {'assetPath' : assetPath, 'section': section, 'section_name' : section_name, 'page_name' : page_name }); + res.render('examples/example_icons', { 'section': section, 'section_name' : section_name, 'page_name' : page_name }); }); // Data app.get('/data', function (req, res) { var page_name = "Data"; - res.render('guide_data', {'assetPath' : assetPath, 'page_name' : page_name }); + res.render('guide_data', { 'page_name' : page_name }); }); // Buttons app.get('/buttons', function (req, res) { var page_name = "Buttons"; - res.render('guide_buttons', {'assetPath' : assetPath, 'page_name' : page_name }); + res.render('guide_buttons', { 'page_name' : page_name }); }); // Forms app.get('/form-elements', function (req, res) { var page_name = "Form elements"; - res.render('guide_form_elements', {'assetPath' : assetPath, 'page_name' : page_name }); + res.render('guide_form_elements', { 'page_name' : page_name }); }); // Example page: Basic form @@ -104,7 +104,7 @@ module.exports = { var section = "form-elements"; var section_name = "Form elements"; var page_name = "Example: Form"; - res.render('examples/example_forms', {'assetPath' : assetPath, 'section': section, 'section_name' : section_name, 'page_name' : page_name }); + res.render('examples/example_forms', { 'section': section, 'section_name' : section_name, 'page_name' : page_name }); }); // Redirect examples from /examples/ to /section/example-name-of-example @@ -117,7 +117,7 @@ module.exports = { var section = "form-elements"; var section_name = "Form elements"; var page_name = "Example: Date"; - res.render('examples/example_date', {'assetPath' : assetPath, 'section': section, 'section_name' : section_name, 'page_name' : page_name }); + res.render('examples/example_date', { 'section': section, 'section_name' : section_name, 'page_name' : page_name }); }); // Redirect examples from /patterns/ to /section/example-name-of-example @@ -130,7 +130,7 @@ module.exports = { var section = "form-elements"; var section_name = "Form elements"; var page_name = "Example: Radio buttons and checkboxes"; - res.render('examples/example_radios_checkboxes', {'assetPath' : assetPath, 'section': section, 'section_name' : section_name, 'page_name' : page_name }); + res.render('examples/example_radios_checkboxes', { 'section': section, 'section_name' : section_name, 'page_name' : page_name }); }); // Redirect examples from /patterns/ to /section/example-name-of-example @@ -143,13 +143,13 @@ module.exports = { var section = "form-elements"; var section_name = "Form elements"; var page_name = "Example: Form elements"; - res.render('examples/example_form_elements', {'assetPath' : assetPath, 'section': section, 'section_name' : section_name, 'page_name' : page_name }); + res.render('examples/example_form_elements', { 'section': section, 'section_name' : section_name, 'page_name' : page_name }); }); // Errors and validation app.get('/errors', function (req, res) { var page_name = "Errors and validation"; - res.render('guide_errors', {'assetPath' : assetPath, 'page_name' : page_name }); + res.render('guide_errors', { 'page_name' : page_name }); }); // Example page: Form validation @@ -157,7 +157,7 @@ module.exports = { var section = "errors"; var section_name = "Errors and validation"; var page_name = "Example: Form validation - single question"; - res.render('examples/example_form_validation_single_question_radio', {'assetPath' : assetPath, 'section': section, 'section_name' : section_name, 'page_name' : page_name }); + res.render('examples/example_form_validation_single_question_radio', { 'section': section, 'section_name' : section_name, 'page_name' : page_name }); }); app.post('/errors/example-form-validation-single-question-radio', function (req, res) { @@ -171,7 +171,7 @@ module.exports = { } else { error = false; } - res.render('examples/example_form_validation_single_question_radio', {'assetPath' : assetPath, 'section': section, 'section_name' : section_name, 'page_name' : page_name, 'personal_details': personal_details, 'error': error}); + res.render('examples/example_form_validation_single_question_radio', { 'section': section, 'section_name' : section_name, 'page_name' : page_name, 'personal_details': personal_details, 'error': error}); }); // Redirect examples from /examples/ to /section/example-name-of-example @@ -183,7 +183,7 @@ module.exports = { var section = "errors"; var section_name = "Errors and validation"; var page_name = "Example: Form validation - multiple questions"; - res.render('examples/example_form_validation_multiple_questions', {'assetPath' : assetPath, 'section': section, 'section_name' : section_name, 'page_name' : page_name }); + res.render('examples/example_form_validation_multiple_questions', { 'section': section, 'section_name' : section_name, 'page_name' : page_name }); }); app.post('/errors/example-form-validation-multiple-questions', function (req, res) { @@ -198,7 +198,7 @@ module.exports = { } else { error = false; } - res.render('examples/example_form_validation_multiple_questions', {'assetPath' : assetPath, 'section': section, 'section_name' : section_name, 'page_name' : page_name, 'fullName': fullName, 'niNo': niNo, 'error': error}); + res.render('examples/example_form_validation_multiple_questions', { 'section': section, 'section_name' : section_name, 'page_name' : page_name, 'fullName': fullName, 'niNo': niNo, 'error': error}); }); // Redirect examples from /examples/ to /section/example-name-of-example @@ -209,7 +209,7 @@ module.exports = { // Alpha and beta banners app.get('/alpha-beta-banners', function (req, res) { var page_name = "Alpha and beta banners"; - res.render('guide_alpha_beta', {'assetPath' : assetPath, 'page_name' : page_name }); + res.render('guide_alpha_beta', { 'page_name' : page_name }); }); } diff --git a/views/examples/example_date.html b/app/views/examples/example_date.html similarity index 100% rename from views/examples/example_date.html rename to app/views/examples/example_date.html diff --git a/views/examples/example_details_summary.html b/app/views/examples/example_details_summary.html similarity index 100% rename from views/examples/example_details_summary.html rename to app/views/examples/example_details_summary.html diff --git a/views/examples/example_form_elements.html b/app/views/examples/example_form_elements.html similarity index 100% rename from views/examples/example_form_elements.html rename to app/views/examples/example_form_elements.html diff --git a/views/examples/example_form_validation_multiple_questions.html b/app/views/examples/example_form_validation_multiple_questions.html similarity index 100% rename from views/examples/example_form_validation_multiple_questions.html rename to app/views/examples/example_form_validation_multiple_questions.html diff --git a/views/examples/example_form_validation_single_question_radio.html b/app/views/examples/example_form_validation_single_question_radio.html similarity index 100% rename from views/examples/example_form_validation_single_question_radio.html rename to app/views/examples/example_form_validation_single_question_radio.html diff --git a/views/examples/example_grid_layout.html b/app/views/examples/example_grid_layout.html similarity index 100% rename from views/examples/example_grid_layout.html rename to app/views/examples/example_grid_layout.html diff --git a/views/examples/example_icons.html b/app/views/examples/example_icons.html similarity index 100% rename from views/examples/example_icons.html rename to app/views/examples/example_icons.html diff --git a/views/examples/example_radios_checkboxes.html b/app/views/examples/example_radios_checkboxes.html similarity index 100% rename from views/examples/example_radios_checkboxes.html rename to app/views/examples/example_radios_checkboxes.html diff --git a/views/examples/example_typography.html b/app/views/examples/example_typography.html similarity index 100% rename from views/examples/example_typography.html rename to app/views/examples/example_typography.html diff --git a/views/guide_alpha_beta.html b/app/views/guide_alpha_beta.html similarity index 100% rename from views/guide_alpha_beta.html rename to app/views/guide_alpha_beta.html diff --git a/views/guide_buttons.html b/app/views/guide_buttons.html similarity index 100% rename from views/guide_buttons.html rename to app/views/guide_buttons.html diff --git a/views/guide_colour.html b/app/views/guide_colour.html similarity index 100% rename from views/guide_colour.html rename to app/views/guide_colour.html diff --git a/views/guide_data.html b/app/views/guide_data.html similarity index 100% rename from views/guide_data.html rename to app/views/guide_data.html diff --git a/views/guide_errors.html b/app/views/guide_errors.html similarity index 100% rename from views/guide_errors.html rename to app/views/guide_errors.html diff --git a/views/guide_form_elements.html b/app/views/guide_form_elements.html similarity index 100% rename from views/guide_form_elements.html rename to app/views/guide_form_elements.html diff --git a/views/guide_icons_images.html b/app/views/guide_icons_images.html similarity index 100% rename from views/guide_icons_images.html rename to app/views/guide_icons_images.html diff --git a/views/guide_layout.html b/app/views/guide_layout.html similarity index 100% rename from views/guide_layout.html rename to app/views/guide_layout.html diff --git a/views/guide_typography.html b/app/views/guide_typography.html similarity index 100% rename from views/guide_typography.html rename to app/views/guide_typography.html diff --git a/views/includes/breadcrumb.html b/app/views/includes/breadcrumb.html similarity index 100% rename from views/includes/breadcrumb.html rename to app/views/includes/breadcrumb.html diff --git a/views/includes/elements_head.html b/app/views/includes/elements_head.html similarity index 100% rename from views/includes/elements_head.html rename to app/views/includes/elements_head.html diff --git a/views/includes/elements_tracking.html b/app/views/includes/elements_tracking.html similarity index 100% rename from views/includes/elements_tracking.html rename to app/views/includes/elements_tracking.html diff --git a/views/includes/head.html b/app/views/includes/head.html similarity index 100% rename from views/includes/head.html rename to app/views/includes/head.html diff --git a/views/includes/phase_banner.html b/app/views/includes/phase_banner.html similarity index 100% rename from views/includes/phase_banner.html rename to app/views/includes/phase_banner.html diff --git a/views/includes/propositional_navigation.html b/app/views/includes/propositional_navigation.html similarity index 100% rename from views/includes/propositional_navigation.html rename to app/views/includes/propositional_navigation.html diff --git a/views/includes/scripts.html b/app/views/includes/scripts.html similarity index 100% rename from views/includes/scripts.html rename to app/views/includes/scripts.html diff --git a/views/includes/service_manual_breadcrumb.html b/app/views/includes/service_manual_breadcrumb.html similarity index 100% rename from views/includes/service_manual_breadcrumb.html rename to app/views/includes/service_manual_breadcrumb.html diff --git a/views/includes/service_manual_navigation.html b/app/views/includes/service_manual_navigation.html similarity index 100% rename from views/includes/service_manual_navigation.html rename to app/views/includes/service_manual_navigation.html diff --git a/views/includes/snippets_head.html b/app/views/includes/snippets_head.html similarity index 100% rename from views/includes/snippets_head.html rename to app/views/includes/snippets_head.html diff --git a/views/includes/snippets_scripts.html b/app/views/includes/snippets_scripts.html similarity index 100% rename from views/includes/snippets_scripts.html rename to app/views/includes/snippets_scripts.html diff --git a/views/index.html b/app/views/index.html similarity index 100% rename from views/index.html rename to app/views/index.html diff --git a/views/layout.html b/app/views/layout.html similarity index 100% rename from views/layout.html rename to app/views/layout.html diff --git a/views/layout_example.html b/app/views/layout_example.html similarity index 100% rename from views/layout_example.html rename to app/views/layout_example.html diff --git a/views/snippets/buttons_button.html b/app/views/snippets/buttons_button.html similarity index 100% rename from views/snippets/buttons_button.html rename to app/views/snippets/buttons_button.html diff --git a/views/snippets/buttons_button_disabled.html b/app/views/snippets/buttons_button_disabled.html similarity index 100% rename from views/snippets/buttons_button_disabled.html rename to app/views/snippets/buttons_button_disabled.html diff --git a/views/snippets/buttons_button_start_now.html b/app/views/snippets/buttons_button_start_now.html similarity index 100% rename from views/snippets/buttons_button_start_now.html rename to app/views/snippets/buttons_button_start_now.html diff --git a/views/snippets/data_table.html b/app/views/snippets/data_table.html similarity index 100% rename from views/snippets/data_table.html rename to app/views/snippets/data_table.html diff --git a/views/snippets/data_table_numeric.html b/app/views/snippets/data_table_numeric.html similarity index 100% rename from views/snippets/data_table_numeric.html rename to app/views/snippets/data_table_numeric.html diff --git a/views/snippets/form_checkbox_native.html b/app/views/snippets/form_checkbox_native.html similarity index 100% rename from views/snippets/form_checkbox_native.html rename to app/views/snippets/form_checkbox_native.html diff --git a/views/snippets/form_checkboxes.html b/app/views/snippets/form_checkboxes.html similarity index 100% rename from views/snippets/form_checkboxes.html rename to app/views/snippets/form_checkboxes.html diff --git a/views/snippets/form_date.html b/app/views/snippets/form_date.html similarity index 100% rename from views/snippets/form_date.html rename to app/views/snippets/form_date.html diff --git a/views/snippets/form_error_multiple.html b/app/views/snippets/form_error_multiple.html similarity index 100% rename from views/snippets/form_error_multiple.html rename to app/views/snippets/form_error_multiple.html diff --git a/views/snippets/form_error_multiple_show_errors.html b/app/views/snippets/form_error_multiple_show_errors.html similarity index 100% rename from views/snippets/form_error_multiple_show_errors.html rename to app/views/snippets/form_error_multiple_show_errors.html diff --git a/views/snippets/form_error_radio.html b/app/views/snippets/form_error_radio.html similarity index 100% rename from views/snippets/form_error_radio.html rename to app/views/snippets/form_error_radio.html diff --git a/views/snippets/form_error_radio_show_errors.html b/app/views/snippets/form_error_radio_show_errors.html similarity index 100% rename from views/snippets/form_error_radio_show_errors.html rename to app/views/snippets/form_error_radio_show_errors.html diff --git a/views/snippets/form_focus.html b/app/views/snippets/form_focus.html similarity index 100% rename from views/snippets/form_focus.html rename to app/views/snippets/form_focus.html diff --git a/views/snippets/form_hint_text.html b/app/views/snippets/form_hint_text.html similarity index 100% rename from views/snippets/form_hint_text.html rename to app/views/snippets/form_hint_text.html diff --git a/views/snippets/form_inset_checkboxes.html b/app/views/snippets/form_inset_checkboxes.html similarity index 100% rename from views/snippets/form_inset_checkboxes.html rename to app/views/snippets/form_inset_checkboxes.html diff --git a/views/snippets/form_inset_radios.html b/app/views/snippets/form_inset_radios.html similarity index 100% rename from views/snippets/form_inset_radios.html rename to app/views/snippets/form_inset_radios.html diff --git a/views/snippets/form_labels.html b/app/views/snippets/form_labels.html similarity index 100% rename from views/snippets/form_labels.html rename to app/views/snippets/form_labels.html diff --git a/views/snippets/form_radio_buttons.html b/app/views/snippets/form_radio_buttons.html similarity index 100% rename from views/snippets/form_radio_buttons.html rename to app/views/snippets/form_radio_buttons.html diff --git a/views/snippets/form_radio_buttons_inline.html b/app/views/snippets/form_radio_buttons_inline.html similarity index 100% rename from views/snippets/form_radio_buttons_inline.html rename to app/views/snippets/form_radio_buttons_inline.html diff --git a/views/snippets/form_radio_inline_yes_no.html b/app/views/snippets/form_radio_inline_yes_no.html similarity index 100% rename from views/snippets/form_radio_inline_yes_no.html rename to app/views/snippets/form_radio_inline_yes_no.html diff --git a/views/snippets/form_spacing.html b/app/views/snippets/form_spacing.html similarity index 100% rename from views/snippets/form_spacing.html rename to app/views/snippets/form_spacing.html diff --git a/views/snippets/layout_grid_halves.html b/app/views/snippets/layout_grid_halves.html similarity index 100% rename from views/snippets/layout_grid_halves.html rename to app/views/snippets/layout_grid_halves.html diff --git a/views/snippets/layout_grid_quarters.html b/app/views/snippets/layout_grid_quarters.html similarity index 100% rename from views/snippets/layout_grid_quarters.html rename to app/views/snippets/layout_grid_quarters.html diff --git a/views/snippets/layout_grid_thirds.html b/app/views/snippets/layout_grid_thirds.html similarity index 100% rename from views/snippets/layout_grid_thirds.html rename to app/views/snippets/layout_grid_thirds.html diff --git a/views/snippets/layout_grid_thirds_one_third_two_thirds.html b/app/views/snippets/layout_grid_thirds_one_third_two_thirds.html similarity index 100% rename from views/snippets/layout_grid_thirds_one_third_two_thirds.html rename to app/views/snippets/layout_grid_thirds_one_third_two_thirds.html diff --git a/views/snippets/layout_grid_thirds_two_thirds_one_third.html b/app/views/snippets/layout_grid_thirds_two_thirds_one_third.html similarity index 100% rename from views/snippets/layout_grid_thirds_two_thirds_one_third.html rename to app/views/snippets/layout_grid_thirds_two_thirds_one_third.html diff --git a/views/snippets/layout_spacing.html b/app/views/snippets/layout_spacing.html similarity index 100% rename from views/snippets/layout_spacing.html rename to app/views/snippets/layout_spacing.html diff --git a/views/snippets/phase_banner_alpha.html b/app/views/snippets/phase_banner_alpha.html similarity index 100% rename from views/snippets/phase_banner_alpha.html rename to app/views/snippets/phase_banner_alpha.html diff --git a/views/snippets/phase_banner_beta.html b/app/views/snippets/phase_banner_beta.html similarity index 100% rename from views/snippets/phase_banner_beta.html rename to app/views/snippets/phase_banner_beta.html diff --git a/views/snippets/typography_headings.html b/app/views/snippets/typography_headings.html similarity index 100% rename from views/snippets/typography_headings.html rename to app/views/snippets/typography_headings.html diff --git a/views/snippets/typography_headings_example.html b/app/views/snippets/typography_headings_example.html similarity index 100% rename from views/snippets/typography_headings_example.html rename to app/views/snippets/typography_headings_example.html diff --git a/views/snippets/typography_inset_text.html b/app/views/snippets/typography_inset_text.html similarity index 100% rename from views/snippets/typography_inset_text.html rename to app/views/snippets/typography_inset_text.html diff --git a/views/snippets/typography_lead_paragraph.html b/app/views/snippets/typography_lead_paragraph.html similarity index 100% rename from views/snippets/typography_lead_paragraph.html rename to app/views/snippets/typography_lead_paragraph.html diff --git a/views/snippets/typography_lead_paragraph_example.html b/app/views/snippets/typography_lead_paragraph_example.html similarity index 100% rename from views/snippets/typography_lead_paragraph_example.html rename to app/views/snippets/typography_lead_paragraph_example.html diff --git a/views/snippets/typography_legal_text.html b/app/views/snippets/typography_legal_text.html similarity index 100% rename from views/snippets/typography_legal_text.html rename to app/views/snippets/typography_legal_text.html diff --git a/views/snippets/typography_links.html b/app/views/snippets/typography_links.html similarity index 100% rename from views/snippets/typography_links.html rename to app/views/snippets/typography_links.html diff --git a/views/snippets/typography_lists.html b/app/views/snippets/typography_lists.html similarity index 100% rename from views/snippets/typography_lists.html rename to app/views/snippets/typography_lists.html diff --git a/views/snippets/typography_paragraphs.html b/app/views/snippets/typography_paragraphs.html similarity index 100% rename from views/snippets/typography_paragraphs.html rename to app/views/snippets/typography_paragraphs.html diff --git a/views/snippets/typography_paragraphs_example.html b/app/views/snippets/typography_paragraphs_example.html similarity index 100% rename from views/snippets/typography_paragraphs_example.html rename to app/views/snippets/typography_paragraphs_example.html diff --git a/views/snippets/typography_progressive_disclosure.html b/app/views/snippets/typography_progressive_disclosure.html similarity index 100% rename from views/snippets/typography_progressive_disclosure.html rename to app/views/snippets/typography_progressive_disclosure.html diff --git a/lib/template-conversion.js b/lib/template-conversion.js index cd3eb51d6..186f42999 100755 --- a/lib/template-conversion.js +++ b/lib/template-conversion.js @@ -1,7 +1,7 @@ var Hogan = require('hogan.js'), fs = require('fs'), path = require('path'), - govukDir = path.normalize(__dirname + '/../govuk_modules'), + govukDir = path.normalize(__dirname + '/../govuk_modules/'), govukConfig = require(__dirname + '/template-config'), compiledTemplate, govukTemplate, @@ -15,8 +15,8 @@ handleErr = function (err) { module.exports = { convert : function () { - govukTemplate = fs.readFileSync(govukDir + '/views/govuk_template.html', { encoding : 'utf-8' }); + govukTemplate = fs.readFileSync(govukDir + '/govuk_template/views/layouts/govuk_template.html', { encoding : 'utf-8' }); compiledTemplate = Hogan.compile(govukTemplate); - fs.writeFileSync(govukDir + '/views/govuk_template.html', compiledTemplate.render(govukConfig), { encoding : 'utf-8' }); + fs.writeFileSync(govukDir + '/govuk_template/views/layouts/govuk_template.html', compiledTemplate.render(govukConfig), { encoding : 'utf-8' }); } }; diff --git a/app.js b/server.js similarity index 60% rename from app.js rename to server.js index de1f4e08b..022ff225f 100755 --- a/app.js +++ b/server.js @@ -1,18 +1,20 @@ var express = require('express'), bodyParser = require('body-parser'), - routes = require(__dirname + '/routes.js'), + routes = require(__dirname + '/app/routes.js'), app = express(), port = (process.env.PORT || 3000); // Application settings app.engine('html', require(__dirname + '/lib/template-engine.js').__express); app.set('view engine', 'html'); -app.set('vendorViews', __dirname + '/govuk_modules/views'); -app.set('views', __dirname + '/views'); +app.set('vendorViews', __dirname + '/govuk_modules/govuk_template/views/layouts'); +app.set('views', __dirname + '/app/views'); // Middleware to serve static assets app.use('/public', express.static(__dirname + '/public')); app.use('/public', express.static(__dirname + '/govuk_modules/public')); +app.use('/public', express.static(__dirname + '/govuk_modules/govuk_template/assets')); +app.use('/public', express.static(__dirname + '/govuk_modules/govuk_frontend_toolkit')); // Support for parsing data in POSTs app.use(bodyParser.json()); @@ -20,6 +22,12 @@ app.use(bodyParser.urlencoded({ extended: true })); +// send assetPath to all views +app.use(function (req, res, next) { + res.locals.assetPath="/public/"; + next(); +}); + // routes (found in routes.js) routes.bind(app, '/public/');