git ssb

16+

Dominic / patchbay



Commit 4d12101d5c56d1007d547af47a2cb083913aaf7c

Merge branch 'master' into fulltext-search

mix irving committed on 2/6/2017, 9:49:54 PM
Parent: f715d01c1a678fca975815e634302f528078efbf
Parent: edabe8be49e24684f650eea0bbebd38e65df4f9f

Files changed

modules_basic/compose.jschanged
modules_basic/compose.mcsschanged
modules_basic/thread.jschanged
modules_extra/channel.jschanged
modules_extra/raw.jschanged
package.jsonchanged
modules_basic/compose.jsView
@@ -1,11 +1,13 @@
11 'use strict'
22 const fs = require('fs')
33 const h = require('../h')
4 +const { Value, when } = require('@mmckegg/mutant')
45 const mentions = require('ssb-mentions')
56
67 exports.needs = {
78 suggest_mentions: 'map', //<-- THIS MUST BE REWRITTEN
9 + suggest_channel: 'map',
810 build_suggest_box: 'first',
911 publish: 'first',
1012 message_content: 'first',
1113 message_confirm: 'first',
@@ -40,31 +42,58 @@
4042 }
4143 }
4244 opts.prepublish = opts.prepublish || id
4345
44- var actions
46 + const isExpanded = Value(opts.shrink === false)
4547
4648 var textArea = h('textarea', {
4749 placeholder: opts.placeholder || 'Write a message'
4850 })
4951
52 + var channelInput = h('input.channel', {
53 + placeholder: '#channel (optional)',
54 + value: meta.channel ? `#${meta.channel}` : '',
55 + disabled: meta.channel ? true : false,
56 + title: meta.channel ? 'Reply is in same channel as original message' : '',
57 + })
58 +
59 + channelInput.addEventListener('keyup', (e) => {
60 + e.target.value = e.target.value
61 + .replace(/^#*([\w@%&])/, '#$1')
62 + })
63 +
5064 if(opts.shrink !== false) {
65 + isExpanded.set(false)
5166 var blur
67 +
5268 textArea.addEventListener('focus', () => {
5369 clearTimeout(blur)
5470 if(!textArea.value) {
55- composer.className = 'Compose -expanded'
71 + isExpanded.set(true)
5672 }
5773 })
5874 textArea.addEventListener('blur', () => {
5975 //don't shrink right away, so there is time
6076 //to click the publish button.
6177 clearTimeout(blur)
6278 blur = setTimeout(() => {
6379 if(textArea.value) return
64- composer.className = 'Compose -contracted'
80 + isExpanded.set(false)
6581 }, 300)
6682 })
83 + channelInput.addEventListener('focus', () => {
84 + clearTimeout(blur)
85 + if (!textArea.value) {
86 + isExpanded.set(true)
87 + }
88 + })
89 + channelInput.addEventListener('blur', () => {
90 + clearTimeout(blur)
91 + blur = setTimeout(() => {
92 + if (textArea.value || channelInput.value) return
93 + isExpanded.set(false)
94 + }, 300)
95 + })
6796 }
6897
6998 textArea.addEventListener('keydown', ev => {
7099 if(ev.keyCode === 13 && ev.ctrlKey) publish()
@@ -79,8 +108,10 @@
79108 try {
80109 content = JSON.parse(textArea.value)
81110 } catch (err) {
82111 meta.text = textArea.value
112 + meta.channel = (channelInput.value.startsWith('#') ?
113 + channelInput.value.substr(1).trim() : channelInput.value.trim()) || null
83114 meta.mentions = mentions(textArea.value).map(mention => {
84115 // merge markdown-detected mention with file info
85116 var file = filesById[mention.link]
86117 if (file) {
@@ -116,26 +147,25 @@
116147
117148 var embed = file.type.indexOf('image/') === 0 ? '!' : ''
118149
119150 textArea.value += embed + '['+file.name+']('+file.link+')'
120- composer.className = 'Compose -expanded'
151 + isExpanded.set(true)
121152 console.log('added:', file)
122153 })
123154 var publishBtn = h('button', {'ev-click': publish}, 'Publish' )
124- var actions = h('section.actions', [
125- fileInput, publishBtn
126- ])
155 + var actions = h('section.actions', [ fileInput, publishBtn ])
127156
128157 api.build_suggest_box(textArea, api.suggest_mentions)
158 + api.build_suggest_box(channelInput, api.suggest_channel)
129159
130160 var composer = h('Compose', {
131- className: opts.shrink === false ? '-expanded' : '-contracted'
161 + classList: [ when(isExpanded, '-expanded', '-contracted') ]
132162 }, [
163 + channelInput,
133164 textArea,
134165 actions
135166 ])
136167
137-
138168 return composer
139169 }
140170
141171 }
modules_basic/compose.mcssView
@@ -5,10 +5,29 @@
55 padding: 1rem .5rem 1rem 7.3rem
66
77 textarea {
88 border: 1px solid gainsboro
9 + border-top-left-radius: 0
10 + border-top-right-radius: 0
911 }
1012
13 + input.channel {
14 + border: 1px solid gainsboro
15 + border-bottom: none
16 + border-bottom-left-radius: 0
17 + border-bottom-right-radius: 0
18 + padding: .5rem
19 +
20 + :focus {
21 + outline: none
22 + box-shadow: none
23 + }
24 + :disabled {
25 + background-color: #f1f1f1
26 + cursor: not-allowed
27 + }
28 + }
29 +
1130 section.actions {
1231 display: flex
1332 flex-direction: row
1433 align-items: baseline
@@ -25,9 +44,9 @@
2544
2645 ::-webkit-file-upload-button {
2746 visibility: hidden
2847 }
29-
48 +
3049 ::before {
3150 $composeButton
3251 padding-top: .3rem
3352
@@ -37,12 +56,12 @@
3756 outline: none
3857 white-space: nowrap
3958 -webkit-user-select: none
4059 }
41-
60 +
4261 :active, :focus {
4362 outline: none
44- box-shadow: none
63 + box-shadow: none
4564 }
4665 }
4766
4867 button {
@@ -59,19 +78,27 @@
5978 height: 200px
6079 transition: height .15s ease-out
6180 }
6281
82 + input.channel {
83 + display: flex
84 + }
85 +
6386 section.actions {
6487 display: flex
6588 }
6689 }
6790
68- -contracted {
91 + -contracted {
6992 textarea {
7093 height: 50px
7194 transition: height .15s ease-in
7295 }
7396
97 + input.channel {
98 + display: none
99 + }
100 +
74101 section.actions {
75102 display: none
76103 }
77104 }
@@ -86,5 +113,4 @@
86113 padding: .5rem
87114 margin: 0
88115 cursor: pointer
89116 }
90-
modules_basic/thread.jsView
@@ -101,8 +101,14 @@
101101 meta.branch = branches.length > 1 ? branches : branches[0]
102102 meta.root = thread[0].value.content.root || thread[0].key
103103 meta.channel = thread[0].value.content.channel
104104
105 + if (meta.channel) {
106 + const channelInput = composer.querySelector('input')
107 + channelInput.value = `#${meta.channel}`
108 + channelInput.disabled = true
109 + }
110 +
105111 var recps = thread[0].value.content.recps
106112 var priv = thread[0].value['private']
107113 if(priv) {
108114 if(recps)
modules_extra/channel.jsView
@@ -15,9 +15,10 @@
1515 message_meta: true,
1616 screen_view: true,
1717 connection_status: true,
1818 suggest_search: true,
19- suggest_mentions: true
19 + suggest_mentions: true,
20 + suggest_channel: true
2021 }
2122
2223 exports.create = function (api) {
2324
@@ -34,9 +35,10 @@
3435 message_meta,
3536 screen_view,
3637 connection_status,
3738 suggest_search,
38- suggest_mentions
39 + suggest_mentions,
40 + suggest_channel
3941 }
4042
4143 function message_meta (msg) {
4244 var chan = msg.value.content.channel
@@ -138,6 +140,23 @@
138140 }
139141 }))
140142 }
141143 }
144 +
145 + function suggest_channel (query) {
146 + return function (cb) {
147 + if (!/^#\w/.test(query)) return cb()
148 +
149 + cb(null, channels.filter(function (chan) {
150 + return (`#${chan.name}`).substring(0, query.length) === query
151 + })
152 + .map(function (chan) {
153 + var name = `#${chan.name}`
154 + return {
155 + title: name,
156 + subtitle: `(${chan.rank})`,
157 + value: `#${name.substr(1)}`
158 + }
159 + }))
160 + }
161 + }
142162 }
143-
modules_extra/raw.jsView
@@ -78,6 +78,4 @@
7878 arr[i] = h('a', {href: '#' + arr[i]}, arr[i])
7979 }
8080 return arr
8181 }
82-
83-
package.jsonView
@@ -1,8 +1,8 @@
11 {
22 "name": "patchbay",
33 "description": "a pluggable patchwork",
4- "version": "6.7.4",
4 + "version": "6.8.0",
55 "homepage": "https://github.com/ssbc/patchbay",
66 "repository": {
77 "type": "git",
88 "url": "git://github.com/ssbc/patchbay.git"

Built with git-ssb-web