@@ -16,18 +16,64 @@ function Hallway (sites) {
1616 this.fetchFeeds()
1717 }
1818
19− this.refresh = function () {
20− const entries = this.sortEntries()
21− let html = ''
19+ this.refresh = function (feeds) {
20+ const entries = this.findEntries(feeds)
21+ const channels = this.findChannels(entries)
22+ const users = this.findUsers(entries)
23+
24+ let _entries = ''
2225 for (const id in entries) {
23− html += `${this.templateEntry(entries[id])}\n`
26+ const entry = entries[id]
27+ _entries += `${this.templateEntry(entry)}\n`
28+ }
29+
30+ let _channels = ''
31+ for (const id in channels) {
32+ _channels += `<li>${id} ${channels[id]}</li>\n`
2433 }
25− this.el.innerHTML = `<ul>${html}</ul>${this._footer()}`
34+
35+ let _users = ''
36+ for (const id in users) {
37+ _users += `<li>${id} ${users[id]}</li>\n`
38+ }
39+
40+ this.el.innerHTML = `
41+ <ul id='entries'>
42+ ${_entries}
43+ </ul>
44+ <div id='sidebar'>
45+ <ul id='channels'>
46+ ${_channels}
47+ </ul>
48+ <ul id='users'>
49+ ${_users}
50+ </ul>
51+ </div>
52+ ${this._footer()}`
2653 }
2754
2855 // Entries
2956
30− this.sortEntries = function () {
57+ this.findChannels = function (entries) {
58+ const channels = {}
59+ for (const id in entries) {
60+ const entry = entries[id]
61+ if (!entry.channel) { continue }
62+ channels[entry.channel] = channels[entry.channel] ? channels[entry.channel] + 1 : 1
63+ }
64+ return channels
65+ }
66+
67+ this.findUsers = function (entries) {
68+ const users = {}
69+ for (const id in entries) {
70+ const entry = entries[id]
71+ users[entry.author] = users[entry.author] ? users[entry.author] + 1 : 1
72+ }
73+ return users
74+ }
75+
76+ this.findEntries = function (feeds) {
3177 const a = []
3278 for (const id in feeds) {
3379 const feed = feeds[id]
@@ -85,7 +131,7 @@ function Hallway (sites) {
85131
86132 fetch(feed.path, { cache: 'no-store' }).then(x => x.text()).then((content) => {
87133 feeds[id].content = parseFeed(id, content)
88− this.refresh()
134+ this.refresh(feeds)
89135 }).catch((err) => {
90136 console.warn(`${id}`, err)
91137 })
@@ -112,8 +158,9 @@ function Hallway (sites) {
112158 const parts = line.replace(' ', '\t').split('\t')
113159 const date = parts[0].trim()
114160 const body = parts[1].trim()
161+ const channel = body.substr(0, 1) === '/' ? body.split(' ')[0].substr(1).toLowerCase() : null
115162 const offset = new Date() - new Date(date)
116− entries.push({ date, body, author, offset })
163+ entries.push({ date, body, author, offset, channel })
117164 }
118165 return entries
119166 }