mirror of
https://github.com/ascribe/onion.git
synced 2024-11-15 09:35:10 +01:00
Merged in AD-419-decouple-piece-registration-from- (pull request #9)
Ad 419 decouple piece registration from
This commit is contained in:
commit
27f04f59a3
27
js/app.js
27
js/app.js
@ -8,10 +8,12 @@ import Router from 'react-router';
|
|||||||
import fetch from 'isomorphic-fetch';
|
import fetch from 'isomorphic-fetch';
|
||||||
|
|
||||||
import ApiUrls from './constants/api_urls';
|
import ApiUrls from './constants/api_urls';
|
||||||
import constants from './constants/application_constants';
|
import appConstants from './constants/application_constants';
|
||||||
import getRoutes from './routes';
|
import getRoutes from './routes';
|
||||||
import requests from './utils/requests';
|
import requests from './utils/requests';
|
||||||
|
|
||||||
|
import { getSubdomainSettings } from './utils/constants_utils';
|
||||||
|
|
||||||
let headers = {
|
let headers = {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
@ -33,26 +35,21 @@ requests.defaults({
|
|||||||
class AppGateway {
|
class AppGateway {
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
console.log('start');
|
let settings;
|
||||||
let subdomain = window.location.host.split('.')[0];
|
let subdomain = window.location.host.split('.')[0];
|
||||||
requests.get('whitelabel_settings', {'subdomain': subdomain})
|
|
||||||
.then(this.loadSubdomain.bind(this))
|
|
||||||
.catch(this.loadDefault.bind(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
loadSubdomain(data) {
|
try {
|
||||||
let settings = data.whitelabel;
|
settings = getSubdomainSettings(subdomain);
|
||||||
constants.whitelabel = settings;
|
appConstants.whitelabel = settings;
|
||||||
this.load('prize');
|
this.load(settings.type);
|
||||||
}
|
} catch(err) {
|
||||||
|
// if there are no matching subdomains, we're routing
|
||||||
loadDefault(error) {
|
// to the default frontend
|
||||||
console.log('Loading default app, error'. error);
|
|
||||||
this.load('default');
|
this.load('default');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
load(type) {
|
load(type) {
|
||||||
console.log('loading', type);
|
|
||||||
Router.run(getRoutes(type), Router.HistoryLocation, (App) => {
|
Router.run(getRoutes(type), Router.HistoryLocation, (App) => {
|
||||||
React.render(
|
React.render(
|
||||||
<App />,
|
<App />,
|
||||||
|
@ -20,7 +20,7 @@ let PrizeApp = React.createClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="whitelabel-prize">
|
<div className="wp">
|
||||||
<Hero />
|
<Hero />
|
||||||
{header}
|
{header}
|
||||||
<RouteHandler />
|
<RouteHandler />
|
||||||
|
@ -8,7 +8,10 @@ let Hero = React.createClass({
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="hero">
|
<div className="hero">
|
||||||
<img className="logo" src={constants.whitelabel.logo} alt="Sluice Art Prize" />
|
<img
|
||||||
|
className="logo" src={constants.whitelabel.logo}
|
||||||
|
alt="Sluice Art Prize"
|
||||||
|
height="300px"/>
|
||||||
<h1>Sluice Art Prize 2015</h1>
|
<h1>Sluice Art Prize 2015</h1>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -11,8 +11,10 @@ let Link = Router.Link;
|
|||||||
let Landing = React.createClass({
|
let Landing = React.createClass({
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div>
|
|
||||||
<div className="container">
|
<div className="container">
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-xs-12 wp-landing-wrapper">
|
||||||
|
<p></p>
|
||||||
<ButtonGroup className="enter" bsSize="large" vertical block>
|
<ButtonGroup className="enter" bsSize="large" vertical block>
|
||||||
<ButtonLink to="signup">
|
<ButtonLink to="signup">
|
||||||
Signup to the prize
|
Signup to the prize
|
||||||
@ -22,6 +24,7 @@ let Landing = React.createClass({
|
|||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -5,13 +5,49 @@ let constants = {
|
|||||||
|
|
||||||
//FIXME: referring to a global variable in `window` is not
|
//FIXME: referring to a global variable in `window` is not
|
||||||
// super pro. What if we render stuff on the server?
|
// super pro. What if we render stuff on the server?
|
||||||
|
// - super-bro - Senor Developer, 14th July 2015
|
||||||
//'baseUrl': window.BASE_URL,
|
//'baseUrl': window.BASE_URL,
|
||||||
'apiEndpoint': window.API_ENDPOINT,
|
'apiEndpoint': window.API_ENDPOINT,
|
||||||
'serverUrl': window.SERVER_URL,
|
'serverUrl': window.SERVER_URL,
|
||||||
'baseUrl': window.BASE_URL,
|
'baseUrl': window.BASE_URL,
|
||||||
'aclList': ['acl_coa', 'acl_consign', 'acl_delete', 'acl_download', 'acl_edit', 'acl_editions', 'acl_loan', 'acl_share', 'acl_transfer', 'acl_unconsign', 'acl_unshare', 'acl_view', 'acl_withdraw_transfer'],
|
'aclList': ['acl_coa', 'acl_consign', 'acl_delete', 'acl_download', 'acl_edit', 'acl_editions', 'acl_loan', 'acl_share', 'acl_transfer', 'acl_unconsign', 'acl_unshare', 'acl_view', 'acl_withdraw_transfer'],
|
||||||
|
|
||||||
// in case of whitelabel cusomization, we store stuff here
|
'subdomains': [
|
||||||
|
{
|
||||||
|
'user': 22,
|
||||||
|
'subdomain': 'cc',
|
||||||
|
'name': 'Creative Commons France',
|
||||||
|
'logo': 'https://s3-us-west-2.amazonaws.com/ascribe0/public/creativecommons/cc.logo.sm.png',
|
||||||
|
'permissions': ['register', 'edit', 'share', 'del_from_collection'],
|
||||||
|
'type': 'wallet'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'user': 22,
|
||||||
|
'subdomain': 'cc-staging',
|
||||||
|
'name': 'Creative Commons France',
|
||||||
|
'logo': 'https://s3-us-west-2.amazonaws.com/ascribe0/public/creativecommons/cc.logo.sm.png',
|
||||||
|
'permissions': ['register', 'edit', 'share', 'del_from_collection'],
|
||||||
|
'type': 'wallet'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'user': 1,
|
||||||
|
'subdomain': 'sluice',
|
||||||
|
'name': 'Sluice Art Fair',
|
||||||
|
'logo': 'http://sluice.info/images/logo.gif',
|
||||||
|
'permissions': ['register', 'edit', 'share', 'del_from_collection'],
|
||||||
|
'type': 'prize'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'user': 1,
|
||||||
|
'subdomain': 'sluice-staging',
|
||||||
|
'name': 'Sluice Art Fair',
|
||||||
|
'logo': 'https://s3-us-west-2.amazonaws.com/ascribe0/whitelabel/sluice/logo.jpeg',
|
||||||
|
'permissions': ['register', 'edit', 'share', 'del_from_collection'],
|
||||||
|
'type': 'prize'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
// in case of whitelabel customization, we store stuff here
|
||||||
'whitelabel': {}
|
'whitelabel': {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ const COMMON_ROUTES = (
|
|||||||
|
|
||||||
function getRoutes(type) {
|
function getRoutes(type) {
|
||||||
let routes = null;
|
let routes = null;
|
||||||
console.log(type)
|
|
||||||
if (type === 'prize') {
|
if (type === 'prize') {
|
||||||
routes = getPrizeRoutes(COMMON_ROUTES);
|
routes = getPrizeRoutes(COMMON_ROUTES);
|
||||||
} else {
|
} else {
|
||||||
|
15
js/utils/constants_utils.js
Normal file
15
js/utils/constants_utils.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
import appConstants from '../constants/application_constants';
|
||||||
|
|
||||||
|
export function getSubdomainSettings(subdomain) {
|
||||||
|
let settings = appConstants.subdomains.filter((sdSettings) => subdomain === sdSettings.subdomain);
|
||||||
|
|
||||||
|
if(settings.length === 1) {
|
||||||
|
return settings[0];
|
||||||
|
} else if(settings.length === 0) {
|
||||||
|
throw new Error('There are no subdomain settings for the subdomain: ' + subdomain);
|
||||||
|
} else {
|
||||||
|
throw new Error('Matched multiple subdomains. Adjust constants file.');
|
||||||
|
}
|
||||||
|
}
|
@ -79,6 +79,8 @@ export function getCookie(name) {
|
|||||||
|
|
||||||
Taken from: http://jsfiddle.net/jan_miksovsky/yy7zs/
|
Taken from: http://jsfiddle.net/jan_miksovsky/yy7zs/
|
||||||
|
|
||||||
|
CURRENTLY NOT USED...
|
||||||
|
|
||||||
*/
|
*/
|
||||||
export function fetchImageAsBlob(url) {
|
export function fetchImageAsBlob(url) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
.whitelabel-prize {
|
.wp {
|
||||||
.hero {
|
background-color: #CCC;
|
||||||
|
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
> .hero {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
text-align: center;
|
||||||
.logo {
|
|
||||||
float: left;
|
|
||||||
padding-right: 2em;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.enter {
|
.wp-landing-wrapper {
|
||||||
|
text-align: center;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user