on master help sign in
#
commitb45dda183eb0b844ad79ce4e6397afa6fabd8506 authorDevine Lu Linvega <aliceffekt@gmail.com> dateWed 3 Jul 2019, 17:34 (7 years ago) parentb701193
2 files changed+12−18
links/main.css+3−2 scripts/hallway.js+9−16
links/main.css+3−2
@@ -14,18 +14,19 @@ body div p.readme { max-width:500px; }
1414body #hallway #entries { width: calc(100vw - 300px) !important; }
1515body #hallway #sidebar { position: absolute;top: 0px;right: 0px;padding: 0px 15px;width: 200px; }
1616
17−body #hallway #sidebar > * { border-bottom: 0px; line-height: 15px; padding-bottom: 0px }
17+body #hallway #sidebar > * { border-bottom: 0px; line-height: 16px; padding-bottom: 0px }
1818body #hallway #sidebar > * li { text-transform: lowercase; }
1919body #hallway #sidebar > * li span.right { color:#555; float:right; }
2020body #hallway #sidebar > * li span.right:after { content: " msgs"; }
2121
2222body #hallway .entry { line-height: 16px; display: block; position: relative; padding-left:140px; }
23−body #hallway .entry .date { color: #555;display: block;float:right; margin-left:20px;}
23+body #hallway .entry .date { color: #555;display: block;float:right; margin-left:20px; padding-bottom: 16px;}
2424body #hallway .entry .author { font-family: 'input_mono_medium'; position: absolute;left: 0px; }
2525body #hallway .entry .author:after { content:":"; }
2626body #hallway .entry .body { display: block;border-bottom: 1px solid #333;padding-bottom: 10px;margin-bottom: 10px; }
2727body #hallway .entry .body a { text-decoration: underline; }
2828body #hallway .entry .body .channel { display: inline-block;border-radius: 1px;font-family: 'input_mono_medium';color: #777; }
29+body #hallway .entry .body .user { display: inline-block;border-radius: 1px;font-family: 'input_mono_medium';color: #777; }
2930body #hallway .entry.highlight .author { color:#555; }
3031body #hallway .entry:hover .author { color:#ccc; }
3132body #hallway .entry:hover .date { color:#ccc; }
scripts/hallway.js+9−16
@@ -21,9 +21,9 @@ function Hallway (sites) {
2121 const channels = this.findChannels(entries)
2222 const users = this.findUsers(entries)
2323
24− let _entries = entries.reduce((acc, val, id) => { return acc + this.templateEntry(val) + '\n' }, '')
25− let _channels = Object.keys(channels).reduce((acc, val, id) => { return acc + `<li>${val} <span class='right'>${channels[val]}</span></li>\n` }, '')
26− let _users = Object.keys(users).reduce((acc, val, id) => { return acc + `<li>${val} <span class='right'>${users[val]}</span></li>\n` }, '')
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` }, '')
2727
2828 this.el.innerHTML = `
2929 <ul id='entries'>
@@ -64,28 +64,22 @@ function Hallway (sites) {
6464 this.findEntries = function (feeds) {
6565 const a = []
6666 for (const id in feeds) {
67− const feed = feeds[id]
68− for (const i in feed.content) {
69− const entry = feed.content[i]
70− a.push(entry)
67+ for (const i in feeds[id].content) {
68+ a.push(feeds[id].content[i])
7169 }
7270 }
7371 return a.sort(compare)
7472 }
7573
7674 this.templateEntry = function (entry) {
77− // Find mention
78− if (entry.body.indexOf('@<') > -1) {
79− const data = entry.body.split('@<').pop().split('>')[0]
80− const mention = data.split(' ')
81− const name = mention[0]
82− const path = mention[1]
83− entry.body = entry.body.replace(`@<${data}>`, `<a href='${path}'>@${name}</a>`)
75+ if (entry.body.substr(0, 1) === '@') {
76+ const user = entry.body.split(' ')[0]
77+ entry.body = entry.body.replace(user, `<span class='user'>${user.toLowerCase()}</span>`)
8478 }
8579
8680 if (entry.body.substr(0, 1) === '/') {
8781 const channel = entry.body.split(' ')[0]
88− entry.body = entry.body.replace(channel, `<span class='channel'>${channel}</span>`)
82+ entry.body = entry.body.replace(channel, `<span class='channel'>${channel.toLowerCase()}</span>`)
8983 }
9084
9185 const filter = window.location.hash.substr(1).replace(/\+/g, ' ').toLowerCase()
@@ -116,7 +110,6 @@ function Hallway (sites) {
116110
117111 this.fetchFeed = function (id, feed) {
118112 console.log(`Fetching ${id}(${feed.path})..`)
119−
120113 fetch(feed.path, { cache: 'no-store' }).then(x => x.text()).then((content) => {
121114 feeds[id].content = parseFeed(id, content)
122115 this.refresh(feeds)