@@ -13,8 +13,9 @@ function Wiki (sites) {
1313 this._entry.id = 'entry'
1414
1515 this.loc = ''
16− this.index = {}
17− this.categories = {}
16+ this.byName = {}
17+ this.byCat = {}
18+ this.byAuthor = {}
1819
1920 this.install = (host) => {
2021 console.log('Wiki', 'Installing..')
@@ -32,17 +33,16 @@ function Wiki (sites) {
3233 }
3334
3435 this.refresh = () => {
35− console.log(Object.keys(this.index).length + ' terms')
3636 // Main
3737 if (this.loc) {
38− if (this.categories[this.index]) {
38+ if (this.byCat[this.byName]) {
3939 let html = `term: ${this.loc}`
4040 this._entry.innerHTML = html
41− } else if (this.categories[this.loc]) {
41+ } else if (this.byCat[this.loc]) {
4242 let html = ''
43− for (const id in this.categories[this.loc]) {
44− const name = this.categories[this.loc][id].name
45− html += `${this.templateTerm(name, this.index[name])}<br />`
43+ for (const id in this.byCat[this.loc]) {
44+ const name = this.byCat[this.loc][id].name
45+ html += `${this.templateTerm(name, this.byName[name])}<br />`
4646 }
4747 this._entry.innerHTML = html
4848 } else {
@@ -51,10 +51,10 @@ function Wiki (sites) {
5151 }
5252 } else {
5353 const random = this.random()
54− this._entry.innerHTML = `Click a /topic to get started, or try a <a href='#${random.toUrl()}' onclick='wiki.go("${random}")'>random page</a>.<br />The wiki contains ${Object.keys(this.index).length} terms, in ${Object.keys(this.categories).length} categories.`
54+ this._entry.innerHTML = `Click a /topic to get started, or try a <a href='#${random.toUrl()}' onclick='wiki.go("${random}")'>random page</a>.<br />The wiki contains ${Object.keys(this.byName).length} terms, in ${Object.keys(this.byCat).length} categories, by ${Object.keys(this.byAuthor).length} authors.`
5555 }
5656 // Sidebar
57− this._categories.innerHTML = Object.keys(this.categories).reduce((acc, id) => { return this.categories[id].length > 5 ? `${acc}<li onclick='wiki.go("${id}")' class='${wiki.at(id) ? 'selected' : ''}'>${id.substr(0, 20)} <span class='right'>${this.categories[id].length}</span></li>` : acc }, '')
57+ this._categories.innerHTML = Object.keys(this.byCat).reduce((acc, id) => { return this.byCat[id].length > 5 ? `${acc}<li onclick='wiki.go("${id}")' class='${wiki.at(id) ? 'selected' : ''}'>${id.substr(0, 20)} <span class='right'>${this.byCat[id].length}</span></li>` : acc }, '')
5858 this._entry.innerHTML += `<p id='footer'>The <b>Wiki</b> is a decentralized encyclopedia, to join the conversation, simply create yourself an <a href="https://wiki.xxiivv.com/Indental">twtxt</a> feed and <a href="https://github.com/XXIIVV/Webring/">add it</a> to your entry in the <a href="index.html">webring</a>.</p>`
5959 }
6060
@@ -69,7 +69,7 @@ function Wiki (sites) {
6969 }
7070
7171 this.random = () => {
72− const keys = Object.keys(this.categories)
72+ const keys = Object.keys(this.byCat)
7373 const target = Math.floor(Math.random() * keys.length)
7474 return keys[target]
7575 }
@@ -92,14 +92,21 @@ function Wiki (sites) {
9292 }
9393
9494 this.add = (name, value, cat, origin) => {
95− if (!this.index[name]) {
96− this.index[name] = []
95+ //
96+ if (!this.byName[name]) {
97+ this.byName[name] = []
9798 }
98− this.index[name].push({ name, value, cat, origin })
99− if (!this.categories[cat]) {
100− this.categories[cat] = []
99+ this.byName[name].push({ name, value, cat, origin })
100+ //
101+ if (!this.byCat[cat]) {
102+ this.byCat[cat] = []
101103 }
102− this.categories[cat].push({ name, value, cat, origin })
104+ this.byCat[cat].push({ name, value, cat, origin })
105+ //
106+ if (!this.byAuthor[origin.author]) {
107+ this.byAuthor[origin.author] = []
108+ }
109+ this.byAuthor[origin.author].push({ name, value, cat, origin })
103110 }
104111
105112 this.parse = (site, content) => {