Commit 6f759b4773736953bd3aa57e1dafc20c315f3bbd
handle `query` in any ssb ref link, unfork ssb-ref
Matt McKegg committed on 4/20/2018, 9:04:16 AMParent: eb7933358238526bccf4c320ca689b9269c61f95
Files changed
message/html/markdown.js | changed |
package-lock.json | changed |
package.json | changed |
message/html/markdown.js | ||
---|---|---|
@@ -18,9 +18,8 @@ | ||
18 | 18 … | return nest('message.html.markdown', markdown) |
19 | 19 … | |
20 | 20 … | function markdown (content) { |
21 | 21 … | if (typeof content === 'string') { content = {text: content} } |
22 | - // handle patchwork style mentions and custom emoji. | |
23 | 22 … | var mentions = {} |
24 | 23 … | var typeLookup = {} |
25 | 24 … | var emojiMentions = {} |
26 | 25 … | if (Array.isArray(content.mentions)) { |
@@ -28,10 +27,15 @@ | ||
28 | 27 … | if (link && link.link && link.type) { |
29 | 28 … | typeLookup[link.link] = link.type |
30 | 29 … | } |
31 | 30 … | if (link && link.name && link.link) { |
32 | - if (link.emoji) emojiMentions[link.name] = link.link | |
33 | - else mentions['@' + link.name] = link.link | |
31 … | + if (link.emoji) { | |
32 … | + // handle custom emoji | |
33 … | + emojiMentions[link.name] = link.link | |
34 … | + } else { | |
35 … | + // handle old-style patchwork v2 mentions (deprecated) | |
36 … | + mentions['@' + link.name] = link.link | |
37 … | + } | |
34 | 38 … | } |
35 | 39 … | }) |
36 | 40 … | } |
37 | 41 … | |
@@ -46,20 +50,20 @@ | ||
46 | 50 … | : api.emoji.sync.url(emoji) |
47 | 51 … | return renderEmoji(emoji, url) |
48 | 52 … | }, |
49 | 53 … | toUrl: (id) => { |
50 | - if (ref.isBlob(id)) { | |
51 | - var blob = ref.parseBlob(id) | |
52 | - var url = api.blob.sync.url(blob.link) | |
54 … | + var link = ref.parseLink(id) | |
55 … | + if (link && ref.isBlob(link.link)) { | |
56 … | + var url = api.blob.sync.url(link.link) | |
53 | 57 … | var query = {} |
54 | - if (blob.query && blob.query.unbox) query['unbox'] = blob.query.unbox | |
55 | - if (typeLookup[blob.link]) query['contentType'] = typeLookup[blob.link] | |
58 … | + if (link.query && link.query.unbox) query['unbox'] = link.query.unbox | |
59 … | + if (typeLookup[link.link]) query['contentType'] = typeLookup[link.link] | |
56 | 60 … | return url + '?' + querystring.stringify(query) |
57 | - } | |
58 | - if (mentions[id]) { | |
61 … | + } else if (link || id.startsWith('#') || id.startsWith('?')) { | |
62 … | + return id | |
63 … | + } else if (mentions[id]) { | |
64 … | + // handle old-style patchwork v2 mentions (deprecated) | |
59 | 65 … | return mentions[id] |
60 | - } else if (ref.isLink(id) || id.startsWith('#') || id.startsWith('?')) { | |
61 | - return id | |
62 | 66 … | } |
63 | 67 … | return false |
64 | 68 … | }, |
65 | 69 … | imageLink: (id) => id |
package-lock.json | ||
---|---|---|
The diff is too large to show. Use a local git client to view these changes. Old file size: 106974 bytes New file size: 106737 bytes |
package.json | ||
---|---|---|
@@ -58,9 +58,9 @@ | ||
58 | 58 … | "ssb-feed": "^2.3.0", |
59 | 59 … | "ssb-friends": "^2.2.3", |
60 | 60 … | "ssb-keys": "^7.0.9", |
61 | 61 … | "ssb-markdown": "github:ssbc/ssb-markdown#embed-audio-video", |
62 | - "ssb-ref": "github:ssbc/ssb-ref#secret-blobs", | |
62 … | + "ssb-ref": "^2.11.0", | |
63 | 63 … | "ssb-sort": "^1.0.0", |
64 | 64 … | "xtend": "^4.0.1" |
65 | 65 … | }, |
66 | 66 … | "browserify": { |
Built with git-ssb-web