Skip to content

Commit

Permalink
Big refactor, implementing build process
Browse files Browse the repository at this point in the history
  • Loading branch information
tobika committed Jan 14, 2016
1 parent 96da41f commit 2cb82ea
Show file tree
Hide file tree
Showing 198 changed files with 2,069 additions and 176,737 deletions.
2 changes: 1 addition & 1 deletion .bowerrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"directory": "www/lib"
"directory": "vendor"
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ playstore/
*.sublime*
*.keystore
.idea/
vendor

www/js/app.bundle.js
www/dist/
4 changes: 2 additions & 2 deletions build-playstore.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash
VERSION="0.2.7"
VERSION="0.3"

echo Preparing playstore apks for version $VERSION

BUILD_MULTIPLE_APKS=true ionic build --release android
#BUILD_MULTIPLE_APKS=true ionic build --release android

read -p "Press any key to continue... " -n1 -s

Expand Down
4 changes: 2 additions & 2 deletions config.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.tobik.poocount" version="0.2.8" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Poocount</name>
<widget id="com.tobik.poocountdev" version="0.3" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Poocount dev</name>
<description>
An app to count your poo. Why would you want to do this? For medical reasons.
</description>
Expand Down
30 changes: 26 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@ var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var sh = require('shelljs');
var sourcemaps = require('gulp-sourcemaps');
var templateCache = require('gulp-angular-templatecache');

var paths = {
sass: ['./scss/**/*.scss'],
scripts: ['./www/js/**/*.js', '!./www/js/app.bundle.js']
scripts: ['./src/**/*.js', '!./www/js/app.bundle.js'],
vendor: ['./vendor/**/*.js'],
templateCache: ['./www/templates/**/*.html']
};

var files = {
jsbundle: 'app.bundle.js',
vendorbundle: 'vendor.bundle.js',
appcss: 'app.css'
};

gulp.task('default', ['sass']);

gulp.task('default', ['sass','vendor','templatecache']);

// scripts - clean dist dir then annotate, minify, concat
gulp.task('scripts', function() {
Expand All @@ -35,7 +38,24 @@ gulp.task('scripts', function() {
// .pipe(uglify())
.pipe(concat(files.jsbundle))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./www/js'));
.pipe(gulp.dest('./www/dist'));
});

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

gulp.task('vendor', function() {
gulp.src(['./vendor/ionic/js/ionic.bundle.min.js',
'./vendor/ngCordova/dist/ng-cordova.min.js',
'./vendor/angular-translate/angular-translate.min.js',
'vendor/angular-translate-loader-static-files/angular-translate-loader-static-files.min.js',
'./vendor_manual/**/*.js'])
.pipe(concat(files.vendorbundle))
.pipe(gulp.dest('./www/dist/'));
});

gulp.task('sass', function(done) {
Expand All @@ -53,6 +73,8 @@ gulp.task('sass', function(done) {
gulp.task('watch', function() {
gulp.watch(paths.sass, ['sass']);
gulp.watch(paths.scripts, ['scripts']);
gulp.watch(paths.vendor, ['vendor']);
gulp.watch(paths.templatecache, ['templatecache']);
});

gulp.task('install', ['git-check'], function() {
Expand Down
2 changes: 1 addition & 1 deletion hooks/before_prepare/02_jshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var foldersToProcess = [
];

foldersToProcess.forEach(function(folder) {
processFiles("www/" + folder);
processFiles("src/" + folder);
});

function processFiles(dir, callback) {
Expand Down
6 changes: 5 additions & 1 deletion ionic.project
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
"app_id": "7c28fcc7",
"gulpStartupTasks": [
"sass",
"scripts",
"vendor",
"templatecache",
"watch"
],
"watchPatterns": [
"www/**/*",
"!www/lib/**/*"
"!www/lib/**/*",
"vendor/**/*"
],
"browsers": [
{
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
"gulp-rename": "^1.2.0",
"gulp-sass": "^0.7.1",
"gulp-sourcemaps": "^1.5.2",
"highcharts": "^4.2.1",
"jshint": "^2.7.0"
},
"devDependencies": {
"bower": "^1.3.3",
"gulp-angular-templatecache": "^1.8.0",
"gulp-util": "^2.2.14",
"karma": "^0.12.31",
"karma-chrome-launcher": "^0.1.8",
Expand All @@ -29,7 +31,8 @@
"org.apache.cordova.inappbrowser",
"cordova-plugin-whitelist",
"cordova-plugin-crosswalk-webview",
"com.ionic.keyboard"
"com.ionic.keyboard",
"nl.x-services.plugins.toast"
],
"cordovaPlatforms": [
"android",
Expand All @@ -39,4 +42,4 @@
"locator": "android"
}
]
}
}
4 changes: 2 additions & 2 deletions www/css/poocount.css → scss/_poocount.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/*margin-top: 20px;*/
}

input.add {chi
input.add {
/*border: solid 1px !important;*/
text-align: left;
background-color: white !important;
Expand Down Expand Up @@ -43,7 +43,7 @@ input.add {chi
}

.bar-footer {
height: 50px;
height: 70px;
padding: 0;
}

Expand Down
6 changes: 5 additions & 1 deletion scss/ionic.app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ $dark: #36352C !default;
$ionicons-font-path: "../lib/ionic/fonts" !default;

// Include all of Ionic
@import "www/lib/ionic/scss/ionic";
@import "vendor/ionic/scss/ionic";
@import "poocount";
@import "picker/default";
@import "picker/default.date";
@import "picker/default.time";

input {
width: 40% !important;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion www/js/app.js → src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// the 2nd parameter is an array of 'requires'
// 'starter.services' is found in service_database.js
// 'starter.controllers' is found in controllers.js
angular.module('starter', ['ionic', 'ngCordova', 'starter.controllers', 'starter.services', 'angular-datepicker', 'pascalprecht.translate'])
angular.module('starter', ['ionic', 'templates', 'ngCordova', 'starter.controllers', 'starter.services', 'angular-datepicker', 'pascalprecht.translate'])

.run(function($ionicPlatform, $translate, SettingsService) {
$ionicPlatform.ready(function() {
Expand Down
131 changes: 131 additions & 0 deletions src/config_routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
angular.module('starter').config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) {

$ionicConfigProvider.tabs.position("top");
//ionicConfigProvider.views.maxCache(0);

// Ionic uses AngularUI Router which uses the concept of states
// Learn more here: https://github.com/angular-ui/ui-router
// Set up the various states which the app can be in.
// Each state's controller can be found in controllers.js
$stateProvider

// setup an abstract state for the tabs directive
.state('tab', {
url: "/tab",
abstract: true,
templateUrl: "tabs.html",
controller: 'TabCtrl'
})

// Each tab has its own nav history stack:

.state('tab.add', {
url: '/add',
views: {
'tab-add': {
templateUrl: 'tab-new.html',
controller: 'AddCtrl'
}
}
})

.state('tab.stats', {
url: '/stats',
views: {
'tab-stats': {
templateUrl: 'tab-stats.html',
controller: 'StatsCtrl'
}
}
})
.state('tab.stats-charts', {
url: '/stats/charts',
views: {
'tab-stats': {
templateUrl: 'stats-charts.html',
controller: 'StatsChartsCtrl'
}
}
})
.state('tab.list', {
url: '/list',
views: {
'tab-list': {
templateUrl: 'tab-list.html',
controller: 'ListCtrl',
resolve: {
message: function (ListService) {
return ListService.initListService();
}
}
}
}
})
.state('tab.list-day', {
url: '/listday/:dayId',
views: {
'tab-list': {
templateUrl: 'list-day.html',
controller: 'ListDetailDayCtrl'
}
}
})
.state('tab.list-detail', {
url: '/list/:friendId',
views: {
'tab-list': {
templateUrl: 'list-detail.html',
controller: 'FriendDetailCtrl'
}
}
})
.state('tab.settings', {
url: '/settings',
views: {
'tab-settings': {
templateUrl: 'tab-settings.html',
controller: 'SettingsCtrl'
}
}
})
.state('tab.settings-languages', {
url: '/settings/languages',
views: {
'tab-settings': {
templateUrl: 'settings-languages.html',
controller: 'SettingsLanguagesCtrl'
}
}
})
.state('tab.settings-backup', {
url: '/settings/backup',
views: {
'tab-settings': {
templateUrl: 'settings-backup.html',
controller: 'SettingsBackupCtrl'
}
}
})
.state('tab.settings-developer', {
url: '/settings/developer',
views: {
'tab-settings': {
templateUrl: 'settings-developer.html',
controller: 'SettingsDeveloperCtrl'
}
}
})
.state('tab.settings-help', {
url: '/settings/help',
views: {
'tab-settings': {
templateUrl: 'settings-help.html'
}
}
});


// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/tab/add');

});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions src/controller_stats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
angular.module('starter.controllers').controller('StatsCtrl', function($scope, Database, $timeout, $translate, SettingsService) {

$scope.$on("$ionicView.beforeEnter", function( scopes, states ) {
//alert('fuh');
});
});
12 changes: 8 additions & 4 deletions www/js/controller_stats.js → src/controller_stats_charts.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
angular.module('starter.controllers').controller('StatsCtrl', function($scope, Database, $timeout, $translate, SettingsService) {
angular.module('starter.controllers').controller('StatsChartsCtrl', function($scope, Database, $timeout, $translate, SettingsService, $ionicLoading) {

$scope.$on("$ionicView.beforeEnter", function( scopes, states ) {
$scope.$on("$ionicView.beforeEnter", function() {
$ionicLoading.show({
template: 'Loading...'
});
$scope.showDiarrhea = SettingsService.getShowDiarrhea();
if (Database.hasChanged('stats') === true) {
//if (Database.hasChanged('stats') === true) {
Database.all(function(allData) {
$timeout(function() {
$scope.allData = allData;
Database.gotData('stats');
calulateChartData(allData);
});
});
}
//}
});

var calulateChartData = function(chartData) {
Expand Down Expand Up @@ -38,6 +41,7 @@ angular.module('starter.controllers').controller('StatsCtrl', function($scope, D

$translate(["POO","add_BLOOD","add_DIARRHEA"]).then(function successFn(translations) {
drawChart(finalData, bloodData, diarrheaData, translations);
$ionicLoading.hide();
});
};

Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions www/js/service_database.js → src/service_database.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ angular.module('starter.services').factory('Database', function() {
createDemoData: function() {
allData = [];
var currentDate = new Date();
var entrysPerDay = 2;
var entrysPerDay = 4;

for(var i=0; i<30; i++) {
for(var i=0; i<360; i++) {
var newEntrysPerDay = Math.random() * (7 - 1) + 1;
if (newEntrysPerDay > entrysPerDay) {
entrysPerDay++;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ion-view title="{{ 'stats_STATS' | translate }}">
<ion-view title="{{ 'stats_STATS' | translate }} Charts">
<ion-content>
<div id="container" style="min-width: 310px; height: 50%; margin: 0 auto"></div>
</ion-content>
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion www/templates/tab-new.html → src/templates/tab-new.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<a class="button button-outline button-assertive" ng-class="{active: (element.blood == 2)}" ng-click="setBlood(2)">++</a>
</div>
<br>
<div ng-if="(showDiarrhea)" ng-init="element.diarrhea = 0" class="button-bar">
<div ng-if="showDiarrhea" ng-init="element.diarrhea = 0" class="button-bar">
<a class="button button-outline button-energized" ng-class="{active: (element.diarrhea == 0)}" ng-click="setDiarrhea(0)">{{ 'add_DIARRHEA' | translate }} 0</a>
<a class="button button-outline button-energized" ng-class="{active: (element.diarrhea == 1)}" ng-click="setDiarrhea(1)">+</a>
<a class="button button-outline button-energized" ng-class="{active: (element.diarrhea == 2)}" ng-click="setDiarrhea(2)">++</a>
Expand Down
File renamed without changes.
Loading

0 comments on commit 2cb82ea

Please sign in to comment.