Skip to content

Commit

Permalink
Hello world
Browse files Browse the repository at this point in the history
  • Loading branch information
pirhoo committed Nov 9, 2014
0 parents commit 08da6c3
Show file tree
Hide file tree
Showing 38 changed files with 2,109 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "bower_components"
}
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist
.tmp
.sass-cache
bower_components
25 changes: 25 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"node": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"smarttabs": true,
"white": true,
"validthis": true,
"globals": {
"angular": false
}
}
40 changes: 40 additions & 0 deletions .yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"generator-gulp-angular": {
"props": {
"angularVersion": "1.3.x",
"angularModules": [
{
"name": "angular-sanitize",
"module": "ngSanitize",
"version": "1.3.x"
}
],
"jQuery": {
"name": "jquery",
"version": "2.x.x"
},
"resource": {
"name": null,
"version": "1.3.x",
"module": null
},
"router": {
"name": "angular-ui-router",
"version": "0.2.x",
"module": "ui.router"
},
"ui": {
"name": "bootstrap",
"version": "3.2.x",
"key": "bootstrap"
},
"cssPreprocessor": {
"key": "less",
"extension": "less",
"npm": {
"gulp-less": "^1.3.3"
}
}
}
}
}
19 changes: 19 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "iframeScaffolder",
"version": "0.0.0",
"dependencies": {
"modernizr": "2.8.x",
"angular": "1.3.x",
"jquery": "2.x.x",
"angular-sanitize": "1.3.x",
"angular-ui-router": "0.2.x",
"bootstrap": "3.3.x",
"angular-zeroclipboard": "~0.3.2"
},
"devDependencies": {
"angular-mocks": "1.3.x"
},
"resolutions": {
"angular": "1.3.x"
}
}
116 changes: 116 additions & 0 deletions gulp/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
'use strict';

var gulp = require('gulp');

var $ = require('gulp-load-plugins')({
pattern: ['gulp-*', 'main-bower-files', 'uglify-save-license', 'del']
});

function handleError(err) {
console.error(err.toString());
this.emit('end');
}

gulp.task('styles', ['wiredep'], function () {
return gulp.src('src/{app,components}/**/*.less')
.pipe($.less({
paths: [
'src/bower_components',
'src/app',
'src/components'
]
}))
.on('error', handleError)
.pipe($.autoprefixer('last 1 version'))
.pipe(gulp.dest('.tmp'))
.pipe($.size());
});

gulp.task('scripts', function () {
return gulp.src('src/{app,components}/**/*.js')
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish'))
.pipe($.size());
});

gulp.task('partials', function () {
return gulp.src('src/{app,components}/**/*.html')
.pipe($.minifyHtml({
empty: true,
spare: true,
quotes: true
}))
.pipe($.ngHtml2js({
moduleName: 'iframeLayout'
}))
.pipe(gulp.dest('.tmp'))
.pipe($.size());
});

gulp.task('html', ['styles', 'scripts', 'partials'], function () {
var htmlFilter = $.filter('*.html');
var jsFilter = $.filter('**/*.js');
var cssFilter = $.filter('**/*.css');
var assets;

return gulp.src('src/*.html')
.pipe($.inject(gulp.src('.tmp/{app,components}/**/*.js'), {
read: false,
starttag: '<!-- inject:partials -->',
addRootSlash: false,
addPrefix: '../'
}))
.pipe(assets = $.useref.assets())
.pipe($.rev())
.pipe(jsFilter)
.pipe($.ngAnnotate())
.pipe($.uglify({preserveComments: $.uglifySaveLicense}))
.pipe(jsFilter.restore())
.pipe(cssFilter)
.pipe($.replace('bower_components/bootstrap/fonts','fonts'))
.pipe($.csso())
.pipe(cssFilter.restore())
.pipe(assets.restore())
.pipe($.useref())
.pipe($.revReplace())
.pipe(htmlFilter)
.pipe($.minifyHtml({
empty: true,
spare: true,
quotes: true
}))
.pipe(htmlFilter.restore())
.pipe(gulp.dest('dist'))
.pipe($.size());
});

gulp.task('images', function () {
return gulp.src('src/assets/images/**/*')
.pipe($.cache($.imagemin({
optimizationLevel: 3,
progressive: true,
interlaced: true
})))
.pipe(gulp.dest('dist/assets/images'))
.pipe($.size());
});

gulp.task('fonts', function () {
return gulp.src($.mainBowerFiles())
.pipe($.filter('**/*.{eot,svg,ttf,woff}'))
.pipe($.flatten())
.pipe(gulp.dest('dist/fonts'))
.pipe($.size());
});

gulp.task('misc', function () {
return gulp.src('src/**/*.ico')
.pipe(gulp.dest('dist'))
.pipe($.size());
});

gulp.task('clean', function (done) {
$.del(['.tmp', 'dist'], done);
});

gulp.task('build', ['html', 'images', 'fonts', 'misc']);
36 changes: 36 additions & 0 deletions gulp/e2e-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

var gulp = require('gulp');

var $ = require('gulp-load-plugins')();

var browserSync = require('browser-sync');

// Downloads the selenium webdriver
gulp.task('webdriver-update', $.protractor.webdriver_update);

gulp.task('webdriver-standalone', $.protractor.webdriver_standalone);

gulp.task('protractor-only', ['webdriver-update', 'wiredep'], function (done) {
var testFiles = [
'test/e2e/**/*.js'
];

gulp.src(testFiles)
.pipe($.protractor.protractor({
configFile: 'test/protractor.conf.js',
}))
.on('error', function (err) {
// Make sure failed tests cause gulp to exit non-zero
throw err;
})
.on('end', function () {
// Close browser sync server
browserSync.exit();
done();
});
});

gulp.task('protractor', ['serve:e2e', 'protractor-only']);
gulp.task('protractor:src', ['serve:e2e', 'protractor-only']);
gulp.task('protractor:dist', ['serve:e2e-dist', 'protractor-only']);
65 changes: 65 additions & 0 deletions gulp/proxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*jshint unused:false */

/***************
This file allow to configure a proxy system plugged into BrowserSync
in order to redirect backend requests while still serving and watching
files from the web project
IMPORTANT: The proxy is disabled by default.
If you want to enable it, watch at the configuration options and finally
change the `module.exports` at the end of the file
***************/

'use strict';

var httpProxy = require('http-proxy');
var chalk = require('chalk');

/*
* Location of your backend server
*/
var proxyTarget = 'http://server/context/';

var proxy = httpProxy.createProxyServer({
target: proxyTarget
});

proxy.on('error', function(error, req, res) {
res.writeHead(500, {
'Content-Type': 'text/plain'
});

console.error(chalk.red('[Proxy]'), error);
});

/*
* The proxy middleware is an Express middleware added to BrowserSync to
* handle backend request and proxy them to your backend.
*/
function proxyMiddleware(req, res, next) {
/*
* This test is the switch of each request to determine if the request is
* for a static file to be handled by BrowserSync or a backend request to proxy.
*
* The existing test is a standard check on the files extensions but it may fail
* for your needs. If you can, you could also check on a context in the url which
* may be more reliable but can't be generic.
*/
if (/\.(html|css|js|png|jpg|jpeg|gif|ico|xml|rss|txt|eot|svg|ttf|woff|cur)(\?((r|v|rel|rev)=[\-\.\w]*)?)?$/.test(req.url)) {
next();
} else {
proxy.web(req, res);
}
}

/*
* This is where you activate or not your proxy.
*
* The first line activate if and the second one ignored it
*/

//module.exports = [proxyMiddleware];
module.exports = [];
58 changes: 58 additions & 0 deletions gulp/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
'use strict';

var gulp = require('gulp');

var util = require('util');

var browserSync = require('browser-sync');

var middleware = require('./proxy');

function browserSyncInit(baseDir, files, browser) {
browser = browser === undefined ? 'default' : browser;

var routes = null;
if(baseDir === 'src' || (util.isArray(baseDir) && baseDir.indexOf('src') !== -1)) {
routes = {
// Should be '/bower_components': '../bower_components'
// Waiting for https://github.com/shakyShane/browser-sync/issues/308
'/bower_components': 'bower_components'
};
}

browserSync.instance = browserSync.init(files, {
startPath: '/index.html',
server: {
baseDir: baseDir,
middleware: middleware,
routes: routes
},
browser: browser
});

}

gulp.task('serve', ['watch'], function () {
browserSyncInit([
'src',
'.tmp'
], [
'.tmp/{app,components}/**/*.css',
'src/assets/images/**/*',
'src/*.html',
'src/{app,components}/**/*.html',
'src/{app,components}/**/*.js'
]);
});

gulp.task('serve:dist', ['build'], function () {
browserSyncInit('dist');
});

gulp.task('serve:e2e', function () {
browserSyncInit(['src', '.tmp'], null, []);
});

gulp.task('serve:e2e-dist', ['watch'], function () {
browserSyncInit('dist', null, []);
});
Loading

0 comments on commit 08da6c3

Please sign in to comment.