Commit 9bc144cce7f943481bbdf418bd837395b337c712
inlcude ssb-horcrux
mix irving committed on 3/30/2017, 9:33:33 AMParent: 6f4a164dcf3ceba120878c266e2f477496eb7b3e
Files changed
index.js | changed |
main/html/scroller.mcss | changed |
main/sync/catch-keyboard-shortcut.js | changed |
package.json | changed |
router/html/page/search.js | changed |
index.js | ||
---|---|---|
@@ -2,16 +2,22 @@ | ||
2 | 2 | const entry = require('depject/entry') |
3 | 3 | const nest = require('depnest') |
4 | 4 | const bulk = require('bulk-require') |
5 | 5 | |
6 | +// const git = require('patch-git') | |
7 | +const horcrux = require('ssb-horcrux') | |
8 | +const patchbay = { pathcbay: bulk(__dirname, [ '!(node_modules|junk)/**/*.js' ]) } | |
9 | +const patchcore = require('patchcore') | |
10 | + | |
6 | 11 | // polyfills |
7 | 12 | require('setimmediate') |
8 | 13 | |
9 | 14 | // from more specialized to more general |
10 | 15 | const sockets = combine( |
11 | - // require(patchgit) | |
12 | - bulk(__dirname, [ '!(node_modules|junk)/**/*.js' ]), | |
13 | - require('patchcore') | |
16 | + // git, | |
17 | + horcrux, | |
18 | + patchbay, | |
19 | + patchcore | |
14 | 20 | ) |
15 | 21 | |
16 | 22 | const api = entry(sockets, nest('main.html.app', 'first')) |
17 | 23 |
main/html/scroller.mcss | ||
---|---|---|
@@ -8,9 +8,9 @@ | ||
8 | 8 | min-height: 0px |
9 | 9 | |
10 | 10 | div.wrapper { |
11 | 11 | flex: 1 |
12 | - width: 600px | |
12 | + width: 720px | |
13 | 13 | margin-left: auto |
14 | 14 | margin-right: auto |
15 | 15 | |
16 | 16 | section.content { |
main/sync/catch-keyboard-shortcut.js | ||
---|---|---|
@@ -10,9 +10,9 @@ | ||
10 | 10 | |
11 | 11 | root.addEventListener('keydown', (ev) => { |
12 | 12 | isTextFieldEvent(ev) |
13 | 13 | ? textFieldShortcuts(ev) |
14 | - : genericShortcuts(ev, opts) | |
14 | + : genericShortcuts(ev, opts) | |
15 | 15 | }) |
16 | 16 | } |
17 | 17 | } |
18 | 18 | |
@@ -24,14 +24,13 @@ | ||
24 | 24 | } |
25 | 25 | |
26 | 26 | function textFieldShortcuts (ev) { |
27 | 27 | if (ev.keyCode === 13 && ev.ctrlKey) { |
28 | - ev.target.publish() //expects the textField to have a publish method | |
28 | + ev.target.publish() // expects the textField to have a publish method | |
29 | 29 | } |
30 | 30 | } |
31 | - | |
31 | + | |
32 | 32 | function genericShortcuts (ev, { tabs, search }) { |
33 | - | |
34 | 33 | // Messages |
35 | 34 | if (ev.keyCode === 71) { // gg = scroll to top |
36 | 35 | if (!gPressed) { |
37 | 36 | gPressed = true |
@@ -54,9 +53,8 @@ | ||
54 | 53 | return goToMessage(ev) |
55 | 54 | case 192: // ` = toggle raw message view |
56 | 55 | return toggleRawMessage(ev) |
57 | 56 | |
58 | - | |
59 | 57 | // Tabs |
60 | 58 | case 72: // h = left |
61 | 59 | return tabs.selectRelative(-1) |
62 | 60 | case 76: // l = right |
@@ -69,9 +67,9 @@ | ||
69 | 67 | tabs.select(Math.max(i - 1, 0)) |
70 | 68 | } |
71 | 69 | return |
72 | 70 | |
73 | - // Search | |
71 | + // Search | |
74 | 72 | case 191: // / = routes search |
75 | 73 | if (ev.shiftKey) search.activate('?', ev) |
76 | 74 | else search.activate('/', ev) |
77 | 75 | return |
@@ -86,9 +84,8 @@ | ||
86 | 84 | return |
87 | 85 | } |
88 | 86 | } |
89 | 87 | |
90 | - | |
91 | 88 | function goToMessage (ev) { |
92 | 89 | const msg = ev.target |
93 | 90 | if (!msg.classList.contains('Message')) return |
94 | 91 |
package.json | ||
---|---|---|
@@ -41,8 +41,9 @@ | ||
41 | 41 | "pull-scroll": "^1.0.3", |
42 | 42 | "pull-stream": "^3.5.0", |
43 | 43 | "read-directory": "^2.0.0", |
44 | 44 | "setimmediate": "^1.0.5", |
45 | + "ssb-horcrux": "0.0.1", | |
45 | 46 | "ssb-mentions": "^0.1.1", |
46 | 47 | "suggest-box": "^2.2.3", |
47 | 48 | "text-node-searcher": "^1.1.1", |
48 | 49 | "xtend": "^4.0.1" |
router/html/page/search.js | ||
---|---|---|
@@ -10,56 +10,56 @@ | ||
10 | 10 | |
11 | 11 | exports.needs = nest({ |
12 | 12 | 'main.html.scroller': 'first', |
13 | 13 | 'message.html.render': 'first', |
14 | - 'sbot.pull.log': 'first', | |
14 | + 'sbot.pull.log': 'first' | |
15 | 15 | // sbot_fulltext_search: 'first' // TODO add to core? |
16 | 16 | }) |
17 | 17 | |
18 | 18 | var whitespace = /\s+/ |
19 | 19 | |
20 | -function andSearch(terms, inputs) { | |
21 | - for(var i = 0; i < terms.length; i++) { | |
20 | +function andSearch (terms, inputs) { | |
21 | + for (var i = 0; i < terms.length; i++) { | |
22 | 22 | var match = false |
23 | - for(var j = 0; j < inputs.length; j++) { | |
24 | - if(terms[i].test(inputs[j])) match = true | |
23 | + for (var j = 0; j < inputs.length; j++) { | |
24 | + if (terms[i].test(inputs[j])) match = true | |
25 | 25 | } |
26 | - //if a term was not matched by anything, filter this one | |
27 | - if(!match) return false | |
26 | + // if a term was not matched by anything, filter this one | |
27 | + if (!match) return false | |
28 | 28 | } |
29 | 29 | return true |
30 | 30 | } |
31 | 31 | |
32 | -function searchFilter(terms) { | |
32 | +function searchFilter (terms) { | |
33 | 33 | return function (msg) { |
34 | 34 | var c = msg && msg.value && msg.value.content |
35 | 35 | return c && ( |
36 | - msg.key == terms[0] || | |
36 | + msg.key === terms[0] || | |
37 | 37 | andSearch(terms.map(function (term) { |
38 | - return new RegExp('\\b'+term+'\\b', 'i') | |
38 | + return new RegExp('\\b' + term + '\\b', 'i') | |
39 | 39 | }), [c.text, c.name, c.title]) |
40 | 40 | ) |
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | -function createOrRegExp(ary) { | |
44 | +function createOrRegExp (ary) { | |
45 | 45 | return new RegExp(ary.map(function (e) { |
46 | - return '\\b'+e+'\\b' | |
46 | + return '\\b' + e + '\\b' | |
47 | 47 | }).join('|'), 'i') |
48 | 48 | } |
49 | 49 | |
50 | -function highlight(el, query) { | |
50 | +function highlight (el, query) { | |
51 | 51 | var searcher = new TextNodeSearcher({container: el}) |
52 | 52 | searcher.query = query |
53 | 53 | searcher.highlight() |
54 | 54 | return el |
55 | 55 | } |
56 | 56 | |
57 | -function fallback(reader) { | |
57 | +function fallback (reader) { | |
58 | 58 | var fallbackRead |
59 | 59 | return function (read) { |
60 | 60 | return function (abort, cb) { |
61 | - read(abort, function next(end, data) { | |
61 | + read(abort, function next (end, data) { | |
62 | 62 | if (end && reader && (fallbackRead = reader(end))) { |
63 | 63 | reader = null |
64 | 64 | read = fallbackRead |
65 | 65 | read(abort, next) |
@@ -71,9 +71,8 @@ | ||
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | 74 | exports.create = function (api) { |
75 | - | |
76 | 75 | return nest('router.html.page', searchPage) |
77 | 76 | |
78 | 77 | function searchPage (path) { |
79 | 78 | if (path.match(/^[@#%\/]/)) return |
@@ -94,9 +93,8 @@ | ||
94 | 93 | }) |
95 | 94 | const hasNoFulltextMatches = computed([search.fulltext.isDone, search.matches], |
96 | 95 | (done, matches) => done && matches === 0) |
97 | 96 | |
98 | - | |
99 | 97 | const searchHeader = h('Search', [ |
100 | 98 | h('header', h('h1', query.join(' '))), |
101 | 99 | when(search.isLinear, |
102 | 100 | h('section.details', [ |
@@ -111,9 +109,9 @@ | ||
111 | 109 | ]) |
112 | 110 | var { container, content } = api.main.html.scroller({ prepend: searchHeader }) |
113 | 111 | container.id = path // helps tabs find this tab |
114 | 112 | |
115 | - function renderMsg(msg) { | |
113 | + function renderMsg (msg) { | |
116 | 114 | var el = api.message.html.render(msg) |
117 | 115 | highlight(el, createOrRegExp(query)) |
118 | 116 | return el |
119 | 117 | } |
@@ -127,9 +125,9 @@ | ||
127 | 125 | // <Temp> |
128 | 126 | search.isLinear.set(true) |
129 | 127 | pull( |
130 | 128 | next(api.sbot.pull.log, {reverse: true, limit: 500, live: false}), |
131 | - pull.through(() => search.linear.checked.set(search.linear.checked()+1)), | |
129 | + pull.through(() => search.linear.checked.set(search.linear.checked() + 1)), | |
132 | 130 | pull.filter(matchesQuery), |
133 | 131 | // </Temp> |
134 | 132 | // TODO - reinstate fulltext search |
135 | 133 | // pull( |
@@ -145,9 +143,9 @@ | ||
145 | 143 | // pull.filter(matchesQuery) |
146 | 144 | // ) |
147 | 145 | // } |
148 | 146 | // }), |
149 | - pull.through(() => search.matches.set(search.matches()+1)), | |
147 | + pull.through(() => search.matches.set(search.matches() + 1)), | |
150 | 148 | Scroller(container, content, renderMsg, false, false) |
151 | 149 | ) |
152 | 150 | |
153 | 151 | return container |
Built with git-ssb-web