@@ -13,8 +13,9 @@ function Wiki (sites) {
13 this._entry.id = 'entry'
13 this._entry.id = 'entry'
15 this.loc = ''
15 this.loc = ''
16− this.index = {}
16+ this.byName = {}
17− this.categories = {}
17+ this.byCat = {}
19 this.install = (host) => {
20 this.install = (host) => {
20 console.log('Wiki', 'Installing..')
21 console.log('Wiki', 'Installing..')
@@ -32,17 +33,16 @@ function Wiki (sites) {
34 this.refresh = () => {
35 this.refresh = () => {
35− console.log(Object.keys(this.index).length + ' terms')
37 if (this.loc) {
37 if (this.loc) {
38− if (this.categories[this.index]) {
38+ if (this.byCat[this.byName]) {
39 let html = `term: ${this.loc}`
39 let html = `term: ${this.loc}`
40 this._entry.innerHTML = html
40 this._entry.innerHTML = html
41− } else if (this.categories[this.loc]) {
41+ } else if (this.byCat[this.loc]) {
42 let html = ''
42 let html = ''
43− for (const id in this.categories[this.loc]) {
43+ for (const id in this.byCat[this.loc]) {
44− const name = this.categories[this.loc][id].name
44+ const name = this.byCat[this.loc][id].name
45− html += `${this.templateTerm(name, this.index[name])}<br />`
45+ html += `${this.templateTerm(name, this.byName[name])}<br />`
47 this._entry.innerHTML = html
47 this._entry.innerHTML = html
@@ -51,10 +51,10 @@ function Wiki (sites) {
53 const random = this.random()
53 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.`
56 // Sidebar
56 // 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 }, '')
58 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>`
58 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>`
@@ -69,7 +69,7 @@ function Wiki (sites) {
71 this.random = () => {
71 this.random = () => {
72− const keys = Object.keys(this.categories)
72+ const keys = Object.keys(this.byCat)
73 const target = Math.floor(Math.random() * keys.length)
73 const target = Math.floor(Math.random() * keys.length)
74 return keys[target]
74 return keys[target]
@@ -92,14 +92,21 @@ function Wiki (sites) {
94 this.add = (name, value, cat, origin) => {
94 this.add = (name, value, cat, origin) => {
95− if (!this.index[name]) {
96+ if (!this.byName[name]) {
96− this.index[name] = []
97+ this.byName[name] = []
98− this.index[name].push({ name, value, cat, origin })
99+ this.byName[name].push({ name, value, cat, origin })
99− if (!this.categories[cat]) {
101+ if (!this.byCat[cat]) {
100− this.categories[cat] = []
102+ this.byCat[cat] = []
102− this.categories[cat].push({ name, value, cat, origin })
104+ this.byCat[cat].push({ name, value, cat, origin })
106+ if (!this.byAuthor[origin.author]) {
107+ this.byAuthor[origin.author] = []
109+ this.byAuthor[origin.author].push({ name, value, cat, origin })
105 this.parse = (site, content) => {
112 this.parse = (site, content) => {