Skip to content

Commit

Permalink
Remove v6 backwards compatibility with GOV.UK Elements
Browse files Browse the repository at this point in the history
GOV.UK Elements has not been released since July 2018.
New prototypes should be using the GOV.UK Design System.
  • Loading branch information
fofr committed Oct 22, 2021
1 parent 1438e34 commit b701f8c
Show file tree
Hide file tree
Showing 11 changed files with 4 additions and 243 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

Remove v6 backwards compatibility with GOV.UK Elements. GOV.UK Elements is deprecated and has not been released since July 2018. New prototypes should be using the GOV.UK Design System.

# 9.15.0 (Feature release)

## New features
Expand Down
61 changes: 0 additions & 61 deletions docs/documentation/backwards-compatibility.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/views/tutorials-and-examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ <h3 class="govuk-heading-s">Advanced usage</h3>
Template partial areas
</a>
</li>
<li>
<a href="/docs/backwards-compatibility">Backwards compatibility</a>
</li>
</ul>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion gulp/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"public": "public/",
"assets" : "app/assets/",
"docsAssets" : "docs/assets/",
"v6Assets": "app/v6/assets/",
"nodeModules": "node_modules/",
"lib": "lib/"
}
Expand Down
8 changes: 0 additions & 8 deletions gulp/copy-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,3 @@ gulp.task('copy-assets-documentation', function () {
])
.pipe(gulp.dest(config.paths.public))
})

gulp.task('copy-assets-v6', function () {
return gulp.src([
`${config.paths.v6Assets}/**`,
`!${config.paths.v6Assets}/sass/**`
])
.pipe(gulp.dest(config.paths.public + '/v6'))
})
17 changes: 0 additions & 17 deletions gulp/sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,3 @@ gulp.task('sass-documentation', function () {
.pipe(sourcemaps.write())
.pipe(gulp.dest(config.paths.public + '/stylesheets/'))
})

// Backward compatibility with Elements

gulp.task('sass-v6', function () {
return gulp.src(config.paths.v6Assets + '/sass/*.scss')
.pipe(sourcemaps.init())
.pipe(sass({
outputStyle: 'expanded',
includePaths: [
'node_modules/govuk_frontend_toolkit/stylesheets',
'node_modules/govuk-elements-sass/public/sass',
'node_modules/govuk_template_jinja/assets/stylesheets'
]
}).on('error', sass.logError))
.pipe(sourcemaps.write())
.pipe(gulp.dest(config.paths.public + '/v6/stylesheets/'))
})
11 changes: 0 additions & 11 deletions gulp/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,3 @@ gulp.task('watch-assets', function () {
return gulp.watch([config.paths.assets + 'images/**',
config.paths.assets + 'javascripts/**'], { cwd: './' }, gulp.task('copy-assets'))
})

// Backward compatibility with Elements

gulp.task('watch-sass-v6', function () {
return gulp.watch(config.paths.v6Assets + 'sass/**', { cwd: './' }, gulp.task('sass-v6'))
})

gulp.task('watch-assets-v6', function () {
return gulp.watch([config.paths.v6Assets + 'images/**',
config.paths.v6Assets + 'javascripts/**'], { cwd: './' }, gulp.task('copy-assets-v6'))
})
8 changes: 2 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ gulp.task('generate-assets', gulp.series(
'sass',
'copy-assets',
'sass-documentation',
'copy-assets-documentation',
'sass-v6',
'copy-assets-v6'
'copy-assets-documentation'
)
))
gulp.task('watch', gulp.parallel(
'watch-sass',
'watch-assets',
'watch-sass-v6',
'watch-assets-v6'
'watch-assets'
))
gulp.task('default', gulp.series(
'generate-assets',
Expand Down
74 changes: 0 additions & 74 deletions lib/v6/govuk_template_unbranded.html

This file was deleted.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
"express-session": "^1.13.0",
"express-writer": "0.0.4",
"fancy-log": "^1.3.3",
"govuk-elements-sass": "^3.1.3",
"govuk-frontend": "^3.14.0",
"govuk_frontend_toolkit": "^7.5.0",
"govuk_template_jinja": "^0.24.1",
"gulp": "^4.0.0",
"gulp-nodemon": "^2.5.0",
Expand Down
60 changes: 0 additions & 60 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,9 @@ const routes = require('./app/routes.js')
const utils = require('./lib/utils.js')
const extensions = require('./lib/extensions/extensions.js')

// Variables for v6 backwards compatibility
// Set false by default, then turn on if we find /app/v6/routes.js
var useV6 = false
var v6App
var v6Routes

if (fs.existsSync('./app/v6/routes.js')) {
v6Routes = require('./app/v6/routes.js')
useV6 = true
}

const app = express()
const documentationApp = express()

if (useV6) {
console.log('/app/v6/routes.js detected - using v6 compatibility mode')
v6App = express()
}

// Set up configuration variables
var releaseVersion = packageJson.version
var glitchEnv = (process.env.PROJECT_REMIX_CHAIN) ? 'production' : false // glitch.com
Expand Down Expand Up @@ -129,28 +113,6 @@ app.use(bodyParser.urlencoded({
extended: true
}))

// Set up v6 app for backwards compatibility
if (useV6) {
var v6Views = [
path.join(__dirname, '/node_modules/govuk_template_jinja/views/layouts'),
path.join(__dirname, '/app/v6/views/'),
path.join(__dirname, '/lib/v6') // for old unbranded template
]
nunjucksConfig.express = v6App
var nunjucksV6Env = nunjucks.configure(v6Views, nunjucksConfig)

// Nunjucks filters
utils.addNunjucksFilters(nunjucksV6Env)

// Set views engine
v6App.set('view engine', 'html')

// Backward compatibility with GOV.UK Elements
app.use('/public/v6/', express.static(path.join(__dirname, '/node_modules/govuk_template_jinja/assets')))
app.use('/public/v6/', express.static(path.join(__dirname, '/node_modules/govuk_frontend_toolkit')))
app.use('/public/v6/javascripts/govuk/', express.static(path.join(__dirname, '/node_modules/govuk_frontend_toolkit/javascripts/govuk/')))
}

// Add variables that are available in all views
app.locals.asset_path = '/public/'
app.locals.useAutoStoreData = (useAutoStoreData === 'true')
Expand Down Expand Up @@ -193,9 +155,6 @@ if (useAutoStoreData === 'true') {
if (useDocumentation) {
utils.addCheckedFunction(nunjucksDocumentationEnv)
}
if (useV6) {
utils.addCheckedFunction(nunjucksV6Env)
}
}

// Clear all data in session if you open /prototype-admin/clear-data
Expand Down Expand Up @@ -254,18 +213,6 @@ if (useDocumentation) {
documentationApp.use('/', documentationRoutes)
}

if (useV6) {
// Clone app locals to v6 app locals
v6App.locals = Object.assign({}, app.locals)
v6App.locals.asset_path = '/public/v6/'

// Create separate router for v6
app.use('/', v6App)

// Docs under the /docs namespace
v6App.use('/', v6Routes)
}

// Strip .html and .htm if provided
app.get(/\.html?$/i, function (req, res) {
var path = req.path
Expand All @@ -291,13 +238,6 @@ if (useDocumentation) {
})
}

if (useV6) {
// App folder routes get priority
v6App.get(/^([^.]+)$/, function (req, res, next) {
utils.matchRoutes(req, res, next)
})
}

// Redirect all POSTs to GETs - this allows users to use POST for autoStoreData
app.post(/^\/([^.]+)$/, function (req, res) {
res.redirect('/' + req.params[0])
Expand Down

0 comments on commit b701f8c

Please sign in to comment.