on master help sign in
add in findMention function
55ef5bcckipp01
scripts/hallway.js+8−1
@@ -94,10 +94,17 @@ function Hallway (sites) {
94 return a.sort( (a, b) => a.offset - b.offset )
94 return a.sort( (a, b) => a.offset - b.offset )
95 }
95 }
96
96
97+ this.findMention = function (found) {
98+ const mention = Object.keys(feeds).filter(user => found.indexOf(feeds[user].path) > -1)
99+ return mention.length === 1
100+ ? ` <span class='user'>@${mention[0]}</span>`
101+ : ` <span class='user'>${found}</span>`
102+ }
103+
97 this.templateEntry = function (entry) {
104 this.templateEntry = function (entry) {
98 entry.html = entry.body
105 entry.html = entry.body
99 .replace(re_channel, `$1<span class='channel'>/$2</span>`)
106 .replace(re_channel, `$1<span class='channel'>/$2</span>`)
100− .replace(re_user, ` <span class='user'>$1</span>`)
107+ .replace(re_user, this.findMention)
101 .replace(re_tag, `$1<span class='tag'>#$2</span>`)
108 .replace(re_tag, `$1<span class='tag'>#$2</span>`)
102 .replace(re_url, `<a target="_blank" href='$1'>$1</a>`)
109 .replace(re_url, `<a target="_blank" href='$1'>$1</a>`)
103
110