From 8d152388183a123c2139ddb36868985a32299625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Tue, 14 Jul 2015 16:53:27 +0200 Subject: [PATCH 1/3] add subdomain settings to constants --- js/constants/application_constants.js | 52 +++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/js/constants/application_constants.js b/js/constants/application_constants.js index 2a8e0807..d03c6423 100644 --- a/js/constants/application_constants.js +++ b/js/constants/application_constants.js @@ -4,14 +4,62 @@ let constants = { //'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? + // super pro. What if we render stuff on the server? + // - super-bro - Senor Developer, 14th July 2015 //'baseUrl': window.BASE_URL, 'apiEndpoint': window.API_ENDPOINT, 'serverUrl': window.SERVER_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'], - // in case of whitelabel cusomization, we store stuff here + 'subdomains': [ + { + 'fields': { + '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'] + }, + 'model': 'whitelabel.whitelabelsettings', + 'pk': 1 + }, + { + 'fields': { + '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'] + }, + 'model': 'whitelabel.whitelabelsettings', + 'pk': 2 + }, + { + 'fields': { + 'user': 1, + 'subdomain': 'sluice', + 'name': 'Sluice Art Fair', + 'logo': 'https://s3-us-west-2.amazonaws.com/ascribe0/whitelabel/sluice/logo.jpeg', + 'permissions': ['register', 'edit', 'share', 'del_from_collection'] + }, + 'model': 'whitelabel.whitelabelsettings', + 'pk': 3 + }, + { + 'fields': { + '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'] + }, + 'model': 'whitelabel.whitelabelsettings', + 'pk': 4 + } + ], + + // in case of whitelabel customization, we store stuff here 'whitelabel': {} }; From 5ef63fbba340be9d0880f664227d6c1f6ef58121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Tue, 14 Jul 2015 17:12:32 +0200 Subject: [PATCH 2/3] use local whitelabel constants for route switching --- js/app.js | 29 ++++++------- js/constants/application_constants.js | 60 ++++++++++----------------- js/utils/constants_utils.js | 15 +++++++ js/utils/fetch_api_utils.js | 2 + 4 files changed, 52 insertions(+), 54 deletions(-) create mode 100644 js/utils/constants_utils.js diff --git a/js/app.js b/js/app.js index 94b733cd..318e59f8 100644 --- a/js/app.js +++ b/js/app.js @@ -8,10 +8,12 @@ import Router from 'react-router'; import fetch from 'isomorphic-fetch'; import ApiUrls from './constants/api_urls'; -import constants from './constants/application_constants'; +import appConstants from './constants/application_constants'; import getRoutes from './routes'; import requests from './utils/requests'; +import { getSubdomainSettings } from './utils/constants_utils'; + let headers = { 'Accept': 'application/json', 'Content-Type': 'application/json' @@ -33,26 +35,21 @@ requests.defaults({ class AppGateway { start() { - console.log('start'); + let settings; 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) { - let settings = data.whitelabel; - constants.whitelabel = settings; - this.load('prize'); - } - - loadDefault(error) { - console.log('Loading default app, error'. error); - this.load('default'); + try { + settings = getSubdomainSettings(subdomain); + appConstants.whitelabel = settings; + this.load('prize'); + } catch(err) { + // if there are no matching subdomains, we're routing + // to the default frontend + this.load('default'); + } } load(type) { - console.log('loading', type); Router.run(getRoutes(type), Router.HistoryLocation, (App) => { React.render( , diff --git a/js/constants/application_constants.js b/js/constants/application_constants.js index d03c6423..c7245f61 100644 --- a/js/constants/application_constants.js +++ b/js/constants/application_constants.js @@ -14,48 +14,32 @@ let constants = { 'subdomains': [ { - 'fields': { - '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'] - }, - 'model': 'whitelabel.whitelabelsettings', - 'pk': 1 + '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'] }, { - 'fields': { - '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'] - }, - 'model': 'whitelabel.whitelabelsettings', - 'pk': 2 - }, - { - 'fields': { - 'user': 1, - 'subdomain': 'sluice', - 'name': 'Sluice Art Fair', - 'logo': 'https://s3-us-west-2.amazonaws.com/ascribe0/whitelabel/sluice/logo.jpeg', - 'permissions': ['register', 'edit', 'share', 'del_from_collection'] - }, - 'model': 'whitelabel.whitelabelsettings', - 'pk': 3 + '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'] }, { - 'fields': { - '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'] - }, - 'model': 'whitelabel.whitelabelsettings', - 'pk': 4 + 'user': 1, + 'subdomain': 'sluice', + 'name': 'Sluice Art Fair', + 'logo': 'https://s3-us-west-2.amazonaws.com/ascribe0/whitelabel/sluice/logo.jpeg', + 'permissions': ['register', 'edit', 'share', 'del_from_collection'] + }, + { + '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'] } ], diff --git a/js/utils/constants_utils.js b/js/utils/constants_utils.js new file mode 100644 index 00000000..923c98fc --- /dev/null +++ b/js/utils/constants_utils.js @@ -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.'); + } +} \ No newline at end of file diff --git a/js/utils/fetch_api_utils.js b/js/utils/fetch_api_utils.js index a4939770..8b8cf89a 100644 --- a/js/utils/fetch_api_utils.js +++ b/js/utils/fetch_api_utils.js @@ -79,6 +79,8 @@ export function getCookie(name) { Taken from: http://jsfiddle.net/jan_miksovsky/yy7zs/ + CURRENTLY NOT USED... + */ export function fetchImageAsBlob(url) { return new Promise((resolve, reject) => { From ff647345458f0b2edde767ab468df388ba7218d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Tue, 14 Jul 2015 17:41:57 +0200 Subject: [PATCH 3/3] styling --- js/app.js | 2 +- js/components/whitelabel/prize/app.js | 2 +- .../whitelabel/prize/components/hero.js | 5 +++- .../whitelabel/prize/components/landing.js | 19 ++++++++------- js/constants/application_constants.js | 14 +++++++---- js/routes.js | 2 +- sass/whitelabel/prize/landing.scss | 23 ++++++++++--------- 7 files changed, 39 insertions(+), 28 deletions(-) diff --git a/js/app.js b/js/app.js index 318e59f8..1c329753 100644 --- a/js/app.js +++ b/js/app.js @@ -41,7 +41,7 @@ class AppGateway { try { settings = getSubdomainSettings(subdomain); appConstants.whitelabel = settings; - this.load('prize'); + this.load(settings.type); } catch(err) { // if there are no matching subdomains, we're routing // to the default frontend diff --git a/js/components/whitelabel/prize/app.js b/js/components/whitelabel/prize/app.js index 0828faa4..98ca2a45 100644 --- a/js/components/whitelabel/prize/app.js +++ b/js/components/whitelabel/prize/app.js @@ -20,7 +20,7 @@ let PrizeApp = React.createClass({ } return ( -
+
{header} diff --git a/js/components/whitelabel/prize/components/hero.js b/js/components/whitelabel/prize/components/hero.js index 101d599a..bd77f5ca 100644 --- a/js/components/whitelabel/prize/components/hero.js +++ b/js/components/whitelabel/prize/components/hero.js @@ -8,7 +8,10 @@ let Hero = React.createClass({ render() { return (
- Sluice Art Prize + Sluice Art Prize

Sluice Art Prize 2015

); diff --git a/js/components/whitelabel/prize/components/landing.js b/js/components/whitelabel/prize/components/landing.js index b7f1fa95..e536fe42 100644 --- a/js/components/whitelabel/prize/components/landing.js +++ b/js/components/whitelabel/prize/components/landing.js @@ -11,15 +11,18 @@ let Link = Router.Link; let Landing = React.createClass({ render() { return ( -
-
- - - Signup to the prize - +
+
+
+

+ + + Signup to the prize + - Already a user? log in - + Already a user? log in + +
); diff --git a/js/constants/application_constants.js b/js/constants/application_constants.js index c7245f61..de61b105 100644 --- a/js/constants/application_constants.js +++ b/js/constants/application_constants.js @@ -18,28 +18,32 @@ let constants = { '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'] + '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'] + 'permissions': ['register', 'edit', 'share', 'del_from_collection'], + 'type': 'wallet' }, { 'user': 1, 'subdomain': 'sluice', 'name': 'Sluice Art Fair', - 'logo': 'https://s3-us-west-2.amazonaws.com/ascribe0/whitelabel/sluice/logo.jpeg', - 'permissions': ['register', 'edit', 'share', 'del_from_collection'] + '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'] + 'permissions': ['register', 'edit', 'share', 'del_from_collection'], + 'type': 'prize' } ], diff --git a/js/routes.js b/js/routes.js index 669a0fc7..8b038372 100644 --- a/js/routes.js +++ b/js/routes.js @@ -39,7 +39,7 @@ const COMMON_ROUTES = ( function getRoutes(type) { let routes = null; - console.log(type) + if (type === 'prize') { routes = getPrizeRoutes(COMMON_ROUTES); } else { diff --git a/sass/whitelabel/prize/landing.scss b/sass/whitelabel/prize/landing.scss index 968fee29..d7278ad2 100644 --- a/sass/whitelabel/prize/landing.scss +++ b/sass/whitelabel/prize/landing.scss @@ -1,16 +1,17 @@ -.whitelabel-prize { - .hero { +.wp { + background-color: #CCC; + + height: 100%; + width: 100%; + + > .hero { overflow: hidden; - - .logo { - float: left; - padding-right: 2em; - } - } - - .enter { - + text-align: center; } } +.wp-landing-wrapper { + text-align: center; +} +