@@ -5,6 +5,8 @@ function Hallway (sites) {
5 this.sites = sites
5 this.sites = sites
6 this.el = document.createElement('div')
6 this.el = document.createElement('div')
7 this.el.id = 'hallway'
7 this.el.id = 'hallway'
8+ this.filter = window.location.hash.replace('#', '').trim()
9 this.install = function (host) {
11 this.install = function (host) {
10 host.appendChild(this.el)
12 host.appendChild(this.el)
@@ -16,24 +18,28 @@ function Hallway (sites) {
16 this.fetchFeeds()
18 this.fetchFeeds()
19− this.refresh = function (feeds) {
21+ this.refresh = function (feeds = this.cache) {
20 const entries = this.findEntries(feeds)
22 const entries = this.findEntries(feeds)
21 const channels = this.findChannels(entries)
23 const channels = this.findChannels(entries)
22 const users = this.findUsers(entries)
24 const users = this.findUsers(entries)
24 this.el.innerHTML = `
26 this.el.innerHTML = `
25 <ul id='entries'>
27 <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' }, '')}
28 <div id='sidebar'>
30 <div id='sidebar'>
29 <ul id='channels'>
31 <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` }, '')}
32 <ul id='users'>
34 <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` }, '')}
36 <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>`
38 <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 // Entries
45 // Entries
@@ -86,7 +92,7 @@ function Hallway (sites) {
86 entry.body = entry.body.replace(users[id], `<span class='user'>${users[id]}</span>`)
92 entry.body = entry.body.replace(users[id], `<span class='user'>${users[id]}</span>`)
88 for (const id in channels) {
94 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>`)
91 for (const id in tags) {
97 for (const id in tags) {
92 entry.body = entry.body.replace(tags[id], `<span class='tag'>${tags[id]}</span>`)
98 entry.body = entry.body.replace(tags[id], `<span class='tag'>${tags[id]}</span>`)
@@ -169,7 +175,7 @@ function Hallway (sites) {
169 } else if (seconds < 60) {
175 } else if (seconds < 60) {
170 return `${seconds} seconds ago`
176 return `${seconds} seconds ago`
171 } else if (seconds < 90) {
177 } else if (seconds < 90) {
172− return 'about a minute ago'
178+ return 'a minute ago'
173 } else if (minutes < 60) {
179 } else if (minutes < 60) {
174 return `${minutes} minutes ago`
180 return `${minutes} minutes ago`
175 } else if (isToday) {
181 } else if (isToday) {
@@ -185,3 +191,9 @@ function Hallway (sites) {
185 return unsafe.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''')
191 return unsafe.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''')
195+function filter (name) {
196+ window.location.hash = name
197+ hallway.filter = window.location.hash.replace('#', '').trim()