Commit b934c63c9cd0fa08b3e84acd8cf5c8bae64e994c
basic git message render, and show if a message is private
Ev Bogue committed on 6/11/2018, 9:29:12 PMParent: 82667629e00c7d73e813e77adc04302f468562dc
Files changed
render.js | changed |
render.js | ||
---|---|---|
@@ -8,8 +8,9 @@ | ||
8 | 8 | |
9 | 9 | var config = require('./config')() |
10 | 10 | var id = require('./keys').id |
11 | 11 | |
12 | +var avatar = require('./avatar') | |
12 | 13 | |
13 | 14 | module.exports = function (msg) { |
14 | 15 | var message = h('div.message#' + msg.key.substring(0, 44)) |
15 | 16 | |
@@ -23,13 +24,50 @@ | ||
23 | 24 | message.appendChild(tools.mini(msg, muted)) |
24 | 25 | return message |
25 | 26 | } |
26 | 27 | |
27 | - if (msg.value.private == true) { | |
28 | + /*if (msg.value.private == true) { | |
28 | 29 | var privateMsg = h('span', ' ', h('img.emoji', {src: config.emojiUrl + 'lock.png'}), ' ', h('button.btn', 'Open')) |
29 | 30 | message.appendChild(tools.mini(msg, privateMsg)) |
30 | 31 | return message |
32 | + }*/ | |
33 | + else if (msg.value.content.type == 'git-update') { | |
34 | + | |
35 | + message.appendChild(tools.header(msg)) | |
36 | + | |
37 | + var reponame = h('p', 'pushed to ', h('a', {href: '#' + msg.value.content.repo}, msg.value.content.repo)) | |
38 | + | |
39 | + var cloneurl = h('pre', 'git clone ssb://' + msg.value.content.repo) | |
40 | + | |
41 | + message.appendChild(reponame) | |
42 | + | |
43 | + pull( | |
44 | + sbot.get(msg.value.content.repo, function (err, data) { | |
45 | + if (err) throw err | |
46 | + console.log(data) | |
47 | + if (data.content.name) { | |
48 | + actualname = h('p', 'pushed to ', h('a', {href: '#' + msg.value.content.repo}, '%' + data.content.name)) | |
49 | + reponame.parentNode.replaceChild(actualname, reponame) | |
50 | + } | |
51 | + }) | |
52 | + ) | |
53 | + message.appendChild(cloneurl) | |
54 | + //message.appendChild(h('pre', tools.rawJSON(msg.value))) | |
55 | + return message | |
56 | + | |
31 | 57 | } |
58 | + else if (msg.value.content.type == 'git-repo') { | |
59 | + message.appendChild(tools.header(msg)) | |
60 | + if (msg.value.content.name) { | |
61 | + message.appendChild(h('p', h('a', {href: msg.link}, '%' + msg.value.content.name))) | |
62 | + } else { | |
63 | + message.appendChild(h('p', h('a', {href: msg.link}, msg.link))) | |
64 | + } | |
65 | + var cloneurl = h('pre', 'git clone ssb://' + msg.key) | |
66 | + message.appendChild(cloneurl) | |
67 | + //message.appendChild(h('pre', tools.rawJSON(msg.value.content))) | |
68 | + return message | |
69 | + } | |
32 | 70 | |
33 | 71 | else if (msg.value.content.type == 'post') { |
34 | 72 | var opts = { |
35 | 73 | type: 'post', |
@@ -72,8 +110,12 @@ | ||
72 | 110 | var buttons = h('div.buttons') |
73 | 111 | buttons.appendChild(h('button.btn', 'Reply', { |
74 | 112 | onclick: function () { |
75 | 113 | opts.type = 'post' |
114 | + opts.mentions = '[' + avatar.name(msg.value.author).textContent + '](' + msg.value.author + ')' | |
115 | + if (msg.value.content.recps) { | |
116 | + opts.recps = msg.value.content.recps | |
117 | + } | |
76 | 118 | var r = message.childNodes.length - 1 |
77 | 119 | delete opts.updated |
78 | 120 | delete opts.original |
79 | 121 | delete fallback.messageText |
@@ -102,14 +144,10 @@ | ||
102 | 144 | message.replaceChild(compose, message.lastElementChild) |
103 | 145 | } |
104 | 146 | })) |
105 | 147 | |
148 | + buttons.appendChild(tools.done(msg.key)) | |
106 | 149 | |
107 | - var done = h('button.btn.right', '+') | |
108 | - var add = h('button.btn.right', '-') | |
109 | - | |
110 | - buttons.appendChild(done) | |
111 | - buttons.appendChild(add) | |
112 | 150 | buttons.appendChild(tools.star(msg)) |
113 | 151 | message.appendChild(buttons) |
114 | 152 | return message |
115 | 153 | |
@@ -126,14 +164,13 @@ | ||
126 | 164 | return message |
127 | 165 | } else { |
128 | 166 | |
129 | 167 | //FULL FALLBACK |
130 | - //message.appendChild(tools.header(msg)) | |
131 | - //message.appendChild(h('pre', tools.rawJSON(msg.value.content))) | |
132 | - //return message | |
168 | + message.appendChild(tools.header(msg)) | |
169 | + message.appendChild(h('pre', tools.rawJSON(msg.value.content))) | |
133 | 170 | |
134 | 171 | //MINI FALLBACK |
135 | - var fallback = h('span', ' ' + msg.value.content.type) | |
136 | - message.appendChild(tools.mini(msg, fallback)) | |
172 | + //var fallback = h('span', ' ' + msg.value.content.type) | |
173 | + //message.appendChild(tools.mini(msg, fallback)) | |
137 | 174 | return message |
138 | 175 | } |
139 | 176 | } |
Built with git-ssb-web