├── .gitignore
├── README.md
├── app
├── app.js
├── pages
│ ├── home
│ │ ├── authservice.js
│ │ ├── home.html
│ │ ├── home.js
│ │ └── home.scss
│ ├── signup
│ │ ├── signup.html
│ │ ├── signup.js
│ │ └── signup.scss
│ └── userpage
│ │ ├── userpage.html
│ │ ├── userpage.js
│ │ └── userpage.scss
└── theme
│ ├── app.core.scss
│ ├── app.ios.scss
│ ├── app.md.scss
│ └── app.variables.scss
├── config.xml
├── gulpfile.js
├── hooks
├── README.md
└── after_prepare
│ └── 010_add_platform_class.js
├── ionic.config.js
├── package.json
├── resources
├── android
│ ├── icon
│ │ ├── drawable-hdpi-icon.png
│ │ ├── drawable-ldpi-icon.png
│ │ ├── drawable-mdpi-icon.png
│ │ ├── drawable-xhdpi-icon.png
│ │ ├── drawable-xxhdpi-icon.png
│ │ └── drawable-xxxhdpi-icon.png
│ └── splash
│ │ ├── drawable-land-hdpi-screen.png
│ │ ├── drawable-land-ldpi-screen.png
│ │ ├── drawable-land-mdpi-screen.png
│ │ ├── drawable-land-xhdpi-screen.png
│ │ ├── drawable-land-xxhdpi-screen.png
│ │ ├── drawable-land-xxxhdpi-screen.png
│ │ ├── drawable-port-hdpi-screen.png
│ │ ├── drawable-port-ldpi-screen.png
│ │ ├── drawable-port-mdpi-screen.png
│ │ ├── drawable-port-xhdpi-screen.png
│ │ ├── drawable-port-xxhdpi-screen.png
│ │ └── drawable-port-xxxhdpi-screen.png
├── icon.png
├── ios
│ ├── icon
│ │ ├── icon-40.png
│ │ ├── icon-40@2x.png
│ │ ├── icon-50.png
│ │ ├── icon-50@2x.png
│ │ ├── icon-60.png
│ │ ├── icon-60@2x.png
│ │ ├── icon-60@3x.png
│ │ ├── icon-72.png
│ │ ├── icon-72@2x.png
│ │ ├── icon-76.png
│ │ ├── icon-76@2x.png
│ │ ├── icon-small.png
│ │ ├── icon-small@2x.png
│ │ ├── icon-small@3x.png
│ │ ├── icon.png
│ │ └── icon@2x.png
│ └── splash
│ │ ├── Default-568h@2x~iphone.png
│ │ ├── Default-667h.png
│ │ ├── Default-736h.png
│ │ ├── Default-Landscape-736h.png
│ │ ├── Default-Landscape@2x~ipad.png
│ │ ├── Default-Landscape~ipad.png
│ │ ├── Default-Portrait@2x~ipad.png
│ │ ├── Default-Portrait~ipad.png
│ │ ├── Default@2x~iphone.png
│ │ └── Default~iphone.png
└── splash.png
├── webpack.config.js
└── www
└── index.html
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | www/build/
3 | platforms/
4 | plugins/
5 | .DS_Store
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ionic-authentication-frontend
2 | Ionic 2 application for the authentications series in tphangout.com
3 |
4 | Since this repo has now become obsolete after the new Ionic 2 releases, you can find an updated version at this link - https://github.com/rajayogan/ionic2-authentication
5 |
--------------------------------------------------------------------------------
/app/app.js:
--------------------------------------------------------------------------------
1 | import {App, Platform} from 'ionic-angular';
2 | import {HomePage} from './pages/home/home';
3 |
4 |
5 | @App({
6 | template: '',
7 | config: {} // http://ionicframework.com/docs/v2/api/config/Config/
8 | })
9 | export class MyApp {
10 | static get parameters() {
11 | return [[Platform]];
12 | }
13 |
14 | constructor(platform) {
15 | this.rootPage = HomePage;
16 |
17 | platform.ready().then(() => {
18 | // The platform is now ready. Note: if this callback fails to fire, follow
19 | // the Troubleshooting guide for a number of possible solutions:
20 | //
21 | // Okay, so the platform is ready and our plugins are available.
22 | // Here you can do any higher level native things you might need.
23 | //
24 | // First, let's hide the keyboard accessory bar (only works natively) since
25 | // that's a better default:
26 | //
27 | // Keyboard.setAccessoryBarVisible(false);
28 | //
29 | // For example, we might change the StatusBar color. This one below is
30 | // good for dark backgrounds and light text:
31 | // StatusBar.setStyle(StatusBar.LIGHT_CONTENT)
32 | });
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/pages/home/authservice.js:
--------------------------------------------------------------------------------
1 | import {Injectable, Inject} from 'angular2/core';
2 | import {Http, Headers} from 'angular2/http';
3 |
4 | @Injectable()
5 | export class AuthService {
6 | static get parameters() {
7 | return [Http];
8 | }
9 | constructor(http) {
10 | this.http = http;
11 | this.isLoggedin = false;
12 | this.AuthToken = null;
13 | }
14 |
15 | storeUserCredentials(token) {
16 | window.localStorage.setItem('raja', token);
17 | this.useCredentials(token);
18 |
19 | }
20 |
21 | useCredentials(token) {
22 | this.isLoggedin = true;
23 | this.AuthToken = token;
24 | }
25 |
26 | loadUserCredentials() {
27 | var token = window.localStorage.getItem('raja');
28 | this.useCredentials(token);
29 | }
30 |
31 | destroyUserCredentials() {
32 | this.isLoggedin = false;
33 | this.AuthToken = null;
34 | window.localStorage.clear();
35 | }
36 |
37 | authenticate(user) {
38 | var creds = "name=" + user.name + "&password=" + user.password;
39 | var headers = new Headers();
40 | headers.append('Content-Type', 'application/x-www-form-urlencoded');
41 |
42 | return new Promise(resolve => {
43 | this.http.post('http://localhost:3333/authenticate', creds, {headers: headers}).subscribe(data => {
44 | if(data.json().success){
45 | this.storeUserCredentials(data.json().token);
46 | resolve(true);
47 | }
48 | else
49 | resolve(false);
50 | });
51 | });
52 | }
53 | adduser(user) {
54 | var creds = "name=" + user.name + "&password=" + user.password;
55 | var headers = new Headers();
56 | headers.append('Content-Type', 'application/x-www-form-urlencoded');
57 |
58 | return new Promise(resolve => {
59 | this.http.post('http://localhost:3333/adduser', creds, {headers: headers}).subscribe(data => {
60 | if(data.json().success){
61 | resolve(true);
62 | }
63 | else
64 | resolve(false);
65 | });
66 | });
67 | }
68 |
69 | getinfo() {
70 | return new Promise(resolve => {
71 | var headers = new Headers();
72 | this.loadUserCredentials();
73 | console.log(this.AuthToken);
74 | headers.append('Authorization', 'Bearer ' +this.AuthToken);
75 | this.http.get('http://localhost:3333/getinfo', {headers: headers}).subscribe(data => {
76 | if(data.json().success)
77 | resolve(data.json());
78 | else
79 | resolve(false);
80 | });
81 | })
82 | }
83 |
84 | logout() {
85 | this.destroyUserCredentials();
86 | }
87 | }
--------------------------------------------------------------------------------
/app/pages/home/home.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Home
4 |
5 |
6 |
7 |
8 |
9 |
10 | Username
11 |
12 |
13 |
14 | Password
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/pages/home/home.js:
--------------------------------------------------------------------------------
1 | import {Page, NavController} from 'ionic-angular';
2 | import {AuthService} from './authservice';
3 | import {UserPage} from '../userpage/userpage';
4 | import {Signup} from '../signup/signup';
5 |
6 |
7 | @Page({
8 | templateUrl: 'build/pages/home/home.html',
9 | providers: [AuthService]
10 | })
11 | export class HomePage {
12 | static get parameters() {
13 | return [[AuthService],[NavController]];
14 | }
15 | constructor(authservice, navcontroller) {
16 | this.usercreds = {
17 | name: '',
18 | password: ''
19 | }
20 | this.service = authservice;
21 | this.nav = navcontroller;
22 | }
23 | login(user) {
24 | this.service.authenticate(user).then(data => {
25 | if(data) {
26 | this.nav.setRoot(UserPage);
27 | }
28 | });
29 | }
30 | signup() {
31 | this.nav.push(Signup);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/pages/home/home.scss:
--------------------------------------------------------------------------------
1 | .home {
2 |
3 | }
4 |
--------------------------------------------------------------------------------
/app/pages/signup/signup.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Register
4 |
5 |
6 |
7 |
8 |
9 |
10 | Username
11 |
12 |
13 |
14 | Password
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/pages/signup/signup.js:
--------------------------------------------------------------------------------
1 | import {Page, NavController, Alert} from 'ionic-angular';
2 | import {AuthService} from '../home/authservice';
3 |
4 |
5 |
6 | @Page({
7 | templateUrl: 'build/pages/signup/signup.html',
8 | providers: [AuthService]
9 | })
10 | export class Signup {
11 | static get parameters() {
12 | return [[AuthService],[NavController]];
13 | }
14 | constructor(authservice, navcontroller) {
15 | this.newcreds = {
16 | name: '',
17 | password: ''
18 | }
19 | this.service = authservice;
20 | this.nav = navcontroller;
21 | }
22 | register(user) {
23 | this.service.adduser(user).then(data => {
24 | if(data) {
25 | var alert = Alert.create({
26 | title: 'Success',
27 | subTitle: 'User Created',
28 | buttons: ['ok']
29 | });
30 | this.nav.present(alert);
31 | }
32 | });
33 | }
34 | }
--------------------------------------------------------------------------------
/app/pages/signup/signup.scss:
--------------------------------------------------------------------------------
1 | .signup {
2 |
3 | }
--------------------------------------------------------------------------------
/app/pages/userpage/userpage.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Home
4 |
5 |
6 |
7 |
8 |
9 | You are logged in
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/pages/userpage/userpage.js:
--------------------------------------------------------------------------------
1 | import {Page, NavController, Alert} from 'ionic-angular';
2 | import {AuthService} from '../home/authservice';
3 | import {HomePage} from '../home/home';
4 |
5 | @Page({
6 | templateUrl: 'build/pages/userpage/userpage.html',
7 | providers: [AuthService]
8 | })
9 |
10 | export class UserPage {
11 | static get parameters() {
12 | return [[AuthService],[NavController]];
13 | }
14 | constructor(authservice, navcontroller) {
15 | this.service = authservice;
16 | this.nav = navcontroller;
17 |
18 | }
19 |
20 | logout() {
21 | this.service.logout();
22 | this.nav.setRoot(HomePage);
23 | }
24 |
25 | getinfo() {
26 | this.service.getinfo().then(data => {
27 | if(data.success) {
28 | var alert = Alert.create({
29 | title: data.success,
30 | subTitle: data.msg,
31 | buttons: ['ok']
32 | });
33 | this.nav.present(alert);
34 | }
35 |
36 | })
37 |
38 | }
39 | }
--------------------------------------------------------------------------------
/app/pages/userpage/userpage.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/app/pages/userpage/userpage.scss
--------------------------------------------------------------------------------
/app/theme/app.core.scss:
--------------------------------------------------------------------------------
1 | // http://ionicframework.com/docs/v2/theming/
2 |
3 |
4 | // App Shared Imports
5 | // --------------------------------------------------
6 | // These are the imports which make up the design of this app.
7 | // By default each design mode includes these shared imports.
8 | // App Shared Sass variables belong in app.variables.scss.
9 |
10 | @import "../pages/home/home";
11 |
--------------------------------------------------------------------------------
/app/theme/app.ios.scss:
--------------------------------------------------------------------------------
1 | // http://ionicframework.com/docs/v2/theming/
2 |
3 |
4 | // App Shared Variables
5 | // --------------------------------------------------
6 | // Shared Sass variables go in the app.varialbes.scss file
7 | @import 'app.variables';
8 |
9 |
10 | // App iOS Variables
11 | // --------------------------------------------------
12 | // iOS only Sass variables can go here
13 |
14 |
15 | // Ionic iOS Sass
16 | // --------------------------------------------------
17 | // Custom App variables must be declared before importing Ionic.
18 | // Ionic will use its default values when a custom variable isn't provided.
19 | @import "ionic.ios";
20 |
21 |
22 | // App Shared Sass
23 | // --------------------------------------------------
24 | // All Sass files that make up this app goes into the app.core.scss file.
25 | // For simpler CSS overrides, custom app CSS must come after Ionic's CSS.
26 | @import 'app.core';
27 |
28 |
29 | // App iOS Only Sass
30 | // --------------------------------------------------
31 | // CSS that should only apply to the iOS app
32 |
--------------------------------------------------------------------------------
/app/theme/app.md.scss:
--------------------------------------------------------------------------------
1 | // http://ionicframework.com/docs/v2/theming/
2 |
3 |
4 | // App Shared Variables
5 | // --------------------------------------------------
6 | // Shared Sass variables go in the app.varialbes.scss file
7 | @import 'app.variables';
8 |
9 |
10 | // App Material Design Variables
11 | // --------------------------------------------------
12 | // Material Design only Sass variables can go here
13 |
14 |
15 | // Ionic Material Design Sass
16 | // --------------------------------------------------
17 | // Custom App variables must be declared before importing Ionic.
18 | // Ionic will use its default values when a custom variable isn't provided.
19 | @import "ionic.md";
20 |
21 |
22 | // App Shared Sass
23 | // --------------------------------------------------
24 | // All Sass files that make up this app goes into the app.core.scss file.
25 | // For simpler CSS overrides, custom app CSS must come after Ionic's CSS.
26 | @import 'app.core';
27 |
28 |
29 | // App Material Design Only Sass
30 | // --------------------------------------------------
31 | // CSS that should only apply to the Material Design app
32 |
--------------------------------------------------------------------------------
/app/theme/app.variables.scss:
--------------------------------------------------------------------------------
1 | // http://ionicframework.com/docs/v2/theming/
2 |
3 |
4 | // App Shared Variables
5 | // --------------------------------------------------
6 | // To customize the look and feel of this app, you can override
7 | // the Sass variables found in Ionic's source scss files. Setting
8 | // variables before Ionic's Sass will use these variables rather than
9 | // Ionic's default Sass variable values. App Shared Sass imports belong
10 | // in the app.core.scss file and not this file. Sass variables specific
11 | // to the mode belong in either the app.ios.scss or app.md.scss files.
12 |
13 |
14 | // App Shared Color Variables
15 | // --------------------------------------------------
16 | // It's highly recommended to change the default colors
17 | // to match your app's branding. Ionic uses a Sass map of
18 | // colors so you can add, rename and remove colors as needed.
19 | // The "primary" color is the only required color in the map.
20 | // Both iOS and MD colors can be further customized if colors
21 | // are different per mode.
22 |
23 | $colors: (
24 | primary: #387ef5,
25 | secondary: #32db64,
26 | danger: #f53d3d,
27 | light: #f4f4f4,
28 | dark: #222,
29 | favorite: #69BB7B
30 | );
31 |
--------------------------------------------------------------------------------
/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | V2 Test
4 | An Ionic Framework and Cordova project.
5 | Ionic Framework Team
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Gulpfile
3 | * Be sure to run `npm install` for `gulp` and the following tasks to be
4 | * available from the command line. All tasks are run using `gulp taskName`.
5 | ******************************************************************************/
6 | var gulp = require('gulp'),
7 | webpack = require('webpack'),
8 | sass = require('gulp-sass'),
9 | autoprefixer = require('gulp-autoprefixer'),
10 | watch = require('gulp-watch'),
11 | del = require('del');
12 |
13 |
14 | var IONIC_DIR = "node_modules/ionic-angular/"
15 |
16 |
17 | /******************************************************************************
18 | * watch
19 | * Build the app and watch for source file changes.
20 | ******************************************************************************/
21 | gulp.task('watch', ['sass', 'copy.fonts', 'copy.html'], function(done) {
22 | watch('www/app/**/*.scss', function(){
23 | gulp.start('sass');
24 | });
25 | watch('www/app/**/*.html', function(){
26 | gulp.start('copy.html');
27 | });
28 | bundle(true, done);
29 | });
30 |
31 |
32 | /******************************************************************************
33 | * build
34 | * Build the app once, without watching for source file changes.
35 | ******************************************************************************/
36 | gulp.task('build', ['sass', 'copy.fonts', 'copy.html'], function(done) {
37 | bundle(false, done);
38 | });
39 |
40 |
41 | /******************************************************************************
42 | * sass
43 | * Convert Sass files to a single bundled CSS file. Uses auto-prefixer
44 | * to automatically add required vendor prefixes when needed.
45 | ******************************************************************************/
46 | gulp.task('sass', function(){
47 | var autoprefixerOpts = {
48 | browsers: [
49 | 'last 2 versions',
50 | 'iOS >= 7',
51 | 'Android >= 4',
52 | 'Explorer >= 10',
53 | 'ExplorerMobile >= 11'
54 | ],
55 | cascade: false
56 | };
57 |
58 | return gulp.src('app/theme/app.+(ios|md).scss')
59 | .pipe(sass({
60 | includePaths: [
61 | IONIC_DIR,
62 | 'node_modules/ionicons/dist/scss'
63 | ]
64 | }))
65 | .on('error', function(err){
66 | console.error(err.message);
67 | this.emit('end');
68 | })
69 | .pipe(autoprefixer(autoprefixerOpts))
70 | .pipe(gulp.dest('www/build/css'))
71 | });
72 |
73 |
74 | /******************************************************************************
75 | * copy.fonts
76 | * Copy Ionic font files to build directory.
77 | ******************************************************************************/
78 | gulp.task('copy.fonts', function() {
79 | return gulp.src(IONIC_DIR + 'fonts/**/*.+(ttf|woff|woff2)')
80 | .pipe(gulp.dest('www/build/fonts'));
81 | });
82 |
83 |
84 | /******************************************************************************
85 | * copy.html
86 | * Copy html files to build directory.
87 | ******************************************************************************/
88 | gulp.task('copy.html', function(){
89 | return gulp.src('app/**/*.html')
90 | .pipe(gulp.dest('www/build'));
91 | });
92 |
93 |
94 | /******************************************************************************
95 | * clean
96 | * Delete previous build files.
97 | ******************************************************************************/
98 | gulp.task('clean', function(done) {
99 | del(['www/build'], done);
100 | });
101 |
102 |
103 | /******************************************************************************
104 | * Bundle
105 | * Transpiles source files and bundles them into build directory using webpack.
106 | ******************************************************************************/
107 | function bundle(watch, cb) {
108 | // prevent gulp calling done callback more than once when watching
109 | var firstTime = true;
110 |
111 | // load webpack config
112 | var config = require('./webpack.config.js');
113 |
114 | // https://github.com/webpack/docs/wiki/node.js-api#statstojsonoptions
115 | var statsOptions = {
116 | 'colors': true,
117 | 'modules': false,
118 | 'chunks': false,
119 | 'exclude': ['node_modules']
120 | }
121 |
122 | var compiler = webpack(config);
123 | if (watch) {
124 | compiler.watch(null, compileHandler);
125 | } else {
126 | compiler.run(compileHandler);
127 | }
128 |
129 | function compileHandler(err, stats){
130 | if (firstTime) {
131 | firstTime = false;
132 | cb();
133 | }
134 |
135 | // print build stats and errors
136 | console.log(stats.toString(statsOptions));
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/hooks/README.md:
--------------------------------------------------------------------------------
1 |
21 | # Cordova Hooks
22 |
23 | Cordova Hooks represent special scripts which could be added by application and plugin developers or even by your own build system to customize cordova commands. Hook scripts could be defined by adding them to the special predefined folder (`/hooks`) or via configuration files (`config.xml` and `plugin.xml`) and run serially in the following order:
24 | * Application hooks from `/hooks`;
25 | * Application hooks from `config.xml`;
26 | * Plugin hooks from `plugins/.../plugin.xml`.
27 |
28 | __Remember__: Make your scripts executable.
29 |
30 | __Note__: `.cordova/hooks` directory is also supported for backward compatibility, but we don't recommend using it as it is deprecated.
31 |
32 | ## Supported hook types
33 | The following hook types are supported:
34 |
35 | after_build/
36 | after_compile/
37 | after_docs/
38 | after_emulate/
39 | after_platform_add/
40 | after_platform_rm/
41 | after_platform_ls/
42 | after_plugin_add/
43 | after_plugin_ls/
44 | after_plugin_rm/
45 | after_plugin_search/
46 | after_plugin_install/ <-- Plugin hooks defined in plugin.xml are executed exclusively for a plugin being installed
47 | after_prepare/
48 | after_run/
49 | after_serve/
50 | before_build/
51 | before_compile/
52 | before_docs/
53 | before_emulate/
54 | before_platform_add/
55 | before_platform_rm/
56 | before_platform_ls/
57 | before_plugin_add/
58 | before_plugin_ls/
59 | before_plugin_rm/
60 | before_plugin_search/
61 | before_plugin_install/ <-- Plugin hooks defined in plugin.xml are executed exclusively for a plugin being installed
62 | before_plugin_uninstall/ <-- Plugin hooks defined in plugin.xml are executed exclusively for a plugin being uninstalled
63 | before_prepare/
64 | before_run/
65 | before_serve/
66 | pre_package/ <-- Windows 8 and Windows Phone only.
67 |
68 | ## Ways to define hooks
69 | ### Via '/hooks' directory
70 | To execute custom action when corresponding hook type is fired, use hook type as a name for a subfolder inside 'hooks' directory and place you script file here, for example:
71 |
72 | # script file will be automatically executed after each build
73 | hooks/after_build/after_build_custom_action.js
74 |
75 |
76 | ### Config.xml
77 |
78 | Hooks can be defined in project's `config.xml` using `` elements, for example:
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 | ...
89 |
90 |
91 |
92 |
93 |
94 |
95 | ...
96 |
97 |
98 | ### Plugin hooks (plugin.xml)
99 |
100 | As a plugin developer you can define hook scripts using `` elements in a `plugin.xml` like that:
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 | ...
109 |
110 |
111 | `before_plugin_install`, `after_plugin_install`, `before_plugin_uninstall` plugin hooks will be fired exclusively for the plugin being installed/uninstalled.
112 |
113 | ## Script Interface
114 |
115 | ### Javascript
116 |
117 | If you are writing hooks in Javascript you should use the following module definition:
118 | ```javascript
119 | module.exports = function(context) {
120 | ...
121 | }
122 | ```
123 |
124 | You can make your scipts async using Q:
125 | ```javascript
126 | module.exports = function(context) {
127 | var Q = context.requireCordovaModule('q');
128 | var deferral = new Q.defer();
129 |
130 | setTimeout(function(){
131 | console.log('hook.js>> end');
132 | deferral.resolve();
133 | }, 1000);
134 |
135 | return deferral.promise;
136 | }
137 | ```
138 |
139 | `context` object contains hook type, executed script full path, hook options, command-line arguments passed to Cordova and top-level "cordova" object:
140 | ```json
141 | {
142 | "hook": "before_plugin_install",
143 | "scriptLocation": "c:\\script\\full\\path\\appBeforePluginInstall.js",
144 | "cmdLine": "The\\exact\\command\\cordova\\run\\with arguments",
145 | "opts": {
146 | "projectRoot":"C:\\path\\to\\the\\project",
147 | "cordova": {
148 | "platforms": ["wp8"],
149 | "plugins": ["com.plugin.withhooks"],
150 | "version": "0.21.7-dev"
151 | },
152 | "plugin": {
153 | "id": "com.plugin.withhooks",
154 | "pluginInfo": {
155 | ...
156 | },
157 | "platform": "wp8",
158 | "dir": "C:\\path\\to\\the\\project\\plugins\\com.plugin.withhooks"
159 | }
160 | },
161 | "cordova": {...}
162 | }
163 |
164 | ```
165 | `context.opts.plugin` object will only be passed to plugin hooks scripts.
166 |
167 | You can also require additional Cordova modules in your script using `context.requireCordovaModule` in the following way:
168 | ```javascript
169 | var Q = context.requireCordovaModule('q');
170 | ```
171 |
172 | __Note__: new module loader script interface is used for the `.js` files defined via `config.xml` or `plugin.xml` only.
173 | For compatibility reasons hook files specified via `/hooks` folders are run via Node child_process spawn, see 'Non-javascript' section below.
174 |
175 | ### Non-javascript
176 |
177 | Non-javascript scripts are run via Node child_process spawn from the project's root directory and have the root directory passes as the first argument. All other options are passed to the script using environment variables:
178 |
179 | * CORDOVA_VERSION - The version of the Cordova-CLI.
180 | * CORDOVA_PLATFORMS - Comma separated list of platforms that the command applies to (e.g.: android, ios).
181 | * CORDOVA_PLUGINS - Comma separated list of plugin IDs that the command applies to (e.g.: org.apache.cordova.file, org.apache.cordova.file-transfer)
182 | * CORDOVA_HOOK - Path to the hook that is being executed.
183 | * CORDOVA_CMDLINE - The exact command-line arguments passed to cordova (e.g.: cordova run ios --emulate)
184 |
185 | If a script returns a non-zero exit code, then the parent cordova command will be aborted.
186 |
187 | ## Writing hooks
188 |
189 | We highly recommend writing your hooks using Node.js so that they are
190 | cross-platform. Some good examples are shown here:
191 |
192 | [http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/](http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/)
193 |
194 | Also, note that even if you are working on Windows, and in case your hook scripts aren't bat files (which is recommended, if you want your scripts to work in non-Windows operating systems) Cordova CLI will expect a shebang line as the first line for it to know the interpreter it needs to use to launch the script. The shebang line should match the following example:
195 |
196 | #!/usr/bin/env [name_of_interpreter_executable]
197 |
--------------------------------------------------------------------------------
/hooks/after_prepare/010_add_platform_class.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | // Add Platform Class
4 | // v1.0
5 | // Automatically adds the platform class to the body tag
6 | // after the `prepare` command. By placing the platform CSS classes
7 | // directly in the HTML built for the platform, it speeds up
8 | // rendering the correct layout/style for the specific platform
9 | // instead of waiting for the JS to figure out the correct classes.
10 |
11 | var fs = require('fs');
12 | var path = require('path');
13 |
14 | var rootdir = process.argv[2];
15 |
16 | function addPlatformBodyTag(indexPath, platform) {
17 | // add the platform class to the body tag
18 | try {
19 | var platformClass = 'platform-' + platform;
20 | var cordovaClass = 'platform-cordova platform-webview';
21 |
22 | var html = fs.readFileSync(indexPath, 'utf8');
23 |
24 | var bodyTag = findBodyTag(html);
25 | if(!bodyTag) return; // no opening body tag, something's wrong
26 |
27 | if(bodyTag.indexOf(platformClass) > -1) return; // already added
28 |
29 | var newBodyTag = bodyTag;
30 |
31 | var classAttr = findClassAttr(bodyTag);
32 | if(classAttr) {
33 | // body tag has existing class attribute, add the classname
34 | var endingQuote = classAttr.substring(classAttr.length-1);
35 | var newClassAttr = classAttr.substring(0, classAttr.length-1);
36 | newClassAttr += ' ' + platformClass + ' ' + cordovaClass + endingQuote;
37 | newBodyTag = bodyTag.replace(classAttr, newClassAttr);
38 |
39 | } else {
40 | // add class attribute to the body tag
41 | newBodyTag = bodyTag.replace('>', ' class="' + platformClass + ' ' + cordovaClass + '">');
42 | }
43 |
44 | html = html.replace(bodyTag, newBodyTag);
45 |
46 | fs.writeFileSync(indexPath, html, 'utf8');
47 |
48 | process.stdout.write('add to body class: ' + platformClass + '\n');
49 | } catch(e) {
50 | process.stdout.write(e);
51 | }
52 | }
53 |
54 | function findBodyTag(html) {
55 | // get the body tag
56 | try{
57 | return html.match(/])(.*?)>/gi)[0];
58 | }catch(e){}
59 | }
60 |
61 | function findClassAttr(bodyTag) {
62 | // get the body tag's class attribute
63 | try{
64 | return bodyTag.match(/ class=["|'](.*?)["|']/gi)[0];
65 | }catch(e){}
66 | }
67 |
68 | if (rootdir) {
69 |
70 | // go through each of the platform directories that have been prepared
71 | var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
72 |
73 | for(var x=0; x= 7',
36 | 'Android >= 4',
37 | 'Explorer >= 10',
38 | 'ExplorerMobile >= 11'
39 | ],
40 | cascade: false
41 | },
42 |
43 | // hooks execute before or after all project-related Ionic commands
44 | // (so not for start, docs, but serve, run, etc.) and take in the arguments
45 | // passed to the command as a parameter
46 | //
47 | // The format is 'before' or 'after' + commandName (uppercased)
48 | // ex: beforeServe, afterRun, beforePrepare, etc.
49 | hooks: {
50 | beforeServe: function(argv) {
51 | //console.log('beforeServe');
52 | }
53 | }
54 | };
55 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "angular2": "2.0.0-beta.6",
4 | "es6-promise": "3.0.2",
5 | "es6-shim": "0.33.13",
6 | "ionic-angular": "2.0.0-beta.2",
7 | "ionicons": "3.0.0-alpha.3",
8 | "reflect-metadata": "0.1.2",
9 | "rxjs": "5.0.0-beta.0",
10 | "zone.js": "0.5.14"
11 | },
12 | "devDependencies": {
13 | "babel-core": "6.5.2",
14 | "babel-loader": "6.2.3",
15 | "babel-plugin-transform-decorators-legacy": "1.3.4",
16 | "babel-preset-es2015": "6.5.0",
17 | "del": "2.2.0",
18 | "gulp": "3.9.1",
19 | "gulp-autoprefixer": "^3.1.0",
20 | "gulp-sass": "2.2.0",
21 | "gulp-watch": "4.3.5",
22 | "strip-sourcemap-loader": "0.0.1",
23 | "webpack": "1.12.14"
24 | },
25 | "name": "frontendrest",
26 | "description": "frontendrest: An Ionic project"
27 | }
--------------------------------------------------------------------------------
/resources/android/icon/drawable-hdpi-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/android/icon/drawable-hdpi-icon.png
--------------------------------------------------------------------------------
/resources/android/icon/drawable-ldpi-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/android/icon/drawable-ldpi-icon.png
--------------------------------------------------------------------------------
/resources/android/icon/drawable-mdpi-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/android/icon/drawable-mdpi-icon.png
--------------------------------------------------------------------------------
/resources/android/icon/drawable-xhdpi-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/android/icon/drawable-xhdpi-icon.png
--------------------------------------------------------------------------------
/resources/android/icon/drawable-xxhdpi-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/android/icon/drawable-xxhdpi-icon.png
--------------------------------------------------------------------------------
/resources/android/icon/drawable-xxxhdpi-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/android/icon/drawable-xxxhdpi-icon.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-land-hdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/android/splash/drawable-land-hdpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-land-ldpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/android/splash/drawable-land-ldpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-land-mdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/android/splash/drawable-land-mdpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-land-xhdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/android/splash/drawable-land-xhdpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-land-xxhdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/android/splash/drawable-land-xxhdpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-land-xxxhdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/android/splash/drawable-land-xxxhdpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-port-hdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/android/splash/drawable-port-hdpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-port-ldpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/android/splash/drawable-port-ldpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-port-mdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/android/splash/drawable-port-mdpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-port-xhdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/android/splash/drawable-port-xhdpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-port-xxhdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/android/splash/drawable-port-xxhdpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-port-xxxhdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/android/splash/drawable-port-xxxhdpi-screen.png
--------------------------------------------------------------------------------
/resources/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/icon.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/icon/icon-40.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/icon/icon-40@2x.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/icon/icon-50.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-50@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/icon/icon-50@2x.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/icon/icon-60.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/icon/icon-60@2x.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/icon/icon-60@3x.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/icon/icon-72.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-72@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/icon/icon-72@2x.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/icon/icon-76.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/icon/icon-76@2x.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/icon/icon-small.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-small@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/icon/icon-small@2x.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-small@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/icon/icon-small@3x.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/icon/icon.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/icon/icon@2x.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default-568h@2x~iphone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/splash/Default-568h@2x~iphone.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default-667h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/splash/Default-667h.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default-736h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/splash/Default-736h.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default-Landscape-736h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/splash/Default-Landscape-736h.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default-Landscape@2x~ipad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/splash/Default-Landscape@2x~ipad.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default-Landscape~ipad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/splash/Default-Landscape~ipad.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default-Portrait@2x~ipad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/splash/Default-Portrait@2x~ipad.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default-Portrait~ipad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/splash/Default-Portrait~ipad.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default@2x~iphone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/splash/Default@2x~iphone.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default~iphone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/ios/splash/Default~iphone.png
--------------------------------------------------------------------------------
/resources/splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajayogan/ionic-authentication-frontend/0b951cbb98c44961744e4251048ac7648a799c20/resources/splash.png
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | var path = require('path');
2 |
3 |
4 | module.exports = {
5 | entry: [
6 | path.normalize('es6-shim/es6-shim.min'),
7 | 'reflect-metadata',
8 | path.normalize('zone.js/dist/zone-microtask'),
9 | path.resolve('app/app')
10 | ],
11 | output: {
12 | path: path.resolve('www/build/js'),
13 | filename: 'app.bundle.js',
14 | pathinfo: false // show module paths in the bundle, handy for debugging
15 | },
16 | module: {
17 | loaders: [
18 | {
19 | test: /\.js$/,
20 | loader: 'babel',
21 | query: {
22 | presets: ['es2015'],
23 | plugins: ['transform-decorators-legacy']
24 | },
25 | include: path.resolve('app'),
26 | exclude: /node_modules/
27 | },
28 | {
29 | test: /\.js$/,
30 | include: path.resolve('node_modules/angular2'),
31 | loader: 'strip-sourcemap'
32 | }
33 | ],
34 | noParse: [
35 | /es6-shim/,
36 | /reflect-metadata/,
37 | /zone\.js(\/|\\)dist(\/|\\)zone-microtask/
38 | ]
39 | },
40 | resolve: {
41 | root: ['app'],
42 | alias: {
43 | 'angular2': path.resolve('node_modules/angular2')
44 | },
45 | extensions: ['', '.js']
46 | }
47 | };
48 |
--------------------------------------------------------------------------------
/www/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ionic
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------