From 3608e67a57a403584a6a64cffdce57b0ca65b3ad Mon Sep 17 00:00:00 2001 From: Joe Lanman Date: Mon, 13 Jun 2016 12:30:13 +0100 Subject: [PATCH 1/7] move files to /app/ and use server.js --- Gruntfile.js | 2 +- routes.js => app/routes.js | 0 {views => app/views}/examples/example_date.html | 0 {views => app/views}/examples/example_details_summary.html | 0 {views => app/views}/examples/example_form_elements.html | 0 .../examples/example_form_validation_multiple_questions.html | 0 .../example_form_validation_single_question_radio.html | 0 {views => app/views}/examples/example_grid_layout.html | 0 {views => app/views}/examples/example_icons.html | 0 {views => app/views}/examples/example_radios_checkboxes.html | 0 {views => app/views}/examples/example_typography.html | 0 {views => app/views}/guide_alpha_beta.html | 0 {views => app/views}/guide_buttons.html | 0 {views => app/views}/guide_colour.html | 0 {views => app/views}/guide_data.html | 0 {views => app/views}/guide_errors.html | 0 {views => app/views}/guide_form_elements.html | 0 {views => app/views}/guide_icons_images.html | 0 {views => app/views}/guide_layout.html | 0 {views => app/views}/guide_typography.html | 0 {views => app/views}/includes/breadcrumb.html | 0 {views => app/views}/includes/elements_head.html | 0 {views => app/views}/includes/elements_tracking.html | 0 {views => app/views}/includes/head.html | 0 {views => app/views}/includes/phase_banner.html | 0 {views => app/views}/includes/propositional_navigation.html | 0 {views => app/views}/includes/scripts.html | 0 {views => app/views}/includes/service_manual_breadcrumb.html | 0 {views => app/views}/includes/service_manual_navigation.html | 0 {views => app/views}/includes/snippets_head.html | 0 {views => app/views}/includes/snippets_scripts.html | 0 {views => app/views}/index.html | 0 {views => app/views}/layout.html | 0 {views => app/views}/layout_example.html | 0 {views => app/views}/snippets/buttons_button.html | 0 {views => app/views}/snippets/buttons_button_disabled.html | 0 {views => app/views}/snippets/buttons_button_start_now.html | 0 {views => app/views}/snippets/data_table.html | 0 {views => app/views}/snippets/data_table_numeric.html | 0 {views => app/views}/snippets/form_checkbox_native.html | 0 {views => app/views}/snippets/form_checkboxes.html | 0 {views => app/views}/snippets/form_date.html | 0 {views => app/views}/snippets/form_error_multiple.html | 0 .../views}/snippets/form_error_multiple_show_errors.html | 0 {views => app/views}/snippets/form_error_radio.html | 0 .../views}/snippets/form_error_radio_show_errors.html | 0 {views => app/views}/snippets/form_focus.html | 0 {views => app/views}/snippets/form_hint_text.html | 0 {views => app/views}/snippets/form_inset_checkboxes.html | 0 {views => app/views}/snippets/form_inset_radios.html | 0 {views => app/views}/snippets/form_labels.html | 0 {views => app/views}/snippets/form_radio_buttons.html | 0 {views => app/views}/snippets/form_radio_buttons_inline.html | 0 {views => app/views}/snippets/form_radio_inline_yes_no.html | 0 {views => app/views}/snippets/form_spacing.html | 0 {views => app/views}/snippets/layout_grid_halves.html | 0 {views => app/views}/snippets/layout_grid_quarters.html | 0 {views => app/views}/snippets/layout_grid_thirds.html | 0 .../snippets/layout_grid_thirds_one_third_two_thirds.html | 0 .../snippets/layout_grid_thirds_two_thirds_one_third.html | 0 {views => app/views}/snippets/layout_spacing.html | 0 {views => app/views}/snippets/phase_banner_alpha.html | 0 {views => app/views}/snippets/phase_banner_beta.html | 0 {views => app/views}/snippets/typography_headings.html | 0 .../views}/snippets/typography_headings_example.html | 0 {views => app/views}/snippets/typography_inset_text.html | 0 {views => app/views}/snippets/typography_lead_paragraph.html | 0 .../views}/snippets/typography_lead_paragraph_example.html | 0 {views => app/views}/snippets/typography_legal_text.html | 0 {views => app/views}/snippets/typography_links.html | 0 {views => app/views}/snippets/typography_lists.html | 0 {views => app/views}/snippets/typography_paragraphs.html | 0 .../views}/snippets/typography_paragraphs_example.html | 0 .../views}/snippets/typography_progressive_disclosure.html | 0 app.js => server.js | 4 ++-- 75 files changed, 3 insertions(+), 3 deletions(-) rename routes.js => app/routes.js (100%) rename {views => app/views}/examples/example_date.html (100%) rename {views => app/views}/examples/example_details_summary.html (100%) rename {views => app/views}/examples/example_form_elements.html (100%) rename {views => app/views}/examples/example_form_validation_multiple_questions.html (100%) rename {views => app/views}/examples/example_form_validation_single_question_radio.html (100%) rename {views => app/views}/examples/example_grid_layout.html (100%) rename {views => app/views}/examples/example_icons.html (100%) rename {views => app/views}/examples/example_radios_checkboxes.html (100%) rename {views => app/views}/examples/example_typography.html (100%) rename {views => app/views}/guide_alpha_beta.html (100%) rename {views => app/views}/guide_buttons.html (100%) rename {views => app/views}/guide_colour.html (100%) rename {views => app/views}/guide_data.html (100%) rename {views => app/views}/guide_errors.html (100%) rename {views => app/views}/guide_form_elements.html (100%) rename {views => app/views}/guide_icons_images.html (100%) rename {views => app/views}/guide_layout.html (100%) rename {views => app/views}/guide_typography.html (100%) rename {views => app/views}/includes/breadcrumb.html (100%) rename {views => app/views}/includes/elements_head.html (100%) rename {views => app/views}/includes/elements_tracking.html (100%) rename {views => app/views}/includes/head.html (100%) rename {views => app/views}/includes/phase_banner.html (100%) rename {views => app/views}/includes/propositional_navigation.html (100%) rename {views => app/views}/includes/scripts.html (100%) rename {views => app/views}/includes/service_manual_breadcrumb.html (100%) rename {views => app/views}/includes/service_manual_navigation.html (100%) rename {views => app/views}/includes/snippets_head.html (100%) rename {views => app/views}/includes/snippets_scripts.html (100%) rename {views => app/views}/index.html (100%) rename {views => app/views}/layout.html (100%) rename {views => app/views}/layout_example.html (100%) rename {views => app/views}/snippets/buttons_button.html (100%) rename {views => app/views}/snippets/buttons_button_disabled.html (100%) rename {views => app/views}/snippets/buttons_button_start_now.html (100%) rename {views => app/views}/snippets/data_table.html (100%) rename {views => app/views}/snippets/data_table_numeric.html (100%) rename {views => app/views}/snippets/form_checkbox_native.html (100%) rename {views => app/views}/snippets/form_checkboxes.html (100%) rename {views => app/views}/snippets/form_date.html (100%) rename {views => app/views}/snippets/form_error_multiple.html (100%) rename {views => app/views}/snippets/form_error_multiple_show_errors.html (100%) rename {views => app/views}/snippets/form_error_radio.html (100%) rename {views => app/views}/snippets/form_error_radio_show_errors.html (100%) rename {views => app/views}/snippets/form_focus.html (100%) rename {views => app/views}/snippets/form_hint_text.html (100%) rename {views => app/views}/snippets/form_inset_checkboxes.html (100%) rename {views => app/views}/snippets/form_inset_radios.html (100%) rename {views => app/views}/snippets/form_labels.html (100%) rename {views => app/views}/snippets/form_radio_buttons.html (100%) rename {views => app/views}/snippets/form_radio_buttons_inline.html (100%) rename {views => app/views}/snippets/form_radio_inline_yes_no.html (100%) rename {views => app/views}/snippets/form_spacing.html (100%) rename {views => app/views}/snippets/layout_grid_halves.html (100%) rename {views => app/views}/snippets/layout_grid_quarters.html (100%) rename {views => app/views}/snippets/layout_grid_thirds.html (100%) rename {views => app/views}/snippets/layout_grid_thirds_one_third_two_thirds.html (100%) rename {views => app/views}/snippets/layout_grid_thirds_two_thirds_one_third.html (100%) rename {views => app/views}/snippets/layout_spacing.html (100%) rename {views => app/views}/snippets/phase_banner_alpha.html (100%) rename {views => app/views}/snippets/phase_banner_beta.html (100%) rename {views => app/views}/snippets/typography_headings.html (100%) rename {views => app/views}/snippets/typography_headings_example.html (100%) rename {views => app/views}/snippets/typography_inset_text.html (100%) rename {views => app/views}/snippets/typography_lead_paragraph.html (100%) rename {views => app/views}/snippets/typography_lead_paragraph_example.html (100%) rename {views => app/views}/snippets/typography_legal_text.html (100%) rename {views => app/views}/snippets/typography_links.html (100%) rename {views => app/views}/snippets/typography_lists.html (100%) rename {views => app/views}/snippets/typography_paragraphs.html (100%) rename {views => app/views}/snippets/typography_paragraphs_example.html (100%) rename {views => app/views}/snippets/typography_progressive_disclosure.html (100%) rename app.js => server.js (89%) diff --git a/Gruntfile.js b/Gruntfile.js index aeb8a6e8f..2b38c041d 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -93,7 +93,7 @@ module.exports = function (grunt) { // nodemon watches for changes and restarts app nodemon: { dev: { - script: 'app.js', + script: 'server.js', options: { ext: 'html, js' } diff --git a/routes.js b/app/routes.js similarity index 100% rename from routes.js rename to app/routes.js 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/app.js b/server.js similarity index 89% rename from app.js rename to server.js index de1f4e08b..a21583f6a 100755 --- a/app.js +++ b/server.js @@ -1,6 +1,6 @@ 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); @@ -8,7 +8,7 @@ var express = require('express'), 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('views', __dirname + '/app/views'); // Middleware to serve static assets app.use('/public', express.static(__dirname + '/public')); From 8a7416a97aec564058a5cf6245afb554955a7074 Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 12:56:57 +0100 Subject: [PATCH 2/7] send assetPath to all views --- app/routes.js | 42 +++++++++++++++++++++--------------------- server.js | 6 ++++++ 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/app/routes.js b/app/routes.js index ce9392397..9f9a0b276 100755 --- a/app/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/server.js b/server.js index a21583f6a..2fec3e1da 100755 --- a/server.js +++ b/server.js @@ -20,6 +20,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/'); From f6110827983f37f98a7cbbd3a4ad1700f822dfa3 Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 13:01:27 +0100 Subject: [PATCH 3/7] Add Middleware to serve static assets --- server.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server.js b/server.js index 2fec3e1da..04b879721 100755 --- a/server.js +++ b/server.js @@ -13,6 +13,8 @@ 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()); From 69e9c6e5c00fe66906e25f2aaf6ebe7890691f4f Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 13:34:59 +0100 Subject: [PATCH 4/7] Copy assets to public and consolidate govuk copy task --- Gruntfile.js | 71 ++++++++++++++++------------------------------------ 1 file changed, 22 insertions(+), 49 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 2b38c041d..04b994b26 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -26,47 +26,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/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 @@ -145,12 +126,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 +137,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' ] From 32f6c896d6cba158097e8319b9a82404023d0076 Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 14:10:44 +0100 Subject: [PATCH 5/7] Correct includePaths To include the template stylesheets and the toolkit stylesheets --- Gruntfile.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 04b994b26..a734ed897 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' } From a417dadfededa36728bc54fd421697b986dd4112 Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 14:07:13 +0100 Subject: [PATCH 6/7] Update path to convert template --- lib/template-conversion.js | 6 +++--- server.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) 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/server.js b/server.js index 04b879721..022ff225f 100755 --- a/server.js +++ b/server.js @@ -7,7 +7,7 @@ var express = require('express'), // 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('vendorViews', __dirname + '/govuk_modules/govuk_template/views/layouts'); app.set('views', __dirname + '/app/views'); // Middleware to serve static assets From db507709a819041befa9b1aa74e83a119f36b506 Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Mon, 13 Jun 2016 14:11:47 +0100 Subject: [PATCH 7/7] Correct path for toolkit node module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This isn’t in a folder inside itself any more. Remove the subfolder. --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index a734ed897..8c50ce4a1 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -40,7 +40,7 @@ module.exports = function (grunt) { govuk: { files: [{ expand: true, - cwd: 'node_modules/govuk_frontend_toolkit/govuk_frontend_toolkit', + cwd: 'node_modules/govuk_frontend_toolkit/', src: '**', dest: 'govuk_modules/govuk_frontend_toolkit/' },