git ssb

16+

Dominic / patchbay



Commit 9bc144cce7f943481bbdf418bd837395b337c712

inlcude ssb-horcrux

mix irving committed on 3/30/2017, 9:33:33 AM
Parent: 6f4a164dcf3ceba120878c266e2f477496eb7b3e

Files changed

index.jschanged
main/html/scroller.mcsschanged
main/sync/catch-keyboard-shortcut.jschanged
package.jsonchanged
router/html/page/search.jschanged
index.jsView
@@ -2,16 +2,22 @@
22 const entry = require('depject/entry')
33 const nest = require('depnest')
44 const bulk = require('bulk-require')
55
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+
611 // polyfills
712 require('setimmediate')
813
914 // from more specialized to more general
1015 const sockets = combine(
11- // require(patchgit)
12- bulk(__dirname, [ '!(node_modules|junk)/**/*.js' ]),
13- require('patchcore')
16+ // git,
17+ horcrux,
18+ patchbay,
19+ patchcore
1420 )
1521
1622 const api = entry(sockets, nest('main.html.app', 'first'))
1723
main/html/scroller.mcssView
@@ -8,9 +8,9 @@
88 min-height: 0px
99
1010 div.wrapper {
1111 flex: 1
12- width: 600px
12+ width: 720px
1313 margin-left: auto
1414 margin-right: auto
1515
1616 section.content {
main/sync/catch-keyboard-shortcut.jsView
@@ -10,9 +10,9 @@
1010
1111 root.addEventListener('keydown', (ev) => {
1212 isTextFieldEvent(ev)
1313 ? textFieldShortcuts(ev)
14- : genericShortcuts(ev, opts)
14+ : genericShortcuts(ev, opts)
1515 })
1616 }
1717 }
1818
@@ -24,14 +24,13 @@
2424 }
2525
2626 function textFieldShortcuts (ev) {
2727 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
2929 }
3030 }
31-
31+
3232 function genericShortcuts (ev, { tabs, search }) {
33-
3433 // Messages
3534 if (ev.keyCode === 71) { // gg = scroll to top
3635 if (!gPressed) {
3736 gPressed = true
@@ -54,9 +53,8 @@
5453 return goToMessage(ev)
5554 case 192: // ` = toggle raw message view
5655 return toggleRawMessage(ev)
5756
58-
5957 // Tabs
6058 case 72: // h = left
6159 return tabs.selectRelative(-1)
6260 case 76: // l = right
@@ -69,9 +67,9 @@
6967 tabs.select(Math.max(i - 1, 0))
7068 }
7169 return
7270
73- // Search
71+ // Search
7472 case 191: // / = routes search
7573 if (ev.shiftKey) search.activate('?', ev)
7674 else search.activate('/', ev)
7775 return
@@ -86,9 +84,8 @@
8684 return
8785 }
8886 }
8987
90-
9188 function goToMessage (ev) {
9289 const msg = ev.target
9390 if (!msg.classList.contains('Message')) return
9491
package.jsonView
@@ -41,8 +41,9 @@
4141 "pull-scroll": "^1.0.3",
4242 "pull-stream": "^3.5.0",
4343 "read-directory": "^2.0.0",
4444 "setimmediate": "^1.0.5",
45+ "ssb-horcrux": "0.0.1",
4546 "ssb-mentions": "^0.1.1",
4647 "suggest-box": "^2.2.3",
4748 "text-node-searcher": "^1.1.1",
4849 "xtend": "^4.0.1"
router/html/page/search.jsView
@@ -10,56 +10,56 @@
1010
1111 exports.needs = nest({
1212 'main.html.scroller': 'first',
1313 'message.html.render': 'first',
14- 'sbot.pull.log': 'first',
14+ 'sbot.pull.log': 'first'
1515 // sbot_fulltext_search: 'first' // TODO add to core?
1616 })
1717
1818 var whitespace = /\s+/
1919
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++) {
2222 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
2525 }
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
2828 }
2929 return true
3030 }
3131
32-function searchFilter(terms) {
32+function searchFilter (terms) {
3333 return function (msg) {
3434 var c = msg && msg.value && msg.value.content
3535 return c && (
36- msg.key == terms[0] ||
36+ msg.key === terms[0] ||
3737 andSearch(terms.map(function (term) {
38- return new RegExp('\\b'+term+'\\b', 'i')
38+ return new RegExp('\\b' + term + '\\b', 'i')
3939 }), [c.text, c.name, c.title])
4040 )
4141 }
4242 }
4343
44-function createOrRegExp(ary) {
44+function createOrRegExp (ary) {
4545 return new RegExp(ary.map(function (e) {
46- return '\\b'+e+'\\b'
46+ return '\\b' + e + '\\b'
4747 }).join('|'), 'i')
4848 }
4949
50-function highlight(el, query) {
50+function highlight (el, query) {
5151 var searcher = new TextNodeSearcher({container: el})
5252 searcher.query = query
5353 searcher.highlight()
5454 return el
5555 }
5656
57-function fallback(reader) {
57+function fallback (reader) {
5858 var fallbackRead
5959 return function (read) {
6060 return function (abort, cb) {
61- read(abort, function next(end, data) {
61+ read(abort, function next (end, data) {
6262 if (end && reader && (fallbackRead = reader(end))) {
6363 reader = null
6464 read = fallbackRead
6565 read(abort, next)
@@ -71,9 +71,8 @@
7171 }
7272 }
7373
7474 exports.create = function (api) {
75-
7675 return nest('router.html.page', searchPage)
7776
7877 function searchPage (path) {
7978 if (path.match(/^[@#%\/]/)) return
@@ -94,9 +93,8 @@
9493 })
9594 const hasNoFulltextMatches = computed([search.fulltext.isDone, search.matches],
9695 (done, matches) => done && matches === 0)
9796
98-
9997 const searchHeader = h('Search', [
10098 h('header', h('h1', query.join(' '))),
10199 when(search.isLinear,
102100 h('section.details', [
@@ -111,9 +109,9 @@
111109 ])
112110 var { container, content } = api.main.html.scroller({ prepend: searchHeader })
113111 container.id = path // helps tabs find this tab
114112
115- function renderMsg(msg) {
113+ function renderMsg (msg) {
116114 var el = api.message.html.render(msg)
117115 highlight(el, createOrRegExp(query))
118116 return el
119117 }
@@ -127,9 +125,9 @@
127125 // <Temp>
128126 search.isLinear.set(true)
129127 pull(
130128 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)),
132130 pull.filter(matchesQuery),
133131 // </Temp>
134132 // TODO - reinstate fulltext search
135133 // pull(
@@ -145,9 +143,9 @@
145143 // pull.filter(matchesQuery)
146144 // )
147145 // }
148146 // }),
149- pull.through(() => search.matches.set(search.matches()+1)),
147+ pull.through(() => search.matches.set(search.matches() + 1)),
150148 Scroller(container, content, renderMsg, false, false)
151149 )
152150
153151 return container

Built with git-ssb-web