Skip to content
Snippets Groups Projects
Commit 6d993a4b authored by Akshay S Dinesh's avatar Akshay S Dinesh
Browse files

feat: remove gulp with bash scripts and direct dev tools

Must also fix #7
parent 95066def
No related merge requests found
build.sh 0 → 100644
echo "Processing assets"
mkdir -p public/fonts public/img
rsync -avzh --ignore-missing-args node_modules/bootstrap/fonts/*.{ttf,woff,eot,svg,woff2} node_modules/font-awesome/fonts/*.{ttf,woff,eot,svg,woff2,otf} fonts/*.{ttf,woff,woff2} node_modules/bootcards/dist/fonts/*.{ttf,woff,eot,svg,woff2,otf} public/fonts
rsync -avzh --ignore-missing-args node_modules/leaflet/dist/images/** img/** public/img
npx pug pug/pages --out public
echo "Processing events"
mkdir -p public/events
echo "events:" > public/events/index.yaml
for f in $(ls -r events/details); do
event=$(basename $f .yaml)
echo "Processing $event"
echo " $event:" >> public/events/index.yaml
cat "events/details/$f" | sed 's/^/ /' >> public/events/index.yaml
if ! [ -f public/events/$event.html ]; then
npx js-yaml "events/details/$f" > "public/events/$event.json"
npx pug -O public/events/$event.json pug/templates/individual_event_page.pug
mv pug/templates/individual_event_page.html public/events/$event.html
fi
done
npx js-yaml public/events/index.yaml > public/events/index.json
npx pug -O public/events/index.json pug/templates/events.pug
mv pug/templates/events.html public/events/index.html
echo "Processing CSS"
mkdir -p public/css
cat 'node_modules/bootstrap/dist/css/bootstrap.min.css' 'node_modules/font-awesome/css/font-awesome.min.css' 'node_modules/leaflet/dist/leaflet.css' 'node_modules/bootcards/dist/css/bootcards-desktop.min.css' css/*.css | npx postcss > public/css/index.css
echo "Processing JS"
mkdir -p public/js
npx uglify-js 'node_modules/jquery/dist/jquery.min.js' 'node_modules/bootstrap/dist/js/bootstrap.min.js' 'node_modules/leaflet/dist/leaflet.js' 'node_modules/bootcards/dist/js/bootcards.min.js' 'js/*.js' -o public/js/index.js
\ No newline at end of file
var gulp = require('gulp');
var htmlhint = require('gulp-htmlhint');
var jshint = require('gulp-jshint');
var csslint = require('gulp-csslint');
var pug = require('gulp-pug');
var concat = require('gulp-concat');
var cssmin = require('gulp-cssmin');
var uglify = require('gulp-uglify');
var connect = require('gulp-connect');
var connectProxy = require('gulp-connect-proxy');
var yamlinc = require('gulp-yaml-include');
var runSequence = require('run-sequence');
var readYaml = require('read-yaml');
var glob = require('glob');
var yaml = require('gulp-yaml');
var sortJSON = require('gulp-json-sort').default;
var fs = require('fs');
gulp.task('assetscopy', function() {
gulp.src([
'node_modules/bootstrap/fonts/*.{ttf,woff,eot,svg, woff2}',
'node_modules/font-awesome/fonts/*.{ttf,woff,eot,svg,woff2,otf}',
'fonts/*.{ttf,woff,woff2}',
'node_modules/bootcards/dist/fonts/*.{ttf,woff,eot,svg,woff2,otf}'
]).pipe(gulp.dest('public/fonts'));
gulp.src([
'node_modules/leaflet/dist/images/**',
'img/**'
]).pipe(gulp.dest('public/img'));
});
gulp.task('htmllint', function() {
gulp.src("public/*.html")
.pipe(htmlhint());
});
gulp.task('csslint', function() {
gulp.src('css/*.css')
.pipe(csslint({
'shorthand': false
}))
.pipe(csslint.formatter());
});
gulp.task('jslint', function() {
gulp.src(["gulpfile.js", "js/*.js"])
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('GenerateIndexPage', function() {
gulp.src('pug/pages/*.pug')
.pipe(pug({
pretty: true,
data: {
debug: true
}
}))
.pipe(gulp.dest('public'));
});
gulp.task('GenerateEventsYAML', function() {
return gulp.src("events/index.yaml")
.pipe(yamlinc())
.pipe(gulp.dest('public/events'));
});
gulp.task('GenerateEventsJSON', function() {
return gulp.src('public/events/index.yaml')
.pipe(yaml())
.pipe(sortJSON({
cmp: function(a, b) {
return a.key < b.key ? 1 : -1;
},
space: 2
}))
.pipe(gulp.dest('public/events'))
});
gulp.task('GenerateEventsIndex', function() {
fs.readFile('./public/events/index.json', "utf-8", function(err, sortedEvents){
if(err){
throw err;
}
gulp.src('pug/templates/events.pug')
.pipe(pug({
pretty: true,
data: {
debug: true,
events: JSON.parse(sortedEvents)
}
}))
.pipe(concat('index' + '.html'))
.pipe(gulp.dest('public/events'));
});
});
gulp.task('GenerateEventPages', function() {
glob("events/details/*.yaml", {}, function(er, files) {
var nooffiles = files.length;
for (var i = 0; i < nooffiles; i++) {
readYaml(files[i], function(err, ydata) {
if (err) throw err;
var id = ydata.id;
gulp.src('pug/templates/individual_event_page.pug')
.pipe(pug({
pretty: true,
data: {
debug: true,
evt: ydata
}
}))
.pipe(concat(id + '.html'))
.pipe(gulp.dest('public/events'));
});
}
});
});
gulp.task('pughtml', function() {
runSequence(
['GenerateIndexPage', 'GenerateEventPages'],
'GenerateEventsYAML',
'GenerateEventsJSON',
'GenerateEventsIndex'
)
});
gulp.task('cssmin', function() {
gulp.src([
'node_modules/bootstrap/dist/css/bootstrap.min.css',
'node_modules/font-awesome/css/font-awesome.min.css',
//'node_modules/normalize.css/normalize.css',
'node_modules/leaflet/dist/leaflet.css',
'node_modules/bootcards/dist/css/bootcards-desktop.min.css',
// 'node_modules/bootcards/dist/css/bootcards-android.min.css',
// 'node_modules/bootcards/dist/css/bootcards-ios.min.css',
'css/*.css'
])
.pipe(concat('index.css'))
.pipe(cssmin())
.pipe(gulp.dest('public/css'));
});
gulp.task('jsuglify', function() {
gulp.src([
'node_modules/jquery/dist/jquery.min.js',
'node_modules/bootstrap/dist/js/bootstrap.min.js',
'node_modules/leaflet/dist/leaflet.js',
'node_modules/bootcards/dist/js/bootcards.min.js',
'js/*.js'
])
.pipe(concat('index.js'))
.pipe(uglify())
.pipe(gulp.dest('public/js'));
gulp.src([
'node_modules/html5shiv/dist/html5shiv.js',
'node_modules/Respond.js/src/respond.js'
])
.pipe(uglify())
.pipe(gulp.dest('public/js'));
});
gulp.task('verify', [
'public',
'htmllint',
'csslint',
'jslint'
]);
gulp.task('public', [
'assetscopy',
'pughtml',
'cssmin',
'jsuglify'
]);
gulp.task('connect', function() {
connect.server({
root: 'public',
port: 8080,
livereload: true
});
});
gulp.task('watch', function() {
gulp.watch([
'./pug/**/*.pug'
], [
'pughtml',
'htmllint',
]);
gulp.watch([
'css/*.css',
'package.json'
], [
'csslint',
'cssmin'
]);
gulp.watch([
'js/*.js',
'package.json'
], [
'jslint',
'jsuglify',
]);
});
gulp.task('serve', [
'public',
'connect',
'watch'
]);
gulp.task('default', [
'serve'
]);
This diff is collapsed.
...@@ -10,32 +10,19 @@ ...@@ -10,32 +10,19 @@
}, },
"homepage": "https://fsug.in", "homepage": "https://fsug.in",
"devDependencies": { "devDependencies": {
"connect-livereload": "^0.5.4", "csslint": "^1.0.5",
"fs": "0.0.1-security", "cssnano": "^6.0.1",
"glob": "^7.1.2", "htmlhint": "^1.1.4",
"gulp": "^3.9.1", "js-yaml": "^4.1.0",
"gulp-concat": "^2.6.1", "jshint": "^2.13.6",
"gulp-connect": "^5.0.0", "postcss-cli": "^10.1.0",
"gulp-connect-proxy": "^0.3.1", "pug-cli": "^1.0.0-alpha6",
"gulp-csslint": "^1.0.0", "uglify-js": "^3.17.4"
"gulp-cssmin": "^0.2.0",
"gulp-htmlhint": "^0.3.1",
"gulp-jshint": "^2.0.4",
"gulp-json-sort": "^1.0.0",
"gulp-pug": "^3.3.0",
"gulp-uglify": "^3.0.0",
"gulp-yaml": "^1.0.1",
"gulp-yaml-data": "^0.2.0",
"gulp-yaml-include": "^0.2.0",
"read-yaml": "^1.1.0",
"run-sequence": "^1.2.2"
}, },
"dependencies": { "dependencies": {
"Respond.js": "git+https://github.com/scottjehl/Respond.git#1.4.0",
"bootcards": "git+https://github.com/bootcards/bootcards.git", "bootcards": "git+https://github.com/bootcards/bootcards.git",
"bootstrap": "^3.3.7", "bootstrap": "^3.3.7",
"font-awesome": "^4.7.0", "font-awesome": "^4.7.0",
"html5shiv": "^3.7.0",
"jquery": "2.2.4", "jquery": "2.2.4",
"leaflet": "^1.0.3", "leaflet": "^1.0.3",
"normalize.css": "^7.0.0" "normalize.css": "^7.0.0"
...@@ -43,6 +30,6 @@ ...@@ -43,6 +30,6 @@
"author": "FSCI - Free Software Community of India <fosscommunity.in@disroot.org>", "author": "FSCI - Free Software Community of India <fosscommunity.in@disroot.org>",
"license": "GPL-3.0", "license": "GPL-3.0",
"scripts": { "scripts": {
"install": "gulp public" "build": "sh build.sh"
} }
} }
module.exports = {
plugins: [
require('cssnano')({
preset: 'default',
}),
],
};
\ No newline at end of file
...@@ -30,7 +30,7 @@ block content ...@@ -30,7 +30,7 @@ block content
// panel body // panel body
.list-group .list-group
// list of sample data // list of sample data
for event in events.events for event in events
a.list-group-item.events-list.separator(href='/events/' + event.id + '.html') a.list-group-item.events-list.separator(href='/events/' + event.id + '.html')
img.img-rounded.pull-left(src=event.imgurl) img.img-rounded.pull-left(src=event.imgurl)
h4.list-group-item-heading= event.name h4.list-group-item-heading= event.name
......
...@@ -41,24 +41,24 @@ block content ...@@ -41,24 +41,24 @@ block content
.list-group .list-group
.list-group-item.separator-top .list-group-item.separator-top
label= "NAME" label= "NAME"
h4.list-group-item-heading= evt.name h4.list-group-item-heading= name
.list-group-item.separator .list-group-item.separator
label= "LOCATION" label= "LOCATION"
if (evt.lat != "" && evt.lng != "") if (lat != "" && lng != "")
a(href="http://www.openstreetmap.org/?mlat=" + evt.lat + "&mlon=" + evt.lng + "&ref=FSCI") a(href="http://www.openstreetmap.org/?mlat=" + lat + "&mlon=" + lng + "&ref=FSCI")
h4.list-group-item-heading= evt.venue + ', ' + evt.district h4.list-group-item-heading= venue + ', ' + district
else else
h4.list-group-item-heading= evt.venue + ', ' + evt.district h4.list-group-item-heading= venue + ', ' + district
.list-group-item.separator .list-group-item.separator
label= "ORGANIZED BY" label= "ORGANIZED BY"
h4.list-group-item-heading= evt.organizedby h4.list-group-item-heading= organizedby
.list-group-item.separator .list-group-item.separator
label= "DATETIME" label= "DATETIME"
h4.list-group-item-heading= evt.when h4.list-group-item-heading= when
if (evt.contactinfo != "") if (contactinfo != "")
.list-group-item.separator .list-group-item.separator
label= "CONTACT INFO" label= "CONTACT INFO"
h4.list-group-item-heading= evt.contactinfo h4.list-group-item-heading= contactinfo
#description-card.event-card.col-sm-8 #description-card.event-card.col-sm-8
.panel.panel-default.bootcards-richtext.event-details .panel.panel-default.bootcards-richtext.event-details
...@@ -66,6 +66,6 @@ block content ...@@ -66,6 +66,6 @@ block content
h3.panel-title Description h3.panel-title Description
a.btn.btn-primary.pull-right(href='http://fsci.org.in/events') a.btn.btn-primary.pull-right(href='http://fsci.org.in/events')
span Back span Back
.panel-body!= evt.description .panel-body!= description
p.lead p.lead
img(src=evt.imgurl, alt=evt.name) img(src=imgurl, alt=name)
npx htmlhint public/*.html
npx csslint css/*.css
npx jshint js/*.js
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment