@@ -16,18 +16,64 @@ function Hallway (sites) {
16 this.fetchFeeds()
16 this.fetchFeeds()
19− this.refresh = function () {
19+ this.refresh = function (feeds) {
20− const entries = this.sortEntries()
20+ const entries = this.findEntries(feeds)
21− let html = ''
21+ const channels = this.findChannels(entries)
22+ const users = this.findUsers(entries)
22 for (const id in entries) {
25 for (const id in entries) {
26+ const entry = entries[id]
23− html += `${this.templateEntry(entries[id])}\n`
27+ _entries += `${this.templateEntry(entry)}\n`
31+ for (const id in channels) {
32+ _channels += `<li>${id} ${channels[id]}</li>\n`
36+ for (const id in users) {
37+ _users += `<li>${id} ${users[id]}</li>\n`
25− this.el.innerHTML = `<ul>${html}</ul>${this._footer()}`
40+ this.el.innerHTML = `
28 // Entries
55 // Entries
30− this.sortEntries = function () {
57+ this.findChannels = function (entries) {
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
67+ this.findUsers = function (entries) {
69+ for (const id in entries) {
70+ const entry = entries[id]
71+ users[entry.author] = users[entry.author] ? users[entry.author] + 1 : 1
76+ this.findEntries = function (feeds) {
31 const a = []
77 const a = []
32 for (const id in feeds) {
78 for (const id in feeds) {
33 const feed = feeds[id]
79 const feed = feeds[id]
@@ -85,7 +131,7 @@ function Hallway (sites) {
86 fetch(feed.path, { cache: 'no-store' }).then(x => x.text()).then((content) => {
132 fetch(feed.path, { cache: 'no-store' }).then(x => x.text()).then((content) => {
87 feeds[id].content = parseFeed(id, content)
133 feeds[id].content = parseFeed(id, content)
88− this.refresh()
134+ this.refresh(feeds)
89 }).catch((err) => {
135 }).catch((err) => {
90 console.warn(`${id}`, err)
136 console.warn(`${id}`, err)
@@ -112,8 +158,9 @@ function Hallway (sites) {
112 const parts = line.replace(' ', '\t').split('\t')
158 const parts = line.replace(' ', '\t').split('\t')
113 const date = parts[0].trim()
159 const date = parts[0].trim()
114 const body = parts[1].trim()
160 const body = parts[1].trim()
161+ const channel = body.substr(0, 1) === '/' ? body.split(' ')[0].substr(1).toLowerCase() : null
115 const offset = new Date() - new Date(date)
162 const offset = new Date() - new Date(date)
116− entries.push({ date, body, author, offset })
163+ entries.push({ date, body, author, offset, channel })
118 return entries
165 return entries