Skip to content

Commit

Permalink
add ability to supply extra URLs as LAB_EXTRA_URLS
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesfalkner committed May 27, 2020
1 parent 8d500de commit 296edc4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,15 @@ You can set these variables via a `Deployment` or `DeploymentConfig`, or by moun
| LAB_USER_ACCESS_TOKEN | redhatlabs || Access token required to join the lab. Give this to your users. |
| LAB_BLOCKLIST | [] | | Comma separated list of user numbers to block off. These numbers will not be assigned |
| LAB_USER_PREFIX | evals || The username prefix for each account (eg. evals1, evals2) |
| LAB_MODULE_URLS | [] | | Comma separated list of modules and module names, e.g "https://module.a;Lab 1,https://module.b;Lab2" |
| LAB_MODULE_URLS | sample set | | Comma separated list of modules and module names, e.g `https://module.a;Lab 1,https://module.b;Lab2` |
| LAB_EXTRA_URLS | [] | | Comma separated list of extra URLs to display at the bottom. e.g. `https://redhat.com;Red Hat Homepage,http://ibm.com;IBM Homepage` |
| LAB_USER_PAD_ZERO | false || Determines if user should be formatted as evals01 or "evals1" when user number is less than 10 |
| LAB_ADMIN_PASS | pleasechangethis | | The password used to login at the /admin URL |
| LAB_REDIS_HOST | not set | | The Redis instance to use. Provide only the hostname, and no port |
| LAB_REDIS_PASS | not set | | The password used to access Redis |
| LAB_SESSION_SECRET | Randomly generated on startup | | The secret used to sign cookies. |

For config names marked as _Substitutable_ (✅) above, these names can be referenced in the value for `LAB_MODULE_URLS` to substitute the values using `%`_NAME_`%`. The values `%USERNAME%` and `%REALNAME%` may also be used to refer to the name the user gave and their assigned username. For example, to include the assigned username and number of users in the URLs generated for each user, set the variable `LAB_MODULE_URLS` to:
For config names marked as _Substitutable_ (✅) above, these names can be referenced in the value for `LAB_MODULE_URLS` and `LAB_EXTRA_URLS` to substitute the values using `%`_NAME_`%`. The values `%USERNAME%` and `%REALNAME%` may also be used to refer to the name the user gave and their assigned username. For example, to include the assigned username and number of users in the URLs generated for each user, set the variable `LAB_MODULE_URLS` to:

```
https://module.a?userid=%USERNAME%;The First Lab,https://module.b?userid=%USERNAME%&count=%LAB_USER_COUNT%;The Final Lab
Expand Down
4 changes: 3 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const env = require('env-var').from({
LAB_USER_PAD_ZERO: 'false',
LAB_ADMIN_PASS: 'pleasechangethis',
LAB_MODULE_URLS: 'https://a.com;Lab 1,https://b.com;Lab 2',
LAB_EXTRA_URLS: '',

// If you plan to use redis uncomment and set these,
// or provide in values for them in the environment
Expand Down Expand Up @@ -44,5 +45,6 @@ module.exports = {
padZeroes: env.get('LAB_USER_PAD_ZERO').asBool()
},
// Comma separated list of URLS
modules: env.get('LAB_MODULE_URLS').asArray()
modules: env.get('LAB_MODULE_URLS').asArray(),
extraUrls: env.get('LAB_EXTRA_URLS').asArray()
}
12 changes: 12 additions & 0 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ router.get('/', async (req, res) => {
prettyName = prettyName.replace('%' + sub[0] + '%', sub[1])
})
return {url: url, prettyName: prettyName}
}),
extraUrls: config.extraUrls.map(function(val){
val = val.split(';');
return {url:val[0], prettyName:val[1]}
}).map(function(val) {
var url = val.url
var prettyName = val.prettyName
subs.forEach(function(sub) {
url = url.replace('%' + sub[0] + '%', sub[1])
prettyName = prettyName.replace('%' + sub[0] + '%', sub[1])
})
return {url: url, prettyName: prettyName}
})
});
}
Expand Down
10 changes: 10 additions & 0 deletions views/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,14 @@
</div>
</div>
</div>
<div class="d-flex mt-4 justify-content-center">
{{#each extraUrls}}
<a class="text-base mt-2 text-blue-600" target="_blank" href="{{this.url}}">{{this.prettyName}}</a>
{{!-- add a separator except for the last one --}}
{{#if @last}}
{{else}}
|
{{/if}}
{{/each}}
</div>
</div>

0 comments on commit 296edc4

Please sign in to comment.