Commit cba374c25c373104effa4eb8d66f3c376c6518df
Merge branch 'master' into fix-reply-quote-in-threads
Anders Rune Jensen committed on 8/8/2018, 7:00:35 PMParent: 51cce4b91688bab9a65aaab93e4e95848d30f84b
Parent: 372af7ef0364ce311abbfd591690266f8fc41e35
Files changed
app/html/search-bar.js | changed |
app/page/blogs.js | added |
package-lock.json | changed |
router/sync/routes.js | changed |
app/html/search-bar.js | ||
---|---|---|
@@ -72,9 +72,9 @@ | ||
72 | 72 … | |
73 | 73 … | // TODO extract |
74 | 74 … | function getPagesSuggestions (word) { |
75 | 75 … | const pages = [ |
76 | - 'calendar', 'posts', 'public', 'private', 'inbox', 'profile', 'notifications', 'settings', | |
76 … | + 'blogs', 'calendar', 'posts', 'public', 'private', 'inbox', 'profile', 'notifications', 'settings', | |
77 | 77 … | 'gatherings', 'chess', 'books', 'imageSearch', 'polls', 'query' |
78 | 78 … | ] |
79 | 79 … | |
80 | 80 … | return pages |
app/page/blogs.js | ||
---|---|---|
@@ -1,0 +1,92 @@ | ||
1 … | +const nest = require('depnest') | |
2 … | +const { h } = require('mutant') | |
3 … | +// const pull = require('pull-stream') | |
4 … | +const Scroller = require('mutant-scroll') | |
5 … | +const next = require('pull-next-query') | |
6 … | + | |
7 … | +exports.gives = nest({ | |
8 … | + 'app.html.menuItem': true, | |
9 … | + 'app.page.blogs': true | |
10 … | +}) | |
11 … | + | |
12 … | +exports.needs = nest({ | |
13 … | + 'message.html.render': 'first', | |
14 … | + 'sbot.pull.stream': 'first' | |
15 … | +}) | |
16 … | + | |
17 … | +exports.create = function (api) { | |
18 … | + return nest({ | |
19 … | + 'app.html.menuItem': menuItem, | |
20 … | + 'app.page.blogs': blogsPage | |
21 … | + }) | |
22 … | + | |
23 … | + function menuItem () { | |
24 … | + return h('a', { | |
25 … | + style: { order: 1 }, | |
26 … | + 'ev-click': () => api.app.sync.goTo({ page: 'blogs' }) | |
27 … | + }, '/blogs') | |
28 … | + } | |
29 … | + | |
30 … | + function blogsPage (location) { | |
31 … | + const createStream = (opts) => { | |
32 … | + const query = [{ | |
33 … | + $filter: { | |
34 … | + timestamp: { $gt: 0 }, | |
35 … | + value: { | |
36 … | + content: { type: 'blog' } | |
37 … | + } | |
38 … | + } | |
39 … | + }] | |
40 … | + return api.sbot.pull.stream(server => { | |
41 … | + return next(server.query.read, Object.assign({}, { limit: 100, query }, opts), ['timestamp']) | |
42 … | + }) | |
43 … | + } | |
44 … | + var page = Scroller({ | |
45 … | + classList: ['Blogs'], | |
46 … | + streamToTop: createStream({ live: true, old: false }), | |
47 … | + streamToBottom: createStream({ reverse: true }), | |
48 … | + render: api.message.html.render | |
49 … | + }) | |
50 … | + | |
51 … | + page.title = '/blogs' | |
52 … | + page.scroll = keyscroll(page.querySelector('section.content')) | |
53 … | + return page | |
54 … | + } | |
55 … | +} | |
56 … | + | |
57 … | +// copied from app.html.scroller | |
58 … | +function keyscroll (content) { | |
59 … | + var curMsgEl | |
60 … | + | |
61 … | + if (!content) return () => {} | |
62 … | + | |
63 … | + content.addEventListener('click', onActivateChild, false) | |
64 … | + content.addEventListener('focus', onActivateChild, true) | |
65 … | + | |
66 … | + function onActivateChild (ev) { | |
67 … | + for (var el = ev.target; el; el = el.parentNode) { | |
68 … | + if (el.parentNode === content) { | |
69 … | + curMsgEl = el | |
70 … | + return | |
71 … | + } | |
72 … | + } | |
73 … | + } | |
74 … | + | |
75 … | + return function scroll (d) { | |
76 … | + selectChild((!curMsgEl || d === 'first') ? content.firstChild | |
77 … | + : d < 0 ? curMsgEl.previousElementSibling || content.firstChild | |
78 … | + : d > 0 ? curMsgEl.nextElementSibling || content.lastChild | |
79 … | + : curMsgEl) | |
80 … | + | |
81 … | + return curMsgEl | |
82 … | + } | |
83 … | + | |
84 … | + function selectChild (el) { | |
85 … | + if (!el) { return } | |
86 … | + | |
87 … | + if (!el.scrollIntoViewIfNeeded && !el.scrollIntoView) return | |
88 … | + ;(el.scrollIntoViewIfNeeded || el.scrollIntoView).call(el) | |
89 … | + el.focus() | |
90 … | + curMsgEl = el | |
91 … | + } | |
92 … | +} |
package-lock.json | ||
---|---|---|
The diff is too large to show. Use a local git client to view these changes. Old file size: 292918 bytes New file size: 293309 bytes |
router/sync/routes.js | ||
---|---|---|
@@ -6,8 +6,9 @@ | ||
6 | 6 … | exports.needs = nest({ |
7 | 7 … | 'app.page': { |
8 | 8 … | 'calendar': 'first', |
9 | 9 … | 'blob': 'first', |
10 … | + 'blogs': 'first', | |
10 | 11 … | 'errors': 'first', |
11 | 12 … | 'channel': 'first', |
12 | 13 … | 'imageSearch': 'first', |
13 | 14 … | 'notifications': 'first', |
@@ -29,8 +30,9 @@ | ||
29 | 30 … | const pages = api.app.page |
30 | 31 … | |
31 | 32 … | // loc = location |
32 | 33 … | const routes = [ |
34 … | + [ loc => loc.page === 'blogs', pages.blogs ], | |
33 | 35 … | [ loc => loc.page === 'calendar', pages.calendar ], |
34 | 36 … | [ loc => loc.page === 'errors', pages.errors ], |
35 | 37 … | [ loc => loc.page === 'imageSearch', pages.imageSearch ], |
36 | 38 … | [ loc => loc.page === 'notifications', pages.notifications ], |
Built with git-ssb-web