Skip to content

Commit 17938c9

Browse files
committed
Add Literate programming sub-system.
1 parent 715b1ad commit 17938c9

7 files changed

+52
-29
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# bootstrap-dashboard
22
Fully Functional Pure Bootstrap Dashboard, powered by EventEmitter, npm, Node and Electron.
33

4-
The dashboard is configured via Literate Programming in STORY.md with parser located at STORY.md.js
4+
The dashboard is configured via Literate Programming in [STORY.md](STORY.md) with parser located at STORY.md.js
55

6+
![](screenshot-colors.png)
67
![](screenshot.png)

STORY.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Code Generation Dashboard
22
---
33

4-
Card Primary Server monitors example.com health every 3 minutes.
4+
Card Primary Server monitors www.example.com health every 1 minutes.
55

6-
Card Sample Web Server #1 monitors example.com server availability every 20 minutes.
6+
Card Secondary Server monitors ww2.example.com health every 2 minutes.
77

8-
Card Sample Web Server #2 monitors example.com server availability every 20 minutes.
8+
Card Mail Server monitors mail.example.com health every 3 minutes.

STORY.md.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
2-
3-
register(Dashboard Title: $title)
4-
emit dashboard-title, title
1+
module.exports = function(){
2+
this.register('monitor-server', `Card (?<title>[a-zA-Z0-9 ]+) monitors (?<url>[a-zA-Z0-9.]+) health every (?<interval>[0-9]+) minutes.`);
3+
}

package-lock.json

+14-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "bootstrap-dashboard",
33
"productName": "Bootstrap Dashboard",
4-
"version": "1.0.1",
4+
"version": "1.0.2",
55
"description": "Fully Functional Pure Bootstrap Dashboard, powered by EventEmitter, npm, Node and Electron.",
66
"main": "main.js",
77
"scripts": {
@@ -19,6 +19,7 @@
1919
},
2020
"homepage": "https://github.com/fantasyui-com/bootstrap-dashboard#readme",
2121
"dependencies": {
22+
"civilized": "^1.0.2",
2223
"faker": "^4.1.0"
2324
}
2425
}

renderer.js

+28-19
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const EventEmitter = require('events');
77
const fs = require('fs');
88
const path = require('path');
99

10+
const civilized = require('civilized');
11+
1012
const faker = require('faker');
1113

1214
class MyEmitter extends EventEmitter {}
@@ -97,11 +99,11 @@ Vue.component('card', {
9799
},
98100

99101
created: function(){
100-
102+
let level = this.level;
101103
setInterval(()=>{
102-
this.level++;
103-
if(this.level > (this.cardClasses.length-1)) this.level = 0;
104-
this.cardClass = this.cardClasses[this.level];
104+
level++;
105+
if(level > (this.cardClasses.length-1)) level = 0;
106+
this.cardClass = this.cardClasses[level];
105107
},500);
106108

107109
}
@@ -111,24 +113,31 @@ var workspace = new Vue({
111113
el: '#workspace',
112114
data: {
113115
cards: [
114-
{ id:0, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:'Last Run: '+faker.date.past(), level: 0},
115-
{ id:1, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:'Last Run: '+faker.date.past(), level: 1},
116-
{ id:2, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:'Last Run: '+faker.date.past(), level: 2},
117-
{ id:3, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:'Last Run: '+faker.date.past(), level: 3},
118-
{ id:4, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:'Last Run: '+faker.date.past(), level: 0},
119-
{ id:5, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:'Last Run: '+faker.date.past(), level: 1},
120-
{ id:6, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:'Last Run: '+faker.date.past(), level: 2},
121-
{ id:7, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:'Last Run: '+faker.date.past(), level: 3},
122-
{ id:8, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:'Last Run: '+faker.date.past(), level: 0},
123-
{ id:9, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:'Last Run: '+faker.date.past(), level: 1},
124-
{ id:10, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:'Last Run: '+faker.date.past(), level: 2},
125-
{ id:11, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:'Last Run: '+faker.date.past(), level: 3},
126-
{ id:12, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:'Last Run: '+faker.date.past(), level: 0},
127-
{ id:13, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:'Last Run: '+faker.date.past(), level: 1},
128-
{ id:14, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:'Last Run: '+faker.date.past(), level: 2},
116+
{ id:0, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:faker.date.past().toString(), level: 0},
117+
{ id:1, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:faker.date.past().toString(), level: 1},
118+
{ id:2, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:faker.date.past().toString(), level: 2},
119+
{ id:3, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:faker.date.past().toString(), level: 3},
120+
{ id:4, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:faker.date.past().toString(), level: 0},
121+
{ id:5, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:faker.date.past().toString(), level: 1},
122+
{ id:6, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:faker.date.past().toString(), level: 2},
123+
{ id:7, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:faker.date.past().toString(), level: 3},
124+
{ id:8, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:faker.date.past().toString(), level: 0},
125+
{ id:9, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:faker.date.past().toString(), level: 1},
126+
{ id:10, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:faker.date.past().toString(), level: 2},
127+
{ id:11, header:faker.company.companyName(), title: faker.hacker.ingverb() + ' ' + faker.hacker.noun(), text:faker.date.past().toString(), level: 3},
128+
129129
]
130130
},
131131

132+
created: function(){
133+
134+
let story = civilized(__dirname + '/STORY.md').filter(i=>i.name==='monitor-server');
135+
console.log(story)
136+
story.forEach((item,index)=>{
137+
this.cards.unshift( { id:(99+index), header:`Monitoring ${item.data.url} (${item.data.interval} min.)`, title: item.data.title, text:faker.date.past().toString(), level: 2} );
138+
});
139+
}
140+
132141
})
133142

134143

screenshot-colors.png

182 KB
Loading

0 commit comments

Comments
 (0)