@@ -21,23 +21,19 @@ function Hallway (sites) {
21 const channels = this.findChannels(entries)
21 const channels = this.findChannels(entries)
22 const users = this.findUsers(entries)
22 const users = this.findUsers(entries)
24− const _entries = entries.filter((val,id) => { return id < 50 }).reduce((acc, val, id) => { return acc + this.templateEntry(val) + '\n' }, '')
25− const _channels = Object.keys(channels).reduce((acc, val, id) => { return acc + `<li>${val} <span class='right'>${channels[val]}</span></li>\n` }, '')
26− const _users = Object.keys(users).reduce((acc, val, id) => { return acc + `<li>${val} <span class='right'>${users[val]}</span></li>\n` }, '')
28 this.el.innerHTML = `
24 this.el.innerHTML = `
29 <ul id='entries'>
25 <ul id='entries'>
30− ${_entries}
26+ ${entries.filter((val, id) => { return id < 50 }).reduce((acc, val, id) => { return acc + this.templateEntry(val) + '\n' }, '')}
32 <div id='sidebar'>
28 <div id='sidebar'>
33 <ul id='channels'>
29 <ul id='channels'>
34− ${_channels}
30+ ${Object.keys(channels).reduce((acc, val, id) => { return acc + `<li>${val} <span class='right'>${channels[val]}</span></li>\n` }, '')}
36 <ul id='users'>
32 <ul id='users'>
37− ${_users}
33+ ${Object.keys(users).reduce((acc, val, id) => { return acc + `<li>${val} <span class='right'>${users[val]}</span></li>\n` }, '')}
40− ${this._footer()}`
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>`
43 // Entries
39 // Entries
@@ -72,18 +68,30 @@ function Hallway (sites) {
74 this.templateEntry = function (entry) {
70 this.templateEntry = function (entry) {
75− if (entry.body.substr(0, 1) === '@') {
76− const user = entry.body.split(' ')[0]
71+ const words = entry.body.split(' ')
77− entry.body = entry.body.replace(user, `<span class='user'>${user.toLowerCase()}</span>`)
72+ const users = []
77+ for (const id in words) {
78+ if (words[id].substr(0, 1) === '@') { users.push(words[id]) }
79+ if (words[id].substr(0, 1) === '/') { channels.push(words[id]) }
80+ if (words[id].substr(0, 1) === '#') { tags.push(words[id]) }
80− if (entry.body.substr(0, 1) === '/') {
83+ for (const id in users) {
81− const channel = entry.body.split(' ')[0]
84+ entry.body = entry.body.replace(users[id], `<span class='user'>${users[id]}</span>`)
86+ for (const id in channels) {
87+ entry.body = entry.body.replace(channels[id], `<span class='user'>${channels[id]}</span>`)
89+ for (const id in tags) {
82− entry.body = entry.body.replace(channel, `<span class='channel'>${channel.toLowerCase()}</span>`)
90+ entry.body = entry.body.replace(tags[id], `<span class='tag'>${tags[id]}</span>`)
85 const filter = window.location.hash.substr(1).replace(/\+/g, ' ').toLowerCase()
93 const filter = window.location.hash.substr(1).replace(/\+/g, ' ').toLowerCase()
86− const highlight = filter == entry.author.toLowerCase()
94+ const highlight = filter === entry.author.toLowerCase()
88 return `<li class='entry ${highlight ? 'highlight' : ''}'><span class='date'>${timeAgo(Date.parse(entry.date))}</span> <a class='author' href=''>${entry.author}</a> <span class='body'>${entry.body}</span></li>`
96 return `<li class='entry ${highlight ? 'highlight' : ''}'><span class='date'>${timeAgo(Date.parse(entry.date))}</span> <a class='author' href=''>${entry.author}</a> <span class='body'>${entry.body}</span></li>`
@@ -118,12 +126,6 @@ function Hallway (sites) {
123− this._footer = function () {
124− return '<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>'
129 function compare (a, b) {
131 function compare (a, b) {