git ssb

0+

ev / 0qc



Commit 423e77eca80692c36556b549a46bcb6c572c3dbb

add vote buttons and fix some things

Ev Bogue committed on 3/10/2019, 11:33:03 PM
Parent: 29b1007fd8c97fe650f2f5eed160497aa7fd643b

Files changed

config.jschanged
render.jschanged
style.csschanged
style.css.jsonchanged
tools.jschanged
views.jschanged
config.jsView
@@ -1,11 +1,9 @@
11 var http = require('http')
22
33 module.exports = function () {
4- //var host = window.location.origin
4 + var host = window.location.origin
55
6- var host = 'http://localhost:8989'
7-
86 function getConfig () {
97 http.get(host + '/get-config', function (res) {
108 res.on('data', function (data, remote) {
119 var config = data
render.jsView
@@ -21,215 +21,241 @@
2121 }
2222
2323 module.exports.render = function (msg) {
2424
25- var message = h('div.message#' + msg.key.substring(0, 44))
26-
27- var messageContent = h('div.messageContent')
28- message.appendChild(messageContent)
29-
30- pull(
31- sbot.backlinks({
32- query: [{$filter: {dest: msg.key}}],
33- live: true,
34- reverse: false,
35- index: 'DTA'
36- }),
37- pull.drain(function (data) {
38- if (data.sync) {
39- console.log('waiting')
40- } else {
41- var dataId = 'NOTNULL'
42- var dataId = document.getElementById(data.key.substring(0, 44))
4325
44- if (dataId == null) {
45- console.log('rendering message')
46- if (
47- (data.value.content.vote) ||
48- (msg.key == data.value.content.root) ||
49- (msg.key == data.value.content.repo) ||
50- (msg.key == data.value.content.link)
51- ) {
52- message.appendChild(h('div.submessage', (exports.render(data))))
53- } else if (!data.value.content.root) {
54- var link = h('span', ' backlinked from ', tools.messageLink(data.key))
55- message.appendChild(h('div.submessage', h('div.messageContent', tools.mini(data, link))))
56- } else {
57- //console.log('DOES NOT MATCH')
58- message.appendChild(h('div.submessage', (exports.render(data))))
26 + var messageExists = (document.getElementById(msg.key.substring(0, 44)) !== null);
27 +
28 + if (!messageExists) {
29 + var message = h('div.message#' + msg.key.substring(0, 44))
30 + //console.log(msg)
31 + var messageContent = h('div.messageContent')
32 + message.appendChild(messageContent)
33 +
34 + pull(
35 + sbot.backlinks({
36 + query: [{$filter: {dest: msg.key}}],
37 + live: true,
38 + reverse: false,
39 + index: 'DTA'
40 + }),
41 + pull.drain(function (data) {
42 + if (data.sync) {
43 + } else {
44 + var subMessageExists = (document.getElementById(data.key.substring(0, 44)) !== null)
45 +
46 + if (!subMessageExists) {
47 + //console.log(data)
48 + if (data.value.content.type == 'vote') {
49 + if (msg.key == data.value.content.vote.link) {
50 + console.log(data)
51 + if (data.value.content.vote.value == 1)
52 + var link = h('span', ' ', h('img.emoji', {src: config.emojiUrl + 'star.png'}), ' ', h('a', {href: '#' + data.value.content.vote.link}, tools.messageLink(data.value.content.vote.link)))
53 + if (data.value.author == id) {
54 + var gotIt = document.getElementById('votebutton:' + msg.key.substring(0,44))
55 + if (gotIt != null) {
56 + gotIt.parentNode.appendChild(tools.unstar(msg))
57 + gotIt.removeChild(gotIt.firstChild)
58 + //gotIt.outerHTML = ''
59 + }
60 + }
61 + else if (data.value.content.vote.value == -1)
62 + var link = h('span', ' ', h('img.emoji', {src: config.emojiUrl + 'stars.png'}), ' ', h('a', {href: '#' + data.value.content.vote.link}, tools.messageLink(data.value.content.vote.link)))
63 + message.appendChild(h('div.submessage', h('div.messageContent', tools.mini(data, link))))
64 + } else {
65 + //console.log('did not render vote')
66 + }
67 + } else if (data.value.content.type == 'post') {
68 + if (
69 + (msg.key == data.value.content.root) ||
70 + (msg.value.content.root == data.value.content.root)
71 + ) {
72 + message.appendChild(h('div.submessage', (exports.render(data))))
73 + }
74 + } else {
75 + var link = h('span', ' backlinked from ', tools.messageLink(data.key))
76 + message.appendChild(h('div.submessage', h('div.messageContent', tools.mini(data, link))))
77 + }
78 + } else { //console.log('message already rendered')
5979 }
60- } else { console.log('message already rendered')}
80 + }
81 + })
82 + )
83 +
84 + if (msg.value.content.type == 'post') {
85 +
86 + messageContent.appendChild(tools.header(msg))
87 +
88 + if (msg.value.content.root) {
89 + messageContent.appendChild(h('span', 're: ', tools.messageLink(msg.value.content.root)))
6190 }
62- })
63- )
64-
65- if (msg.value.content.type == 'post') {
6691
67- messageContent.appendChild(tools.header(msg))
68-
69- if (msg.value.content.root) {
70- messageContent.appendChild(h('span', 're: ', tools.messageLink(msg.value.content.root)))
71- }
92 + messageContent.appendChild(h('div.message__body', tools.markdown(msg.value.content.text)))
7293
73- messageContent.appendChild(h('div.message__body', tools.markdown(msg.value.content.text)))
74- return message
75- }
94 + var buttons = h('div.buttons')
7695
77- if (msg.value.content.type == 'vote') {
78- if (msg.value.content.vote.value == 1)
79- var link = h('span', ' ', h('img.emoji', {src: config.emojiUrl + 'star.png'}), ' ', h('a', {href: '#' + msg.value.content.vote.link}, tools.messageLink(msg.value.content.vote.link)))
80- else if (msg.value.content.vote.value == -1)
81- var link = h('span', ' ', h('img.emoji', {src: config.emojiUrl + 'stars.png'}), ' ', h('a', {href: '#' + msg.value.content.vote.link}, tools.messageLink(msg.value.content.vote.link)))
82- messageContent.appendChild(tools.mini(msg, link))
83- return message
84- }
96 + buttons.appendChild(tools.star(msg))
8597
86- if (msg.value.content.type == 'about') {
87- if (msg.value.content.image) {
88- var image = h('span.avatar--small',
89- ' identified ',
90- h('a', {href: '#' + msg.value.content.about}, avatar.cachedName(msg.value.content.about)),
91- ' as ',
92- h('img', {src: config.blobsUrl + msg.value.content.image.link})
93- )
94- messageContent.appendChild(tools.mini(msg, image))
98 + messageContent.appendChild(buttons)
99 + return message
100 + }
101 +
102 + if (msg.value.content.type == 'vote') {
103 + if (msg.value.content.vote.value == 1)
104 + var link = h('span', ' ', h('img.emoji', {src: config.emojiUrl + 'star.png'}), ' ', h('a', {href: '#' + msg.value.content.vote.link}, tools.messageLink(msg.value.content.vote.link)))
105 + else if (msg.value.content.vote.value == -1)
106 + var link = h('span', ' ', h('img.emoji', {src: config.emojiUrl + 'stars.png'}), ' ', h('a', {href: '#' + msg.value.content.vote.link}, tools.messageLink(msg.value.content.vote.link)))
107 + messageContent.appendChild(tools.mini(msg, link))
95108 return message
96109 }
97- if (msg.value.content.name) {
98- var name = h('span',
99- ' identified ',
100- h('a', {href: '#' + msg.value.content.about}, avatar.cachedName(msg.value.content.about)),
101- ' as ', msg.value.content.name
110 +
111 + if (msg.value.content.type == 'about') {
112 + if (msg.value.content.image) {
113 + var image = h('span.avatar--small',
114 + ' identified ',
115 + h('a', {href: '#' + msg.value.content.about}, avatar.cachedName(msg.value.content.about)),
116 + ' as ',
117 + h('img', {src: config.blobsUrl + msg.value.content.image.link})
102118 )
103- messageContent.appendChild(tools.mini(msg, name))
104- return message
119 + messageContent.appendChild(tools.mini(msg, image))
120 + return message
121 + }
122 + if (msg.value.content.name) {
123 + var name = h('span',
124 + ' identified ',
125 + h('a', {href: '#' + msg.value.content.about}, avatar.cachedName(msg.value.content.about)),
126 + ' as ', msg.value.content.name
127 + )
128 + messageContent.appendChild(tools.mini(msg, name))
129 + return message
130 + }
105131 }
106- }
107132
108- if (msg.value.content.type == 'label'){
109- var content = h('span', ' labeled ', tools.messageLink(msg.value.content.link), ' as ', h('mark', h('a', {href: '#label/' + msg.value.content.label}, msg.value.content.label)))
110- messageContent.appendChild(tools.mini(msg, content))
111- return message
112- }
113-
114- if (msg.value.content.type == 'queue') {
115- if (msg.value.content.queue == true) {
116- var content = h('span', ' added ', tools.messageLink(msg.value.content.message), ' to their ', h('a', {href: '#queue'}, 'queue'))
133 + if (msg.value.content.type == 'label'){
134 + var content = h('span', ' labeled ', tools.messageLink(msg.value.content.link), ' as ', h('mark', h('a', {href: '#label/' + msg.value.content.label}, msg.value.content.label)))
117135 messageContent.appendChild(tools.mini(msg, content))
136 + return message
118137 }
119- if (msg.value.content.queue == false) {
120- var content = h('span', ' removed ', tools.messageLink(msg.value.content.message), ' from their ', h('a', {href: '#queue'}, 'queue'))
121- messageContent.appendChild(tools.mini(msg, content))
122138
139 + if (msg.value.content.type == 'queue') {
140 + if (msg.value.content.queue == true) {
141 + var content = h('span', ' added ', tools.messageLink(msg.value.content.message), ' to their ', h('a', {href: '#queue'}, 'queue'))
142 + messageContent.appendChild(tools.mini(msg, content))
143 + }
144 + if (msg.value.content.queue == false) {
145 + var content = h('span', ' removed ', tools.messageLink(msg.value.content.message), ' from their ', h('a', {href: '#queue'}, 'queue'))
146 + messageContent.appendChild(tools.mini(msg, content))
147 +
148 + }
149 + return message
123150 }
124- return message
125- }
126151
127- if (msg.value.content.type == 'scat_message') {
128- var src = hash()
129- if (src != 'backchannel') {
130- messageContent.appendChild(h('button.btn.right', h('a', {href: '#backchannel'}, 'Chat')))
152 + if (msg.value.content.type == 'scat_message') {
153 + var src = hash()
154 + if (src != 'backchannel') {
155 + messageContent.appendChild(h('button.btn.right', h('a', {href: '#backchannel'}, 'Chat')))
156 + }
157 + messageContent.appendChild(tools.mini(msg, ' ' + msg.value.content.text))
158 + return message
131159 }
132- messageContent.appendChild(tools.mini(msg, ' ' + msg.value.content.text))
133- return message
134- }
135160
136- else if (msg.value.content.type == 'contact') {
137- if (msg.value.content.contact) {
138- var contact = h('a', {href: '#' + msg.value.content.contact}, avatar.name(msg.value.content.contact))
139- } else { var contact = h('p', 'no contact named')}
161 + else if (msg.value.content.type == 'contact') {
162 + if (msg.value.content.contact) {
163 + var contact = h('a', {href: '#' + msg.value.content.contact}, avatar.name(msg.value.content.contact))
164 + } else { var contact = h('p', 'no contact named')}
140165
141- if (msg.value.content.following == true) {
142- var following = h('span', ' follows ', contact)
143- messageContent.appendChild(tools.mini(msg, following))
166 + if (msg.value.content.following == true) {
167 + var following = h('span', ' follows ', contact)
168 + messageContent.appendChild(tools.mini(msg, following))
169 + }
170 + if (msg.value.content.following == false) {
171 + var unfollowing = h('span', ' unfollows ', contact)
172 + messageContent.appendChild(tools.mini(msg, unfollowing))
173 + }
174 + if (msg.value.content.blocking == true) {
175 + var blocking = h('span', ' blocks ', contact)
176 + messageContent.appendChild(tools.mini(msg, blocking))
177 + }
178 + if (msg.value.content.blocking == false) {
179 + var unblocking = h('span', ' unblocks ', contact)
180 + messageContent.appendChild(tools.mini(msg, unblocking))
181 + }
182 + return message
183 +
144184 }
145- if (msg.value.content.following == false) {
146- var unfollowing = h('span', ' unfollows ', contact)
147- messageContent.appendChild(tools.mini(msg, unfollowing))
148- }
149- if (msg.value.content.blocking == true) {
150- var blocking = h('span', ' blocks ', contact)
151- messageContent.appendChild(tools.mini(msg, blocking))
152- }
153- if (msg.value.content.blocking == false) {
154- var unblocking = h('span', ' unblocks ', contact)
155- messageContent.appendChild(tools.mini(msg, unblocking))
156- }
157- return message
158185
159- }
160186
187 + if (msg.value.content.type == 'git-update') {
161188
162- if (msg.value.content.type == 'git-update') {
189 + messageContent.appendChild(tools.header(msg))
163190
164- messageContent.appendChild(tools.header(msg))
191 + var reponame = h('p', 'pushed to ', h('a', {href: '#' + msg.value.content.repo}, msg.value.content.repo))
165192
166- var reponame = h('p', 'pushed to ', h('a', {href: '#' + msg.value.content.repo}, msg.value.content.repo))
193 + var cloneurl = h('pre', 'git clone ssb://' + msg.value.content.repo)
167194
168- var cloneurl = h('pre', 'git clone ssb://' + msg.value.content.repo)
195 + messageContent.appendChild(reponame)
169196
170- messageContent.appendChild(reponame)
197 + ssbAvatar(sbot, id, msg.value.content.repo, function (err, data) {
198 + if (data) {
199 + var actualname = h('p', 'pushed to ', h('a', {href: '#' + msg.value.content.repo}, '%' + data.name))
200 + reponame.parentNode.replaceChild(actualname, reponame)
201 + }
202 + })
171203
172- ssbAvatar(sbot, id, msg.value.content.repo, function (err, data) {
173- if (data) {
174- var actualname = h('p', 'pushed to ', h('a', {href: '#' + msg.value.content.repo}, '%' + data.name))
175- reponame.parentNode.replaceChild(actualname, reponame)
204 + messageContent.appendChild(cloneurl)
205 +
206 + var commits = h('ul')
207 + if (msg.value.content.commits) {
208 + msg.value.content.commits.map(function (commit) {
209 + commits.appendChild(h('li', h('code', commit.sha1), ' - ', commit.title))
210 + })
176211 }
177- })
178212
179- messageContent.appendChild(cloneurl)
213 + messageContent.appendChild(commits)
180214
181- var commits = h('ul')
182- if (msg.value.content.commits) {
183- msg.value.content.commits.map(function (commit) {
184- commits.appendChild(h('li', h('code', commit.sha1), ' - ', commit.title))
185- })
215 + return message
186216 }
187217
188- messageContent.appendChild(commits)
218 + if (msg.value.content.type == 'git-repo') {
219 + messageContent.appendChild(tools.header(msg))
189220
190- return message
191- }
221 + var reponame = h('p', 'git-ssb repo ', h('a', {href: '#' + msg.key}, msg.key))
192222
193- if (msg.value.content.type == 'git-repo') {
194- messageContent.appendChild(tools.header(msg))
223 + messageContent.appendChild(reponame)
195224
196- var reponame = h('p', 'git-ssb repo ', h('a', {href: '#' + msg.key}, msg.key))
225 + ssbAvatar(sbot, id, msg.key, function (err, data) {
226 + if (data)
227 + var actualname = h('p', 'git-ssb repo ', h('a', {href: '#' + msg.key}, '%' + data.name))
228 + reponame.parentNode.replaceChild(actualname, reponame)
229 + })
197230
198- messageContent.appendChild(reponame)
231 + var cloneurl = h('pre', 'git clone ssb://' + msg.key)
232 + messageContent.appendChild(cloneurl)
233 + return message
234 + }
199235
200- ssbAvatar(sbot, id, msg.key, function (err, data) {
201- if (data)
202- var actualname = h('p', 'git-ssb repo ', h('a', {href: '#' + msg.key}, '%' + data.name))
203- reponame.parentNode.replaceChild(actualname, reponame)
204- })
236 + if (typeof msg.value.content === 'string') {
237 + var unboxed = ssbKeys.unbox(msg.value.content, keys)
238 + if (unboxed) {
239 + msg.value.content = unboxed
240 + msg.value.private = true
241 + return exports.render(msg)
242 + } else {
243 + var privateMsg = h('span', ' sent a private message.')
244 + messageContent.appendChild(tools.mini(msg, privateMsg))
245 + return message
246 + }
247 + }
205248
206- var cloneurl = h('pre', 'git clone ssb://' + msg.key)
207- messageContent.appendChild(cloneurl)
208- return message
209- }
249 + else {
250 + //FULL FALLBACK
251 + //message.appendChild(tools.header(msg))
252 + messageContent.appendChild(tools.header(msg))
253 + messageContent.appendChild(h('pre', tools.rawJSON(msg.value)))
210254
211- if (typeof msg.value.content === 'string') {
212- var unboxed = ssbKeys.unbox(msg.value.content, keys)
213- if (unboxed) {
214- msg.value.content = unboxed
215- msg.value.private = true
216- return module.exports(msg)
217- } else {
218- var privateMsg = h('span', ' sent a private message.')
219- messageContent.appendChild(tools.mini(msg, privateMsg))
255 + //MINI FALLBACK
256 + //var fallback = h('span', ' ' + msg.value.content.type)
257 + //message.appendChild(tools.mini(msg, fallback))
220258 return message
221259 }
222260 }
223-
224- else {
225- //FULL FALLBACK
226- //message.appendChild(tools.header(msg))
227- messageContent.appendChild(tools.header(msg))
228- messageContent.appendChild(h('pre', tools.rawJSON(msg.value)))
229-
230- //MINI FALLBACK
231- //var fallback = h('span', ' ' + msg.value.content.type)
232- //message.appendChild(tools.mini(msg, fallback))
233- return message
234- }
235261 }
style.cssView
@@ -174,4 +174,44 @@
174174 white-space: pre\9;
175175 color: violet;
176176 }
177177
178 +button {margin: 0; margin-top: -.2em;}
179 +
180 +.btn {
181 + display: inline-block;
182 + *display: inline;
183 + padding: 2px 6px;
184 + margin-bottom: 0;
185 + margin-right: .2em;
186 + font-size: 14px;
187 + line-height: 20px;
188 + color: #d5d5d5;
189 + text-align: center;
190 + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75);
191 + vertical-align: middle;
192 + cursor: pointer;
193 + background-color: #222;
194 + border: 1px solid #222;
195 + border-radius: 4px;
196 +}
197 +
198 +
199 +.btn:hover,
200 +.btn:focus,
201 +.btn:active,
202 +.btn.active,
203 +.btn.disabled,
204 +.btn[disabled] {
205 + color: white;
206 + background-color: black;
207 +}
208 +
209 +.btn:active,
210 +.btn.active {
211 + background-color: #111;
212 +}
213 +
214 +.btn:first-child {
215 + *margin-left: 0;
216 +}
217 +
style.css.jsonView
@@ -1,1 +1,1 @@
1-"body {\n margin: 0;\n background: black;\n font-family: sans-serif;\n color: #f5f5f5;\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\nhr {\n border: solid #222;\n clear: both;\n border-width: 1px 0 0;\n height: 0;\n margin-bottom: .9em;\n}\n\np {\n margin-top: .35ex;\n margin-bottom: 10px;\n}\n\na {\n color: cyan;\n text-decoration: none;\n}\n\na:hover, a:focus {\n color: violet;\n text-decoration: underline;\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: 97%;\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: 760px;\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.messageContent {\n display: block;\n margin: .6em;\n background: #111;\n padding: .7em;\n border-radius: 3px;\n border: 1px solid #252525;\n}\n\n.submessage {\n margin-left: 2em;\n}\n\n.message img, .message video {\n max-width: 100%;\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.avatar--medium img {\n float: left;\n vertical-align: top;\n width: 5em;\n height: 5em;\n margin-right: .5em;\n margin-bottom: .5em;\n}\n\n.right {\n float: right;\n margin-right: .25em;\n}\n\n.emoji {\n padding: .2em;\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 {\n overflow: auto;\n word-break: break-all;\n word-wrap: break-word;\n white-space: pre;\n white-space: -moz-pre-wrap;\n white-space: pre-wrap;\n white-space: pre\\9;\n color: violet;\n}\n\n"
1 +"body {\n margin: 0;\n background: black;\n font-family: sans-serif;\n color: #f5f5f5;\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\nhr {\n border: solid #222;\n clear: both;\n border-width: 1px 0 0;\n height: 0;\n margin-bottom: .9em;\n}\n\np {\n margin-top: .35ex;\n margin-bottom: 10px;\n}\n\na {\n color: cyan;\n text-decoration: none;\n}\n\na:hover, a:focus {\n color: violet;\n text-decoration: underline;\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: 97%;\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: 760px;\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.messageContent {\n display: block;\n margin: .6em;\n background: #111;\n padding: .7em;\n border-radius: 3px;\n border: 1px solid #252525;\n}\n\n.submessage {\n margin-left: 2em;\n}\n\n.message img, .message video {\n max-width: 100%;\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.avatar--medium img {\n float: left;\n vertical-align: top;\n width: 5em;\n height: 5em;\n margin-right: .5em;\n margin-bottom: .5em;\n}\n\n.right {\n float: right;\n margin-right: .25em;\n}\n\n.emoji {\n padding: .2em;\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 {\n overflow: auto;\n word-break: break-all;\n word-wrap: break-word;\n white-space: pre;\n white-space: -moz-pre-wrap;\n white-space: pre-wrap;\n white-space: pre\\9;\n color: violet;\n}\n\nbutton {margin: 0; margin-top: -.2em;}\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"
tools.jsView
@@ -7,14 +7,66 @@
77 var id = require('./keys').id
88 var avatar = require('./avatar')
99 var human = require('human-time')
1010
11 +
1112 module.exports.timestamp = function (msg, edited) {
1213 var timestamp = h('span.right', h('a', {href: '#' + msg.key}, human(new Date(msg.value.timestamp))))
1314 return timestamp
1415 }
1516
1617
18 +module.exports.star = function (msg) {
19 + var votebutton = h('span#votebutton:' + msg.key.substring(0, 44))
20 +
21 + var vote = {
22 + type: 'vote',
23 + vote: {link: msg.key, expression: 'Star'}
24 + }
25 +
26 + var star = h('button.btn', 'Star ',
27 + h('img.emoji', {src: config.emojiUrl + 'star.png'}), {
28 + onclick: function () {
29 + vote.vote.value = 1
30 + if (vote.recps) {
31 + vote = exports.box(vote)
32 + }
33 + sbot.publish(vote, function (err, voted) {
34 + if(err) throw err
35 + })
36 + }
37 + }
38 + )
39 +
40 + votebutton.appendChild(star)
41 +
42 + return votebutton
43 +}
44 +
45 +module.exports.unstar = function (msg) {
46 + var votebutton = h('span#votebutton:' + msg.key.substring(0, 44))
47 +
48 + var vote = {
49 + type: 'vote',
50 + vote: {link: msg.key, expression: 'Star'}
51 + }
52 +
53 + var unstar = h('button.btn ', 'Unstar ',
54 + h('img.emoji', {src: config.emojiUrl + 'stars.png'}), {
55 + onclick: function () {
56 + vote.vote.value = -1
57 + sbot.publish(vote, function (err, voted) {
58 + if(err) throw err
59 + })
60 + }
61 + }
62 + )
63 +
64 + votebutton.appendChild(unstar)
65 +
66 + return votebutton
67 +}
68 +
1769 module.exports.header = function (msg) {
1870 var header = h('div.header')
1971
2072 header.appendChild(h('span.avatar',
@@ -26,8 +78,35 @@
2678 )
2779
2880 header.appendChild(exports.timestamp(msg))
2981
82 + var lock = h('span.right', h('img.emoji', {src: config.emojiUrl + 'lock.png'}))
83 +
84 + if (msg.value.content.recps) {
85 + header.appendChild(lock)
86 + for (var i = 0; i < msg.value.content.recps.length; i++) {
87 + console.log(msg.value.content.recps[i])
88 + if (ref.isFeed(msg.value.content.recps[i].link)) {
89 + header.appendChild(h('a', {href: '#' + msg.value.content.recps[i].link}, h('span.avatar--small.right', avatar.cachedImage(msg.value.content.recps[i].link))))
90 + }
91 + if (ref.isFeed(msg.value.content.recps[i])) {
92 + header.appendChild(h('a', {href: '#' + msg.value.content.recps[i]}, h('span.avatar--small.right', avatar.cachedImage(msg.value.content.recps[i]))))
93 + }
94 + }
95 + } else if (msg.value.content.mentions) {
96 + for (var i = 0; i < msg.value.content.mentions.length; i++) {
97 + console.log(msg.value.content.mentions[i])
98 + if (ref.isFeed(msg.value.content.mentions[i].link)) {
99 + header.appendChild(h('a', {href: '#' + msg.value.content.mentions[i].link}, h('span.avatar--small.right', avatar.cachedImage(msg.value.content.mentions[i].link))))
100 + }
101 + if (ref.isFeed(msg.value.content.mentions[i])) {
102 + header.appendChild(h('a', {href: '#' + msg.value.content.mentions[i]}, h('span.avatar--small.right', avatar.cachedImage(msg.value.content.mentions[i]))))
103 + }
104 + }
105 + }
106 +
107 +
108 +
30109 return header
31110 }
32111
33112 module.exports.mini = function (msg, content) {
@@ -40,14 +119,13 @@
40119 avatar.cachedName(msg.value.author)
41120 )
42121 )
43122 )
44- var lock = h('span.right', h('img.emoji', {src: config.emojiUrl + 'lock.png'}))
45123
46-
47124 mini.appendChild(h('span', content))
48125 mini.appendChild(exports.timestamp(msg))
49126
127 + var lock = h('span.right', h('img.emoji', {src: config.emojiUrl + 'lock.png'}))
50128 if (msg.value.content.recps) {
51129 mini.appendChild(lock)
52130 }
53131
@@ -122,11 +200,13 @@
122200 }
123201
124202 module.exports.markdown = function (msg, md) {
125203 return {innerHTML: markdown.block(msg, {toUrl: function (url, image) {
204 + console.log(url)
126205 if(url[0] == '%' || url[0] == '@' || url[0] == '#') return '#' + url
127206 if(url[0] !== '&') return url
207 + if(ref.isBlobLink(url)) return config.blobsUrl + url
128208 //if(url[0] == '&') return config.blobsUrl + url
129209 //if(!image) return url
130- return config.blobsUrl + url
210 + //return config.blobsUrl + url
131211 }})}
132212 }
views.jsView
@@ -172,9 +172,9 @@
172172 }
173173
174174 pull(
175175 createStream({
176- limit: 100,
176 + limit: 250,
177177 reverse: true,
178178 live: false,
179179 query: [{$filter: { value: { timestamp: { $gt: 0 }}}}]
180180 }),
@@ -182,9 +182,9 @@
182182 )
183183
184184 pull(
185185 createStream({
186- limit: 100,
186 + limit: 250,
187187 old: false,
188188 live: true,
189189 query: [{$filter: { value: { timestamp: { $gt: 0 }}}}]
190190 }),

Built with git-ssb-web