Commit ee61f163c310b3f658adf766c7d7e0aed9c5e0b3
fix some bugs
mix irving committed on 12/8/2017, 3:23:56 AMParent: 5f59445f9e468790a0106acff65bdd3ce873c37a
Files changed
app/page/blogNew.js | changed |
blog/html/blog.js | changed |
blog/html/post.js | changed |
app/page/blogNew.js | ||
---|---|---|
@@ -1,8 +1,9 @@ | ||
1 | 1 | const nest = require('depnest') |
2 | 2 | const { h, Struct, Value } = require('mutant') |
3 | 3 | const addSuggest = require('suggest-box') |
4 | 4 | const pull = require('pull-stream') |
5 | +const marksum = require('markdown-summary') | |
5 | 6 | |
6 | 7 | exports.gives = nest('app.page.blogNew') |
7 | 8 | |
8 | 9 | exports.needs = nest({ |
@@ -36,8 +37,9 @@ | ||
36 | 37 | shrink: false, |
37 | 38 | prepublish: function (content, cb) { |
38 | 39 | var m = /\!\[[^]+\]\(([^\)]+)\)/.exec(marksum.image(content.text)) |
39 | 40 | content.thumbnail = m && m[1] |
41 | + // content.summary = marksum.summary(content.text) // Need a summary whihch doesn't trim the start | |
40 | 42 | |
41 | 43 | var stream = pull.values([content.text]) |
42 | 44 | delete content.text |
43 | 45 | api.sbot.async.addBlob(stream, function (err, hash) { |
@@ -99,9 +101,11 @@ | ||
99 | 101 | |
100 | 102 | cb(null, suggestions) |
101 | 103 | }, {cls: 'PatchSuggest.-channelHorizontal'}) // WARNING hacking suggest-box cls |
102 | 104 | |
103 | - channelInput.addEventListener('suggestselect', (e) => meta.channel.set(e.value)) | |
105 | + channelInput.addEventListener('suggestselect', (e) => { | |
106 | + meta.channel.set(e.detail.value) | |
107 | + }) | |
104 | 108 | |
105 | 109 | return page |
106 | 110 | } |
107 | 111 | } |
blog/html/blog.js | ||
---|---|---|
@@ -18,37 +18,33 @@ | ||
18 | 18 | exports.create = function (api) { |
19 | 19 | |
20 | 20 | return nest({ |
21 | 21 | 'blog.html.title': function (data) { |
22 | - if('blog' == typeof data.value.content.type) return | |
22 | + if('blog' !== data.value.content.type) return | |
23 | 23 | return data.value.content.title |
24 | 24 | }, |
25 | 25 | 'blog.html.summary': function (data) { |
26 | - if('blog' == typeof data.value.content.type) return | |
26 | + if('blog' !== data.value.content.type) return | |
27 | 27 | return data.value.content.summary |
28 | 28 | }, |
29 | 29 | 'blog.html.thumbnail': function (data) { |
30 | - if('blog' == typeof data.value.content.type) return | |
30 | + if('blog' !== data.value.content.type) return | |
31 | 31 | return data.value.content.thumbnail |
32 | 32 | }, |
33 | 33 | 'blog.html.content': function (data) { |
34 | - if('blog' == typeof data.value.content.type) return | |
34 | + if('blog' !== data.value.content.type) return | |
35 | 35 | var div = h('Markdown') |
36 | 36 | pull( |
37 | 37 | api.sbot.pull.stream(function (sbot) { |
38 | 38 | return sbot.blobs.get(data.value.content.blog) |
39 | 39 | }), |
40 | 40 | pull.collect(function (err, ary) { |
41 | 41 | if(err) return |
42 | - var md = api.message.html.markdown({text:Buffer.concat(ary).toString()}) | |
42 | + var md = api.message.html.markdown({text: Buffer.concat(ary).toString()}) | |
43 | 43 | div.innerHTML = md.innerHTML |
44 | 44 | }) |
45 | 45 | ) |
46 | 46 | return div |
47 | 47 | } |
48 | 48 | }) |
49 | 49 | } |
50 | 50 | |
51 | - | |
52 | - | |
53 | - | |
54 | - |
blog/html/post.js | ||
---|---|---|
@@ -31,8 +31,9 @@ | ||
31 | 31 | 'blog.html.thumbnail': function (data) { |
32 | 32 | if('post' !== data.value.content.type) return |
33 | 33 | var content = data.value.content |
34 | 34 | if(content.thumbnail) return content.thumbnail |
35 | + | |
35 | 36 | var img = marksum.image(content.text) |
36 | 37 | var m = /\!\[[^]+\]\(([^\)]+)\)/.exec(img) |
37 | 38 | if(m) return m[1] |
38 | 39 | }, |
Built with git-ssb-web