Skip to content

Commit

Permalink
- Fix scollbar on desktop browser - Fix #41
Browse files Browse the repository at this point in the history
- Add build time on JS path - Fix #55
- Remove menu footer on mobile device - fix #47
- Currency explore: remove duplicate layout for large screen UI - Fix #18
- Build: add minfy, useref and ngInject
- Build: add gulp task 'build:web', that genrate a ZIP for web site deployment
- Generate templates and i18n info JS file
  • Loading branch information
blavenie committed Jun 13, 2016
1 parent a877d70 commit 8f29797
Show file tree
Hide file tree
Showing 48 changed files with 1,150 additions and 1,512 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ www/lib/angular-ui-router
www/lib/angular-moment
www/lib/moment
www/lib/waves
www/dist
28 changes: 3 additions & 25 deletions app/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,15 @@
"DUNITER_NODE": "cgeek.fr:9330",
"NEW_ISSUE_LINK": "https://github.com/duniter/cesium/issues/new?labels=bug",
"TIMEOUT": 4000,
"DEBUG": false,
"NATIVE_TRANSITION": false
}
},

"duniter-fr": {
"APP_CONFIG": {
"DUNITER_NODE": "cgeek.fr:9330",
"NEW_ISSUE_LINK": "https://github.com/duniter/cesium/issues/new?labels=bug",
"TIMEOUT": 4000,
"DEBUG": false,
"NATIVE_TRANSITION": false
}
},

"android": {
"APP_CONFIG": {
"DUNITER_NODE": "cgeek.fr:9330",
"NEW_ISSUE_LINK": "https://github.com/duniter/cesium/issues/new?labels=bug",
"TIMEOUT": 6000,
"DEBUG": false,
"NATIVE_TRANSITION": true
"DEBUG": false
}
},

"dev": {
"APP_CONFIG": {
"DUNITER_NODE": "localhost:9201",
"TIMEOUT": 4000,
"DEBUG": false,
"NATIVE_TRANSITION": true
"TIMEOUT": 6000,
"DEBUG": true
}
}
}
48 changes: 26 additions & 22 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,32 @@
xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0"
id="fr.duniter.cesium"
version="0.1.15"
android-versionCode="3"
version="0.1.16"
android-versionCode="4"
>
<name>Cesium</name>
<description>
A webapp client for Duniter
</description>
<author email="contact@duniter.fr" href="http://www.duniter.fr">
Duniter team
</author>
<content src="index.html" />
<access origin="*" />
<preference name="webviewbounce" value="false" />
<preference name="UIWebViewBounce" value="false" />
<preference name="DisallowOverscroll" value="true" />
<preference name="android-minSdkVersion" value="16" />
<preference name="BackupWebStorage" value="none" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="3000" />
<feature name="StatusBar">
<param name="ios-package" onload="true" value="CDVStatusBar" />
</feature>
<name>Cesium</name>
<description>
A webapp client for Duniter
</description>
<author email="contact@duniter.fr" href="http://www.duniter.fr">
Duniter team
</author>
<content src="index.html" />
<access origin="*" />
<!-- icon requirement for Ubuntu click packages -->
<icon src="www/img/logo.png" />
<preference name="webviewbounce" value="false" />
<preference name="UIWebViewBounce" value="false" />
<preference name="DisallowOverscroll" value="true" />
<preference name="android-minSdkVersion" value="16" />
<preference name="BackupWebStorage" value="none" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="3000" />
<preference name="CrosswalkAnimatable" value="true" />
<allow-navigation href="*" />
<feature name="StatusBar">
<param name="ios-package" onload="true" value="CDVStatusBar" />
</feature>
<platform name="android">
<icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
<icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
Expand Down Expand Up @@ -73,5 +77,5 @@
<splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
<splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
</platform>
<allow-navigation href="*" />
<hook type="after_build" src="scripts/afterBuild.js" />
</widget>
214 changes: 202 additions & 12 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,34 @@ var fs = require("fs");
var argv = require('yargs').argv;
var header = require('gulp-header');
var removeCode = require('gulp-remove-code');
//var bump = require('gulp-bump');
var removeHtml = require('gulp-html-remove');
var templateCache = require('gulp-angular-templatecache');
var ngTranslate = require('gulp-angular-translate');
var ngAnnotate = require('gulp-ng-annotate');
var es = require('event-stream');
var zip = require('gulp-zip');
var del = require('del');
var useref = require('gulp-useref');
var filter = require('gulp-filter');
var uglify = require('gulp-uglify');
var csso = require('gulp-csso');
var rev = require('gulp-rev');
var revReplace = require('gulp-rev-replace');
var clean = require('gulp-clean');
var htmlmin = require('gulp-htmlmin');
var deleteEmpty = require('delete-empty');
var jshint = require('gulp-jshint');

var paths = {
sass: ['./scss/**/*.scss'],
config: ['./app/config.json'],
templates: ['./www/templates/**/*.html']
templates: ['./www/templates/**/*.html'],
templatecache: ['./www/templates/**/*.html'],
ng_translate: ['./www/i18n/locale-*.json'],
ng_annotate: ['./www/js/*.js']
};

gulp.task('default', ['sass', 'config']);
gulp.task('default', ['sass', 'config', 'templatecache', 'ng_translate', 'ng_annotate']);

gulp.task('sass', function(done) {
gulp.src('./scss/ionic.app.scss')
Expand All @@ -35,18 +54,12 @@ gulp.task('sass', function(done) {
.on('end', done);
});

// TODO : enable to have a special buidl for phone
//gulp.task('removeCode', function(done) {
// gulp.src('./www/templates/**/*.html')
// .pipe(removeCode({ production: true }))
// .pipe(gulp.dest('./dist/templates'))
// .on('end', done);
//});

gulp.task('watch', function() {
gulp.watch(paths.sass, ['sass']);
//gulp.watch(paths.config, ['config']);
//gulp.watch(paths.templates, ['removeCode']);
gulp.watch(paths.templatecache, ['templatecache']);
gulp.watch(paths.ng_translate, ['ng_translate']);
gulp.watch(paths.ng_annotate, ['ng_annotate']);
});

gulp.task('install', ['git-check'], function() {
Expand Down Expand Up @@ -102,3 +115,180 @@ gulp.task('config', function (done) {
.pipe(gulp.dest('www/js'))
;
});

gulp.task('templatecache', function (done) {
gulp.src('./www/templates/**/*.html')
.pipe(templateCache({
standalone:true,
module:"cesium.templates",
root: "templates/"
}))
.pipe(gulp.dest('./www/dist/dist_js/app'))
.on('end', done);
});

gulp.task('ng_annotate', function (done) {
gulp.src('./www/js/**/*.js')
.pipe(ngAnnotate({single_quotes: true}))
.pipe(gulp.dest('./www/dist/dist_js/app'))
.on('end', done);
});

gulp.task('ng_translate', function() {
return gulp.src('www/i18n/locale-*.json')
.pipe(ngTranslate({standalone:true, module: 'cesium.translations'}))
.pipe(gulp.dest('www/dist/dist_js/app'));
});

gulp.task('clean:tmp', function(done) {
return del([
'./tmp'
]);
});

gulp.task('clean:web', function(done) {
return del([
'./platforms/web/www',
'./platforms/web/build'
]);
});

gulp.task('copy-files:web', ['clean:tmp', 'clean:web', 'sass', 'config'], function(done) {
var tmpPath = './platforms/web/www';
es.concat(
// Copy Js (and remove unused code)
gulp.src('./www/js/**/*.js')
.pipe(removeCode({"no-device": true}))
.pipe(jshint())
.pipe(gulp.dest(tmpPath + '/js')),

// Copy HTML templates (and remove unused code)
gulp.src('./www/templates/**/*.html')
.pipe(removeCode({"no-device": true}))
.pipe(removeHtml('.hidden-no-device'))
.pipe(removeHtml('[remove-if][remove-if="no-device"]'))
.pipe(htmlmin())
.pipe(gulp.dest(tmpPath + '/templates')),

// Copy index.html (and remove unused code)
gulp.src('./www/index.html')
.pipe(removeCode({"no-device": true}))
.pipe(removeHtml('.hidden-no-device'))
.pipe(removeHtml('[remove-if][remove-if="no-device"]'))
.pipe(htmlmin())
.pipe(gulp.dest(tmpPath)),

// Copy CSS
gulp.src('./www/css/**/*.*')
.pipe(gulp.dest(tmpPath + '/css')),

// Copy i18n
gulp.src('./www/i18n/locale-*.json')
.pipe(ngTranslate({standalone:true, module: 'cesium.translations'}))
.pipe(gulp.dest(tmpPath + '/js')),

// Copy img
gulp.src('./www/img/**/*.*')
.pipe(gulp.dest(tmpPath + '/img')),

// Copy lib/ionic
gulp.src('./www/lib/ionic/**/*.*')
.pipe(gulp.dest(tmpPath + '/lib/ionic'))
)
.on('end', done);
});

gulp.task('templatecache:web', ['copy-files:web'], function (done) {
var tmpPath = './platforms/web/www';
gulp.src(tmpPath + '/templates/**/*.html')
.pipe(templateCache({
standalone:true,
module:"cesium.templates",
root: "templates/"
}))
.pipe(gulp.dest(tmpPath + '/js'))
.on('end', done);
});

gulp.task('ng_annotate:web', ['templatecache:web'], function (done) {
var tmpPath = './platforms/web/www';
var jsFilter = filter(["**/*.js", "!**/vendor/*"]);

gulp.src(tmpPath + '/js/**/*.js')
.pipe(jsFilter)
.pipe(ngAnnotate({single_quotes: true}))
.pipe(gulp.dest(tmpPath + '/dist/dist_js/app'))
.on('end', done);
});

gulp.task('optimize-files:web', ['ng_annotate:web'], function(done) {
var tmpPath = './platforms/web/www';
var jsFilter = filter(["**/*.js", "!**/vendor/*"], { restore: true });
var cssFilter = filter("**/*.css", { restore: true });
var indexHtmlFilter = filter(['**/*', '!**/index.html'], { restore: true });

gulp.src(tmpPath + '/index.html')
.pipe(useref()) // Concatenate with gulp-useref
.pipe(jsFilter)
.pipe(uglify()) // Minify any javascript sources
.pipe(jsFilter.restore)
.pipe(cssFilter)
.pipe(csso()) // Minify any CSS sources
.pipe(cssFilter.restore)
.pipe(indexHtmlFilter)
.pipe(rev()) // Rename the concatenated files (but not index.html)
.pipe(indexHtmlFilter.restore)
.pipe(revReplace()) // Substitute in new filenames
.pipe(gulp.dest(tmpPath))
.on('end', done);
});

gulp.task('clean-unused-files:web', ['optimize-files:web'], function(done) {
var tmpPath = './platforms/web/www';
var jsFilter = filter(["**/*.js", "!**/cesium-*.js"]);
var cssFilter = filter(["**/*.css", "!**/cesium-*.css"]);

es.concat(
gulp.src(tmpPath + '/js/**/*.js', {read: false})
.pipe(jsFilter)
.pipe(clean()),

gulp.src(tmpPath + '/css/**/*.css', {read: false})
.pipe(cssFilter)
.pipe(clean())
)
.on ('end', done);
});

gulp.task('clean-unused-directories:web', ['clean-unused-files:web'], function(done) {
var tmpPath = './platforms/web/www';
return del([
tmpPath + '/css',
tmpPath + '/templates',
tmpPath + '/js',
tmpPath + '/dist',
tmpPath + '/lib/ionic/scss',
tmpPath + '/lib/ionic/css',
tmpPath + '/lib/ionic/js'
]);
});

gulp.task('zip:web', ['clean-unused-directories:web'], function(done) {
var tmpPath = './platforms/web/www';
var version = JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
var fileFilter = filter(['**', '!*/templates', '!*/css', '!*/js']);

gulp.src(tmpPath + '/**/*.*')
.pipe(zip('cesium-web-'+version+'.zip'))
.pipe(fileFilter)
.pipe(gulp.dest('./platforms/web/build'))
.on('end', done);
});

gulp.task('build:web', ['zip:web'], function(done) {
var version = JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
gutil.log(gutil.colors.green("Build for web created at: 'plateforms/web/build/cesium-web-" + version + ".zip'"));
return del([
'./tmp'
]);
});
Loading

0 comments on commit 8f29797

Please sign in to comment.