diff --git a/.gitignore b/.gitignore index fdd0ea3..eabf113 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules/* lib/* css/* /api/resultats.json +/index.html diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 96a2d04..7dddb11 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ pages: stage: deploy script: - npm install - - node_modules/.bin/gulp + - node_modules/.bin/gulp prod - rm -rf node_modules .public public - mkdir .public - cp -r * .public diff --git a/gulpfile.js b/gulpfile.js index c3ae212..45e71a6 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,7 +3,9 @@ var bower = require('gulp-bower'); var help = require('gulp-task-listing'); var clean = require('gulp-clean'); var sass = require('gulp-sass'); +var rename = require("gulp-rename"); var yaml = require('gulp-yaml'); +var template = require('gulp-template'); var webserver = require('gulp-webserver'); gulp.task('help', help); @@ -32,8 +34,25 @@ gulp.task('compile-results', function(){ .pipe(gulp.dest('./api')); }); +gulp.task('template-prod', function () { + return gulp.src('index.tmpl.html') + .pipe(rename("index.html")) + .pipe(template({production: true})) + .pipe(gulp.dest('.')); +}); + +gulp.task('template-dev', function () { + return gulp.src('index.tmpl.html') + .pipe(rename("index.html")) + .pipe(template({production: false})) + .pipe(gulp.dest('.')); +}); + + gulp.task('default', ['bower', 'sass', 'compile-results']); +gulp.task('prod', ['default', 'template-prod']); + gulp.task('webserver', function(){ return gulp.src('.') .pipe(webserver({ @@ -42,8 +61,8 @@ gulp.task('webserver', function(){ })); }); -gulp.task('dev', ['default', 'webserver'], function(){ +gulp.task('dev', ['default', 'webserver', 'template-dev'], function(){ gulp.watch('./scss/*.scss', ['sass']); + gulp.watch('*.tmpl.html', ['template-dev']); return gulp.watch('./data/*.yaml', ['compile-results']); - }); diff --git a/index.html b/index.tmpl.html similarity index 66% rename from index.html rename to index.tmpl.html index 5dd5c31..754acec 100644 --- a/index.html +++ b/index.tmpl.html @@ -6,8 +6,12 @@ - + <%if(production){ %> + + <% }else{ %> + + <% } %> diff --git a/package.json b/package.json index 08e5a16..d25cd91 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,10 @@ "gulp": "^3.9.0", "gulp-bower": "0.0.13", "gulp-clean": "^0.3.1", + "gulp-rename": "^1.2.2", "gulp-sass": "^2.1.1", "gulp-task-listing": "^1.0.1", + "gulp-template": "^3.1.0", "requirejs": "^2.1.22" }, "devDependencies": { diff --git a/script/views/calendarPage.js b/script/views/calendarPage.js index 2bffa94..346bf60 100644 --- a/script/views/calendarPage.js +++ b/script/views/calendarPage.js @@ -3,7 +3,7 @@ define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/foo statsView.controller = function(){ var games = m.prop([]); - return m.request({method: "GET", url: "/api/resultats.json"}) + return m.request({method: "GET", url: "api/resultats.json"}) .then(games) .then(resultParser.getStats); }; @@ -68,7 +68,7 @@ define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/foo schedulView.controller = function(){ var games = m.prop([]); - return m.request({method: "GET", url: "/api/resultats.json"}) + return m.request({method: "GET", url: "api/resultats.json"}) .then(games) .then(resultParser.getNightGames); }; diff --git a/script/views/mainPage.js b/script/views/mainPage.js index 80ab8d4..d9e9615 100644 --- a/script/views/mainPage.js +++ b/script/views/mainPage.js @@ -25,7 +25,7 @@ define(['m', '_', 'util', 'resultParser', 'views/topNavBar', 'views/footer'], fu nextGameDaySchedule.controller = function(){ var games = m.prop([]); - return m.request({method: "GET", url: "/api/resultats.json"}) + return m.request({method: "GET", url: "api/resultats.json"}) .then(games) .then(resultParser.getNightGames) .then(function(nightGames){