on master help sign in
Basic working copy
commit02e3c7b45166eb84e7b69c90f0e057fb3c15a7c3 authorDevine Lu Linvega <aliceffekt@gmail.com> dateMon 29 Jul 2019, 09:20 (7 years ago) parentc318af1
2 files changed+21−6
links/main.css+9−2 scripts/wiki.js+12−4
links/main.css+9−2
@@ -6,10 +6,10 @@ body div ul { max-width: 800px; border-bottom: 2px solid white;padding-bottom: 1
66body div p { display:block; padding:0px 5px; line-height: 20px; max-width: 600px}
77body div p a { text-decoration: underline;}
88body div p a:hover { text-decoration: underline; }
9−body div p b { font-weight: normal; font-family: 'input_mono_medium' }
9+body b { font-weight: normal; font-family: 'input_mono_medium' }
1010body div p.readme { max-width:500px; }
1111
12−body #sidebar { position: absolute;top: 0px;right: 0px;padding: 15px;width: 200px; overflow: hidden; height: calc(100vh - 75px);}
12+body #sidebar { position: absolute;top: 0px;right: 0px;padding: 15px;width: 200px; overflow: hidden;}
1313body #sidebar > * { border-bottom: 0px; line-height: 16px; padding-bottom: 0px }
1414body #sidebar > * li { text-transform: lowercase; }
1515body #sidebar > * li.selected { background: white; color:black; }
@@ -79,4 +79,11 @@ body #portal ul li a:hover { text-decoration: underline; }
7979
8080/* Wiki */
8181
82+body #wiki #entry { max-width: calc(100% - 230px); }
83+body #wiki ul.term { border-bottom: 0px; margin-bottom: 0px; padding-bottom: 0px}
84+body #wiki ul.term li.name { margin-bottom: 5px }
85+body #wiki ul.term li a.author { color:#555; }
86+
87+
88+
8289
scripts/wiki.js+12−4
@@ -38,7 +38,11 @@ function Wiki (sites) {
3838 let html = `term: ${this.loc}`
3939 this._entry.innerHTML = html
4040 } else if (this.categories[this.loc]) {
41− let html = `category: ${this.loc}`
41+ let html = ''
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 />`
45+ }
4246 this._entry.innerHTML = html
4347 } else {
4448 let html = `Unknown: ${this.loc}`
@@ -48,7 +52,7 @@ function Wiki (sites) {
4852 this._entry.innerHTML = 'Click a /topic to get started.'
4953 }
5054 // Sidebar
51− this._categories.innerHTML = Object.keys(this.categories).reduce((acc, id) => { return `${acc}<li onclick='wiki.go("${id}")' class='${wiki.at(id) ? 'selected' : ''}'>${id} <span class='right'>${this.categories[id].length}</span></li>` }, '')
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>` }, '')
5256 }
5357
5458 this.go = (q) => {
@@ -60,6 +64,10 @@ function Wiki (sites) {
6064 return this.loc.toUpperCase() === q.toUpperCase()
6165 }
6266
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>'
69+ }
70+
6371 this.fetch = () => {
6472 console.log('Wiki', 'Fetching..')
6573 for (const site of sites) {
@@ -77,11 +85,11 @@ function Wiki (sites) {
7785 if (!this.index[name]) {
7886 this.index[name] = []
7987 }
80− this.index[name].push({ value, cat, origin })
88+ this.index[name].push({ name, value, cat, origin })
8189 if (!this.categories[cat]) {
8290 this.categories[cat] = []
8391 }
84− this.categories[cat].push({ value, cat, origin })
92+ this.categories[cat].push({ name, value, cat, origin })
8593 }
8694
8795 this.parse = (site, content) => {