git ssb

16+

Dominic / patchbay



Commit c5ffbda319371810f31821e2ec2475140cb6bc1a

add blog read to patchbay

mix irving committed on 2/17/2018, 5:50:24 AM
Parent: 7cb50d8b0ff27ee2a30a3c39f21c134b12a3ed1c

Files changed

message/html/render/blog.jsadded
message/html/render/blog.mcssadded
package-lock.jsonchanged
package.jsonchanged
message/html/render/blog.jsView
@@ -1,0 +1,99 @@
1 +const nest = require('depnest')
2 +const Blog = require('scuttle-blog')
3 +const isBlog = require('scuttle-blog/isBlog')
4 +const { h, Value, computed, when, resolve, onceTrue } = require('mutant')
5 +const isEmpty = require('lodash/isEmpty')
6 +
7 +exports.gives = nest('message.html.render')
8 +
9 +exports.needs = nest({
10 + 'about.obs.color': 'first',
11 + 'blob.sync.url': 'first',
12 + 'message.html.decorate': 'reduce',
13 + 'message.html.layout': 'first',
14 + 'message.html.markdown': 'first',
15 + 'sbot.obs.connection': 'first',
16 + // 'history.sync.push': 'first',
17 +})
18 +
19 +exports.create = function (api) {
20 + return nest('message.html.render', blogRenderer)
21 +
22 + function blogRenderer (msg, opts) {
23 + if (!isBlog(msg)) return
24 +
25 + var blog = Blog(api.sbot.obs.connection).obs.get(msg)
26 + var showBlog = Value(false)
27 +
28 + const element = api.message.html.layout(msg, Object.assign({}, {
29 + content: when(showBlog,
30 + BlogFull(blog, api.message.html.markdown),
31 + BlogCard({
32 + blog,
33 + onClick: () => showBlog.set(true),
34 + color: api.about.obs.color,
35 + blobUrl: api.blob.sync.url
36 + })
37 + // Sample(blog, api.blob.sync.url, showBlog)
38 + ),
39 + layout: 'default'
40 + }, opts))
41 +
42 + return api.message.html.decorate(element, { msg })
43 +
44 + }
45 +}
46 +
47 +function BlogFull (blog, renderMd) {
48 + return computed(blog.body, body => {
49 + if (!isEmpty(body)) {
50 + return h('BlogFull.Markdown', [
51 + h('h1', blog.title),
52 + renderMd(body)
53 + ])
54 + }
55 +
56 + return h('BlogFull.Markdown', [
57 + h('h1', blog.title),
58 + blog.summary,
59 + h('p', 'loading...')
60 + ])
61 + })
62 +}
63 +
64 +function BlogCard ({ blog, blobUrl, onClick, color }) {
65 + const thumbnail = when(blog.thumbnail,
66 + h('Thumbnail', {
67 + style: {
68 + 'background-image': `url("${blobUrl(resolve(blog.thumbnail))}")`,
69 + 'background-position': 'center',
70 + 'background-size': 'cover'
71 + }
72 + }),
73 + h('Thumbnail -empty', {
74 + style: { 'background-color': color(blog.title) }
75 + }, [
76 + h('i.fa.fa-file-text-o')
77 + ])
78 + )
79 +
80 + var b = h('BlogCard', { 'ev-click': onClick }, [
81 + // h('div.context', [
82 + // api.about.html.avatar(author, 'tiny'),
83 + // h('div.name', api.about.obs.name(author)),
84 + // api.message.html.timeago(blog)
85 + // ]),
86 + h('div.content', [
87 + thumbnail,
88 + h('div.text.Markdown', [
89 + h('h1', blog.title),
90 + // when(blog.channel, api.message.html.channel(blog.channel))
91 + h('div.summary', blog.summary),
92 + h('div.read', 'Read blog')
93 + ])
94 + ])
95 + ])
96 +
97 + return b
98 +}
99 +
message/html/render/blog.mcssView
@@ -1,0 +1,53 @@
1 +BlogCard {
2 + box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 10px
3 + margin: 2rem 0
4 + border: 1px solid rgba(0, 0, 0, 0.1)
5 +
6 + transition: all .5s ease-in
7 +
8 + display: flex
9 + flex-direction: column
10 +
11 + div.content {
12 + display: flex
13 + flex-direction: row
14 + flex-grow: 1
15 +
16 + cursor: pointer
17 +
18 +
19 + div.Thumbnail {
20 + margin-right: 1rem
21 + }
22 +
23 + div.text {
24 + padding: .5rem
25 + div.summary {
26 + }
27 + div.read {
28 + margin-top: 1rem
29 + text-decoration: underline
30 + }
31 + }
32 +
33 + }
34 + background-color: #fff
35 +}
36 +
37 +Thumbnail {
38 + min-width: 20rem
39 + width: 20rem
40 + min-height: 10rem
41 + /* height: 10rem */
42 +
43 + -empty {
44 + color: #fff
45 + font-size: 1.8rem
46 + opacity: .8
47 +
48 + display: flex
49 + justify-content: center
50 + align-items: center
51 + }
52 +}
53 +
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 305638 bytes
New file size: 307075 bytes
package.jsonView
@@ -63,16 +63,17 @@
6363 "patch-settings": "^1.0.1",
6464 "patch-suggest": "^1.1.0",
6565 "patchbay-book": "^1.0.4",
6666 "patchbay-gatherings": "^2.0.0",
67- "patchcore": "^1.23.0",
67 + "patchcore": "^1.23.3",
6868 "pull-abortable": "^4.1.1",
6969 "pull-cat": "^1.1.11",
7070 "pull-next": "^1.0.0",
7171 "pull-scroll": "^1.0.9",
7272 "pull-stream": "^3.6.1",
7373 "read-directory": "^2.1.1",
7474 "require-style": "^1.0.1",
75 + "scuttle-blog": "^1.0.0",
7576 "scuttlebot": "^10.4.10",
7677 "setimmediate": "^1.0.5",
7778 "ssb-about": "^0.1.1",
7879 "ssb-backlinks": "^0.6.1",

Built with git-ssb-web