Skip to content

Commit

Permalink
Merge pull request #1541 from SynBioHub/althome
Browse files Browse the repository at this point in the history
adding althome to sbh1 and backend
  • Loading branch information
danielfang97 authored May 13, 2024
2 parents 94a4e18 + 13a115c commit d02b376
Show file tree
Hide file tree
Showing 14 changed files with 556 additions and 557 deletions.
8 changes: 8 additions & 0 deletions lib/views/admin/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function form (req, res) {
uriPrefix: config.get('databasePrefix'),
frontPageText: config.get('frontPageText'),
firstLaunch: config.get('firstLaunch'),
altHome: config.get('altHome'),
currentTheme: currentTheme,
themeParameters: themeParameters
}
Expand Down Expand Up @@ -112,6 +113,13 @@ function post (req, res) {
publishUpdate = true
}

console.log(typeof (req.body))

if (typeof req.body === 'object' && 'altHome' in req.body && req.body.altHome !== config.get('altHome')) {
config.set('altHome', req.body.altHome)
publishUpdate = true
}

if (publishUpdate) {
updateWor()
}
Expand Down
14 changes: 11 additions & 3 deletions lib/views/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ const settingsSchema = Joi.object({
userName: requiredString('Please enter a username for the initial user account'),
userFullName: requiredString('Please enter a full name for the initial user account'),
userEmail: requiredString('Please enter a valid e-mail address for the initial user account').email(),
frontendURL: requiredString('Please enter the frontend URL of your instance'),
frontendURL: Joi.string().allow(''),
instanceUrl: requiredString('Please enter the backend URL of your instance'),
uriPrefix: requiredString('Please enter the URI prefix of your instance'),
altHome: Joi.string().allow(''),
frontPageText: requiredString('Please enter some welcome text for your homepage'),
userPassword: requiredString('Please enter a password for the initial user account', { trim: false }),
userPasswordConfirm: requiredString("Passwords didn't match", { trim: false }).valid(Joi.ref('userPassword')),
Expand Down Expand Up @@ -55,9 +56,10 @@ module.exports = function (req, res) {

const settings = {
instanceName: 'My SynBioHub',
frontendURL: req.protocol + '://' + req.get('Host') + '/',
frontendURL: '',
instanceUrl: req.protocol + '://' + req.get('Host') + '/',
uriPrefix: req.protocol + '://' + req.get('Host') + '/',
altHome: '',
userName: '',
affiliation: '',
userFullName: '',
Expand Down Expand Up @@ -93,9 +95,10 @@ async function setupPost (req, res, settings) {
{
...settings,
instanceName: req.body.instanceName,
frontendURL: req.body.frontendURL,
frontendURL: req.body.frontendURL || '',
instanceUrl: req.body.instanceUrl,
uriPrefix: req.body.uriPrefix,
altHome: req.body.altHome || '',
userName: req.body.userName,
affiliation: req.body.affiliation,
userFullName: req.body.userFullName,
Expand Down Expand Up @@ -129,6 +132,10 @@ async function setupPost (req, res, settings) {
updatedSettings.uriPrefix += '/'
}

if (updatedSettings.altHome && updatedSettings.altHome[updatedSettings.altHome.length - 1] !== '/') {
updatedSettings.altHome += '/'
}

if (error) {
if (req.accepts('text/html')) {
return setupForm(req, res, updatedSettings, {
Expand Down Expand Up @@ -156,6 +163,7 @@ async function setupPost (req, res, settings) {
config.set('frontPageText', updatedSettings.frontPageText)
config.set('allowPublicSignup', updatedSettings.allowPublicSignup)
config.set('databasePrefix', updatedSettings.uriPrefix)
config.set('altHome', updatedSettings.altHome)

config.set('triplestore', {
...config.get('triplestore'),
Expand Down
8 changes: 1 addition & 7 deletions templates/views/setup.jade
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,12 @@ block body
br
h2 2. Some technical details
div.form-group
p
| Frontend Url: We need to know where this SynBioHub instance is is displayed. If the URL below is incorrect, please change it
b #{settings.frontendURL}
|, but if this is incorrect, please change it here.
label Frontend URL
input.form-control(name='frontendURL',value=settings.frontendURL)
p
| Backend Url: We need to know where this SynBioHub instance is hosted so we can assign URLs to your submissions. The instance URL has been automatically guessed as
b #{settings.instanceUrl}
|, but if this is incorrect, please change it here.
label Instance URL
input.form-control(name='instanceURL',value=settings.instanceUrl)
input.form-control(name='instanceUrl',value=settings.instanceUrl)
p
| We need to know how to prefix URIs of objects stored in this SynBioHub. Its default is the same as the URL, and should only be changed if you are shadowing another instance.
label URI Prefix
Expand Down
2 changes: 1 addition & 1 deletion tests/first_time_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_post(self):
'userEmail': '[email protected]',
'userPassword': 'test',
'userPasswordConfirm': 'test',
'instanceName': 'Test Synbiohub', 'frontendURL': 'http://localhost:7777',
'instanceName': 'Test Synbiohub',
'instanceUrl': 'http://localhost:7777/',
'uriPrefix': 'http://localhost:7777/',
'color': '#D25627',
Expand Down
Loading

0 comments on commit d02b376

Please sign in to comment.