1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00

Merge remote-tracking branch 'remotes/origin/master' into AD-43-in-piece_detail-add-generic-field-

Conflicts:
	js/constants/api_urls.js
	js/constants/application_constants.js
This commit is contained in:
ddejongh 2015-06-11 15:54:50 +02:00
commit f4c6e025ae
11 changed files with 73 additions and 29 deletions

View File

@ -10,7 +10,7 @@ The code is JavaScript ECMA 6.
Getting started Getting started
=============== ===============
Install some nice extensions for Chrom(e|ium): Install some nice extensions for Chrom(e|ium):
<<<<<<< HEAD
- [Allow-Control-Allow-Origin](https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi): - [Allow-Control-Allow-Origin](https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi):
we need this to open connection to external hosts ([staging.ascribe.io](http://staging.ascribe.io/) in our case). we need this to open connection to external hosts ([staging.ascribe.io](http://staging.ascribe.io/) in our case).
Please note that there is an [open issue](https://github.com/vitvad/Access-Control-Allow-Origin/issues/22) that prevents the extension to save the changes in the "intercepted URL or URL pattern". You can follow [this workaround](https://github.com/vitvad/Access-Control-Allow-Origin/issues/22#issuecomment-109898052) to fix the problem. Please note that there is an [open issue](https://github.com/vitvad/Access-Control-Allow-Origin/issues/22) that prevents the extension to save the changes in the "intercepted URL or URL pattern". You can follow [this workaround](https://github.com/vitvad/Access-Control-Allow-Origin/issues/22#issuecomment-109898052) to fix the problem.

View File

@ -3,6 +3,7 @@
require("harmonize")(); require("harmonize")();
var gulp = require('gulp'); var gulp = require('gulp');
var template = require('gulp-template');
var gulpif = require('gulp-if'); var gulpif = require('gulp-if');
var sourcemaps = require('gulp-sourcemaps'); var sourcemaps = require('gulp-sourcemaps');
var util = require('gulp-util'); var util = require('gulp-util');
@ -24,6 +25,7 @@ var minifyCss = require('gulp-minify-css');
var uglify = require('gulp-uglify'); var uglify = require('gulp-uglify');
var config = { var config = {
bootstrapDir: './node_modules/bootstrap-sass', bootstrapDir: './node_modules/bootstrap-sass',
jestOptions: { jestOptions: {
@ -46,6 +48,14 @@ var config = {
} }
}; };
var constants = {
BASE_URL: (function () { var baseUrl = process.env.ONION_BASE_URL || '/'; return baseUrl + (baseUrl.match(/\/$/) ? '' : '/'); })(),
API_ENDPOINT: process.env.ONION_API_ENDPOINT || 'http://staging.ascribe.io/api/',
DEBUG: !argv.production,
CREDENTIALS: 'ZGltaUBtYWlsaW5hdG9yLmNvbTowMDAwMDAwMDAw' // dimi@mailinator:0000000000
};
gulp.task('build', ['js:build', 'sass:build', 'copy'], function() { gulp.task('build', ['js:build', 'sass:build', 'copy'], function() {
}); });
@ -81,6 +91,7 @@ gulp.task('browser-sync', function() {
gulp.task('sass:build', function () { gulp.task('sass:build', function () {
gulp.src('./sass/**/main.scss') gulp.src('./sass/**/main.scss')
.pipe(template(constants))
.pipe(gulpif(!argv.production, sourcemaps.init())) .pipe(gulpif(!argv.production, sourcemaps.init()))
.pipe(sass({ .pipe(sass({
includePaths: [ includePaths: [
@ -108,6 +119,10 @@ gulp.task('copy', function () {
gulp.src(config.bootstrapDir + '/assets/fonts/**/*') gulp.src(config.bootstrapDir + '/assets/fonts/**/*')
.pipe(gulp.dest('./build/fonts')); .pipe(gulp.dest('./build/fonts'));
gulp.src('./index.html')
.pipe(template(constants))
.pipe(gulp.dest('./build'));
}); });
gulp.task('lint', function () { gulp.task('lint', function () {

View File

@ -6,10 +6,16 @@
<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="/static/css/main.css"> <link rel="stylesheet" href="<%= BASE_URL %>static/css/main.css">
<script>
window.BASE_URL = '<%= BASE_URL %>';
window.API_ENDPOINT = '<%= API_ENDPOINT %>';
<% DEBUG && print('window.DEBUG = true'); %>
<% DEBUG && print('window.CREDENTIALS = \'' + CREDENTIALS + '\''); %>
</script>
</head> </head>
<body> <body>
<div id="main" class="container"></div> <div id="main" class="container"></div>
<script src="/static/js/app.js"></script> <script src="<%= BASE_URL %>static/js/app.js"></script>
</body> </body>
</html> </html>

View File

@ -6,19 +6,24 @@ import promise from 'es6-promise';
promise.polyfill(); promise.polyfill();
import AppConstants from './constants/application_constants';
import ApiUrls from './constants/api_urls'; import ApiUrls from './constants/api_urls';
import routes from './routes'; import routes from './routes';
import fetch from './utils/fetch'; import fetch from './utils/fetch';
let headers = {
'Accept': 'application/json',
'Content-Type': 'application/json'
};
if (window.DEBUG) {
headers.Authorization = 'Basic ' + window.CREDENTIALS;
}
fetch.defaults({ fetch.defaults({
urlMap: ApiUrls, urlMap: ApiUrls,
http: { http: {
headers: { headers: headers,
'Authorization': 'Basic ' + AppConstants.debugCredentialBase64, credentials: 'same-origin'
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}, },
fatalErrorHandler: (err) => { fatalErrorHandler: (err) => {
console.log(err); console.log(err);

View File

@ -44,10 +44,10 @@ let Header = React.createClass({
return ( return (
<Navbar> <Navbar>
<Nav> <Nav>
<a className="navbar-brand" href="/"> <Link className="navbar-brand" to="pieces">
<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> </Link>
</Nav> </Nav>
<Nav right> <Nav right>
<ModalWrapper <ModalWrapper

View File

@ -1,7 +1,12 @@
'use strict'; 'use strict';
let constants = { let constants = {
'baseUrl': 'http://localhost:8000/api/', //'baseUrl': 'http://localhost:8000/api/',
//FIXME: referring to a global variable in `window` is not
// super pro. What if we render stuff on the server?
'baseUrl': window.BASE_URL,
'apiEndpoint': window.API_ENDPOINT,
//'baseUrl': 'http://staging.ascribe.io/api/', //'baseUrl': 'http://staging.ascribe.io/api/',
'debugCredentialBase64': 'ZGltaUBtYWlsaW5hdG9yLmNvbTowMDAwMDAwMDAw', // dimi@mailinator:0000000000 'debugCredentialBase64': 'ZGltaUBtYWlsaW5hdG9yLmNvbTowMDAwMDAwMDAw', // dimi@mailinator:0000000000
'aclList': ['edit', 'consign', 'consign_request', 'unconsign', 'unconsign_request', 'transfer', 'aclList': ['edit', 'consign', 'consign_request', 'unconsign', 'unconsign_request', 'transfer',

View File

@ -7,13 +7,20 @@ import AscribeApp from './components/ascribe_app';
import PieceList from './components/piece_list'; import PieceList from './components/piece_list';
import EditionContainer from './components/edition_container'; import EditionContainer from './components/edition_container';
import AppConstants from './constants/application_constants';
let Route = Router.Route; let Route = Router.Route;
let Redirect = Router.Redirect;
let baseUrl = AppConstants.baseUrl;
let routes = ( let routes = (
<Route name="app" handler={AscribeApp}> <Route name="app" path={baseUrl} handler={AscribeApp}>
<Route name="pieces" path="/" handler={PieceList} /> <Route name="pieces" path="collection" handler={PieceList} />
<Route name="edition" path="/editions/:editionId" handler={EditionContainer} /> <Route name="edition" path="editions/:editionId" handler={EditionContainer} />
<Redirect from={baseUrl} to="pieces" />
<Redirect from={baseUrl + '/'} to="pieces" />
</Route> </Route>
); );

View File

@ -24,8 +24,8 @@
"alt": "^0.16.5", "alt": "^0.16.5",
"babelify": "^6.1.2", "babelify": "^6.1.2",
"bootstrap-sass": "^3.3.4", "bootstrap-sass": "^3.3.4",
"browserify": "^9.0.8",
"browser-sync": "^2.7.5", "browser-sync": "^2.7.5",
"browserify": "^9.0.8",
"classnames": "^1.2.2", "classnames": "^1.2.2",
"compression": "^1.4.4", "compression": "^1.4.4",
"envify": "^3.4.0", "envify": "^3.4.0",
@ -41,6 +41,7 @@
"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-template": "^3.0.0",
"gulp-uglify": "^1.2.0", "gulp-uglify": "^1.2.0",
"gulp-util": "^3.0.4", "gulp-util": "^3.0.4",
"harmonize": "^1.4.2", "harmonize": "^1.4.2",
@ -51,9 +52,9 @@
"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", "react-textarea-autosize": "^2.2.3",
"reactify": "^1.1.0",
"shmui": "^0.1.0", "shmui": "^0.1.0",
"uglifyjs": "^2.4.10", "uglifyjs": "^2.4.10",
"vinyl-buffer": "^1.0.0", "vinyl-buffer": "^1.0.0",
@ -70,4 +71,3 @@
] ]
} }
} }

View File

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

View File

@ -1,5 +1,8 @@
// If you import a new .scss file, make sure to restart gulp // If you import a new .scss file, make sure to restart gulp
// otherwise it will not be included // otherwise it will not be included
$BASE_URL: '<%= BASE_URL %>';
@import 'variables'; @import 'variables';
@import 'ascribe_variables'; @import 'ascribe_variables';
@import '../node_modules/bootstrap-sass/assets/stylesheets/bootstrap'; @import '../node_modules/bootstrap-sass/assets/stylesheets/bootstrap';

View File

@ -1,17 +1,20 @@
var argv = require('yargs').argv;
var express = require('express'); var express = require('express');
var compression = require('compression') var compression = require('compression');
var baseUrl = (function () { var baseUrl = process.env.ONION_BASE_URL || '/'; return baseUrl + (baseUrl.match(/\/$/) ? '' : '/'); })();
var app = express(); var app = express();
app.use(compression()); app.use(compression());
app.use('/static/js', express.static(__dirname + '/build/js')); app.use(baseUrl + 'static/js', express.static(__dirname + '/build/js'));
app.use('/static/css', express.static(__dirname + '/build/css')); app.use(baseUrl + 'static/css', express.static(__dirname + '/build/css'));
app.use('/static/fonts', express.static(__dirname + '/build/fonts')); app.use(baseUrl + 'static/fonts', express.static(__dirname + '/build/fonts'));
app.use('/static/thirdparty/', express.static(__dirname + '/node_modules')); app.use(baseUrl + 'static/thirdparty/', express.static(__dirname + '/node_modules'));
app.get(/.*/, function(req, res) { app.get(/.*/, function(req, res) {
res.sendFile(__dirname + '/index.html'); res.sendFile(__dirname + '/build/index.html');
}); });
if (require.main === module) { if (require.main === module) {