Commit 3c761e029f733865217af71297fcde78625a8fac
Merge pull request #61 from ssbc/embed-audio-video
add support for embedded audio/video and query strings on any kind of ssb refMatt McKegg authored on 4/20/2018, 9:13:43 AM
GitHub committed on 4/20/2018, 9:13:43 AM
Parent: e3225b8ba0eb942c8c2661ccc52be6892d106dc6
Parent: b4012c1e311a149e36c63673d281d8e73dc2eafe
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,14 +27,19 @@ | ||
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 … | + | |
38 | 42 … | return h('Markdown', { |
39 | 43 … | hooks: [ |
40 | 44 … | LoadingBlobHook(api.blob.obs.has) |
41 | 45 … | ], |
@@ -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.id) | |
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.key) query['unbox'] = blob.key + '.boxs' | |
55 | - if (typeLookup[blob.id]) query['contentType'] = typeLookup[blob.id] | |
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: 107118 bytes New file size: 106881 bytes |
package.json | ||
---|---|---|
@@ -57,10 +57,10 @@ | ||
57 | 57 … | "ssb-config": "^2.2.0", |
58 | 58 … | "ssb-feed": "^2.3.0", |
59 | 59 … | "ssb-friends": "^2.2.3", |
60 | 60 … | "ssb-keys": "^7.0.9", |
61 | - "ssb-markdown": "^3.3.1", | |
62 | - "ssb-ref": "github:ssbc/ssb-ref#secret-blobs", | |
61 … | + "ssb-markdown": "^3.6.0", | |
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