Skip to content

Commit 5d2ffe1

Browse files
committed
Initial.
0 parents  commit 5d2ffe1

File tree

85 files changed

+1578
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1578
-0
lines changed

.bowerrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "www/lib"
3+
}

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
end_of_line = lf
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
[*.md]
13+
insert_final_newline = false
14+
trim_trailing_whitespace = false

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Specifies intentionally untracked files to ignore when using Git
2+
# http://git-scm.com/docs/gitignore
3+
4+
node_modules/
5+
platforms/
6+
plugins/
7+
www/
8+
.idea
9+
dist
10+
.DS_Store
11+
www/config.js
12+
*.log
13+

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# [IBP ] Node / Heroku Buildpack Frontend
2+
This is ionic app.
3+
4+
## Dependencies
5+
- [nodejs 5+](https://nodejs.org)
6+
- [bower](http://bower.io/)
7+
- [ionic 1.3.1+](http://ionicframework.com/)
8+
- [cordova 6+](https://cordova.apache.org/)
9+
- [git](https://git-scm.com/)
10+
- [gulp](http://gulpjs.com/)(Install gulp globally with command `npm install -g gulp-cli`)
11+
You must also install java, android sdk for android platform, xcode for ios platform.
12+
13+
## Configuration
14+
Edit configuration in `config.json`, You can use environment variable **BUILD_ENV** to load configurations for different environments.
15+
16+
Following variables can be configured:
17+
- `APP_VERSION` the version of app
18+
- `API_TITLE` the title of app
19+
- `API_URL` the url of api server
20+
- `API_TOKEN` the api token
21+
22+
## Backend
23+
Please deploy backend codes through guides in [backend](https://github.com/topcoderinc/BP-Ionic-Heroku/tree/dev/Backend).
24+
25+
## Local deployment
26+
I recommend you to test codes under Mac to test with ios and android platform easily.
27+
28+
Please make sure to configure url of api server rightly in `config.json`.
29+
30+
Please update global ionic,cordova to latest version with `npm install -g cordova ionic`.
31+
For example this is known bug that has been fixed since ios4.1.0 [ios bug](https://cordova.apache.org/announcements/2016/03/02/ios-4.1.0.html).
32+
33+
In the main project folder, run the following commands:
34+
```bash
35+
36+
npm i
37+
# must exists git in path
38+
bower install or gulp install
39+
ionic state reset --plugins
40+
41+
gulp inject
42+
43+
#verify codes by browser
44+
ionic serve
45+
46+
#command for android
47+
ionic platform add android
48+
ionic build android
49+
# test on emulate or real device
50+
ionic emulate android or ionic run android
51+
52+
#command for ios
53+
ionic platform ios
54+
ionic build ios
55+
# test on emulate or real device
56+
ionic emulate ios or ionic run ios
57+
```
58+
59+
##modular
60+
It will use gulp to load modules.You can put modules in **src/components**, root directory of module may exist **menu_{index}.html**(index is order of side menu) to show as menu.
61+
You can also exist css or configuration files in modules.
62+
63+
If you delete entire directory from **src/components** you must run `gulp` again to make sure changes work.
64+
65+
It wiletect and load js,css from **bowser.json** properly, you only need to inject angular modules with environment variable **ANGULAR_MODULES**,
66+
currently it has default value **'ionic','ngResource','ya.nouislider'**.
67+
68+
69+
70+
71+
72+
73+

bower.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "ibp-frontend",
3+
"private": "true",
4+
"dependencies": {
5+
"angular-resource": "1.5.3",
6+
"nouislider-angular": "^2.4.1"
7+
},
8+
"devDependencies": {
9+
"ionic": "driftyco/ionic-bower#1.3.1"
10+
},
11+
"resolutions": {
12+
"angular": "1.5.3"
13+
}
14+
}

config.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"dev": {
3+
"APP_VERSION": "0.1.0",
4+
"API_TITLE": "Ionic Buildpack Demo",
5+
"API_URL": "https://damp-cliffs-16151.herokuapp.com/api/v1",
6+
"API_TOKEN": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlcyI6WyJzdXBlci1hZG1pbiJdLCJlbWFpbCI6InN1cGVyQHRlc3QuY29tIiwiaWF0IjoxNDYzODA4OTA5fQ.tzcdo_YMQOtzRC15sktJUTwhzPD1ncyxUDx-eQ2Kvzs"
7+
},
8+
"test": {
9+
"APP_VERSION": "1.0.0",
10+
"API_TITLE": "Ionic Buildpack Demo",
11+
"API_URL": "https://bp-ionic-heroku-01.herokuapp.com/api/v1",
12+
"API_TOKEN": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlcyI6WyJzdXBlci1hZG1pbiJdLCJlbWFpbCI6InN1cGVyQHRlc3QuY29tIiwiaWF0IjoxNDYzODA4OTA5fQ.tzcdo_YMQOtzRC15sktJUTwhzPD1ncyxUDx-eQ2Kvzs"
13+
}
14+
}

config.xml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<widget id="com.ionicframework.myapp991187" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
3+
<name>myApp</name>
4+
<description>
5+
An Ionic Framework and Cordova project.
6+
</description>
7+
<author email="[email protected]" href="http://example.com.com/">
8+
Your Name Here
9+
</author>
10+
<content src="index.html"/>
11+
<access origin="*"/>
12+
<preference name="webviewbounce" value="false"/>
13+
<preference name="UIWebViewBounce" value="false"/>
14+
<preference name="DisallowOverscroll" value="true"/>
15+
<preference name="SplashScreenDelay" value="2000"/>
16+
<preference name="FadeSplashScreenDuration" value="2000"/>
17+
<preference name="android-minSdkVersion" value="16"/>
18+
<preference name="BackupWebStorage" value="none"/>
19+
<preference name="SplashScreen" value="screen"/>
20+
<feature name="StatusBar">
21+
<param name="ios-package" value="CDVStatusBar" onload="true"/>
22+
</feature>
23+
<platform name="android">
24+
<icon src="resources/android/icon/drawable-ldpi-icon.png" density="ldpi"/>
25+
<icon src="resources/android/icon/drawable-mdpi-icon.png" density="mdpi"/>
26+
<icon src="resources/android/icon/drawable-hdpi-icon.png" density="hdpi"/>
27+
<icon src="resources/android/icon/drawable-xhdpi-icon.png" density="xhdpi"/>
28+
<icon src="resources/android/icon/drawable-xxhdpi-icon.png" density="xxhdpi"/>
29+
<icon src="resources/android/icon/drawable-xxxhdpi-icon.png" density="xxxhdpi"/>
30+
<splash src="resources/android/splash/drawable-land-ldpi-screen.png" density="land-ldpi"/>
31+
<splash src="resources/android/splash/drawable-land-mdpi-screen.png" density="land-mdpi"/>
32+
<splash src="resources/android/splash/drawable-land-hdpi-screen.png" density="land-hdpi"/>
33+
<splash src="resources/android/splash/drawable-land-xhdpi-screen.png" density="land-xhdpi"/>
34+
<splash src="resources/android/splash/drawable-land-xxhdpi-screen.png" density="land-xxhdpi"/>
35+
<splash src="resources/android/splash/drawable-land-xxxhdpi-screen.png" density="land-xxxhdpi"/>
36+
<splash src="resources/android/splash/drawable-port-ldpi-screen.png" density="port-ldpi"/>
37+
<splash src="resources/android/splash/drawable-port-mdpi-screen.png" density="port-mdpi"/>
38+
<splash src="resources/android/splash/drawable-port-hdpi-screen.png" density="port-hdpi"/>
39+
<splash src="resources/android/splash/drawable-port-xhdpi-screen.png" density="port-xhdpi"/>
40+
<splash src="resources/android/splash/drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/>
41+
<splash src="resources/android/splash/drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/>
42+
</platform>
43+
<platform name="ios">
44+
<preference name="Orientation" value="all" />
45+
<icon src="resources/ios/icon/icon.png" width="57" height="57"/>
46+
<icon src="resources/ios/icon/[email protected]" width="114" height="114"/>
47+
<icon src="resources/ios/icon/icon-40.png" width="40" height="40"/>
48+
<icon src="resources/ios/icon/[email protected]" width="80" height="80"/>
49+
<icon src="resources/ios/icon/icon-50.png" width="50" height="50"/>
50+
<icon src="resources/ios/icon/[email protected]" width="100" height="100"/>
51+
<icon src="resources/ios/icon/icon-60.png" width="60" height="60"/>
52+
<icon src="resources/ios/icon/[email protected]" width="120" height="120"/>
53+
<icon src="resources/ios/icon/[email protected]" width="180" height="180"/>
54+
<icon src="resources/ios/icon/icon-72.png" width="72" height="72"/>
55+
<icon src="resources/ios/icon/[email protected]" width="144" height="144"/>
56+
<icon src="resources/ios/icon/icon-76.png" width="76" height="76"/>
57+
<icon src="resources/ios/icon/[email protected]" width="152" height="152"/>
58+
<icon src="resources/ios/icon/icon-small.png" width="29" height="29"/>
59+
<icon src="resources/ios/icon/[email protected]" width="58" height="58"/>
60+
<icon src="resources/ios/icon/[email protected]" width="87" height="87"/>
61+
<splash src="resources/ios/splash/Default-568h@2x~iphone.png" height="1136" width="640"/>
62+
<splash src="resources/ios/splash/Default-667h.png" height="1334" width="750"/>
63+
<splash src="resources/ios/splash/Default-736h.png" height="2208" width="1242"/>
64+
<splash src="resources/ios/splash/Default-Landscape-736h.png" height="1242" width="2208"/>
65+
<splash src="resources/ios/splash/Default-Landscape@2x~ipad.png" height="1536" width="2048"/>
66+
<splash src="resources/ios/splash/Default-Landscape@~ipadpro.png" height="2048" width="2732"/>
67+
<splash src="resources/ios/splash/Default-Landscape~ipad.png" height="768" width="1024"/>
68+
<splash src="resources/ios/splash/Default-Portrait@2x~ipad.png" height="2048" width="1536"/>
69+
<splash src="resources/ios/splash/Default-Portrait@~ipadpro.png" height="2732" width="2048"/>
70+
<splash src="resources/ios/splash/Default-Portrait~ipad.png" height="1024" width="768"/>
71+
<splash src="resources/ios/splash/Default@2x~iphone.png" height="960" width="640"/>
72+
<splash src="resources/ios/splash/Default~iphone.png" height="480" width="320"/>
73+
</platform>
74+
</widget>

gulpfile.js

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/*
2+
* Copyright (C) 2016 TopCoder Inc., All Rights Reserved.
3+
*/
4+
5+
/**
6+
* Represents the gulp file for this ionic application
7+
*
8+
* @author TCDEVELOPER
9+
* @version 1.0
10+
*/
11+
'use strict';
12+
13+
var gulp = require('gulp');
14+
gulp.modules = process.env.ANGULAR_MODULES || "'ionic','ngResource','ya.nouislider'";
15+
gulp.paths = {
16+
src: 'src',
17+
dist: 'www',
18+
bower: 'www/lib'
19+
};
20+
var path = require('path');
21+
var sort = require('gulp-sort');
22+
var gulpNgConfig = require('gulp-ng-config');
23+
var bower = require('bower');
24+
var wiredep = require('wiredep').stream;
25+
var sh = require('shelljs');
26+
var gutil = require('gulp-util');
27+
var sass = require('gulp-sass');
28+
var $ = require('gulp-load-plugins')({
29+
pattern: ['gulp-*', 'main-bower-files', 'del']
30+
});
31+
var paths = gulp.paths;
32+
33+
34+
gulp.task('clean', function (done) {
35+
$.del([paths.dist + '/'], done);
36+
});
37+
38+
gulp.task('install', ['git-check'], function() {
39+
return bower.commands.install()
40+
.on('log', function(data) {
41+
gutil.log('bower', gutil.colors.cyan(data.id), data.message);
42+
});
43+
});
44+
45+
gulp.task('git-check', function(done) {
46+
if (!sh.which('git')) {
47+
console.log(
48+
' ' + gutil.colors.red('Git is not installed.'),
49+
'\n Git, the version control system, is required to download Ionic.',
50+
'\n Download git here:', gutil.colors.cyan('http://git-scm.com/downloads') + '.',
51+
'\n Once git is installed, run \'' + gutil.colors.cyan('gulp install') + '\' again.'
52+
);
53+
process.exit(1);
54+
}
55+
done();
56+
});
57+
58+
gulp.task('sass', function(done) {
59+
gulp.src('./scss/ionic.app.scss')
60+
.pipe(sass())
61+
.on('error', sass.logError)
62+
.pipe(gulp.dest(paths.dist +'/css/'))
63+
.on('end', done);
64+
});
65+
66+
gulp.task('ng-config', function () {
67+
gulp.src('config.json')
68+
.pipe(
69+
gulpNgConfig('app', {
70+
wrap: true,
71+
createModule: false,
72+
environment: process.env.BUILD_ENV || 'dev'
73+
}))
74+
.pipe(gulp.dest(paths.dist+'/js'))
75+
});
76+
77+
gulp.task('menu', function () {
78+
var menuInjectFiles = gulp.src(paths.src + '/components/**/menu*.html').pipe(sort(
79+
{
80+
// sort asc with index number in filename
81+
comparator: function(file1, file2) {
82+
var index1 = Number(path.basename(file1.path,'.html').substring(5));
83+
var index2 = Number(path.basename(file2.path,'.html').substring(5));
84+
return index1-index2;
85+
}
86+
}
87+
));
88+
var menuInjectOptions = {
89+
starttag: '<!-- inject:menu -->',
90+
transform: function (filePath, file) {
91+
return file.contents.toString('utf8')
92+
}
93+
};
94+
return gulp.src(paths.src + '/templates/menu.html')
95+
.pipe($.inject(menuInjectFiles, menuInjectOptions))
96+
.pipe(gulp.dest(paths.dist + '/templates/'));
97+
});
98+
gulp.task('copy-files', function () {
99+
gulp.src(paths.src + '/*.html')
100+
.pipe(gulp.dest(paths.dist));
101+
gulp.src(paths.src + '/js/*.js')
102+
.pipe(gulp.dest(paths.dist+ '/js'));
103+
gulp.src(paths.src + '/img/**')
104+
.pipe(gulp.dest(paths.dist+ '/img'));
105+
gulp.src(paths.src + '/css/*.css')
106+
.pipe(gulp.dest(paths.dist+ '/css'));
107+
gulp.src(paths.src + '/components/**')
108+
.pipe(gulp.dest(paths.dist+ '/components'));
109+
});
110+
gulp.task('inject', ['sass', 'ng-config', 'menu','copy-files'], function () {
111+
gulp.src(paths.dist+ '/js/app.js')
112+
.pipe($.replace(/'<!--replace modules-->'/g, gulp.modules))
113+
.pipe(gulp.dest(paths.dist+ '/js'));
114+
115+
var injectStyles = gulp.src([
116+
paths.dist + '/{css,components}/**/*.css',
117+
paths.dist + '/css/*.css'
118+
], { read: false });
119+
120+
var injectScripts = gulp.src([
121+
paths.dist + '/{js,components}/**/*.js'
122+
]).pipe($.angularFilesort());
123+
124+
var injectOptions = {
125+
ignorePath: [paths.dist],
126+
addRootSlash: false
127+
};
128+
129+
var wiredepOptions = {
130+
directory: paths.bower,
131+
exclude: [/angular\.js/]
132+
};
133+
return gulp.src(paths.dist + '/*.html')
134+
.pipe($.inject(injectStyles, injectOptions))
135+
.pipe($.inject(injectScripts, injectOptions))
136+
.pipe(wiredep(wiredepOptions))
137+
.pipe(gulp.dest(paths.dist));
138+
});
139+
140+
gulp.task('default', ['inject']);

0 commit comments

Comments
 (0)