From d0074e832dbf8739bca1e29f1714ecf9e14af574 Mon Sep 17 00:00:00 2001 From: learner97 Date: Tue, 7 May 2024 14:28:54 -0600 Subject: [PATCH] adding althome to sbh1 and backend --- lib/views/admin/theme.js | 1 + lib/views/setup.js | 8 ++++++++ templates/views/setup.jade | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/lib/views/admin/theme.js b/lib/views/admin/theme.js index 51f7ee3a..72f4f2c3 100644 --- a/lib/views/admin/theme.js +++ b/lib/views/admin/theme.js @@ -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 } diff --git a/lib/views/setup.js b/lib/views/setup.js index 3052622c..9b0b5b05 100644 --- a/lib/views/setup.js +++ b/lib/views/setup.js @@ -22,6 +22,7 @@ const settingsSchema = Joi.object({ frontendURL: requiredString('Please enter the frontend URL of your instance'), instanceUrl: requiredString('Please enter the backend URL of your instance'), uriPrefix: requiredString('Please enter the URI prefix of your instance'), + altHome: requiredString('Please enter your alternate homepage'), 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')), @@ -58,6 +59,7 @@ module.exports = function (req, res) { frontendURL: req.protocol + '://' + req.get('Host') + '/', instanceUrl: req.protocol + '://' + req.get('Host') + '/', uriPrefix: req.protocol + '://' + req.get('Host') + '/', + altHome: req.protocol + '://' + req.get('Host') + '/', userName: '', affiliation: '', userFullName: '', @@ -96,6 +98,7 @@ async function setupPost (req, res, settings) { 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, @@ -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, { @@ -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'), diff --git a/templates/views/setup.jade b/templates/views/setup.jade index 77ee42e3..7f66bd46 100644 --- a/templates/views/setup.jade +++ b/templates/views/setup.jade @@ -66,6 +66,10 @@ block body | 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 input.form-control(name='uriPrefix',value=settings.uriPrefix) + p + | We need to know where if you would like to set up your own home page. + label Alternate Home Page + input.form-control(name='altHome',value=settings.altHome) p | We need to know where the Virtuoso INI is stored. We have guessed it to be b #{config.triplestore.virtuosoINI}