@@ -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, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''')
186192 }
187193}
194+
195+function filter (name) {
196+ window.location.hash = name
197+ hallway.filter = window.location.hash.replace('#', '').trim()
198+ hallway.refresh()
199+}