From 315c6ae90a386254d0e8f4dbcedf891b3b080efd Mon Sep 17 00:00:00 2001 From: Ghislain Loaec Date: Thu, 20 Aug 2015 21:20:17 +0200 Subject: [PATCH 1/8] Grunt + Assets --- Gruntfile.js | 452 +++++++++++++++++++++++++++++++++++++ assets/scripts/momo.coffee | 38 ++++ package.json | 42 ++++ 3 files changed, 532 insertions(+) create mode 100644 Gruntfile.js create mode 100644 assets/scripts/momo.coffee create mode 100644 package.json diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..4cd677b --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,452 @@ +/** + * Gruntfile + * + * If you created your Sails app with `sails new foo --linker`, + * the following files will be automatically injected (in order) + * into the EJS and HTML files in your `views` and `assets` folders. + * + * At the top part of this file, you'll find a few of the most commonly + * configured options, but Sails' integration with Grunt is also fully + * customizable. If you'd like to work with your assets differently + * you can change this file to do anything you like! + * + * More information on using Grunt to work with static assets: + * http://gruntjs.com/configuring-tasks + */ + +module.exports = function (grunt) { + + var cssFilesToInject = [ + + // Vendors + 'styles/vendor/**/*.css', + + // All of the rest of your app styles imported here + 'styles/**/*.css' + ]; + + var jsFilesToInject = [ + + // Below, as a demonstration, you'll see the built-in dependencies + // linked in the proper order order + + // Bring in the socket.io client + //'scripts/vendor/socket.io.js', + + // A simpler boilerplate library for getting you up and running w/ an + // automatic listener for incoming messages from Socket.io. + //'scripts/vendor/app.js', + + // Vendors + 'scripts/vendor/**/*.js', + + // Marionnette Application + 'scripts/config/**/*.js', + 'scripts/app.js', + 'scripts/controllers/**/*.js', + 'scripts/entities/**/*.js', + 'scripts/views/**/*.js', + 'scripts/components/**/*.js', + 'scripts/apps/**/*.js', + + // All of the rest of your app scripts imported here + 'scripts/**/*.js' + ]; + + var templateFilesToInject = [ + 'templates/**/*.html', + ]; + + var ecoFilesToInject = [ + 'templates/**/*.eco', + 'scripts/**/*.eco', + 'scripts/apps/**/**/templates/*.eco' + ]; + + // Modify css file injection paths to use + cssFilesToInject = cssFilesToInject.map(function (path) { + return 'www/' + path; + }); + + // Modify js file injection paths to use + jsFilesToInject = jsFilesToInject.map(function (path) { + return 'www/' + path; + }); + + templateFilesToInject = templateFilesToInject.map(function (path) { + return 'assets/' + path; + }); + + ecoFilesToInject = ecoFilesToInject.map(function (path) { + return 'assets/' + path; + }); + + // Get path to core grunt dependencies + grunt.loadNpmTasks('grunt-concurrent'); + grunt.loadNpmTasks('grunt-run'); + grunt.loadNpmTasks('grunt-contrib-clean'); + grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-connect'); + grunt.loadNpmTasks('grunt-sails-linker'); + grunt.loadNpmTasks('grunt-contrib-jst'); + grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-cssmin'); + grunt.loadNpmTasks('grunt-contrib-less'); + grunt.loadNpmTasks('grunt-contrib-coffee'); + grunt.loadNpmTasks('grunt-contrib-sass'); + grunt.loadNpmTasks('grunt-eco'); + grunt.loadNpmTasks('grunt-groc'); + + // Project configuration. + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + + copy: { + reload: { + files: [ + { + expand: true, + cwd: './assets', + src: ['templates/core/reload.html'], + dest: 'www', + rename: function(dest, src) { + return dest + '/index.html' + } + } + ] + }, + dev: { + files: [ + { + expand: true, + cwd: './assets', + src: ['**/*.!(coffee|scss|sass|eco|haml)'], + dest: 'www' + } + ] + }, + build: { + files: [ + { + expand: true, + cwd: 'www', + src: ['**/*'], + dest: 'www' + } + ] + } + }, + + clean: { + dev: [ + 'www/scripts', + 'www/styles', + 'www/images', + 'www/fonts', + 'www/templates', + 'www/index.html', + 'www/templates.js' + ], + build: ['www'] + }, + + jst: { + dev: { + + // To use other sorts of templates, specify the regexp below: + // options: { + // templateSettings: { + // interpolate: /\{\{(.+?)\}\}/g + // } + // }, + + files: { + // 'www/jst.js': templateFilesToInject + } + } + }, + + eco: { + dev: { + files: { + 'www/templates.js': ecoFilesToInject + } + } + }, + + less: { + dev: { + files: [ + { + expand: true, + cwd: 'assets/styles/', + src: ['*.less'], + dest: 'www/styles/', + ext: '.css' + } + ] + } + }, + + sass: { + dev: { + files: [ + { + expand: true, + cwd: 'assets/styles/', + src: ['*.scss', '*.sass'], + dest: 'www/styles/', + ext: '.css' + } + ] + } + }, + + groc: { + markdown: [ + "README.md" + ], + coffeescript: [ + "assets/scripts/*.coffee", + "assets/scripts/**/*.coffee" + ], + javascript: [ + ], + stylesheet: [ + "assets/styles/*.scss", + "assets/styles/**/*.scss" + ], + options: { + "out": "assets/doc/", + "strip": "assets/", + "index": "README.md", + 'index-page-title': "BambooJS Documentation" + } + }, + + coffee: { + dev: { + options:{ + bare:true + }, + files: [ + { + expand: true, + cwd: 'assets/scripts/', + src: ['**/*.coffee'], + dest: 'www/scripts/', + ext: '.js' + } + ] + } + }, + + concat: { + js: { + src: jsFilesToInject, + dest: 'www/concat/production.js' + }, + css: { + src: cssFilesToInject, + dest: 'www/concat/production.css' + } + }, + + uglify: { + dist: { + src: ['www/concat/production.js'], + dest: 'www/min/production.js' + } + }, + + cssmin: { + dist: { + src: ['www/concat/production.css'], + dest: 'www/min/production.css' + } + }, + + 'sails-linker': { + + devJs: { + options: { + startTag: '', + endTag: '', + fileTmpl: '', + appRoot: 'www/' + }, + files: { + 'www/**/*.html': jsFilesToInject + } + }, + + prodJs: { + options: { + startTag: '', + endTag: '', + fileTmpl: '', + appRoot: 'www/' + }, + files: { + 'www/**/*.html': ['www/min/production.js'] + } + }, + + devStyles: { + options: { + startTag: '', + endTag: '', + fileTmpl: '', + appRoot: 'www/' + }, + + // cssFilesToInject defined up top + files: { + 'www/**/*.html': cssFilesToInject + } + }, + + prodStyles: { + options: { + startTag: '', + endTag: '', + fileTmpl: '', + appRoot: 'www/' + }, + files: { + 'www/index.html': ['www/min/production.css'] + } + }, + + // Bring in JST template object + devTpl: { + options: { + startTag: '', + endTag: '', + fileTmpl: '', + appRoot: 'www/' + }, + files: { + 'www/index.html': ['www/templates.js'] + } + }, + }, + + watch: { + assets: { + + // Assets to watch: + files: ['assets/**/*'], + + // When assets are changed: + tasks: ['compileAssets', 'linkAssets'] + } + }, + + connect: { + options: { + port: process.env.PORT || 3131, + base: 'dist/', + }, + + all: {}, + }, + + concurrent: { + options: { + logConcurrentOutput: true + }, + dev: { + tasks: ["run:phonegap", "watch"] + } + }, + + run: { + options: { + wait: true//false + }, + phonegap: { + cmd: 'phonegap', + args: ['serve', '--no-autoreload', '-p', 3001] + } + } + + }); + + //require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); + + grunt.registerTask('server', [ + 'compileAssets', + 'linkAssets', + 'concurrent:dev', + ]); + + // When Sails is lifted: + grunt.registerTask('default', ['server']); + + grunt.registerTask('compileAssets', [ + 'clean:dev', + 'copy:reload', + 'jst:dev', + 'eco:dev', + 'less:dev', + 'sass:dev', + 'coffee:dev', + 'copy:dev' + ]); + + grunt.registerTask('linkAssets', [ + + // Update link/script/template references in `assets` index.html + 'sails-linker:devJs', + 'sails-linker:devStyles', + 'sails-linker:devTpl' + ]); + + + // Build the assets into a web accessible folder. + // (handy for phone gap apps, chrome extensions, etc.) + grunt.registerTask('build', [ + 'compileAssets', + 'linkAssets', + 'clean:build', + 'copy:build' + ]); + + // When sails is lifted in production + grunt.registerTask('prod', [ + 'clean:dev', + 'eco:dev', + 'jst:dev', + 'less:dev', + 'sass:dev', + 'copy:dev', + 'coffee:dev', + 'concat', + 'uglify', + 'cssmin', + 'sails-linker:prodJs', + 'sails-linker:prodStyles', + 'sails-linker:devTpl' + ]); + + grunt.registerTask('doc', ['groc']); + + // When API files are changed: + // grunt.event.on('watch', function(action, filepath) { + // grunt.log.writeln(filepath + ' has ' + action); + + // // Send a request to a development-only endpoint on the server + // // which will reuptake the file that was changed. + // var baseurl = grunt.option('baseurl'); + // var gruntSignalRoute = grunt.option('signalpath'); + // var url = baseurl + gruntSignalRoute + '?action=' + action + '&filepath=' + filepath; + + // require('http').get(url) + // .on('error', function(e) { + // console.error(filepath + ' has ' + action + ', but could not signal the Sails.js server: ' + e.message); + // }); + // }); +}; diff --git a/assets/scripts/momo.coffee b/assets/scripts/momo.coffee new file mode 100644 index 0000000..a4090de --- /dev/null +++ b/assets/scripts/momo.coffee @@ -0,0 +1,38 @@ +class Momo + + manifest: + meta: + manifestUrl: "index.json" + + contructor: (args...) -> + @bindEvents() + + bindEvents: -> + # Navigation Handler + window.addEventListener "hashchange", @onHashChange, false + document.addEventListener "deviceready", @onDeviceReady, false + + init: -> + @initFileSystem() + @initIndex() + @backupAssets() + @loadLocalManifest() + @checkForUpdate(app.start, app.start) + @updateTimeout = setTimeout( app.checkForLastUpdateCheck, app.manifest.meta.updateFreq ) + + initFileSystem: -> + + + FastClick.attach(document.body) + + start: -> + @loadManifest() + + loadManifest: -> + manifest = JSON.parse + + update: -> + + updateAvailable: (y, n, f) -> + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..90a4a5e --- /dev/null +++ b/package.json @@ -0,0 +1,42 @@ +{ + "name": "momo", + "private": true, + "version": "1.0.3", + "description": "Simple cross-platform application implementing self-update mechanisms", + "dependencies": { + "ejs": "0.8.4", + "optimist": "0.3.4" + }, + "scripts": { + "debug": "node debug app.js", + "grunt": "node_modules/.bin/grunt", + "start": "node_modules/.bin/grunt" + }, + "main": "app.js", + "repository": "http://git.pwr.link/ghis/momo.git", + "author": "Ghislain Loaec", + "license": "", + "devDependencies": { + "font-awesome": "^4.3.0", + "grunt": "^0.4.5", + "grunt-cli": "^0.1.13", + "grunt-concurrent": "^2.0.0", + "grunt-contrib-clean": "^0.6.0", + "grunt-contrib-coffee": "^0.13.0", + "grunt-contrib-concat": "^0.5.1", + "grunt-contrib-connect": "^0.10.1", + "grunt-contrib-copy": "^0.8.0", + "grunt-contrib-cssmin": "^0.12.3", + "grunt-contrib-jst": "^0.6.0", + "grunt-contrib-less": "^1.0.1", + "grunt-contrib-sass": "^0.9.2", + "grunt-contrib-uglify": "^0.9.1", + "grunt-contrib-watch": "^0.6.1", + "grunt-eco": "~0.1.2", + "grunt-groc": "~0.5.0", + "grunt-run": "^0.3.0", + "grunt-sails-linker": "^0.10.1", + "matchdep": "^0.3.0", + "weinre": "^2.0.0-pre-I0Z7U9OV" + } +} From 77419ea9ac75231b1a0812a4b63c789700776749 Mon Sep 17 00:00:00 2001 From: Ghislain Loaec Date: Wed, 2 Sep 2015 09:52:18 +0200 Subject: [PATCH 2/8] Icon persistent --- www/index.html | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/www/index.html b/www/index.html index 77170cf..26ec13d 100644 --- a/www/index.html +++ b/www/index.html @@ -80,32 +80,32 @@ {% } %}
- - {% if(!(o.titlePersistent || o.meta.titlePersistent || o.id == 'home')){ %} - {%# (o.titleSeparator || o.meta.titleSeparator) %} - {% } %} - - {% var icon = (o.titlePersistent || o.meta.titlePersistent || o.id == 'home') ? o.meta.icon : o.icon || o.meta.icon; %} - {% if(icon){ %} - {%# tmpl('momo-icon-tmpl', { icon: icon, size: 20, header: true }) %} - {% } %} - - - {% if(o.titlePersistent || o.meta.titlePersistent || o.id == 'home'){ %} - {%= o.meta.title %} + + {% if(!(o.titlePersistent || o.meta.titlePersistent || o.id == 'home')){ %} {%# (o.titleSeparator || o.meta.titleSeparator) %} - - {% if(o.meta.icon && o.icon){ %} - {%# tmpl('momo-icon-tmpl', { icon: o.icon, size: 20, header: true }) %} - {% } %} - {%# o.title %} - - {% } else { %} - {%# (o.title || o.meta.title) %} {% } %} + + {% var icon = (o.titlePersistent || o.meta.titlePersistent || o.id == 'home') ? o.meta.icon : o.icon || o.meta.icon; %} + {% if(icon){ %} + {%# tmpl('momo-icon-tmpl', { icon: icon, size: 20, header: true }) %} + {% } %} + + + {% if(o.titlePersistent || o.meta.titlePersistent || o.id == 'home'){ %} + {%= o.meta.title %} + {%# (o.titleSeparator || o.meta.titleSeparator) %} + + {% if(o.meta.icon && o.icon){ %} + {%# tmpl('momo-icon-tmpl', { icon: o.icon, size: 20, header: true }) %} + {% } %} + {%# o.title %} + + {% } else { %} + {%# (o.title || o.meta.title) %} + {% } %} + - -
+ From b8677374d57676f3438b38ddbb342a8924140aab Mon Sep 17 00:00:00 2001 From: Ghislain Loaec Date: Wed, 2 Sep 2015 11:34:53 +0200 Subject: [PATCH 3/8] =?UTF-8?q?Iframe=20loading=20spinner=20Ref=C2=A0#8079?= =?UTF-8?q?=20+=20Disable=20fullscreen=20Ref=20#8080?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.xml | 2 +- www/assets/bp.svg | 26 ++++++++++++++++++++++++++ www/css/index.css | 16 +++++++++++++++- www/index.html | 10 ++++++++++ 4 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 www/assets/bp.svg diff --git a/config.xml b/config.xml index 3e1e29d..7914ddc 100644 --- a/config.xml +++ b/config.xml @@ -11,7 +11,7 @@ - + diff --git a/www/assets/bp.svg b/www/assets/bp.svg new file mode 100644 index 0000000..aa4ea18 --- /dev/null +++ b/www/assets/bp.svg @@ -0,0 +1,26 @@ + + + + +Created by potrace 1.10, written by Peter Selinger 2001-2011 + + + + + + + + diff --git a/www/css/index.css b/www/css/index.css index ceae877..896511b 100644 --- a/www/css/index.css +++ b/www/css/index.css @@ -133,6 +133,16 @@ body { /*height: 100% !important;*/ display: block; } +.momo-frame-spinner { + display: table; + position: absolute; + top: 0; + left: 0; + bottom:60px; + right: 0; + width:100%; + height:100%; +} .momo-frame-overlay { display: block; position: absolute; @@ -269,8 +279,11 @@ img { .navbar .col-xs-8 { display: table; } +.navbar-header { + min-width: 200px; +} .parent-navbar-brand { - display: block; + display: table; height: 60px; overflow: hidden; } @@ -282,6 +295,7 @@ img { vertical-align: middle; width: 100%; line-height: 18px; + min-width: 100px; } .navbar .navbar-btn { diff --git a/www/index.html b/www/index.html index 26ec13d..5cfb914 100644 --- a/www/index.html +++ b/www/index.html @@ -241,6 +241,16 @@ {% var displayFooter = true; %}
+ {% if(o.url && !o.url.isImage()){ %} +
+
+ +

+ Chargement du contenu +

+
+
+ {% } %} {% if(!(o.url && o.url.isImage())){ %}
From a7eb9122b90670622c6bd888915c4ad78bff3e78 Mon Sep 17 00:00:00 2001 From: Ghislain Loaec Date: Thu, 24 Sep 2015 11:22:47 +0200 Subject: [PATCH 4/8] Eole logo --- www/assets/eole.svg | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 www/assets/eole.svg diff --git a/www/assets/eole.svg b/www/assets/eole.svg new file mode 100644 index 0000000..44aa517 --- /dev/null +++ b/www/assets/eole.svg @@ -0,0 +1,50 @@ + + + + +Created by potrace 1.10, written by Peter Selinger 2001-2011 + + + + + + + + + From e073f8c1f02118fec93816076ffa9190553fdb82 Mon Sep 17 00:00:00 2001 From: Ghislain Loaec Date: Thu, 24 Sep 2015 11:29:15 +0200 Subject: [PATCH 5/8] updateFreq in milliseconds - Fixes #8085 --- www/js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/js/index.js b/www/js/index.js index 85fad10..d28a90e 100644 --- a/www/js/index.js +++ b/www/js/index.js @@ -201,7 +201,7 @@ var app = { checkForLastUpdateCheck: function(resolve, reject){ // Checklast Update var lastUpdate = localStorage.getItem("momo-timestamp") ? new Date(localStorage.getItem("momo-timestamp")) : new Date(0); - var timeDiff = ((new Date()).getTime() - lastUpdate.getTime()) / 1000; + var timeDiff = ((new Date()).getTime() - lastUpdate.getTime()); var updateRequired = timeDiff > app.manifest.meta.updateFreq; if(updateRequired){ From 3f3c9bedc337b574b7e34fde548a75d871aa0f31 Mon Sep 17 00:00:00 2001 From: Ghislain Loaec Date: Thu, 24 Sep 2015 11:37:26 +0200 Subject: [PATCH 6/8] Wait for updateFreq before asking user to update - Fixes #8084 --- www/index.json | 2 +- www/js/index.js | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/www/index.json b/www/index.json index a17a55c..e50aa44 100644 --- a/www/index.json +++ b/www/index.json @@ -2,7 +2,7 @@ "title": "Ma ville au quotidien (Local)", "icon": "icon.png", "contact": "info@example.net", - "updateFreq": 5, + "updateFreq": 5000, "manifestUrl": "http://pwr.link/entrouvert/index.json", "assetsUrl": "http://pwr.link/entrouvert/assets.zip" }, diff --git a/www/js/index.js b/www/js/index.js index d28a90e..82db41a 100644 --- a/www/js/index.js +++ b/www/js/index.js @@ -130,13 +130,16 @@ var app = { app.loadLocalManifest(); // Check for new updates - app.checkForUpdate(app.start, app.start); + //app.checkForUpdate(app.start, app.start); // Update Reminder app.updateTimeout = setTimeout( app.checkForLastUpdateCheck, app.manifest.meta.updateFreq ); // Touch events faster response patch FastClick.attach(document.body); + + // Start Application + app.start(); }, initFileSystem: function(){ @@ -992,7 +995,7 @@ var app = { prev, next; - console.warn(app.previousPage + " -> " + page); + //console.warn(app.previousPage + " -> " + page); // Hack of the century ? if(app.ignoreHash){ return false; } @@ -1089,7 +1092,7 @@ var app = { var back = page === 'home'; - console.log(app.pageHistory.join(',')+ " (index = "+app.pageIndex+")"); + //console.log(app.pageHistory.join(',')+ " (index = "+app.pageIndex+")"); if (app.pageHistory.length/* && app.historyLength == length*/) { // Goind Back From 722ff15d4d3b88887fafd7684ed30df4dece070f Mon Sep 17 00:00:00 2001 From: Ghislain Loaec Date: Fri, 2 Oct 2015 09:58:24 +0200 Subject: [PATCH 7/8] Description Ref #8116 + Offline mode Ref #8052 + Minor fixes --- assets/scripts/momo.coffee | 3 +- www/css/index.css | 16 ++++++- www/index.html | 68 ++++++++++++++++++--------- www/js/index.js | 95 +++++++++++++++++++++++++++++++++++++- 4 files changed, 157 insertions(+), 25 deletions(-) diff --git a/assets/scripts/momo.coffee b/assets/scripts/momo.coffee index a4090de..51b54e6 100644 --- a/assets/scripts/momo.coffee +++ b/assets/scripts/momo.coffee @@ -7,9 +7,10 @@ class Momo contructor: (args...) -> @bindEvents() + bindEvents: -> # Navigation Handler - window.addEventListener "hashchange", @onHashChange, false + xindow.addEventListener "hashchange", @onHashChange, false document.addEventListener "deviceready", @onDeviceReady, false init: -> diff --git a/www/css/index.css b/www/css/index.css index 896511b..59ad62a 100644 --- a/www/css/index.css +++ b/www/css/index.css @@ -280,7 +280,7 @@ img { display: table; } .navbar-header { - min-width: 200px; + /*min-width: 300px;*/ } .parent-navbar-brand { display: table; @@ -338,6 +338,9 @@ h1 { overflow:visible; padding:0px; } +h5 { + font-size: 16px; +} @keyframes fade { from { opacity: 1.0; } @@ -377,15 +380,26 @@ pre .boolean { color: #7587A6; } pre .null { color: #828282; } pre .key { color: #CDA869; } +.top-0 { + margin-top: 0px; +} .top-10 { margin-top: 10px; } .top-20 { margin-top: 20px; } +.bottom-0 { + margin-bottom: 0px; +} .bottom-10 { margin-bottom: 10px; } .bottom-20 { margin-bottom: 20px; } +@media (min-width: 768px) { + .navbar .navbar-btn { + padding-left: 0; + } +} diff --git a/www/index.html b/www/index.html index 5cfb914..6507c61 100644 --- a/www/index.html +++ b/www/index.html @@ -71,15 +71,15 @@ + + +