on master help sign in
Implemented channels
99c5a59Devine Lu Linvega
links/main.css+4
@@ -16,8 +16,12 @@ body #hallway #sidebar { position: absolute;top: 0px;right: 0px;padding: 0px 15p
16
16
17body #hallway #sidebar > * { border-bottom: 0px; line-height: 16px; padding-bottom: 0px }
17body #hallway #sidebar > * { border-bottom: 0px; line-height: 16px; padding-bottom: 0px }
18body #hallway #sidebar > * li { text-transform: lowercase; }
18body #hallway #sidebar > * li { text-transform: lowercase; }
19+body #hallway #sidebar > * li.selected { background: white; color:black; }
20+body #hallway #sidebar > * li:hover { cursor: pointer; }
19body #hallway #sidebar > * li span.right { color:#555; float:right; }
21body #hallway #sidebar > * li span.right { color:#555; float:right; }
20body #hallway #sidebar > * li span.right:after { content: " msgs"; }
22body #hallway #sidebar > * li span.right:after { content: " msgs"; }
23+body #hallway #sidebar #channels li:before { content:'/'; }
24+body #hallway #sidebar #users li:before { content:'@'; }
21
25
22body #hallway .entry { line-height: 16px; display: block; position: relative; padding-left:100px; }
26body #hallway .entry { line-height: 16px; display: block; position: relative; padding-left:100px; }
23body #hallway .entry .date { color: #555;display: block;float:right; margin-left:20px; padding-bottom: 16px;}
27body #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) {
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.cache = null
8
10
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()
17 }
19 }
18
20
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)
23
25
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' }, '')}
27 </ul>
29 </ul>
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` }, '')}
31 </ul>
33 </ul>
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` }, '')}
34 </ul>
36 </ul>
35 </div>
37 </div>
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+
40+ if (feeds) {
41+ this.cache = feeds
42+ }
37 }
43 }
38
44
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>`)
87 }
93 }
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>`)
90 }
96 }
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, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#039;')
191 return unsafe.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#039;')
186 }
192 }
187}
193}
194+
195+function filter (name) {
196+ window.location.hash = name
197+ hallway.filter = window.location.hash.replace('#', '').trim()
198+ hallway.refresh()
199+}