mod-build 3.6.1--beta.19 → 3.6.1--beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var request = require('request');
|
|
2
|
+
var source = require('vinyl-source-stream');
|
|
3
|
+
|
|
4
|
+
function getDefinedSeasons(gulp, gulpPlugins, siteSettings) {
|
|
5
|
+
return {
|
|
6
|
+
"warmerWeather": {
|
|
7
|
+
"firstDay": "03-14",
|
|
8
|
+
"lastDay": "09-25"
|
|
9
|
+
},
|
|
10
|
+
"spookySeason": {
|
|
11
|
+
"startDate": "10-01",
|
|
12
|
+
"endDate": "10-31"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
// return new Promise(resolve => { // eslint-disable-line no-undef
|
|
16
|
+
// request(`https://${siteSettings.nodeEnv}/quote/resources/mod-site/data/seasons.json`)
|
|
17
|
+
// .on('response', resp => {
|
|
18
|
+
// if (resp.statusCode !== 200) {
|
|
19
|
+
// throw new Error(`${resp.statusCode} Error while fetching data/seasons.json`);
|
|
20
|
+
// }
|
|
21
|
+
// })
|
|
22
|
+
// .pipe(source('seasons'))
|
|
23
|
+
// .then(seasons => { return seasons } )
|
|
24
|
+
// .on('finish', resolve);
|
|
25
|
+
// });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getActiveSeasons() {
|
|
29
|
+
var seasons = getDefinedSeasons();
|
|
30
|
+
const today = new Date();
|
|
31
|
+
const year = today.getFullYear();
|
|
32
|
+
let activeSeason = [];
|
|
33
|
+
|
|
34
|
+
for (const key in seasons) {
|
|
35
|
+
var seasonName = key;
|
|
36
|
+
var dateRanges = seasons[key];
|
|
37
|
+
var startDate = new Date(`${Object.values(dateRanges)[0]}-${year}`);
|
|
38
|
+
var endDate = new Date(`${Object.values(dateRanges)[1]}-${year}`);
|
|
39
|
+
|
|
40
|
+
if (startDate < today && today < endDate) {
|
|
41
|
+
activeSeason.push(seasonName)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return activeSeason;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = getActiveSeasons;
|
package/gulp-tasks/templates.js
CHANGED
|
@@ -12,6 +12,15 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
|
|
|
12
12
|
var qsFooterData = require('../src/data/components/qs-footer.js');
|
|
13
13
|
var quoteFooterData = require('../src/data/components/quote-footer.js');
|
|
14
14
|
|
|
15
|
+
// Checking for seasonal variations in the template.js
|
|
16
|
+
var checkSeasonalVariations = require('./check-seasonal-variations.js');
|
|
17
|
+
const activeSeason = checkSeasonalVariations();
|
|
18
|
+
if (activeSeason !== ''){
|
|
19
|
+
if (activeSeason in siteData.seasonalVariations) {
|
|
20
|
+
siteData = {...siteData, ...siteData.seasonalVariations[activeSeason]};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
15
24
|
var templatesData = Object.assign(commonData(), qsFooterData(siteData), quoteFooterData(siteData), siteData, { isLocal, nodeEnv, assetsPath, buildPath });
|
|
16
25
|
|
|
17
26
|
// This is helper function to evaluate JS expressions
|
|
@@ -66,24 +75,6 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
|
|
|
66
75
|
}
|
|
67
76
|
}
|
|
68
77
|
},
|
|
69
|
-
// Check to see if seasonal changes should be made
|
|
70
|
-
{
|
|
71
|
-
name: 'ifSeason',
|
|
72
|
-
fn: function(season, block) {
|
|
73
|
-
const today = new Date();
|
|
74
|
-
const year = today.getFullYear();
|
|
75
|
-
let isSeason = false;
|
|
76
|
-
|
|
77
|
-
switch(season) {
|
|
78
|
-
case 'coolerWeather':
|
|
79
|
-
const startOfSpring = new Date(`03-14-${year}`);
|
|
80
|
-
const startOfFall = new Date(`09-25-${year}`);
|
|
81
|
-
isSeason = !(today > startOfSpring && today < startOfFall);
|
|
82
|
-
break
|
|
83
|
-
}
|
|
84
|
-
return isSeason ? block.fn(this) : block.inverse(this);
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
78
|
// Convert string to uppercase
|
|
88
79
|
{
|
|
89
80
|
name: 'uppercase',
|
|
@@ -154,4 +145,5 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
|
|
|
154
145
|
}))
|
|
155
146
|
.pipe(gulp.dest(siteSettings.tmpFolder));
|
|
156
147
|
};
|
|
148
|
+
|
|
157
149
|
};
|