git ssb

9+

cel / ssb-viewer



Commit 187cf5d8c031e8ecdfeb9cecd02b4cb1c42f5105

Serve feeds under root directory

cel committed on 4/16/2017, 5:46:48 PM
Parent: dd5c82b06c5cfb2c717fd3b9a9598d789092587c

Files changed

index.jschanged
index.jsView
@@ -17,9 +17,9 @@
1717
1818 var emojiDir = path.join(require.resolve('emoji-named-characters'), '../pngs')
1919 var appHash = hash([fs.readFileSync(__filename)])
2020
21-var urlIdRegex = /^(?:\/(([%&]|%25)(?:[A-Za-z0-9\/+]|%2[Ff]|%2[Bb]){43}(?:=|%3[Dd])\.sha256)(?:\.([^?]*))?|(\/.*?))(?:\?(.*))?$/
21 +var urlIdRegex = /^(?:\/(([%&@]|%25|%26|%40)(?:[A-Za-z0-9\/+]|%2[Ff]|%2[Bb]){43}(?:=|%3[Dd])\.(?:sha256|ed25519))(?:\.([^?]*))?|(\/.*?))(?:\?(.*))?$/
2222
2323 function MdRenderer(opts) {
2424 marked.Renderer.call(this, {})
2525 this.opts = opts
@@ -85,22 +85,21 @@
8585 }
8686
8787 var m = urlIdRegex.exec(req.url)
8888
89- if (req.url.startsWith('/user/')) return serveFeed(req, res, m[4])
90- else if (req.url.startsWith('/user-feed/')) return serveUserFeed(req, res, m[4])
89 + if (req.url.startsWith('/user-feed/')) return serveUserFeed(req, res, m[4])
9190 else if (req.url.startsWith('/channel/')) return serveChannel(req, res, m[4])
9291
9392 switch (m[2]) {
9493 case '%25': m[2] = '%'; m[1] = decodeURIComponent(m[1])
9594 case '%': return serveId(req, res, m[1], m[3], m[5])
95 + case '@': return serveFeed(req, res, m[1], m[3], m[5])
9696 case '&': return serveBlob(req, res, sbot, m[1])
9797 default: return servePath(req, res, m[4])
9898 }
9999 }
100100
101- function serveFeed(req, res, url) {
102- var feedId = url.substring(url.lastIndexOf('user/')+5, 100)
101 + function serveFeed(req, res, feedId) {
103102 console.log("serving feed: " + feedId)
104103
105104 var opts = defaultOpts
106105
@@ -528,9 +527,9 @@
528527 + '<img class="ssb-avatar-image" alt=""'
529528 + ' src="' + opts.img_base + escape(msg.author.image) + '"'
530529 + ' height="32" width="32">'
531530 + '<a class="ssb-avatar-name"'
532- + ' href="/user/' + escape(msg.value.author) + '"'
531 + + ' href="/' + escape(msg.value.author) + '"'
533532 + '>' + msg.author.name + '</a>'
534533 + msgTimestamp(msg, name)
535534 + render(opts, c)
536535 + '</div>'
@@ -559,9 +558,9 @@
559558 }
560559 else if (c.type == 'vote')
561560 return ' voted <a href="/' + c.vote.link + '">this</a>'
562561 else if (c.type == 'contact' && c.following)
563- return ' followed <a href="/user/' + c.contact + '">' + c.contactAbout.name + "</a>"
562 + return ' followed <a href="/' + c.contact + '">' + c.contactAbout.name + "</a>"
564563 else if (typeof c == 'string')
565564 return ' wrote something private '
566565 else if (c.type == 'about')
567566 return ' changed something in about'

Built with git-ssb-web