on master help sign in
clean up

Few different things, cleaning up duplicate key, changing b to strong for screen readers, and then taking out unused variables and simplifying some of the logic

commite6044f870bb6c4475272af63648decad2102fa70 authorckipp01 <ckipp@pm.me> dateSat 3 Aug 2019, 19:12 (7 years ago) parent393ddf9
5 files changed+17−31
links/main.css+1−1 scripts/hallway.js+1−1 scripts/indental.js−2 scripts/sites.js+1−1 scripts/wiki.js+14−26
links/main.css+1−1
@@ -6,7 +6,7 @@ body div ul { max-width: 800px; padding-bottom: 15px;margin-bottom:15px; overflo
66body div p { display:block; padding:0px 5px; line-height: 20px; max-width: 600px}
77body div p a { text-decoration: underline; cursor: pointer;}
88body div p a:hover { text-decoration: underline; }
9−body b { font-weight: normal; font-family: 'input_mono_medium' }
9+body strong { font-weight: normal; font-family: 'input_mono_medium' }
1010body div p.readme { max-width:500px; }
1111body .col3 { columns:3; }
1212body .selected { background: white; color:black; }
scripts/hallway.js+1−1
@@ -20,7 +20,7 @@ function Hallway (sites) {
2020 this._sidebar.id = 'sidebar'
2121 this._footer = document.createElement('p')
2222 this._footer.id = 'footer'
23− this._footer.innerHTML = `The <b>Wiki</b> is a decentralized forum, to join the conversation, add a <a href="https://github.com/XXIIVV/webring#joining-the-hallway">feed:</a> field to your entry in the <a href="https://github.com/XXIIVV/Webring/">webring</a>.`
23+ this._footer.innerHTML = `The <strong>Wiki</strong> is a decentralized forum, to join the conversation, add a <a href="https://github.com/XXIIVV/webring#joining-the-hallway">feed:</a> field to your entry in the <a href="https://github.com/XXIIVV/Webring/">webring</a>.`
2424
2525 this.install = function (host) {
2626 this._el.appendChild(this._entries)
scripts/indental.js−2
@@ -55,5 +55,3 @@ function indental (data, Type) {
5555 }
5656 return h
5757}
58−
59−module.exports = indental
scripts/sites.js+1−1
@@ -4,7 +4,7 @@
44// protocol://url.domain.ext
55
66const sites = [
7− { url: 'https://wiki.xxiivv.com', title: 'xxiivv', type: 'wiki', author: 'neauoire', contact: 'aliceffekt@gmail.com', rss: 'https://wiki.xxiivv.com/links/rss.xml', feed: 'https://wiki.xxiivv.com/twtxt.txt', feed: 'https://wiki.xxiivv.com/twtxt.txt', wiki: 'https://wiki.xxiivv.com/scripts/database/glossary.ndtl' },
7+ { url: 'https://wiki.xxiivv.com', title: 'xxiivv', type: 'wiki', author: 'neauoire', contact: 'aliceffekt@gmail.com', rss: 'https://wiki.xxiivv.com/links/rss.xml', feed: 'https://wiki.xxiivv.com/twtxt.txt', wiki: 'https://wiki.xxiivv.com/scripts/database/glossary.ndtl' },
88 { url: 'http://estevancarlos.com' },
99 { url: 'https://electro.pizza', title: 'electro pizza', type: 'blog', author: 'rho', rss: 'https://electro.pizza/feed.xml', feed: 'https://electro.pizza/twtxt.txt' },
1010 { url: 'https://avanier.now.sh', title: 'Arachne', type: 'wiki', author: 'joshavanier', contact: 'joshavanier@protonmail.com', feed: 'https://avanier.now.sh/tw.txt' },
scripts/wiki.js+14−26
@@ -14,7 +14,7 @@ function Wiki (sites) {
1414
1515 this._footer = document.createElement('p')
1616 this._footer.id = 'footer'
17− this._footer.innerHTML = `The <b>Wiki</b> is a decentralized encyclopedia, to join the conversation, add a <a href="https://github.com/XXIIVV/webring#joining-the-wiki">wiki:</a> field to your entry in the <a href="https://github.com/XXIIVV/Webring/">webring</a>.`
17+ this._footer.innerHTML = `The <strong>Wiki</strong> is a decentralized encyclopedia, to join the conversation, add a <a href="https://github.com/XXIIVV/webring#joining-the-wiki">wiki:</a> field to your entry in the <a href="https://github.com/XXIIVV/Webring/">webring</a>.`
1818
1919 this.loc = ''
2020 this.byName = {}
@@ -38,17 +38,14 @@ function Wiki (sites) {
3838 // Main
3939 if (this.loc) {
4040 if (this.byCat[this.loc]) {
41− let html = ''
42− for (const id in this.byCat[this.loc]) {
43− const name = this.byCat[this.loc][id].name
44− html += `${this.templateTerm(name, this.byName[name])}<br />`
45− }
41+ const formatHtml = (entries, entry) => `${entries} ${this.templateTerm(entry.name, this.byName[entry.name])}<br />`
42+ const html = this.byCat[this.loc].reduce(formatHtml, '')
4643 this._entry.innerHTML = html
4744 } else if (this.byName[this.loc]) {
48− let html = `${this.templateTerm(this.loc, this.byName[this.loc])}<br />${this.templateRelated(this.loc, this.byName[this.loc])}`
45+ const html = `${this.templateTerm(this.loc, this.byName[this.loc])}<br />${this.templateRelated(this.loc)}`
4946 this._entry.innerHTML = html
5047 } else {
51− let html = `Unknown: ${this.loc}. Retun <a onclick='wiki.go("")'>home</a>, or try a <a onclick='wiki.go("${this.random()}")'>random page</a>.`
48+ const html = `Unknown: ${this.loc}. Retun <a onclick='wiki.go("")'>home</a>, or try a <a onclick='wiki.go("${this.random()}")'>random page</a>.`
5249 this._entry.innerHTML = html
5350 }
5451 } else {
@@ -82,16 +79,14 @@ function Wiki (sites) {
8279 return this.byName[name] ? this.byName[name][0].cat : ''
8380 }
8481
85− this.templateRelated = (name, entry) => {
86− let html = ''
87− const cat = entry.cat
82+ this.templateRelated = (name) => {
8883 const relatedWords = this.related(name)
89− html += `<ul class='col3'>${relatedWords.reduce((acc, item, id) => { return `${acc}<li onclick='wiki.go("${item.name}")' class='${wiki.at(item.name) ? 'selected' : ''}'>${item.name.toLowerCase()}</li>` }, '')}</ul>`
84+ const html = `<ul class='col3'>${relatedWords.reduce((acc, item, id) => { return `${acc}<li onclick='wiki.go("${item.name}")' class='${wiki.at(item.name) ? 'selected' : ''}'>${item.name.toLowerCase()}</li>` }, '')}</ul>`
9085 return html
9186 }
9287
9388 this.templateTerm = (name, entry) => {
94− return '<ul class="term"><li class="name"><b>' + name.toLowerCase() + '</b></li>' + entry.reduce((acc, item) => { return `${acc}<li>${item.value} <a class='author' target='_blank' href='${item.origin.url}'> — @${item.origin.author}</a></li>` }, '') + '</ul>'
89+ return '<ul class="term"><li class="name"><strong>' + name.toLowerCase() + '</strong></li>' + entry.reduce((acc, item) => { return `${acc}<li>${item.value} <a class='author' target='_blank' href='${item.origin.url}'> — @${item.origin.author}</a></li>` }, '') + '</ul>'
9590 }
9691
9792 this.fetch = () => {
@@ -108,20 +103,13 @@ function Wiki (sites) {
108103 }
109104
110105 this.add = (name, value, cat, origin) => {
111− //
112− if (!this.byName[name]) {
113− this.byName[name] = []
114− }
106+ this.byName[name] = this.byName[name] || []
115107 this.byName[name].push({ name, value, cat, origin })
116− //
117− if (!this.byCat[cat]) {
118− this.byCat[cat] = []
119− }
108+
109+ this.byCat[cat] = this.byCat[cat] || []
120110 this.byCat[cat].push({ name, value, cat, origin })
121− //
122− if (!this.byAuthor[origin.author]) {
123− this.byAuthor[origin.author] = []
124− }
111+
112+ this.byAuthor[origin.author] = this.byAuthor[origin.author] || []
125113 this.byAuthor[origin.author].push({ name, value, cat, origin })
126114 }
127115
@@ -136,5 +124,5 @@ function Wiki (sites) {
136124 }
137125 }
138126
139− String.prototype.toUrl = function () { return this.toLowerCase().replace(/ /g, '+').replace(/[^0-9a-z\+\:\-\.\/\~]/gi, '').trim() }
127+ String.prototype.toUrl = function () { return this.toLowerCase().replace(/ /g, '+').replace(/[^0-9a-z+:\-./~]/gi, '').trim() }
140128}