mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
Add ENV variable to handle BASE_URL
This commit is contained in:
parent
5445698eea
commit
b9c8002495
@ -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,7 +25,9 @@ var minifyCss = require('gulp-minify-css');
|
|||||||
var uglify = require('gulp-uglify');
|
var uglify = require('gulp-uglify');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
|
baseUrl: (function () { var baseUrl = process.env.ONION_BASE_URL || '/'; return baseUrl + (baseUrl.match(/\/$/) ? '' : '/'); })(),
|
||||||
bootstrapDir: './node_modules/bootstrap-sass',
|
bootstrapDir: './node_modules/bootstrap-sass',
|
||||||
jestOptions: {
|
jestOptions: {
|
||||||
rootDir: 'js',
|
rootDir: 'js',
|
||||||
@ -46,6 +49,7 @@ var config = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
gulp.task('build', ['js:build', 'sass:build', 'copy'], function() {
|
gulp.task('build', ['js:build', 'sass:build', 'copy'], function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -81,6 +85,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({BASE_URL: config.baseUrl}))
|
||||||
.pipe(gulpif(!argv.production, sourcemaps.init()))
|
.pipe(gulpif(!argv.production, sourcemaps.init()))
|
||||||
.pipe(sass({
|
.pipe(sass({
|
||||||
includePaths: [
|
includePaths: [
|
||||||
@ -108,6 +113,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({BASE_URL: config.baseUrl}))
|
||||||
|
.pipe(gulp.dest('./build'));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('lint', function () {
|
gulp.task('lint', function () {
|
||||||
|
@ -6,10 +6,13 @@
|
|||||||
<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="/beta/static/css/main.css">
|
<link rel="stylesheet" href="<%= BASE_URL %>static/css/main.css">
|
||||||
|
<script>
|
||||||
|
window.BASE_URL = '<%= BASE_URL %>';
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="main" class="container"></div>
|
<div id="main" class="container"></div>
|
||||||
<script src="/beta/static/js/app.js"></script>
|
<script src="<%= BASE_URL %>static/js/app.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -3,17 +3,17 @@
|
|||||||
import AppConstants from './application_constants';
|
import AppConstants from './application_constants';
|
||||||
|
|
||||||
let apiUrls = {
|
let apiUrls = {
|
||||||
'ownership_shares_mail': AppConstants.baseUrl + 'ownership/shares/mail/',
|
'ownership_shares_mail': AppConstants.apiEndpoint + 'ownership/shares/mail/',
|
||||||
'ownership_transfers': AppConstants.baseUrl + 'ownership/transfers/',
|
'ownership_transfers': AppConstants.apiEndpoint + 'ownership/transfers/',
|
||||||
'user': AppConstants.baseUrl + 'users/',
|
'user': AppConstants.apiEndpoint + 'users/',
|
||||||
'pieces_list': AppConstants.baseUrl + 'pieces/',
|
'pieces_list': AppConstants.apiEndpoint + 'pieces/',
|
||||||
'piece': AppConstants.baseUrl + 'pieces/${piece_id}',
|
'piece': AppConstants.apiEndpoint + 'pieces/${piece_id}',
|
||||||
'edition': AppConstants.baseUrl + 'editions/${bitcoin_id}/',
|
'edition': AppConstants.apiEndpoint + 'editions/${bitcoin_id}/',
|
||||||
'editions_list': AppConstants.baseUrl + 'pieces/${piece_id}/editions/',
|
'editions_list': AppConstants.apiEndpoint + 'pieces/${piece_id}/editions/',
|
||||||
'ownership_loans': AppConstants.baseUrl + 'ownership/loans/',
|
'ownership_loans': AppConstants.apiEndpoint + 'ownership/loans/',
|
||||||
'ownership_consigns': AppConstants.baseUrl + 'ownership/consigns/',
|
'ownership_consigns': AppConstants.apiEndpoint + 'ownership/consigns/',
|
||||||
'ownership_unconsigns': AppConstants.baseUrl + 'ownership/unconsigns/',
|
'ownership_unconsigns': AppConstants.apiEndpoint + 'ownership/unconsigns/',
|
||||||
'ownership_unconsigns_request': AppConstants.baseUrl + 'ownership/unconsigns/request/'
|
'ownership_unconsigns_request': AppConstants.apiEndpoint + 'ownership/unconsigns/request/'
|
||||||
};
|
};
|
||||||
|
|
||||||
export default apiUrls;
|
export default apiUrls;
|
||||||
|
@ -2,7 +2,11 @@
|
|||||||
|
|
||||||
let constants = {
|
let constants = {
|
||||||
//'baseUrl': 'http://localhost:8000/api/',
|
//'baseUrl': 'http://localhost:8000/api/',
|
||||||
'baseUrl': 'http://staging.ascribe.io/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': 'http://staging.ascribe.io/api/',
|
||||||
'debugCredentialBase64': 'ZGltaUBtYWlsaW5hdG9yLmNvbTowMDAwMDAwMDAw', // dimi@mailinator:0000000000
|
'debugCredentialBase64': 'ZGltaUBtYWlsaW5hdG9yLmNvbTowMDAwMDAwMDAw', // dimi@mailinator:0000000000
|
||||||
'aclList': ['edit', 'consign', 'transfer', 'loan', 'share', 'download', 'view', 'delete', 'del_from_collection', 'add_to_collection']
|
'aclList': ['edit', 'consign', 'transfer', 'loan', 'share', 'download', 'view', 'delete', 'del_from_collection', 'add_to_collection']
|
||||||
};
|
};
|
||||||
|
@ -7,9 +7,11 @@ 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 Redirect = Router.Redirect;
|
||||||
let baseUrl = '/beta';
|
let baseUrl = AppConstants.baseUrl;
|
||||||
|
|
||||||
|
|
||||||
let routes = (
|
let routes = (
|
||||||
|
@ -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 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
@font-face {
|
@font-face {
|
||||||
font-family: 'ascribe';
|
font-family: 'ascribe';
|
||||||
src:url('/beta/static/fonts/ascribe.eot?-oi6ttk');
|
src:url('#{$BASE_URL}static/fonts/ascribe.eot?-oi6ttk');
|
||||||
src:url('/beta/static/fonts/ascribe.eot?#iefix-oi6ttk') format('embedded-opentype'),
|
src:url('#{$BASE_URL}static/fonts/ascribe.eot?#iefix-oi6ttk') format('embedded-opentype'),
|
||||||
url('/beta/static/fonts/ascribe.woff?-oi6ttk') format('woff'),
|
url('#{$BASE_URL}static/fonts/ascribe.woff?-oi6ttk') format('woff'),
|
||||||
url('/beta/static/fonts/ascribe.ttf?-oi6ttk') format('truetype'),
|
url('#{$BASE_URL}static/fonts/ascribe.ttf?-oi6ttk') format('truetype'),
|
||||||
url('/beta/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;
|
||||||
}
|
}
|
||||||
|
@ -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';
|
||||||
|
15
server.js
15
server.js
@ -1,18 +1,21 @@
|
|||||||
|
var argv = require('yargs').argv;
|
||||||
|
|
||||||
var express = require('express');
|
var express = require('express');
|
||||||
var compression = require('compression')
|
var compression = require('compression')
|
||||||
var baseUrl = '/beta';
|
var baseUrl = (function () { var baseUrl = process.env.ONION_BASE_URL || '/'; return baseUrl + (baseUrl.match(/\/$/) ? '' : '/'); })();
|
||||||
|
console.log('base url is', baseUrl);
|
||||||
|
|
||||||
var app = express();
|
var app = express();
|
||||||
|
|
||||||
app.use(compression());
|
app.use(compression());
|
||||||
|
|
||||||
app.use(baseUrl + '/static/js', express.static(__dirname + '/build/js'));
|
app.use(baseUrl + 'static/js', express.static(__dirname + '/build/js'));
|
||||||
app.use(baseUrl + '/static/css', express.static(__dirname + '/build/css'));
|
app.use(baseUrl + 'static/css', express.static(__dirname + '/build/css'));
|
||||||
app.use(baseUrl + '/static/fonts', express.static(__dirname + '/build/fonts'));
|
app.use(baseUrl + 'static/fonts', express.static(__dirname + '/build/fonts'));
|
||||||
app.use(baseUrl + '/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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user