6 this._el = document.createElement('div')
8 this._sidebar = document.createElement('div')
9 this._sidebar.id = 'sidebar'
10 this._categories = document.createElement('ul')
11 this._categories.id = 'categories'
12 this._entry = document.createElement('div')
13 this._entry.id = 'entry'
19 this.install = (host) => {
20 console.log('Wiki', 'Installing..')
22 this._el.appendChild(this._entry)
23 this._sidebar.appendChild(this._categories)
24 this._el.appendChild(this._sidebar)
25 host.appendChild(this._el)
29 console.log('Wiki', 'Starting..')
30 // this.el.innerHTML = 'hello.'
33 this.refresh = () => {
34 console.log(Object.keys(this.index).length + ' terms')
37 if (this.categories[this.index]) {
38 let html = `term: ${this.loc}`
39 this._entry.innerHTML = html
40 } else if (this.categories[this.loc]) {
42 for (const id in this.categories[this.loc]) {
43 const name = this.categories[this.loc][id].name
44 html += `${this.templateTerm(name, this.index[name])}<br />`
46 this._entry.innerHTML = html
48 let html = `Unknown: ${this.loc}`
49 this._entry.innerHTML = html
52 this._entry.innerHTML = 'Click a /topic to get started.'
55 this._categories.innerHTML = Object.keys(this.categories).reduce((acc, id) => { return `${acc}<li onclick='wiki.go("${id}")' class='${wiki.at(id) ? 'selected' : ''}'>${id.substr(0, 20)} <span class='right'>${this.categories[id].length}</span></li>` }, '')
63 this.at = (q = '') => {
64 return this.loc.toUpperCase() === q.toUpperCase()
67 this.templateTerm = (name, entry) => {
68 return '<ul class="term"><li class="name"><b>' + name.toLowerCase() + '</b></li>' + entry.reduce((acc, item) => { return `${acc}<li>${item.value} <a class='author' href='${item.origin.url}'> — @${item.origin.author}</a></li>` }, '') + '</ul>'
72 console.log('Wiki', 'Fetching..')
73 for (const site of sites) {
74 if (!site.wiki || !site.author) { continue }
75 fetch(site.wiki, { cache: 'no-store' }).then(x => x.text()).then((content) => {
76 this.parse(site, content)
79 console.warn(`${site.wiki}`, err)
84 this.add = (name, value, cat, origin) => {
85 if (!this.index[name]) {
88 this.index[name].push({ name, value, cat, origin })
89 if (!this.categories[cat]) {
90 this.categories[cat] = []
92 this.categories[cat].push({ name, value, cat, origin })
95 this.parse = (site, content) => {
96 console.log('Wiki', 'Parsing ' + site.wiki)
97 const cats = indental(this.filter(content))
98 for (const cat in cats) {
99 const terms = cats[cat]
100 for (const name in terms) {
101 this.add(name, terms[name], cat, site)
106 this.filter = (lines) => {
107 return lines.split('\n').filter((line) => { return line.indexOf(' = `') < 0 && line.trim().length > 1 }).join('\n')
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list