1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-14 09:05:08 +01:00

Merge branch 'AD-432-put-onion-online'

Conflicts:
	gulpfile.js
	package.json
This commit is contained in:
vrde 2015-06-08 18:00:17 +02:00
commit f732cec523
8 changed files with 104 additions and 46 deletions

View File

@ -18,6 +18,11 @@ var concat = require('gulp-concat');
var _ = require('lodash'); var _ = require('lodash');
var eslint = require('gulp-eslint'); var eslint = require('gulp-eslint');
var jest = require('jest-cli'); var jest = require('jest-cli');
var argv = require('yargs').argv;
var server = require('./server.js').app;
var minifyCss = require('gulp-minify-css');
var uglify = require('gulp-uglify');
var config = { var config = {
bootstrapDir: './node_modules/bootstrap-sass', bootstrapDir: './node_modules/bootstrap-sass',
@ -41,11 +46,14 @@ var config = {
} }
}; };
gulp.task('build', function() { gulp.task('build', ['js:build', 'sass:build', 'copy'], function() {
});
gulp.task('js:build', function() {
bundle(false); bundle(false);
}); });
gulp.task('serve', ['browser-sync', 'lint:watch', 'sass', 'sass:watch', 'copy'], function() { gulp.task('serve', ['browser-sync', 'run-server', 'lint:watch', 'sass:build', 'sass:watch', 'copy'], function() {
bundle(true); bundle(true);
}); });
@ -59,27 +67,30 @@ gulp.task('jest:watch', function(done) {
gulp.watch([ config.jestOptions.rootDir + "/**/*.js" ], [ 'jest' ]); gulp.watch([ config.jestOptions.rootDir + "/**/*.js" ], [ 'jest' ]);
}); });
gulp.task('run-server', function() {
server.listen(4000);
});
gulp.task('browser-sync', function() { gulp.task('browser-sync', function() {
browserSync({ browserSync({
server: { files: ['build/css/*.css', 'build/js/*.js'],
baseDir: '.' proxy: 'http://localhost:4000',
}, port: 3000
port: process.env.PORT || 3000
}); });
}); });
gulp.task('sass', function () { gulp.task('sass:build', function () {
gulp.src('./sass/**/main.scss') gulp.src('./sass/**/main.scss')
.pipe(sourcemaps.init()) .pipe(gulpif(!argv.production, sourcemaps.init()))
.pipe(sass({ .pipe(sass({
includePaths: [ includePaths: [
config.bootstrapDir + '/assets/stylesheets' config.bootstrapDir + '/assets/stylesheets'
] ]
}) }).on('error', sass.logError))
.on('error', sass.logError)) .pipe(gulpif(!argv.production, sourcemaps.write('./maps')))
.pipe(sourcemaps.write('./maps')) .pipe(gulpif(argv.production, minifyCss()))
.pipe(gulp.dest('./build/css')) .pipe(gulp.dest('./build/css'))
.pipe(browserSync.stream());; .pipe(browserSync.stream());
}); });
gulp.task('sass:watch', function () { gulp.task('sass:watch', function () {
@ -87,13 +98,13 @@ gulp.task('sass:watch', function () {
}); });
gulp.task('copy', function () { gulp.task('copy', function () {
var files = [ var staticAssets = [
'./fonts/**/*', './fonts/**/*',
'./img/**/*' './img/**/*'
]; ];
gulp.src(files, {base: './'}) gulp.src(staticAssets, {base: './'})
.pipe(gulp.dest('build')); .pipe(gulp.dest('./build'));
gulp.src(config.bootstrapDir + '/assets/fonts/**/*') gulp.src(config.bootstrapDir + '/assets/fonts/**/*')
.pipe(gulp.dest('./build/fonts')); .pipe(gulp.dest('./build/fonts'));
@ -117,6 +128,7 @@ gulp.task('lint:watch', function () {
function bundle(watch) { function bundle(watch) {
var bro; var bro;
if (watch) { if (watch) {
bro = watchify(browserify('./js/app.js', bro = watchify(browserify('./js/app.js',
// Assigning debug to have sourcemaps // Assigning debug to have sourcemaps
@ -141,13 +153,14 @@ function bundle(watch) {
.on('error', notify.onError('Error: <%= error.message %>')) .on('error', notify.onError('Error: <%= error.message %>'))
.pipe(source('app.js')) .pipe(source('app.js'))
.pipe(buffer()) .pipe(buffer())
.pipe(sourcemaps.init({ .pipe(gulpif(!argv.production, sourcemaps.init({
loadMaps: true loadMaps: true
})) // loads map from browserify file }))) // loads map from browserify file
.pipe(sourcemaps.write()) // writes .map file .pipe(gulpif(!argv.production, sourcemaps.write())) // writes .map file
.pipe(gulp.dest('./build')) .pipe(gulpif(argv.production, uglify({mangle: false})))
.pipe(gulp.dest('./build/js'))
.pipe(browserSync.stream()); .pipe(browserSync.stream());
} }
return rebundle(bro); return rebundle(bro);
} }

View File

@ -6,11 +6,11 @@
<title>ascribe</title> <title>ascribe</title>
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="//brick.a.ssl.fastly.net/Source+Sans+Pro:400,600,700,900"> <link rel="stylesheet" href="//brick.a.ssl.fastly.net/Source+Sans+Pro:400,600,700,900">
<link rel="stylesheet" href="build/css/main.css"> <link rel="stylesheet" href="/static/css/main.css">
</head> </head>
<body> <body>
<div id="main" class="container"></div> <div id="main" class="container"></div>
<div id="modal" class="container"></div> <div id="modal" class="container"></div>
<script src="build/app.js"></script> <script src="/static/js/app.js"></script>
</body> </body>
</html> </html>

View File

@ -26,7 +26,7 @@ fetch.defaults({
} }
}); });
Router.run(routes, Router.HashLocation, (AscribeApp) => { Router.run(routes, Router.HistoryLocation, (AscribeApp) => {
React.render( React.render(
<AscribeApp />, <AscribeApp />,
document.getElementById('main') document.getElementById('main')

View File

@ -46,8 +46,8 @@ let Image = React.createClass({
this.inject('http://code.jquery.com/jquery-2.1.4.min.js') this.inject('http://code.jquery.com/jquery-2.1.4.min.js')
.then(() => .then(() =>
Promise.all([ Promise.all([
this.inject('node_modules/shmui/shmui.css'), this.inject('/static/thirdparty/shmui/shmui.css'),
this.inject('node_modules/shmui/jquery.shmui.js') this.inject('/static/thirdparty/shmui/jquery.shmui.js')
]).then(() => { window.jQuery('.shmui-ascribe').shmui(); })); ]).then(() => { window.jQuery('.shmui-ascribe').shmui(); }));
}, },

View File

@ -38,7 +38,7 @@ let Header = React.createClass({
return ( return (
<Navbar> <Navbar>
<Nav> <Nav>
<a className="navbar-brand" href="#"> <a className="navbar-brand" href="/">
<span>ascribe </span> <span>ascribe </span>
<span className="glyph-ascribe-spool-chunked ascribe-color"></span> <span className="glyph-ascribe-spool-chunked ascribe-color"></span>
</a> </a>

View File

@ -3,47 +3,71 @@
"version": "0.0.1", "version": "0.0.1",
"description": "Das neue web client for Ascribe", "description": "Das neue web client for Ascribe",
"main": "js/app.js", "main": "js/app.js",
"engines": {
"node": "0.10.x"
},
"scripts": {
"lint": "eslint ./js",
"postinstall": "npm run build",
"build": "gulp build --production",
"start": "node server.js"
},
"author": "Ascribe", "author": "Ascribe",
"license": "Copyright", "license": "Copyright",
"private": true, "private": true,
"devDependencies": { "devDependencies": {
"babel-eslint": "^3.1.11", "babel-eslint": "^3.1.11",
"babel-jest": "^5.2.0", "babel-jest": "^5.2.0",
"jest-cli": "^0.4.0"
},
"dependencies": {
"alt": "^0.16.5",
"babelify": "^6.1.2", "babelify": "^6.1.2",
"bootstrap-sass": "^3.3.4", "bootstrap-sass": "^3.3.4",
"browser-sync": "^2.7.5",
"browserify": "^9.0.8", "browserify": "^9.0.8",
"browser-sync": "^2.7.5",
"classnames": "^1.2.2",
"compression": "^1.4.4",
"envify": "^3.4.0", "envify": "^3.4.0",
"es6-promise": "^2.1.1",
"eslint": "^0.22.1", "eslint": "^0.22.1",
"eslint-plugin-react": "^2.5.0", "eslint-plugin-react": "^2.5.0",
"express": "^4.12.4",
"gulp": "^3.8.11", "gulp": "^3.8.11",
"gulp-concat": "^2.5.2", "gulp-concat": "^2.5.2",
"gulp-eslint": "^0.13.2", "gulp-eslint": "^0.13.2",
"gulp-if": "^1.2.5", "gulp-if": "^1.2.5",
"gulp-minify-css": "^1.1.6",
"gulp-notify": "^2.2.0", "gulp-notify": "^2.2.0",
"gulp-sass": "^2.0.1", "gulp-sass": "^2.0.1",
"gulp-sourcemaps": "^1.5.2", "gulp-sourcemaps": "^1.5.2",
"gulp-uglify": "^1.2.0",
"gulp-util": "^3.0.4", "gulp-util": "^3.0.4",
"harmonize": "^1.4.2", "harmonize": "^1.4.2",
"isomorphic-fetch": "^2.0.2",
"jest-cli": "^0.4.0", "jest-cli": "^0.4.0",
"lodash": "^3.9.3", "lodash": "^3.9.3",
"react-textarea-autosize": "^2.2.3",
"reactify": "^1.1.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"watchify": "^3.1.2"
},
"dependencies": {
"alt": "^0.16.5",
"classnames": "^1.2.2",
"es6-promise": "^2.1.1",
"isomorphic-fetch": "^2.0.2",
"object-assign": "^2.0.0", "object-assign": "^2.0.0",
"react": "^0.13.2", "react": "^0.13.2",
"react-bootstrap": "~0.22.6", "react-bootstrap": "~0.22.6",
"react-datepicker": "~0.8.0", "react-datepicker": "~0.8.0",
"reactify": "^1.1.0",
"react-router": "^0.13.3", "react-router": "^0.13.3",
"react-textarea-autosize": "^2.2.3",
"shmui": "^0.1.0", "shmui": "^0.1.0",
"uglifyjs": "^2.4.10" "uglifyjs": "^2.4.10",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"watchify": "^3.1.2",
"yargs": "^3.10.0"
},
"jest": {
"scriptPreprocessor": "node_modules/babel-jest",
"unmockedModulePathPatterns": [
"<rootDir>/node_modules/react",
"<rootDir>/node_modules/alt",
"<rootDir>/js/alt.js"
]
} }
} }

View File

@ -1,10 +1,10 @@
@font-face { @font-face {
font-family: 'ascribe'; font-family: 'ascribe';
src:url('../../fonts/ascribe.eot?-oi6ttk'); src:url('/static/fonts/ascribe.eot?-oi6ttk');
src:url('../../fonts/ascribe.eot?#iefix-oi6ttk') format('embedded-opentype'), src:url('/static/fonts/ascribe.eot?#iefix-oi6ttk') format('embedded-opentype'),
url('../../fonts/ascribe.woff?-oi6ttk') format('woff'), url('/static/fonts/ascribe.woff?-oi6ttk') format('woff'),
url('../../fonts/ascribe.ttf?-oi6ttk') format('truetype'), url('/static/fonts/ascribe.ttf?-oi6ttk') format('truetype'),
url('../../fonts/ascribe.svg?-oi6ttk#ascribe') format('svg'); url('/static/fonts/ascribe.svg?-oi6ttk#ascribe') format('svg');
font-weight: normal; font-weight: normal;
font-style: normal; font-style: normal;
} }
@ -52,4 +52,4 @@
@font-face { @font-face {
font-family: mercury_light; font-family: mercury_light;
src: url(Mercury_Light.otf); src: url(Mercury_Light.otf);
} }

21
server.js Normal file
View File

@ -0,0 +1,21 @@
var express = require('express');
var compression = require('compression')
var app = express();
app.use(compression());
app.use('/static/js', express.static(__dirname + '/build/js'));
app.use('/static/css', express.static(__dirname + '/build/css'));
app.use('/static/fonts', express.static(__dirname + '/build/fonts'));
app.use('/static/thirdparty/', express.static(__dirname + '/node_modules'));
app.get(/.*/, function(req, res) {
res.sendFile(__dirname + '/index.html');
});
if (require.main === module) {
app.listen(process.env.PORT || 4000);
}
module.exports.app = app;