Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 39550
1
###
2
CoCalc: Collaborative Calculation in the Cloud
3
Copyright (C) 2016, Sagemath Inc.
4
---
5
6
Site Customize -- dynamically customize the look of SMC for the client.
7
###
8
9
10
{redux, Redux, rclass, rtypes, React} = require('./smc-react')
11
{Loading} = require('./r_misc')
12
schema = require('smc-util/schema')
13
misc = require('smc-util/misc')
14
theme = require('smc-util/theme')
15
16
actions = redux.createActions('customize')
17
defaults = misc.dict( ([k, v.default] for k, v of schema.site_settings_conf) )
18
store = redux.createStore('customize', defaults)
19
20
# If we are running in the browser, then we customize the schema. This also gets run on the backend
21
# to generate static content, which can't be customized.
22
$?.get (window.app_base_url + "/customize"), (obj, status) ->
23
if status == 'success'
24
exports.commercial = obj.commercial = (obj.commercial?[0]?.toLowerCase() == 'y') # make it true if starts with y
25
actions.setState(obj)
26
27
HelpEmailLink = rclass
28
displayName : 'HelpEmailLink'
29
reduxProps :
30
customize :
31
help_email : rtypes.string
32
propTypes :
33
text : rtypes.string
34
render: ->
35
if @props.help_email
36
<a href={"mailto:#{@props.help_email}"} target='_blank'>{@props.text ? @props.help_email}</a>
37
else
38
<Loading/>
39
40
exports.HelpEmailLink = rclass
41
displayName : 'HelpEmailLink-redux'
42
propTypes :
43
text : rtypes.string
44
render: ->
45
<Redux redux={redux}>
46
<HelpEmailLink text={@props.text} />
47
</Redux>
48
49
SiteName = rclass
50
displayName : 'SiteName'
51
reduxProps :
52
customize :
53
site_name : rtypes.string
54
render: ->
55
if @props.site_name
56
<span>{@props.site_name}</span>
57
else
58
<Loading/>
59
60
exports.SiteName = rclass
61
displayName : 'SiteName-redux'
62
render: ->
63
<Redux redux={redux}>
64
<SiteName />
65
</Redux>
66
67
SiteDescription = rclass
68
displayName : 'SiteDescription'
69
propTypes:
70
style: rtypes.object
71
reduxProps :
72
customize :
73
site_description : rtypes.string
74
render: ->
75
style = @props.style ? {color:'#666', fontSize:'16px'}
76
if @props.site_description?
77
<span style={style}>{@props.site_description}</span>
78
else
79
<Loading/>
80
81
exports.SiteDescription = rclass
82
displayName : 'SiteDescription-redux'
83
propTypes :
84
style : rtypes.object
85
render: ->
86
<Redux redux={redux}>
87
<SiteDescription style={@props.style}/>
88
</Redux>
89
90
# TODO also make this configurable? Needed in the <Footer/> and maybe elsewhere
91
exports.CompanyName = rclass
92
displayName : 'CompanyName'
93
render:->
94
<span>SageMath, Inc.</span>
95
96
TermsOfService = rclass
97
displayName : 'TermsOfService'
98
99
reduxProps :
100
customize :
101
terms_of_service : rtypes.string
102
103
propTypes :
104
style : rtypes.object
105
106
render: ->
107
if not @props.terms_of_service?
108
return <div></div>
109
return <div style={@props.style} dangerouslySetInnerHTML={__html: @props.terms_of_service}></div>
110
111
exports.TermsOfService = rclass
112
displayName : 'TermsOfService-redux'
113
114
propTypes :
115
style : rtypes.object
116
117
render: ->
118
<Redux redux={redux}>
119
<TermsOfService style={@props.style} />
120
</Redux>
121
122
AccountCreationEmailInstructions = rclass
123
displayName : 'AccountCreationEmailInstructions'
124
125
reduxProps :
126
customize :
127
account_creation_email_instructions : rtypes.string
128
129
render: ->
130
<h3 style={marginTop: 0, textAlign: 'center'} >{@props.account_creation_email_instructions}</h3>
131
132
exports.AccountCreationEmailInstructions = rclass
133
displayName : 'AccountCreationEmailInstructions'
134
135
render: ->
136
<Redux redux={redux}>
137
<AccountCreationEmailInstructions />
138
</Redux>
139
140
# first step of centralizing these URLs in one place collecting all such pages into one
141
# react-class with a 'type' prop is the next step (TODO)
142
# then consolidate this with the existing site-settings database (e.g. TOS above is one fixed HTML string with an anchor)
143
app_base_url = window?.app_base_url ? '' # fallback for react-static
144
exports.PolicyIndexPageUrl = app_base_url + '/policies/index.html'
145
exports.PolicyPricingPageUrl = app_base_url + '/policies/pricing.html'
146
exports.PolicyPrivacyPageUrl = app_base_url + '/policies/privacy.html'
147
exports.PolicyCopyrightPageUrl = app_base_url + '/policies/copyright.html'
148
exports.PolicyTOSPageUrl = app_base_url + '/policies/terms.html'
149
exports.SmcWikiUrl = theme.WIKI_URL
150