on master help sign in
Implemented channels
commit99c5a5920f41cbd1b362b825012aac9bf3fc4cec authorDevine Lu Linvega <aliceffekt@gmail.com> dateWed 3 Jul 2019, 20:53 (7 years ago) parent5a84cd4
2 files changed+22−6
links/main.css+4 scripts/hallway.js+18−6
links/main.css+4
@@ -16,8 +16,12 @@ body #hallway #sidebar { position: absolute;top: 0px;right: 0px;padding: 0px 15p
1616
1717body #hallway #sidebar > * { border-bottom: 0px; line-height: 16px; padding-bottom: 0px }
1818body #hallway #sidebar > * li { text-transform: lowercase; }
19+body #hallway #sidebar > * li.selected { background: white; color:black; }
20+body #hallway #sidebar > * li:hover { cursor: pointer; }
1921body #hallway #sidebar > * li span.right { color:#555; float:right; }
2022body #hallway #sidebar > * li span.right:after { content: " msgs"; }
23+body #hallway #sidebar #channels li:before { content:'/'; }
24+body #hallway #sidebar #users li:before { content:'@'; }
2125
2226body #hallway .entry { line-height: 16px; display: block; position: relative; padding-left:100px; }
2327body #hallway .entry .date { color: #555;display: block;float:right; margin-left:20px; padding-bottom: 16px;}
scripts/hallway.js+18−6
@@ -5,6 +5,8 @@ function Hallway (sites) {
55 this.sites = sites
66 this.el = document.createElement('div')
77 this.el.id = 'hallway'
8+ this.filter = window.location.hash.replace('#', '').trim()
9+ this.cache = null
810
911 this.install = function (host) {
1012 host.appendChild(this.el)
@@ -16,24 +18,28 @@ function Hallway (sites) {
1618 this.fetchFeeds()
1719 }
1820
19− this.refresh = function (feeds) {
21+ this.refresh = function (feeds = this.cache) {
2022 const entries = this.findEntries(feeds)
2123 const channels = this.findChannels(entries)
2224 const users = this.findUsers(entries)
2325
2426 this.el.innerHTML = `
2527 <ul id='entries'>
26− ${entries.filter((val, id) => { return id < 50 }).reduce((acc, val, id) => { return acc + this.templateEntry(val) + '\n' }, '')}
28+ ${entries.filter((val, id) => { return !(this.filter && val.author !== this.filter && val.channel !== this.filter) }).filter((val, id) => { return id < 50 }).reduce((acc, val, id) => { return acc + this.templateEntry(val) + '\n' }, '')}
2729 </ul>
2830 <div id='sidebar'>
2931 <ul id='channels'>
30− ${Object.keys(channels).reduce((acc, val, id) => { return acc + `<li>${val} <span class='right'>${channels[val]}</span></li>\n` }, '')}
32+ ${Object.keys(channels).reduce((acc, val, id) => { return acc + `<li onclick='filter("${val}")' class='${hallway.filter === val ? 'selected' : ''}'><a href='#${val}'>${val} <span class='right'>${channels[val]}</span></a></li>\n` }, '')}
3133 </ul>
3234 <ul id='users'>
33− ${Object.keys(users).reduce((acc, val, id) => { return acc + `<li>${val} <span class='right'>${users[val]}</span></li>\n` }, '')}
35+ ${Object.keys(users).reduce((acc, val, id) => { return acc + `<li onclick='filter("${val}")' class='${hallway.filter === val ? 'selected' : ''}' href='#${val}'>${val} <span class='right'>${users[val]}</span></li>\n` }, '')}
3436 </ul>
3537 </div>
3638 <p>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>`
39+
40+ if (feeds) {
41+ this.cache = feeds
42+ }
3743 }
3844
3945 // Entries
@@ -86,7 +92,7 @@ function Hallway (sites) {
8692 entry.body = entry.body.replace(users[id], `<span class='user'>${users[id]}</span>`)
8793 }
8894 for (const id in channels) {
89− entry.body = entry.body.replace(channels[id], `<span class='user'>${channels[id]}</span>`)
95+ entry.body = entry.body.replace(channels[id], `<span class='channel'>${channels[id]}</span>`)
9096 }
9197 for (const id in tags) {
9298 entry.body = entry.body.replace(tags[id], `<span class='tag'>${tags[id]}</span>`)
@@ -169,7 +175,7 @@ function Hallway (sites) {
169175 } else if (seconds < 60) {
170176 return `${seconds} seconds ago`
171177 } else if (seconds < 90) {
172− return 'about a minute ago'
178+ return 'a minute ago'
173179 } else if (minutes < 60) {
174180 return `${minutes} minutes ago`
175181 } else if (isToday) {
@@ -185,3 +191,9 @@ function Hallway (sites) {
185191 return unsafe.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#039;')
186192 }
187193}
194+
195+function filter (name) {
196+ window.location.hash = name
197+ hallway.filter = window.location.hash.replace('#', '').trim()
198+ hallway.refresh()
199+}