Skip to content

Commit cf7f316

Browse files
Misc cleanup
1 parent 224fa7a commit cf7f316

File tree

8 files changed

+72
-51
lines changed

8 files changed

+72
-51
lines changed

app/assets/sass/_typography.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
h1 {
2+
@extend %nhsuk-heading-l;
3+
}
4+
5+
h2 {
6+
@extend %nhsuk-heading-m;
7+
}
8+
9+
h3 {
10+
@extend %nhsuk-heading-s;
11+
}

app/assets/sass/main.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
@import 'components/list-border';
66
@import 'components/related-nav';
77

8+
@import 'typography';
89
@import 'utils';
910

1011
///////////////////////////////////////////

app/lib/utils/strings.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ const stringLiteral = function(str) {
172172
* @param {string} input - String to wrap
173173
* @returns {string} HTML string with no-wrap class
174174
*/
175-
const nowrap = (input) => {
175+
const noWrap = (input) => {
176176
if (!input) return '';
177177
return `<span class="app-nowrap">${input}</span>`;
178178
};
@@ -184,7 +184,7 @@ module.exports = {
184184
formatWords,
185185
isString,
186186
kebabCase,
187-
nowrap,
187+
noWrap,
188188
padDigits,
189189
possessive,
190190
sentenceCase,

app/views/clinics/index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
{% set back = {
77
href: "/"
88
} %}
9+
910
{% block pageContent %}
10-
<h1 class="nhsuk-heading-l">{{pageHeading}}</h1>
11+
<h1>{{pageHeading}}</h1>
1112

1213
{% if data.clinics.length === 0 %}
1314
<p>No clinics found.</p>
@@ -37,7 +38,7 @@ <h1 class="nhsuk-heading-l">{{pageHeading}}</h1>
3738
{% endif %}
3839
</a>
3940
</td>
40-
<td>{{ clinic.date | formatDate }}</td>
41+
<td>{{ clinic.date | formatDate | noWrap }}</td>
4142
<td class="nhsuk-table__cell--numeric">
4243
{{ tag({
4344
text: clinic.status | formatWords | sentenceCase,

app/views/clinics/show.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ <h1 class="nhsuk-heading-l">
5252
</td>
5353
<td class="nhsuk-table__cell">
5454
{% if event.status === 'scheduled' %}
55-
<a href="/clinics/{{ clinicId }}/check-in/{{ event.id }}" class="nhsuk-link">{{ "Check in" | nowrap | safe }}</a>
55+
<a href="/clinics/{{ clinicId }}/check-in/{{ event.id }}" class="nhsuk-link">{{ "Check in" | noWrap }}</a>
5656
{% endif %}
5757
</td>
5858
</tr>

app/views/participants/show.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
{% set pageHeading = "Today’s clinics" %}
55

6+
{% set back = {
7+
href: "/clinics",
8+
text: "All clinics"
9+
} %}
610

711
{% block pageContent %}
812

gulpfile.js

Lines changed: 37 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@ sass.compiler = require('sass');
2525
function compileStyles() {
2626
return gulp
2727
.src(['app/assets/sass/**/*.scss', 'docs/assets/sass/**/*.scss'])
28-
.pipe(sass())
29-
.pipe(gulp.dest('public/css'))
30-
.on('error', (err) => {
31-
console.log(err);
32-
process.exit(1);
33-
});
28+
.pipe(sass({
29+
outputStyle: 'expanded',
30+
sourceComments: true
31+
}).on('error', sass.logError))
32+
.pipe(gulp.dest('public/css'));
3433
}
3534

3635
// Compile JavaScript (with ES6 support)
@@ -47,31 +46,31 @@ function compileAssets() {
4746
.src([
4847
'app/assets/**/**/*.*',
4948
'docs/assets/**/**/*.*',
50-
'!**/assets/**/**/*.js', // Don't copy JS files
51-
'!**/assets/**/**/*.scss', // Don't copy SCSS files
49+
'!**/assets/**/**/*.js',
50+
'!**/assets/**/**/*.scss',
5251
], { encoding: false })
5352
.pipe(gulp.dest('public'));
5453
}
5554

56-
// Start nodemon with enhanced watching
55+
// Start nodemon
5756
function startNodemon(done) {
5857
const server = nodemon({
5958
script: 'app.js',
6059
stdout: true,
61-
ext: 'js json', // Added json to watch for package.json changes
60+
ext: 'js json',
6261
watch: [
63-
'app/**/*.js', // Watch all JS files in app directory
64-
'app.js', // Watch main app file
65-
'routes/**/*.js', // Watch route files
66-
'lib/**/*.js', // Watch library files
67-
'config/**/*.js' // Watch configuration files
62+
'app/**/*.js',
63+
'app.js',
64+
'routes/**/*.js',
65+
'lib/**/*.js',
66+
'config/**/*.js'
6867
],
6968
ignore: [
70-
'app/assets/**', // Ignore asset files
71-
'public/**', // Ignore compiled files
72-
'node_modules/**' // Ignore node_modules
69+
'app/assets/**',
70+
'public/**',
71+
'node_modules/**'
7372
],
74-
delay: 1000, // Add a small delay to prevent rapid restarts
73+
delay: 1000,
7574
quiet: false,
7675
});
7776

@@ -94,7 +93,6 @@ function startNodemon(done) {
9493
}
9594
});
9695

97-
// Add restart event handler
9896
server.on('restart', () => {
9997
console.log('Restarting server due to changes...');
10098
});
@@ -104,31 +102,26 @@ function reload() {
104102
browserSync.reload();
105103
}
106104

107-
// Start browsersync with enhanced configuration
105+
// Start browsersync
108106
function startBrowserSync(done) {
109-
browserSync.init(
110-
{
111-
proxy: 'localhost:' + port,
112-
port: port + 1000,
113-
ui: false,
114-
files: [
115-
'app/views/**/*.*',
116-
'docs/views/**/*.*',
117-
'public/**/*.*'
118-
],
119-
ghostMode: false,
120-
open: false,
121-
notify: true,
122-
watch: true,
123-
reloadDelay: 1000, // Add delay before reload
124-
reloadDebounce: 1000 // Debounce reloads
125-
},
126-
done
127-
);
128-
gulp.watch('public/**/*.*').on('change', reload);
107+
browserSync.init({
108+
proxy: 'localhost:' + port,
109+
port: port + 1000,
110+
ui: false,
111+
files: [
112+
'public/css/**/*.css',
113+
'public/js/**/*.js',
114+
'app/views/**/*'
115+
],
116+
ghostMode: false,
117+
open: false,
118+
notify: false,
119+
logFileChanges: false,
120+
reloadDebounce: 1000
121+
}, done);
129122
}
130123

131-
// Enhanced watch function
124+
// Watch files
132125
function watch() {
133126
gulp.watch('app/assets/sass/**/*.scss', gulp.series(compileStyles, reload));
134127
gulp.watch('app/assets/javascript/**/*.js', gulp.series(compileScripts, reload));
@@ -143,8 +136,8 @@ exports.compileStyles = compileStyles;
143136
exports.compileScripts = compileScripts;
144137
exports.cleanPublic = cleanPublic;
145138

146-
gulp.task(
147-
'build',
139+
gulp.task('build',
148140
gulp.series(cleanPublic, compileStyles, compileScripts, compileAssets)
149141
);
142+
150143
gulp.task('default', gulp.series(startNodemon, startBrowserSync, watch));

lib/utils.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,21 @@ const crypto = require('crypto');
88
const coreFilters = require('./core_filters');
99
const customFilters = require('../app/filters');
1010

11-
exports.addNunjucksFilters = function (env) { /* eslint-disable-line func-names */
11+
const SAFE_FILTERS = ['noWrap'];
12+
13+
exports.addNunjucksFilters = function (env) {
1214
const filters = Object.assign(coreFilters(env), customFilters(env));
15+
const safe = env.getFilter('safe');
16+
1317
Object.keys(filters).forEach((filterName) => {
14-
env.addFilter(filterName, filters[filterName]);
18+
const filter = filters[filterName];
19+
20+
// If it's in our safe list, wrap the filter to mark its output as safe
21+
if (SAFE_FILTERS.includes(filterName)) {
22+
env.addFilter(filterName, (...args) => safe(filter(...args)));
23+
} else {
24+
env.addFilter(filterName, filter);
25+
}
1526
});
1627
};
1728

0 commit comments

Comments
 (0)