Commit 187cf5d8c031e8ecdfeb9cecd02b4cb1c42f5105
Serve feeds under root directory
cel committed on 4/16/2017, 5:46:48 PMParent: dd5c82b06c5cfb2c717fd3b9a9598d789092587c
Files changed
index.js | changed |
index.js | |||
---|---|---|---|
@@ -17,9 +17,9 @@ | |||
17 | 17 … | ||
18 | 18 … | var emojiDir = path.join(require.resolve('emoji-named-characters'), '../pngs') | |
19 | 19 … | var appHash = hash([fs.readFileSync(__filename)]) | |
20 | 20 … | ||
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))(?:\.([^?]*))?|(\/.*?))(?:\?(.*))?$/ | ||
22 | 22 … | ||
23 | 23 … | function MdRenderer(opts) { | |
24 | 24 … | marked.Renderer.call(this, {}) | |
25 | 25 … | this.opts = opts | |
@@ -85,22 +85,21 @@ | |||
85 | 85 … | } | |
86 | 86 … | ||
87 | 87 … | var m = urlIdRegex.exec(req.url) | |
88 | 88 … | ||
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]) | ||
91 | 90 … | else if (req.url.startsWith('/channel/')) return serveChannel(req, res, m[4]) | |
92 | 91 … | ||
93 | 92 … | switch (m[2]) { | |
94 | 93 … | case '%25': m[2] = '%'; m[1] = decodeURIComponent(m[1]) | |
95 | 94 … | case '%': return serveId(req, res, m[1], m[3], m[5]) | |
95 … | + case '@': return serveFeed(req, res, m[1], m[3], m[5]) | ||
96 | 96 … | case '&': return serveBlob(req, res, sbot, m[1]) | |
97 | 97 … | default: return servePath(req, res, m[4]) | |
98 | 98 … | } | |
99 | 99 … | } | |
100 | 100 … | ||
101 | - function serveFeed(req, res, url) { | ||
102 | - var feedId = url.substring(url.lastIndexOf('user/')+5, 100) | ||
101 … | + function serveFeed(req, res, feedId) { | ||
103 | 102 … | console.log("serving feed: " + feedId) | |
104 | 103 … | ||
105 | 104 … | var opts = defaultOpts | |
106 | 105 … | ||
@@ -528,9 +527,9 @@ | |||
528 | 527 … | + '<img class="ssb-avatar-image" alt=""' | |
529 | 528 … | + ' src="' + opts.img_base + escape(msg.author.image) + '"' | |
530 | 529 … | + ' height="32" width="32">' | |
531 | 530 … | + '<a class="ssb-avatar-name"' | |
532 | - + ' href="/user/' + escape(msg.value.author) + '"' | ||
531 … | + + ' href="/' + escape(msg.value.author) + '"' | ||
533 | 532 … | + '>' + msg.author.name + '</a>' | |
534 | 533 … | + msgTimestamp(msg, name) | |
535 | 534 … | + render(opts, c) | |
536 | 535 … | + '</div>' | |
@@ -559,9 +558,9 @@ | |||
559 | 558 … | } | |
560 | 559 … | else if (c.type == 'vote') | |
561 | 560 … | return ' voted <a href="/' + c.vote.link + '">this</a>' | |
562 | 561 … | 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>" | ||
564 | 563 … | else if (typeof c == 'string') | |
565 | 564 … | return ' wrote something private ' | |
566 | 565 … | else if (c.type == 'about') | |
567 | 566 … | return ' changed something in about' |
Built with git-ssb-web