git ssb

16+

Dominic / patchbay



Commit 705c393ea050af7928c41a20b9597870a3a264f0

use - instead of _ consistently

Dominic Tarr committed on 5/29/2016, 11:15:30 AM
Parent: a75e10540025af11735b3a0b2d0b438eee09e20f

Files changed

modules/message-id.jsadded
modules/message_id.jsdeleted
modules/suggest-mentions.jsadded
modules/suggest_mentions.jsdeleted
modules/message-id.jsView
@@ -1,0 +1,10 @@
1+
2+var h = require('hyperscript')
3+
4+exports.message_meta = function (msg) {
5+ return h('div',h('input', {value: msg.key, readonly:'', onclick: function (ev) {
6+ ev.target.select()
7+ ev.stopPropagation()
8+ ev.preventDefault()
9+ }}))
10+}
modules/message_id.jsView
@@ -1,10 +1,0 @@
1-
2-var h = require('hyperscript')
3-
4-exports.message_meta = function (msg) {
5- return h('div',h('input', {value: msg.key, readonly:'', onclick: function (ev) {
6- ev.target.select()
7- ev.stopPropagation()
8- ev.preventDefault()
9- }}))
10-}
modules/suggest-mentions.jsView
@@ -1,0 +1,44 @@
1+var pull = require('pull-stream')
2+
3+function isImage (filename) {
4+ return /\.(gif|jpg|png|svg)$/i.test(filename)
5+}
6+
7+exports.suggest = function (word, sbot, cb) {
8+
9+ if(!/^[@%&!]/.test(word[0])) return cb()
10+ if(word.length < 2) return cb()
11+
12+ var sigil = word[0]
13+ var embed = ((sigil === '!') ? '!' : '')
14+ if(embed) sigil = '&'
15+ if(word[0] !== '@') word = word.substring(1)
16+
17+ pull(
18+ sbot.links2.read({query: [
19+ {$filter: {rel: ['mentions', {$prefix: word}], dest: {$prefix: sigil}}},
20+ {$reduce: {id: 'dest', name: ['rel', 1], rank: {$count: true}}}
21+ ]}),
22+ pull.collect(function (err, ary) {
23+
24+ ary = ary
25+ .filter(function (e) {
26+ if(!embed) return true
27+ return isImage(e.name)
28+ }).sort(function (a, b) {
29+ return b.rank - a.rank
30+ }).map(function (e) {
31+ return {
32+ title: e.name + ': ' + e.id.substring(0,10)+' ('+e.rank+')',
33+ value: embed+'['+e.name+']('+e.id+')',
34+ rank: e.rank,
35+ image: isImage(e.name) ? 'http://localhost:7777/'+e.id : undefined
36+ }
37+ })
38+ console.log(ary)
39+ cb(null, ary)
40+ })
41+ )
42+}
43+
44+
modules/suggest_mentions.jsView
@@ -1,44 +1,0 @@
1-var pull = require('pull-stream')
2-
3-function isImage (filename) {
4- return /\.(gif|jpg|png|svg)$/i.test(filename)
5-}
6-
7-exports.suggest = function (word, sbot, cb) {
8-
9- if(!/^[@%&!]/.test(word[0])) return cb()
10- if(word.length < 2) return cb()
11-
12- var sigil = word[0]
13- var embed = ((sigil === '!') ? '!' : '')
14- if(embed) sigil = '&'
15- if(word[0] !== '@') word = word.substring(1)
16-
17- pull(
18- sbot.links2.read({query: [
19- {$filter: {rel: ['mentions', {$prefix: word}], dest: {$prefix: sigil}}},
20- {$reduce: {id: 'dest', name: ['rel', 1], rank: {$count: true}}}
21- ]}),
22- pull.collect(function (err, ary) {
23-
24- ary = ary
25- .filter(function (e) {
26- if(!embed) return true
27- return isImage(e.name)
28- }).sort(function (a, b) {
29- return b.rank - a.rank
30- }).map(function (e) {
31- return {
32- title: e.name + ': ' + e.id.substring(0,10)+' ('+e.rank+')',
33- value: embed+'['+e.name+']('+e.id+')',
34- rank: e.rank,
35- image: isImage(e.name) ? 'http://localhost:7777/'+e.id : undefined
36- }
37- })
38- console.log(ary)
39- cb(null, ary)
40- })
41- )
42-}
43-
44-

Built with git-ssb-web