git ssb

7+

dinoworm 🐛 / patchcore



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 ref
Matt 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.jschanged
package-lock.jsonchanged
package.jsonchanged
message/html/markdown.jsView
@@ -18,9 +18,8 @@
1818 return nest('message.html.markdown', markdown)
1919
2020 function markdown (content) {
2121 if (typeof content === 'string') { content = {text: content} }
22- // handle patchwork style mentions and custom emoji.
2322 var mentions = {}
2423 var typeLookup = {}
2524 var emojiMentions = {}
2625 if (Array.isArray(content.mentions)) {
@@ -28,14 +27,19 @@
2827 if (link && link.link && link.type) {
2928 typeLookup[link.link] = link.type
3029 }
3130 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 + }
3438 }
3539 })
3640 }
37-
41 +
3842 return h('Markdown', {
3943 hooks: [
4044 LoadingBlobHook(api.blob.obs.has)
4145 ],
@@ -46,20 +50,20 @@
4650 : api.emoji.sync.url(emoji)
4751 return renderEmoji(emoji, url)
4852 },
4953 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)
5357 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]
5660 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)
5965 return mentions[id]
60- } else if (ref.isLink(id) || id.startsWith('#') || id.startsWith('?')) {
61- return id
6266 }
6367 return false
6468 },
6569 imageLink: (id) => id
package-lock.jsonView
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.jsonView
@@ -57,10 +57,10 @@
5757 "ssb-config": "^2.2.0",
5858 "ssb-feed": "^2.3.0",
5959 "ssb-friends": "^2.2.3",
6060 "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",
6363 "ssb-sort": "^1.0.0",
6464 "xtend": "^4.0.1"
6565 },
6666 "browserify": {

Built with git-ssb-web