Files: 4a58e38afe8d7cd5659d286607457aeb91ee7638 / app / page / blogShow.js
2842 bytesRaw
1 | const nest = require('depnest') |
2 | const { h, computed, when } = require('mutant') |
3 | const { title: getTitle } = require('markdown-summary') |
4 | const last = require('lodash/last') |
5 | const get = require('lodash/get') |
6 | |
7 | exports.gives = nest('app.page.blogShow') |
8 | |
9 | exports.needs = nest({ |
10 | 'about.html.avatar': 'first', |
11 | 'about.obs.name': 'first', |
12 | 'app.html.comments': 'first', |
13 | 'app.html.context': 'first', |
14 | 'contact.html.follow': 'first', |
15 | 'message.html.channel': 'first', |
16 | 'message.html.markdown': 'first', |
17 | 'message.html.timeago': 'first', |
18 | 'feed.obs.thread': 'first' |
19 | }) |
20 | |
21 | exports.create = (api) => { |
22 | return nest('app.page.blogShow', blogShow) |
23 | |
24 | function blogShow (blogMsg) { |
25 | // blogMsg = a thread (message, may be decorated with replies) |
26 | |
27 | const { author, content } = blogMsg.value |
28 | |
29 | const blog = content.text |
30 | const title = api.message.html.markdown(content.title || getTitle(blog)) |
31 | |
32 | const comments = api.app.html.comments(blogMsg.key) |
33 | |
34 | const { lastId: branch } = api.feed.obs.thread(blogMsg.key) |
35 | |
36 | const { timeago, channel, markdown, compose } = api.message.html |
37 | |
38 | // return api.app.html.scroller({ |
39 | // classList: [ 'level', '-one' ], |
40 | // prepend, |
41 | // stream: api.feed.pull.private, |
42 | // filter: () => pull( |
43 | // pull.filter(msg => msg.value.content.type === 'post'), // TODO is this the best way to protect against votes? |
44 | // pull.filter(msg => msg.value.author != myKey), |
45 | // pull.filter(msg => msg.value.content.recps) |
46 | // ), |
47 | // store: recentMsgCache, |
48 | // updateTop: updateRecentMsgCache, |
49 | // updateBottom: updateRecentMsgCache, |
50 | // render: (msgObs) => { |
51 | // const msg = resolve(msgObs) |
52 | // const { author } = msg.value |
53 | // if (nearby.has(author)) return |
54 | |
55 | // return Option({ |
56 | // notifications: Math.random() > 0.7 ? Math.floor(Math.random()*9+1) : 0, // TODO |
57 | // imageEl: api.about.html.avatar(author), |
58 | // label: api.about.obs.name(author), |
59 | // selected: location.feed === author, |
60 | // location: Object.assign({}, msg, { feed: author }) // TODO make obs? |
61 | // }) |
62 | // } |
63 | // }) |
64 | return h('Page -blogShow', [ |
65 | api.app.html.context({ page: 'discover' }), // HACK to highlight discover |
66 | h('div.content', [ |
67 | h('header', [ |
68 | h('div.blog', [ |
69 | h('h1', title), |
70 | timeago(blogMsg), |
71 | channel(blogMsg) |
72 | ]), |
73 | h('div.author', [ |
74 | h('div.leftCol', api.about.html.avatar(author, 'medium')), |
75 | h('div.rightCol', [ |
76 | h('div.name', api.about.obs.name(author)), |
77 | api.contact.html.follow(author) |
78 | ]), |
79 | ]) |
80 | ]), |
81 | h('div.break', h('hr')), |
82 | h('section.blog', markdown(blog)), |
83 | comments, |
84 | ]), |
85 | ]) |
86 | } |
87 | } |
88 | |
89 |
Built with git-ssb-web