Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
add testing of all json file, linting of main js and gulp as test
Browse files Browse the repository at this point in the history
  • Loading branch information
butlerx committed Oct 3, 2016
1 parent 5f04d50 commit 7491d2e
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"json"
],
"env": {
"browser": true
"browser": true,
"jquery": true
},
"extends": "eslint:recommended",
"rules": {
Expand Down
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: node_js
node_js:
- "node"
- "6"
- "5"
- "4"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# TechWeek Website
[![Build Status](https://travis-ci.org/redbrick/techweek.dcu.ie.svg?branch=master)](https://travis-ci.org/redbrick/techweek.dcu.ie)<Paste>
This repository contains the Techweek website
The website was written to have the Google Material Design look and feel. MaterializeCSS was used to speed up the process.

Expand Down
22 changes: 15 additions & 7 deletions bin/check-event-json
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
#!/usr/bin/env node

var fs = require("fs");
var filename = process.argv[2];
var fs = require('fs');
var file = process.argv[2];

if (filename) {
if(file !== undefined && file !== null) {
checkJson(file);
} else {
for(const i of ['events.json', '2015/events.json', '2016/events.json']) {
checkJson(i);
}
process.exit(0);
}

function checkJson (filename) {
try {
JSON.parse(fs.readFileSync(filename, "utf8"));
console.log("Look good");
JSON.parse(fs.readFileSync(filename, 'utf8'));
console.log(filename + ' looks good');
} catch (err) {
console.error(err);
process.exit(1);
}
} else {
console.log("Usage: check-event-json events.json");
}
10 changes: 8 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ var cleanCSS = require('gulp-clean-css');
var minify = require('gulp-minify');
var rename = require('gulp-rename');
var connect = require('gulp-connect');
var jsonSchema = require('gulp-json-schema');

gulp.task('dev', ['compress', 'minify-css', 'less', 'webserver'], function () {
gulp.task('dev', ['compress', 'minify-css', 'less', 'webserver', 'validate'], function () {
gulp.watch(['./css/*.less', './js/*.js', './**/*.html'], ['less', 'compress', 'html']);
});

Expand Down Expand Up @@ -49,4 +50,9 @@ gulp.task('html', function () {
.pipe(connect.reload());
});

gulp.task('default', ['compress', 'minify-css', 'less']);
gulp.task('validate', () => {
return gulp.src(['./events.json', './2016/*.json', '.2015/*.json'])
.pipe(jsonSchema('schema.json'));
});

gulp.task('default', ['compress', 'minify-css', 'less', 'validate']);
24 changes: 13 additions & 11 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ var _hour = _minute * 60;
var _day = _hour * 24;

// setInterval allows you to do certain action every period of time (like cronjob)
setInterval(function(){
setInterval(function() {

// Check is current time + 10 minutes smaller than the starting time
if(now+1000*60*10 < start){
if(now+1000*60*10 < start) {
// If it is, show the box and start counting down
$('.countdown').show(400);
} else {
liveActive = true;
// Otherwise, show the livestream and abjust the height of it to be in
// 19:6 aspect ratio
// When done hiding the countdown show the livestream, make it take 400ms so there is a smooth transition
if(liveActive){
if(liveActive) {
showLive();
}
}
Expand All @@ -74,10 +74,10 @@ setInterval(function(){
}, 1000); // Set the time of the interval, in ms, so 1000 (1s)

// Show the livefeed
function showLive(){
function showLive() {
if(!liveShown){
$('.countdown').hide(400, function(){
$('.livestream').show(0, function(){
$('.countdown').hide(400, function() {
$('.livestream').show(0, function() {
$('video').height(0);
$('video').animate({height: $('video').width() * (9 / 16), display: 'block'}, 1000);
});
Expand All @@ -87,13 +87,15 @@ function showLive(){
}

// Load the events from the file and add them to the page
function loadEvents(days){
function loadEvents(days) {
var ce = $('.card-container__events');
for(var i = 0; i < days.length; i++) {
var day = days[i];
var ds = day.day+'-event';
var ul = day.day+'-events';
var de = $('<li><div id="'+day.day+'" class="collapsible-header container day"><h5 class="day__title" data-position="right"><span class="day__title__bold">' + day.day + '</span> - ' + day.description + '</h5></div><div class="collapsible-body"><ul id="'+ul+'"class="collapsible sub-collapsible" data-collepsible="accordion"></div></ul>').appendTo(ce);
var ul = day.day + '-events';
var de = $('<li><div id="' + day.day + '" class="collapsible-header container day">
<h5 class="day__title" data-position="right"><span class="day__title__bold">' + day.day + '</span> - ' + day.description + '</h5></div>
<div class="collapsible-body"><ul id="'+ul+'"class="collapsible sub-collapsible" data-collepsible="accordion"></div></ul>');
de.appendTo(ce);

for(var j = 0; j < day.events.length; j++) {
var event = day.events[j];
Expand All @@ -114,7 +116,7 @@ function loadEvents(days){
}
}

$('h5').each( function( c ){
$('h5').each( function( c ) {
$(this).css({color: colors[(v+c) % 5]});
});

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "This repository contains the Techweek website",
"main": "gulpfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test": "eslint js/main,js && bin/check-event-json && gulp",
"postinstall": "gulp"
},
"repository": {
Expand All @@ -24,6 +24,7 @@
"gulp": "^3.9.1",
"gulp-clean-css": "^2.0.12",
"gulp-connect": "^5.0.0",
"gulp-json-schema": "^1.0.0",
"gulp-less": "^3.1.0",
"gulp-minify": "0.0.14",
"gulp-rename": "^1.2.2"
Expand Down
72 changes: 72 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "array",
"uniqueItems": false,
"items": {
"type": "object",
"properties": {
"day": {
"type": "string",
"minLength": 1
},
"description": {
"type": "string",
"minLength": 1
},
"events": {
"type": "array",
"uniqueItems": false,
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 1
},
"by": {
"type": "string",
"minLength": 1
},
"time": {
"type": "string",
"minLength": 1
},
"place": {
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"map": {
"type": "string",
"minLength": 1
}
},
"required": [
"id",
"map"
]
},
"description": {
"type": "string",
"minLength": 1
}
},
"required": [
"name",
"by",
"time",
"place",
"description"
]
}
}
},
"required": [
"day",
"description",
"events"
]
}
}

0 comments on commit 7491d2e

Please sign in to comment.