git ssb

2+

ev / mvd



Commit bdc777360c48b4ead49e30a0a5932c35621c0c90

launch generic composer into feed

Ev Bogue committed on 5/25/2018, 8:38:32 PM
Parent: a7f68e1a76889ae73272b63475776b226d864a95

Files changed

compose.jschanged
index.jschanged
render.jschanged
style.csschanged
style.css.jsonchanged
views.jschanged
compose.jsView
@@ -8,8 +8,10 @@
88
99 var mime = require('simple-mime')('application/octect-stream')
1010 var split = require('split-buffer')
1111
12 +var route = require('./views')
13 +
1214 function file_input (onAdded) {
1315 return h('label.btn', 'Upload file',
1416 h('input', { type: 'file', hidden: true,
1517 onchange: function (ev) {
@@ -34,9 +36,9 @@
3436 }
3537 }))
3638 }
3739
38-module.exports = function (opts) {
40 +module.exports = function (opts, buttons) {
3941 var files = []
4042 var filesById = {}
4143
4244 var composer = h('div.composer')
@@ -54,13 +56,15 @@
5456 if (opts.updated) {
5557 cancel = document.getElementById(opts.updated.substring(0,10))
5658 var oldMessage = h('div.message__body', tools.markdown(opts.messageText))
5759 cancel.parentNode.replaceChild(oldMessage, cancel)
58- console.log(opts.buttons)
59- oldMessage.parentNode.appendChild(opts.buttons)
60 + oldMessage.parentNode.appendChild(buttons)
6061 } else if (opts.branch) {
6162 cancel = document.getElementById(opts.branch.substring(0,10))
6263 cancel.parentNode.removeChild(cancel)
64 + } else {
65 + cancel = document.getElementById('composer')
66 + cancel.parentNode.removeChild(cancel)
6367 }
6468 }
6569
6670 })
@@ -92,9 +96,9 @@
9296
9397 if (opts.type == 'post')
9498 var header = tools.header(msg)
9599 if (opts.type == 'update')
96- var header = h('div.timestamp', 'Edited:', h('a', {href: msg.key}, human(new Date(msg.value.timestamp))))
100 + var header = h('div.timestamp', 'Edited: ', h('a', {href: msg.key}, human(new Date(msg.value.timestamp))))
97101
98102 var preview = h('div',
99103 header,
100104 h('div.message__content', tools.markdown(msg.value.content.text)),
@@ -102,10 +106,19 @@
102106 onclick: function () {
103107 sbot.publish(msg.value.content, function (err, msg) {
104108 if(err) throw err
105109 console.log('Published!', msg)
106- window.location.reload()
107- if(cb) cb(err, msg)
110 + if (opts.type == 'update') {
111 + var originalMessage = document.getElementById(opts.updated.substring(0,10))
112 + console.log(originalMessage)
113 + opts.messageText = msg.value.content.text
114 + var newMessage = h('div.message__body',
115 + h('div.timestamp', 'Edited: ', h('a', {href: msg.key}, human(new Date(msg.value.timestamp)))),
116 + h('div', tools.markdown(msg.value.content.text))
117 + )
118 + originalMessage.parentNode.replaceChild(newMessage, originalMessage)
119 + newMessage.parentNode.appendChild(buttons)
120 + }
108121 })
109122 }
110123 }),
111124 h('button.btn', 'Cancel', {
index.jsView
@@ -1,8 +1,10 @@
11 var h = require('hyperscript')
22 var route = require('./views')
33 var avatar = require('./avatar')
44
5 +var compose = require('./compose')
6 +
57 var id = require('./keys').id
68
79 document.head.appendChild(h('style', require('./style.css.json')))
810
@@ -11,9 +13,17 @@
1113 var nav = h('div.navbar',
1214 h('div.internal',
1315 h('li', h('a', {href: '#' + id}, h('span.avatar--small', avatar.image(id)))),
1416 h('li', h('a', {href: '#' + id}, avatar.name(id))),
15- h('li', h('a', {href: '#compose' }, 'Compose')),
17 + h('li', h('a', 'Compose', {
18 + onclick: function () {
19 + document.getElementById('screen')
20 + var opts = {}
21 + opts.type = 'post'
22 + var composer = h('div.content#composer', h('div.message', compose(opts)))
23 + screen.firstChild.insertBefore(composer, screen.firstChild.firstChild)
24 + }
25 + })),
1626 h('li', h('a', {href: '#'}, 'Public')),
1727 h('li', h('a', {href: '#private' }, 'Private')),
1828 h('li', h('a', {href: '#mentions' }, 'Mentions')),
1929 h('li', h('a', {href: '#key' }, 'Key')),
render.jsView
@@ -57,22 +57,24 @@
5757 )
5858 var buttons = h('div.buttons')
5959 buttons.appendChild(h('button.btn', 'Reply', {
6060 onclick: function () {
61 + var r = message.childNodes.length - 1
62 + buttons = message.childNodes[r]
6163 //fallback = message.lastElementChild
6264 //console.log(fallback)
63- var compose = h('div.message#' + reply.branch.substring(0, 10), composer(reply))
65 + var compose = h('div.message#' + reply.branch.substring(0, 10), composer(reply, buttons))
6466 message.parentNode.appendChild(compose)
6567 //message.replaceChild(compose, message.lastElementChild)
6668 }
6769 }))
6870 if (msg.value.author == id)
6971 buttons.appendChild(h('button.btn', 'Edit', {
7072 onclick: function () {
7173 var r = message.childNodes.length - 1
72- edit.buttons = message.childNodes[r]
74 + buttons = message.childNodes[r]
7375 message.removeChild(message.childNodes[r])
74- var compose = h('div#' + edit.updated.substring(0, 10), composer(edit))
76 + var compose = h('div#' + edit.updated.substring(0, 10), composer(edit, buttons))
7577 message.replaceChild(compose, message.lastElementChild)
7678 }
7779 }))
7880
style.cssView
@@ -96,8 +96,14 @@
9696 background: #333;
9797 border-radius: 100%;
9898 }
9999
100 +.content {
101 + max-width: 680px;
102 + margin-left: auto;
103 + margin-right: auto;
104 +}
105 +
100106 .hyperscroll > .content {
101107 max-width: 680px;
102108 margin-left: auto;
103109 margin-right: auto;
style.css.jsonView
@@ -1,1 +1,1 @@
1-"body {\n margin: 0;\n background: #141414;\n font-family: sans-serif;\n color: #d5d5d5;\n font-size: 14px; \n line-height: 20px;\n}\n\n#screen {\n position: absolute;\n top: 35px;\n bottom: 0px;\n left: 0px;\n right: 0px;\n}\n\n.hyperscroll {\n width: 100%;\n}\n\n.header {\n padding-bottom: .7em;\n border-bottom: 1px solid #252525;\n}\n\nh1, h2, h3, h4, h5, h6 {\n font-size: 1.2em;\n margin-top: .35ex;\n}\n\np {\n margin-top: .35ex;\n margin-bottom: 10px;\n}\n\n\na {\n color: white;\n *text-decoration: none;\n}\n\na:hover {\n color: #ddd;\n}\n\n.navbar a {\n color: #999;\n text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);\n text-decoration: none;\n}\n\n.navbar a:hover, .navbar a:focus {\n color: #fff;\n text-decoration: none;\n}\n\n.navbar {\n background: #1b1b1b;\n background: linear-gradient(#222, #111);\n border-bottom: 1px solid #252525;\n}\n\n.navbar {\n width: 100%;\n position: fixed;\n z-index: 1000;\n margin: 0;\n padding-top: .3em;\n padding-bottom: .3em;\n left: 0; right: 0;\n top: 0;\n}\n\n.navbar .internal {\n max-width: 680px;\n margin-left: auto;\n margin-right: auto;\n}\n\n.navbar li {\n margin-top: .3em;\n float: left;\n margin-right: .6em;\n margin-left: .3em;\n list-style-type: none;\n}\n\n.navbar li.right {\n padding-left: .4em;\n padding-right: .4em;\n margin-top: .3em;\n margin-right: 1.7em;\n float: right;\n list-style-type: none;\n background: #333;\n border-radius: 100%;\n}\n\n.hyperscroll > .content {\n max-width: 680px;\n margin-left: auto;\n margin-right: auto;\n}\n\n.message, .message > *, .navbar, .navbar > * {\n animation: fadein .5s;\n}\n\n@keyframes fadein {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n\n.message, .embedded {\n display: block;\n margin: .6em;\n background: #111;\n padding: .7em;\n border-radius: 3px;\n border: 1px solid #252525;\n}\n\n.embedded {\n padding-left: 1em;\n}\n\n.message:hover, .embedded:hover {\n background: #141414;\n}\n\n.message img {\n max-width: 100%;\n}\n\n.timestamp, .votes {\n float: right;\n}\n \n.avatar--small img {\n vertical-align: top;\n width: 1.4em;\n height: 1.4em;\n margin-right: .2em;\n}\n\n.compose {\n background: #222;\n color: #ccc;\n width: 100%;\n height: 100px;\n border: 1px solid #252525;\n border-radius: 3px;\n}\n\n.emoji {\n float: left;\n width: 1em;\n vertical-align: top;\n}\n\npre {\n width: 100%;\n display: block;\n}\n\ncode {\n display: inline-block;\n vertical-align: bottom;\n}\n\ncode, pre {\noverflow: auto;\nword-break: break-all;\nword-wrap: break-word;\nwhite-space: pre;\nwhite-space: -moz-pre-wrap;\nwhite-space: pre-wrap;\nwhite-space: pre\\9;\n}\n\n\n.btn {\n display: inline-block;\n *display: inline;\n padding: 2px 6px;\n margin-bottom: 0;\n margin-right: .2em;\n font-size: 14px;\n line-height: 20px;\n color: #d5d5d5;\n text-align: center;\n text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75);\n vertical-align: middle;\n cursor: pointer;\n background-color: #222;\n border: 1px solid #222;\n border-radius: 4px;\n}\n\n\n.btn:hover,\n.btn:focus,\n.btn:active,\n.btn.active,\n.btn.disabled,\n.btn[disabled] {\n color: white;\n background-color: black;\n}\n\n.btn:active,\n.btn.active {\n background-color: #111;\n}\n\n.btn:first-child {\n *margin-left: 0;\n}\n\n"
1 +"body {\n margin: 0;\n background: #141414;\n font-family: sans-serif;\n color: #d5d5d5;\n font-size: 14px; \n line-height: 20px;\n}\n\n#screen {\n position: absolute;\n top: 35px;\n bottom: 0px;\n left: 0px;\n right: 0px;\n}\n\n.hyperscroll {\n width: 100%;\n}\n\n.header {\n padding-bottom: .7em;\n border-bottom: 1px solid #252525;\n}\n\nh1, h2, h3, h4, h5, h6 {\n font-size: 1.2em;\n margin-top: .35ex;\n}\n\np {\n margin-top: .35ex;\n margin-bottom: 10px;\n}\n\n\na {\n color: white;\n *text-decoration: none;\n}\n\na:hover {\n color: #ddd;\n}\n\n.navbar a {\n color: #999;\n text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);\n text-decoration: none;\n}\n\n.navbar a:hover, .navbar a:focus {\n color: #fff;\n text-decoration: none;\n}\n\n.navbar {\n background: #1b1b1b;\n background: linear-gradient(#222, #111);\n border-bottom: 1px solid #252525;\n}\n\n.navbar {\n width: 100%;\n position: fixed;\n z-index: 1000;\n margin: 0;\n padding-top: .3em;\n padding-bottom: .3em;\n left: 0; right: 0;\n top: 0;\n}\n\n.navbar .internal {\n max-width: 680px;\n margin-left: auto;\n margin-right: auto;\n}\n\n.navbar li {\n margin-top: .3em;\n float: left;\n margin-right: .6em;\n margin-left: .3em;\n list-style-type: none;\n}\n\n.navbar li.right {\n padding-left: .4em;\n padding-right: .4em;\n margin-top: .3em;\n margin-right: 1.7em;\n float: right;\n list-style-type: none;\n background: #333;\n border-radius: 100%;\n}\n\n.content {\n max-width: 680px;\n margin-left: auto;\n margin-right: auto;\n}\n\n.hyperscroll > .content {\n max-width: 680px;\n margin-left: auto;\n margin-right: auto;\n}\n\n.message, .message > *, .navbar, .navbar > * {\n animation: fadein .5s;\n}\n\n@keyframes fadein {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n\n.message, .embedded {\n display: block;\n margin: .6em;\n background: #111;\n padding: .7em;\n border-radius: 3px;\n border: 1px solid #252525;\n}\n\n.embedded {\n padding-left: 1em;\n}\n\n.message:hover, .embedded:hover {\n background: #141414;\n}\n\n.message img {\n max-width: 100%;\n}\n\n.timestamp, .votes {\n float: right;\n}\n \n.avatar--small img {\n vertical-align: top;\n width: 1.4em;\n height: 1.4em;\n margin-right: .2em;\n}\n\n.compose {\n background: #222;\n color: #ccc;\n width: 100%;\n height: 100px;\n border: 1px solid #252525;\n border-radius: 3px;\n}\n\n.emoji {\n float: left;\n width: 1em;\n vertical-align: top;\n}\n\npre {\n width: 100%;\n display: block;\n}\n\ncode {\n display: inline-block;\n vertical-align: bottom;\n}\n\ncode, pre {\noverflow: auto;\nword-break: break-all;\nword-wrap: break-word;\nwhite-space: pre;\nwhite-space: -moz-pre-wrap;\nwhite-space: pre-wrap;\nwhite-space: pre\\9;\n}\n\n\n.btn {\n display: inline-block;\n *display: inline;\n padding: 2px 6px;\n margin-bottom: 0;\n margin-right: .2em;\n font-size: 14px;\n line-height: 20px;\n color: #d5d5d5;\n text-align: center;\n text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75);\n vertical-align: middle;\n cursor: pointer;\n background-color: #222;\n border: 1px solid #222;\n border-radius: 4px;\n}\n\n\n.btn:hover,\n.btn:focus,\n.btn:active,\n.btn.active,\n.btn.disabled,\n.btn[disabled] {\n color: white;\n background-color: black;\n}\n\n.btn:active,\n.btn.active {\n background-color: #111;\n}\n\n.btn:first-child {\n *margin-left: 0;\n}\n\n"
views.jsView
@@ -69,18 +69,8 @@
6969 })
7070 })
7171 }
7272
73- else if (src == 'compose') {
74- var screen = document.getElementById('screen')
75-
76- var opts = {}
77- opts.type = 'post'
78-
79- var content = h('div.content', h('div.message', compose(opts)))
80-
81- screen.appendChild(hyperscroll(content))
82- }
8373 else if (src == 'about') {
8474
8575 var screen = document.getElementById('screen')
8676

Built with git-ssb-web