Skip to content

Commit

Permalink
Merge branch 'master' into addDefaultExplorer
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmyers authored May 22, 2024
2 parents 52e143c + d02b376 commit ed3c0ef
Show file tree
Hide file tree
Showing 19 changed files with 687 additions and 699 deletions.
13 changes: 9 additions & 4 deletions lib/role.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,31 @@ function lookupRole (uri) {
if (!uri.term && uri.indexOf(igemPrefix) === 0) {
return {
uri: uri,
term: uri.slice(igemPrefix.length)
term: uri.slice(igemPrefix.length),
description: { name: uri.slice(igemPrefix.length) }
}
}

if (!uri.term && uri.lastIndexOf('#') >= 0 && uri.lastIndexOf('#') + 1 < uri.length) {
return {
uri: uri,
term: uri.slice(uri.lastIndexOf('#') + 1)
term: uri.slice(uri.lastIndexOf('#') + 1),
description: { name: uri.slice(uri.lastIndexOf('#') + 1) }
}
}

if (!uri.term && uri.lastIndexOf('/') >= 0 && uri.lastIndexOf('/') + 1 < uri.length) {
return {
uri: uri,
term: uri.slice(uri.lastIndexOf('/') + 1)
term: uri.slice(uri.lastIndexOf('/') + 1),
description: { name: uri.slice(uri.lastIndexOf('/') + 1) }
}
}

return {
uri: uri
uri: uri,
term: uri,
description: { name: uri }
}
}

Expand Down
6 changes: 4 additions & 2 deletions lib/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ function lookupType (uri) {
return {
uri: uri,
term: soTerm,
description: sequenceOntology[soTerm]
description: sequenceOntology[soTerm] ? sequenceOntology[soTerm] : { name: soTerm }
}
}
}

return {
uri: uri
uri: uri,
term: uri,
description: uri
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/views/admin/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = function (req, res) {
osRelease: os.release(),
nodeVersion: process.version,
instanceName: config.get('instanceName'),
frontendUrl: config.get('frontendURL'),
instanceUrl: config.get('instanceUrl'),
listenPort: config.get('port'),
sparqlEndpoint: config.get('triplestore').sparqlEndpoint,
Expand Down
13 changes: 12 additions & 1 deletion lib/views/admin/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ function form (req, res) {

var locals = {
instanceName: config.get('instanceName'),
frontendURL: config.get('frontendURL'),
instanceUrl: config.get('instanceUrl'),
uriPrefix: config.get('databasePrefix'),
frontPageText: config.get('frontPageText'),
firstLaunch: config.get('firstLaunch'),
altHome: config.get('altHome'),
currentTheme: currentTheme,
themeParameters: themeParameters
}
Expand Down Expand Up @@ -71,7 +75,7 @@ function post (req, res) {
if (!newParameter.startsWith('#')) {
newParameter = '#' + newParameter
}
var pat = /#[123456789abcdef]{6}/i
var pat = /#[0123456789abcdef]{6}/i
if (newParameter.length === 7 && pat.test(newParameter)) {
console.log('match=' + newParameter)
newParameters[parameter.variable] = newParameter
Expand Down Expand Up @@ -109,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
25 changes: 21 additions & 4 deletions lib/views/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +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(),
instanceUrl: requiredString('Please enter the 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 @@ -54,8 +56,10 @@ module.exports = function (req, res) {

const settings = {
instanceName: 'My SynBioHub',
frontendURL: '',
instanceUrl: req.protocol + '://' + req.get('Host') + '/',
uriPrefix: req.protocol + '://' + req.get('Host') + '/',
altHome: '',
userName: '',
affiliation: '',
userFullName: '',
Expand Down Expand Up @@ -91,8 +95,10 @@ async function setupPost (req, res, settings) {
{
...settings,
instanceName: req.body.instanceName,
instanceUrl: req.body.instanceURL,
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 All @@ -112,14 +118,24 @@ async function setupPost (req, res, settings) {
{ abortEarly: false }
)

if (updatedSettings.instanceUrl[updatedSettings.instanceUrl.length - 1] !== '/') {
console.log(updatedSettings)

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

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

if (updatedSettings.uriPrefix[updatedSettings.uriPrefix.length - 1] !== '/') {
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 All @@ -140,13 +156,14 @@ async function setupPost (req, res, settings) {
config.set('sessionSecret', uuid())
config.set('shareLinkSalt', uuid())
config.set('passwordSalt', uuid())
config.set('frontendURL', updatedSettings.frontendURL)
config.set('instanceUrl', updatedSettings.instanceUrl)
config.set('webOfRegistries', { [updatedSettings.uriPrefix.slice(0, -1)]: updatedSettings.instanceUrl.slice(0, -1) })
config.set('databasePrefix', updatedSettings.instanceUrl)
config.set('themeParameters', { default: { baseColor: updatedSettings.color } })
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
4 changes: 2 additions & 2 deletions templates/views/setup.jade
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ block body
h2 2. Some technical details
div.form-group
p
| 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
| 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 @@ -26,7 +26,7 @@ def test_post(self):
'userPassword': 'test',
'userPasswordConfirm': 'test',
'instanceName': 'Test Synbiohub',
'instanceURL': 'http://localhost:7777/',
'instanceUrl': 'http://localhost:7777/',
'uriPrefix': 'http://localhost:7777/',
'color': '#D25627',
'frontPageText': 'text',
Expand Down
Loading

0 comments on commit ed3c0ef

Please sign in to comment.