on master help sign in
Standardized layouts across hallway/wiki a bit
commit9ca38ef151267fe08a22ff0d54461b8b0baa31dc authorDevine Lu Linvega <aliceffekt@gmail.com> dateMon 29 Jul 2019, 10:51 (7 years ago) parent847734c
3 files changed+44−37
links/main.css+1−1 scripts/hallway.js+35−28 scripts/wiki.js+8−8
links/main.css+1−1
@@ -19,7 +19,7 @@ body #sidebar > * li span.right { color:#555; float:right; }
1919body #sidebar > * li span.right:after { content: " msgs"; }
2020body #sidebar #channels li:before, body #sidebar #categories li:before { content:'/'; }
2121body #sidebar #users li:before { content:'@'; }
22−body #footer { padding-left: 60px;background-image: url(../icon.white.svg);background-size: 40px;background-repeat: no-repeat;background-position: 0px 15px;border-top: 2px solid white;padding-top: 15px; margin-top:15px; max-width: 100%}
22+body #footer { padding-left: 60px; background-image: url(../icon.white.svg); background-size: 40px; background-repeat: no-repeat; background-position: 0px 10px; border-top: 2px solid white; padding-top: 15px; margin-top: 15px; max-width: calc(100% - 300px); min-height: 45px; line-height: 15px;}
2323
2424@media only screen and (min-width:200px) and (max-width: 800px) {
2525 body #hallway #sidebar { position: absolute;top: 0px;right: 0px;padding: 15px;width: 200px;display: none;background-color: #000; }
scripts/hallway.js+35−28
@@ -8,19 +8,30 @@ const re_url = /((https?):\/\/(([-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b)([-a
88function Hallway (sites) {
99 const feeds = {}
1010 this.sites = sites
11− this.el = document.createElement('div')
12− this.el.id = 'hallway'
11+ this._el = document.createElement('div')
12+ this._el.id = 'hallway'
1313 const filterAndPage = window.location.hash.split('^')
1414 this.finder = { filter: filterAndPage[0].trim().replace('#', ''), page: filterAndPage[1] || 1 }
1515 this.cache = null
1616
17+ this._entries = document.createElement('div')
18+ this._entries.id = 'entries'
19+ this._sidebar = document.createElement('div')
20+ this._sidebar.id = 'sidebar'
21+ this._footer = document.createElement('p')
22+ 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>.`
24+
1725 this.install = function (host) {
18− host.appendChild(this.el)
26+ this._el.appendChild(this._entries)
27+ this._el.appendChild(this._sidebar)
28+ this._el.appendChild(this._footer)
29+ host.appendChild(this._el)
1930 this.findFeeds()
2031 }
2132
2233 this.start = function () {
23− this.el.innerHTML = 'Loading..'
34+ this._entries.innerHTML = 'Loading..'
2435 this.fetchFeeds()
2536 }
2637
@@ -31,30 +42,26 @@ function Hallway (sites) {
3142 const tags = this.findTags(entries)
3243 const relevantEntries = entries.filter(val => !this.finder.filter || (val.author === this.finder.filter || val.channel === this.finder.filter || val.tags.includes(this.finder.filter)))
3344
34− this.el.innerHTML = `
35− <div id='entries'>
36− <ul>
37− ${entries.filter((val) => !this.finder.filter || (val.author === this.finder.filter || val.channel === this.finder.filter || val.tags.includes(this.finder.filter))).filter((_, id) => id < Number(this.finder.page) * 20 && id >= (Number(this.finder.page) - 1) * 20).reduce((acc, val) => acc + this.templateEntry(val) + '\n', '')}
38− </ul>
39− <div id='pagination'>
40− ${[...Array(Math.ceil(relevantEntries.length / 20)).keys()].reduce((acc, num) => `${acc}<span class='${Number(hallway.finder.page) === num + 1 ? 'selected' : ''}' onclick='filter("${this.finder.filter}^${num + 1}")'>${num + 1}</span>`, '')}
41− </div>
42− </div>
43− <a id='showbar' onclick="toggleVisibility('sidebar');"></a>
44− <div id='sidebar'>
45− <a id='hidebar' onclick="toggleVisibility('sidebar');"></a>
46− <ul id='channels'>
47− <li onclick='filter("")' class='${hallway.finder.filter === '' ? 'selected' : ''}'><a href='#'>hallway <span class='right'>${entries.length}</span></a></li>
48− ${Object.keys(channels).slice(0, 15).reduce((acc, val) => acc + `<li onclick='filter("${val}")' class='${hallway.finder.filter === val ? 'selected' : ''}'><a href='#${val}'>${val} <span class='right'>${channels[val]}</span></a></li>\n`, '')}
49− </ul>
50− <ul id='users'>
51− ${Object.keys(users).slice(0, 15).reduce((acc, val) => acc + `<li onclick='filter("${val}")' class='${hallway.finder.filter === val ? 'selected' : ''}' href='#${val}'>${val} <span class='right'>${users[val]}</span></li>\n`, '')}
52− </ul>
53− <ul id='tags'>
54− ${Object.keys(tags).slice(0, 15).reduce((acc, val) => acc + `<li onclick='filter("${val}")' class='${hallway.finder.filter === val ? 'selected' : ''}' href='#${val}'>#${val} <span class='right'>${tags[val]}</span></li>\n`, '')}
55− </ul>
56− </div>
57− <p id='footer'>The <b>Hallway</b> is a decentralized forum, to join the conversation, simply create yourself a <a href="https://twtxt.readthedocs.io/en/stable/user/twtxtfile.html">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>`
45+ this._entries.innerHTML = `
46+ <ul>
47+ ${entries.filter((val) => !this.finder.filter || (val.author === this.finder.filter || val.channel === this.finder.filter || val.tags.includes(this.finder.filter))).filter((_, id) => id < Number(this.finder.page) * 20 && id >= (Number(this.finder.page) - 1) * 20).reduce((acc, val) => acc + this.templateEntry(val) + '\n', '')}
48+ </ul>
49+ <div id='pagination'>
50+ ${[...Array(Math.ceil(relevantEntries.length / 20)).keys()].reduce((acc, num) => `${acc}<span class='${Number(hallway.finder.page) === num + 1 ? 'selected' : ''}' onclick='filter("${this.finder.filter}^${num + 1}")'>${num + 1}</span>`, '')}
51+ </div>`
52+
53+ this._sidebar.innerHTML = `
54+ <a id='hidebar' onclick="toggleVisibility('sidebar');"></a>
55+ <ul id='channels'>
56+ <li onclick='filter("")' class='${hallway.finder.filter === '' ? 'selected' : ''}'><a href='#'>hallway <span class='right'>${entries.length}</span></a></li>
57+ ${Object.keys(channels).slice(0, 15).reduce((acc, val) => acc + `<li onclick='filter("${val}")' class='${hallway.finder.filter === val ? 'selected' : ''}'><a href='#${val}'>${val} <span class='right'>${channels[val]}</span></a></li>\n`, '')}
58+ </ul>
59+ <ul id='users'>
60+ ${Object.keys(users).slice(0, 15).reduce((acc, val) => acc + `<li onclick='filter("${val}")' class='${hallway.finder.filter === val ? 'selected' : ''}' href='#${val}'>${val} <span class='right'>${users[val]}</span></li>\n`, '')}
61+ </ul>
62+ <ul id='tags'>
63+ ${Object.keys(tags).slice(0, 15).reduce((acc, val) => acc + `<li onclick='filter("${val}")' class='${hallway.finder.filter === val ? 'selected' : ''}' href='#${val}'>#${val} <span class='right'>${tags[val]}</span></li>\n`, '')}
64+ </ul>`
5865
5966 if (feeds) {
6067 this.cache = feeds
scripts/wiki.js+8−8
@@ -12,23 +12,25 @@ function Wiki (sites) {
1212 this._entry = document.createElement('div')
1313 this._entry.id = 'entry'
1414
15+ this._footer = document.createElement('p')
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>.`
18+
1519 this.loc = ''
1620 this.byName = {}
1721 this.byCat = {}
1822 this.byAuthor = {}
1923
2024 this.install = (host) => {
21− console.log('Wiki', 'Installing..')
22− this.fetch()
2325 this._el.appendChild(this._entry)
2426 this._sidebar.appendChild(this._categories)
2527 this._el.appendChild(this._sidebar)
28+ this._el.appendChild(this._footer)
2629 host.appendChild(this._el)
30+ this.fetch()
2731 }
2832
2933 this.start = () => {
30− console.log('Wiki', 'Starting..')
31− this.loc = window.location.hash.substr(1).replace(/\+/g, ' ').toUpperCase()
3234 this._entry.innerHTML = 'Loading..'
3335 }
3436
@@ -55,10 +57,9 @@ function Wiki (sites) {
5557 }
5658 // Sidebar
5759 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>`
5960 }
6061
61− this.go = (q = this.loc) => {
62+ this.go = (q = window.location.hash.substr(1).replace(/\+/g, ' ').toUpperCase()) => {
6263 this.loc = q
6364 window.location.hash = q.toUrl()
6465 this.refresh()
@@ -70,8 +71,7 @@ function Wiki (sites) {
7071
7172 this.random = () => {
7273 const keys = Object.keys(this.byCat)
73− const target = Math.floor(Math.random() * keys.length)
74− return keys[target]
74+ return keys[Math.floor(Math.random() * keys.length)]
7575 }
7676
7777 this.related = (name) => {