###
CoCalc: Collaborative Calculation in the Cloud
Copyright (C) 2016, Sagemath Inc.
---
Site Customize -- dynamically customize the look of SMC for the client.
###
{redux, Redux, rclass, rtypes, React} = require('./smc-react')
{Loading} = require('./r_misc')
schema = require('smc-util/schema')
misc = require('smc-util/misc')
theme = require('smc-util/theme')
actions = redux.createActions('customize')
defaults = misc.dict( ([k, v.default] for k, v of schema.site_settings_conf) )
store = redux.createStore('customize', defaults)
# If we are running in the browser, then we customize the schema. This also gets run on the backend
# to generate static content, which can't be customized.
$?.get (window.app_base_url + "/customize"), (obj, status) ->
if status == 'success'
exports.commercial = obj.commercial = (obj.commercial?[0]?.toLowerCase() == 'y') # make it true if starts with y
actions.setState(obj)
HelpEmailLink = rclass
displayName : 'HelpEmailLink'
reduxProps :
customize :
help_email : rtypes.string
propTypes :
text : rtypes.string
render: ->
if @props.help_email
{@props.text ? @props.help_email}
else
exports.HelpEmailLink = rclass
displayName : 'HelpEmailLink-redux'
propTypes :
text : rtypes.string
render: ->
SiteName = rclass
displayName : 'SiteName'
reduxProps :
customize :
site_name : rtypes.string
render: ->
if @props.site_name
{@props.site_name}
else
exports.SiteName = rclass
displayName : 'SiteName-redux'
render: ->
SiteDescription = rclass
displayName : 'SiteDescription'
propTypes:
style: rtypes.object
reduxProps :
customize :
site_description : rtypes.string
render: ->
style = @props.style ? {color:'#666', fontSize:'16px'}
if @props.site_description?
{@props.site_description}
else
exports.SiteDescription = rclass
displayName : 'SiteDescription-redux'
propTypes :
style : rtypes.object
render: ->
# TODO also make this configurable? Needed in the and maybe elsewhere …
exports.CompanyName = rclass
displayName : 'CompanyName'
render:->
SageMath, Inc.
TermsOfService = rclass
displayName : 'TermsOfService'
reduxProps :
customize :
terms_of_service : rtypes.string
propTypes :
style : rtypes.object
render: ->
if not @props.terms_of_service?
return
return
exports.TermsOfService = rclass
displayName : 'TermsOfService-redux'
propTypes :
style : rtypes.object
render: ->
AccountCreationEmailInstructions = rclass
displayName : 'AccountCreationEmailInstructions'
reduxProps :
customize :
account_creation_email_instructions : rtypes.string
render: ->
{@props.account_creation_email_instructions}
exports.AccountCreationEmailInstructions = rclass
displayName : 'AccountCreationEmailInstructions'
render: ->
# first step of centralizing these URLs in one place → collecting all such pages into one
# react-class with a 'type' prop is the next step (TODO)
# then consolidate this with the existing site-settings database (e.g. TOS above is one fixed HTML string with an anchor)
app_base_url = window?.app_base_url ? '' # fallback for react-static
exports.PolicyIndexPageUrl = app_base_url + '/policies/index.html'
exports.PolicyPricingPageUrl = app_base_url + '/policies/pricing.html'
exports.PolicyPrivacyPageUrl = app_base_url + '/policies/privacy.html'
exports.PolicyCopyrightPageUrl = app_base_url + '/policies/copyright.html'
exports.PolicyTOSPageUrl = app_base_url + '/policies/terms.html'
exports.SmcWikiUrl = theme.WIKI_URL