Skip to content

Commit 1ef5a81

Browse files
committed
init
1 parent 5ae0892 commit 1ef5a81

33 files changed

+591
-21
lines changed

Diff for: .gitignore

+13-21
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,19 @@
1-
# Logs
2-
logs
31
*.log
4-
5-
# Runtime data
6-
pids
72
*.pid
83
*.seed
9-
10-
# Directory for instrumented libs generated by jscoverage/JSCover
11-
lib-cov
12-
13-
# Coverage directory used by tools like istanbul
14-
coverage
15-
16-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
4+
*.sublime-*
5+
.DS_Store
176
.grunt
18-
19-
# node-waf configuration
7+
.idea
208
.lock-wscript
21-
22-
# Compiled binary addons (http://nodejs.org/api/addons.html)
23-
build/Release
24-
25-
# Dependency directory
26-
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
9+
.sass-cache
10+
.sass-tmp
11+
.tern-port
12+
_SpecRunner.html
13+
bower_components
14+
build
15+
coverage
16+
lib-cov
17+
logs
2718
node_modules
19+
pids

Diff for: .jshintrc

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"bitwise" : false,
3+
"browser" : true,
4+
"camelcase" : true,
5+
"curly" : true,
6+
"debug" : true,
7+
"eqeqeq" : true,
8+
"eqnull" : true,
9+
"esnext" : true,
10+
"forin" : true,
11+
"immed" : true,
12+
"indent" : 2,
13+
"newcap" : true,
14+
"noarg" : true,
15+
"quotmark" : "single",
16+
"smarttabs" : true,
17+
"trailing" : true,
18+
"undef" : true,
19+
"node" : true,
20+
"unused" : false
21+
}

Diff for: Readme.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# angular + es6 seed
2+
3+
## how to start
4+
1. run `npm install` to install all the dependencies
5+
2. run `npm start` to build assets and start the development server
6+
7+
## how to prepare for production
8+
1. run `npm install` to install all the dependencies
9+
2. run `npm run build`
10+
3. grab your assets from `build` folder
11+

Diff for: app/config.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default config;
2+
3+
// @ngInject
4+
function config( $compileProvider ) {
5+
// pass `false` when releasing - perf gain
6+
$compileProvider.debugInfoEnabled( false );
7+
}

Diff for: app/index.html

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!doctype html>
2+
<html lang="en" ng-app="<MAIN_MODULE_NAME>">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title></title>
6+
<link rel="stylesheet" media="screen" href="/style.css">
7+
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
8+
<base href="/">
9+
<script src="/app.js"></script>
10+
<body>
11+
<ui-view></ui-view>

Diff for: app/index.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import ng from 'angular';
2+
3+
import ngAnimate from 'angular-animate';
4+
import coreModule from './modules/core';
5+
6+
const deps = [
7+
ngAnimate,
8+
coreModule
9+
];
10+
11+
import config from './config';
12+
13+
export default ng.module( '<MAIN_MODULE_NAME>', deps )
14+
.config( config )
15+
.name;

Diff for: app/modules/core/config.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import app from './states/app';
2+
import appStart from './states/app.start';
3+
4+
export default config;
5+
6+
// @ngInject
7+
function config( $locationProvider, $stateProvider, $urlRouterProvider, $provide ) {
8+
$locationProvider.html5Mode( true );
9+
$locationProvider.hashPrefix( '!' );
10+
11+
$stateProvider
12+
.state( 'app', app )
13+
.state( 'app.start', appStart );
14+
15+
$urlRouterProvider.otherwise( ( $injector ) => $injector.get( '$state' ).go( 'app.start' ) );
16+
17+
// always scroll to top when switching between views
18+
$provide.decorator( '$uiViewScroll', $uiViewScrollDecorator );
19+
}
20+
21+
// @ngInject
22+
function $uiViewScrollDecorator( $delegate, $window ) {
23+
return () => $window.scrollTo( 0, 0 );
24+
}

Diff for: app/modules/core/directives/foo/controller.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export default class {
2+
// @ngInject
3+
constructor( $log ) {
4+
this.alert = alert;
5+
6+
// ---
7+
8+
function alert() {
9+
$log( 'alert' );
10+
}
11+
}
12+
}

Diff for: app/modules/core/directives/foo/index.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import FooController from './controller';
2+
3+
export default function () {
4+
return {
5+
restrict : 'E',
6+
template : require( 'fs' ).readFileSync( __dirname + '/template.html', 'utf8' ),
7+
controller : FooController,
8+
controllerAs : 'FooCtrl'
9+
};
10+
}

Diff for: app/modules/core/directives/foo/style.scss

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
foo {
2+
background: black;
3+
color: white;
4+
}

Diff for: app/modules/core/directives/foo/template.html

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FOO

Diff for: app/modules/core/index.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import ng from 'angular';
2+
3+
// deps
4+
import router from 'angular-ui-router';
5+
6+
const deps = [
7+
router
8+
];
9+
10+
// config phase
11+
import config from './config';
12+
13+
// directives
14+
import foo from './directives/foo';
15+
16+
// values
17+
import VAL from './values/val';
18+
19+
export default ng.module( '<MAIN_MODULE_NAME>.core', deps )
20+
.config( config )
21+
.directive( 'foo', foo )
22+
.value( 'VAL', VAL )
23+
.name;

Diff for: app/modules/core/states/app.start/controller.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export default class {
2+
// @ngInject
3+
constructor( VAL ) {
4+
this.title = 'this is start state';
5+
6+
this.changeTitle = ( title ) => {
7+
if ( !title ) {
8+
return this.changeTitle( 'some random title : ' + randomElement( VAL ) );
9+
}
10+
11+
this.title = title;
12+
};
13+
}
14+
}
15+
16+
function randomElement( collection ) {
17+
let index = Math.random() * ( collection.length - 1 );
18+
19+
return collection[ index >> 0 ];
20+
}

Diff for: app/modules/core/states/app.start/index.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import StartController from './controller';
2+
3+
export default {
4+
url : '/start',
5+
views : {
6+
'main@app' : {
7+
template : require( 'fs' ).readFileSync( __dirname + '/template.html', 'utf8' ),
8+
controller : StartController,
9+
controllerAs : 'StartCtrl',
10+
}
11+
}
12+
};

Diff for: app/modules/core/states/app.start/template.html

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<h2>{{ StartCtrl.title }}</h2>
2+
<foo>{{ StartCtrl.title }}</foo>
3+
<button ng-click="StartCtrl.changeTitle( 'fixed title' )">set title to &quot;fixed title&quot;</button>
4+
<button ng-click="StartCtrl.changeTitle()">set title to randomized title</button>

Diff for: app/modules/core/states/app/controller.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export default class {
2+
// @ngInject
3+
constructor( $scope, $state, $stateParams ) {
4+
this.title = 'this is an app';
5+
6+
$scope.$on( '$stateChangeSuccess', redirect );
7+
8+
redirect();
9+
10+
// ---
11+
12+
function redirect( ev ) {
13+
if ( $state.is( 'app' ) ) {
14+
$state.go( 'app.start', $stateParams );
15+
}
16+
}
17+
}
18+
}

Diff for: app/modules/core/states/app/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import AppController from './controller';
2+
3+
export default {
4+
url : '/app',
5+
template : require( 'fs' ).readFileSync( __dirname + '/template.html', 'utf8' ),
6+
controller : AppController,
7+
controllerAs : 'AppCtrl'
8+
};

Diff for: app/modules/core/states/app/template.html

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<header>{{ ::AppCtrl.title }}</header>
2+
<main ui-view="main" autoscroll></main>
3+
<footer></footer>

Diff for: app/modules/core/values/val.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default [
2+
'lorem ipsum',
3+
'foo bar baz',
4+
'xxx yyy zzz',
5+
'abc 123'
6+
];

Diff for: app/modules/style.scss

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
body {
2+
max-width: 60rem;
3+
margin: 0 auto;
4+
padding: 2rem;
5+
}

Diff for: gulp-tasks/browser.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// jshint node:true, globalstrict:true
2+
3+
'use strict';
4+
5+
var gulp = require( 'gulp' );
6+
var browserSync = require( 'browser-sync' );
7+
// var reload = browserSync.reload;
8+
var modRewrite = require( 'connect-modrewrite' );
9+
10+
var extensionsPattern = [
11+
'html',
12+
'js',
13+
'map',
14+
'css',
15+
'png',
16+
'svg',
17+
'jpg',
18+
'jpeg',
19+
'gif',
20+
'webp',
21+
'woff',
22+
'ttf',
23+
'svg',
24+
'otf',
25+
'eot',
26+
'json',
27+
]
28+
.map( function ( extension ) {
29+
return '\\.' + extension;
30+
})
31+
.join( '|' );
32+
33+
gulp.task( 'browser', [ 'watch' ], function () {
34+
browserSync({
35+
// files : 'build/styles/*.css',
36+
server : {
37+
baseDir : './build',
38+
middleware : [
39+
modRewrite([
40+
'!' + extensionsPattern + '$ /index.html [L]'
41+
])
42+
]
43+
},
44+
ghostMode : false,
45+
open : false
46+
});
47+
});

Diff for: gulp-tasks/build.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var gulp = require( 'gulp' );
2+
3+
gulp.task( 'build', [
4+
'styles',
5+
'scripts',
6+
'templates',
7+
'images'
8+
]);

Diff for: gulp-tasks/clean.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var gulp = require( 'gulp' );
2+
3+
gulp.task( 'clean', function ( cb ) {
4+
require( 'del' )( 'build/*', cb );
5+
});

Diff for: gulp-tasks/default.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var gulp = require( 'gulp' );
2+
3+
gulp.task( 'default', [ 'browser' ] );

Diff for: gulp-tasks/images.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var gulp = require( 'gulp' );
2+
var $ = global.plugins;
3+
4+
var src = 'app/images/**/*.{jpg,png,jpeg,gif,webp,svg}';
5+
6+
gulp.task( 'images', function () {
7+
var rasterFilter = $.filter([
8+
'*.*',
9+
'!*.svg'
10+
]);
11+
12+
return gulp.src( src )
13+
.pipe( $.cached( 'images' ) )
14+
.pipe( rasterFilter )
15+
.pipe( $.imagemin() )
16+
.pipe( rasterFilter.restore() )
17+
.pipe( $.remember( 'images' ) )
18+
.pipe( gulp.dest( './build/images' ) );
19+
});
20+
21+
module.exports = function () {
22+
gulp.watch( src, [ 'images' ] );
23+
};

Diff for: gulp-tasks/jshint.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var gulp = require( 'gulp' );
2+
var $ = global.plugins;
3+
4+
gulp.task( 'jshint', function () {
5+
var vendorFilter = $.filter([
6+
'**/*',
7+
'!vendor/**/*'
8+
]);
9+
10+
// var nonSpecFilter = $.filter([
11+
// '**/*',
12+
// '!**/*.spec.js'
13+
// ]);
14+
15+
return gulp.src( 'app/**/*.js' )
16+
.pipe( $.cached( 'scripts' ) )
17+
.pipe( vendorFilter )
18+
.pipe( $.jshint( './.jshintrc' ) )
19+
.pipe( $.jshint.reporter( 'jshint-stylish' ) )
20+
// .pipe( $.jshint.reporter( 'fail' ) )
21+
.pipe( vendorFilter.restore() )
22+
.pipe( $.remember( 'scripts' ) );
23+
});
24+
25+
module.exports = function () {
26+
gulp.watch( 'app/**/*.js', [ 'jshint' ] );
27+
};

0 commit comments

Comments
 (0)