on master help sign in
Merge pull request #235 from ckipp01/master
68d5585Chris
links/main.css+3−2
@@ -2,17 +2,18 @@
2
2
3body { background:#f4f4f4; padding:0px; margin:0px; }
3body { background:#f4f4f4; padding:0px; margin:0px; }
4body > div { display:block; background: #111;min-height: calc(100vh - 60px);width: calc(100vw - 60px);margin: 15px;color: #333;padding: 15px;font-family:'input_mono_regular', 'Monospaced','Courier New',courier;font-size:11px; position: relative; border-radius: 2px; color:white; overflow: hidden;}
4body > div { display:block; background: #111;min-height: calc(100vh - 60px);width: calc(100vw - 60px);margin: 15px;color: #333;padding: 15px;font-family:'input_mono_regular', 'Monospaced','Courier New',courier;font-size:11px; position: relative; border-radius: 2px; color:white; overflow: hidden;}
5−body div ul { max-width: 800px; padding-bottom: 15px;margin-bottom:15px; overflow: hidden;}
5+body > div > ul { max-width: 800px; padding-bottom: 15px;margin-bottom:15px; overflow: hidden;}
6body div p { display:block; padding:0px 5px; line-height: 20px; max-width: 600px}
6body div p { display:block; padding:0px 5px; line-height: 20px; max-width: 600px}
7body div p a { text-decoration: underline; cursor: pointer;}
7body div p a { text-decoration: underline; cursor: pointer;}
8body div p a:hover { text-decoration: underline; }
8body 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' }
10body div p.readme { max-width:500px; }
10body div p.readme { max-width:500px; }
11body .col3 { columns:3; }
11body .col3 { columns:3; }
12body .selected { background: white; color:black; }
12body .selected { background: white; color:black; }
13
13
14body #sidebar { position: absolute;top: 0px;right: 0px;padding: 15px;width: 200px; overflow: hidden;}
14body #sidebar { position: absolute;top: 0px;right: 0px;padding: 15px;width: 200px; overflow: hidden;}
15body #sidebar > * { border-bottom: 0px; line-height: 16px; padding-bottom: 0px }
15body #sidebar > * { border-bottom: 0px; line-height: 16px; padding-bottom: 0px }
16+body #sidebar ul { margin-bottom: 15px }
16body #sidebar > * li { text-transform: lowercase; }
17body #sidebar > * li { text-transform: lowercase; }
17body #sidebar > * li:hover { cursor: pointer; }
18body #sidebar > * li:hover { cursor: pointer; }
18body #sidebar > * li span.right { color:#555; float:right; }
19body #sidebar > * li span.right { color:#555; float:right; }
scripts/hallway.js+3−3
@@ -2,7 +2,7 @@
2
2
3const reChannel = /(\s|^)\/([a-zA-Z0-9]+)/g
3const reChannel = /(\s|^)\/([a-zA-Z0-9]+)/g
4const reUser = /((\s|^)@<[a-zA-Z0-9./:\-_+~#= ]*>)/g
4const reUser = /((\s|^)@<[a-zA-Z0-9./:\-_+~#= ]*>)/g
5−const reTag = /([^&]|^)#([a-zA-Z0-9]+)/g
5+const reTag = /(^|\s)(#[a-z\d-]+)/ig
6const reUrl = /((https?):\/\/(([-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b)([-a-zA-Z0-9@:%_+.~#?&//=]*)))/g
6const reUrl = /((https?):\/\/(([-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b)([-a-zA-Z0-9@:%_+.~#?&//=]*)))/g
7
7
8function Hallway (sites) {
8function Hallway (sites) {
@@ -20,7 +20,7 @@ function Hallway (sites) {
20 this._sidebar.id = 'sidebar'
20 this._sidebar.id = 'sidebar'
21 this._footer = document.createElement('p')
21 this._footer = document.createElement('p')
22 this._footer.id = 'footer'
22 this._footer.id = 'footer'
23− this._footer.innerHTML = `The <b>Hallway</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>Hallway</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>.`
24
24
25 this.install = function (host) {
25 this.install = function (host) {
26 this._el.appendChild(this._entries)
26 this._el.appendChild(this._entries)
@@ -117,7 +117,7 @@ function Hallway (sites) {
117 entry.html = entry.body
117 entry.html = entry.body
118 .replace(reChannel, `$1<span class='channel'>/$2</span>`)
118 .replace(reChannel, `$1<span class='channel'>/$2</span>`)
119 .replace(reUser, this.findMention)
119 .replace(reUser, this.findMention)
120− .replace(reTag, `$1<span class='tag'>#$2</span>`)
120+ .replace(reTag, '$1<span class="tag">$2</span>')
121 .replace(reUrl, `<a target="_blank" href='$1'>$1</a>`)
121 .replace(reUrl, `<a target="_blank" href='$1'>$1</a>`)
122
122
123 const filter = window.location.hash.substr(1).replace(/\+/g, ' ').toLowerCase()
123 const filter = window.location.hash.substr(1).replace(/\+/g, ' ').toLowerCase()
scripts/indental.js−2
@@ -55,5 +55,3 @@ function indental (data, Type) {
55 }
55 }
56 return h
56 return h
57}
57}
58−
59−module.exports = indental
scripts/sites.js+1−1
@@ -4,7 +4,7 @@
4// protocol://url.domain.ext
4// protocol://url.domain.ext
5
5
6const sites = [
6const 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' },
8 { url: 'http://estevancarlos.com' },
8 { url: 'http://estevancarlos.com' },
9 { url: 'https://electro.pizza', title: 'electro pizza', type: 'blog', author: 'rho', rss: 'https://electro.pizza/feed.xml', feed: 'https://electro.pizza/twtxt.txt' },
9 { url: 'https://electro.pizza', title: 'electro pizza', type: 'blog', author: 'rho', rss: 'https://electro.pizza/feed.xml', feed: 'https://electro.pizza/twtxt.txt' },
10 { url: 'https://avanier.now.sh', title: 'Arachne', type: 'wiki', author: 'joshavanier', contact: 'joshavanier@protonmail.com', feed: 'https://avanier.now.sh/tw.txt' },
10 { 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+25−27
@@ -14,7 +14,7 @@ function Wiki (sites) {
14
14
15 this._footer = document.createElement('p')
15 this._footer = document.createElement('p')
16 this._footer.id = 'footer'
16 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>.`
18
18
19 this.loc = ''
19 this.loc = ''
20 this.byName = {}
20 this.byName = {}
@@ -38,17 +38,14 @@ function Wiki (sites) {
38 // Main
38 // Main
39 if (this.loc) {
39 if (this.loc) {
40 if (this.byCat[this.loc]) {
40 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 />`
41+ const formatHtml = (entries, entry) => `${entries} ${this.templateTerm(entry.name, this.byName[entry.name])}<br />`
45− }
42+ const html = this.byCat[this.loc].reduce(formatHtml, '')
46 this._entry.innerHTML = html
43 this._entry.innerHTML = html
47 } else if (this.byName[this.loc]) {
44 } 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)}`
49 this._entry.innerHTML = html
46 this._entry.innerHTML = html
50 } else {
47 } 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>.`
52 this._entry.innerHTML = html
49 this._entry.innerHTML = html
53 }
50 }
54 } else {
51 } else {
@@ -82,16 +79,24 @@ function Wiki (sites) {
82 return this.byName[name] ? this.byName[name][0].cat : ''
79 return this.byName[name] ? this.byName[name][0].cat : ''
83 }
80 }
84
81
85− this.templateRelated = (name, entry) => {
82+ this.templateRelated = (name) => {
86− let html = ''
87− const cat = entry.cat
88 const relatedWords = this.related(name)
83 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>`
90 return html
85 return html
91 }
86 }
92
87
93− this.templateTerm = (name, entry) => {
88+ this.templateTerm = (name, entries) => {
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+ const formatEntry = (acc, entry) => {
90+ if (typeof entry.value === 'string') {
91+ return `${acc}<li>${entry.value}<a class='author' target='_blank' href='${entry.origin.url}'> — @${entry.origin.author}</a></li>`
92+ } else {
93+ const listItems = entry.value.reduce((items, item) => `${items}<li>${item}</li>`)
94+ return `${acc}<li><ul>${listItems}<a class='author' target='_blank' href='${entry.origin.url}'> — @${entry.origin.author}</a></ul></li>`
95+ }
96+ }
97+
98+ const htmlEntries = entries.reduce(formatEntry, '')
99+ return `<ul class="term"><li class="name"><strong>${name.toLowerCase()}</strong></li>${htmlEntries}</ul>`
95 }
100 }
96
101
97 this.fetch = () => {
102 this.fetch = () => {
@@ -108,20 +113,13 @@ function Wiki (sites) {
108 }
113 }
109
114
110 this.add = (name, value, cat, origin) => {
115 this.add = (name, value, cat, origin) => {
111− //
112− if (!this.byName[name]) {
113− this.byName[name] = []
116+ this.byName[name] = this.byName[name] || []
114− }
115 this.byName[name].push({ name, value, cat, origin })
117 this.byName[name].push({ name, value, cat, origin })
116− //
118+
117− if (!this.byCat[cat]) {
118− this.byCat[cat] = []
119+ this.byCat[cat] = this.byCat[cat] || []
119− }
120 this.byCat[cat].push({ name, value, cat, origin })
120 this.byCat[cat].push({ name, value, cat, origin })
121− //
121+
122− if (!this.byAuthor[origin.author]) {
123− this.byAuthor[origin.author] = []
122+ this.byAuthor[origin.author] = this.byAuthor[origin.author] || []
124− }
125 this.byAuthor[origin.author].push({ name, value, cat, origin })
123 this.byAuthor[origin.author].push({ name, value, cat, origin })
126 }
124 }
127
125
@@ -136,5 +134,5 @@ function Wiki (sites) {
136 }
134 }
137 }
135 }
138
136
139− String.prototype.toUrl = function () { return this.toLowerCase().replace(/ /g, '+').replace(/[^0-9a-z\+\:\-\.\/\~]/gi, '').trim() }
137+ String.prototype.toUrl = function () { return this.toLowerCase().replace(/ /g, '+').replace(/[^0-9a-z+:\-./~]/gi, '').trim() }
140}
138}