wuffle 0.52.0 → 0.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,7 @@
1
1
  const express = require('express');
2
2
 
3
+ const fs = require('fs');
4
+
3
5
  const path = require('path');
4
6
 
5
7
 
@@ -8,7 +10,7 @@ const path = require('path');
8
10
  *
9
11
  * @param {import('express').Router} router
10
12
  */
11
- module.exports = async (router) => {
13
+ module.exports = async (config, router) => {
12
14
 
13
15
  const staticDirectory = path.join(__dirname, '..', '..', 'public');
14
16
 
@@ -18,8 +20,51 @@ module.exports = async (router) => {
18
20
 
19
21
  // board page
20
22
 
23
+ const {
24
+ name,
25
+ columns
26
+ } = config;
27
+
28
+ const boardConfig = {
29
+ columns: columns.map(c => {
30
+ const { name, collapsed } = c;
31
+
32
+ return {
33
+ name,
34
+ collapsed: collapsed || false
35
+ };
36
+ }),
37
+ name: name || 'Wuffle Board'
38
+ };
39
+
40
+ let indexPage;
41
+
42
+ function getIndexPage() {
43
+ if (indexPage) {
44
+ return indexPage;
45
+ }
46
+
47
+ indexPage = fs.readFileSync(path.join(staticDirectory, 'index.html'), 'utf8');
48
+
49
+ indexPage = indexPage.replace(
50
+ '<title>Wuffle Board</title>',
51
+ '<title>' + boardConfig.name + ' · Wuffle Board</title>'
52
+ );
53
+
54
+ indexPage = indexPage.replace(
55
+ '<script type="application/json+config"></script>',
56
+ '<script type="application/json+config">' +
57
+ JSON.stringify(boardConfig)
58
+ .replace(/</g, '&lt;')
59
+ .replace(/>/g, '&gt;') +
60
+ '</script>'
61
+ );
62
+ }
63
+
21
64
  router.get('/board', (req, res, next) => {
22
- res.sendFile(path.join(staticDirectory, 'index.html'));
65
+ indexPage = getIndexPage();
66
+
67
+ res.type('html').status(200).send(getIndexPage());
23
68
  });
24
69
 
25
70
  router.get('/robots.txt', (req, res, next) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wuffle",
3
- "version": "0.52.0",
3
+ "version": "0.53.0",
4
4
  "description": "A multi-repository task board for GitHub issues",
5
5
  "author": {
6
6
  "name": "Nico Rehwaldt",
@@ -92,5 +92,5 @@
92
92
  "index.js",
93
93
  "wuffle.config.example.js"
94
94
  ],
95
- "gitHead": "5dcc30a2913a0abc514ff94d839724bb33737236"
95
+ "gitHead": "33e580d5670764e17de90752f2045d6b68676bc8"
96
96
  }