Files: f5019994e9135c7fd3dd5614b1006254d170cf63 / modules_extra / music-release-cc.js
2315 bytesRaw
1 | var markdown = require('ssb-markdown'); |
2 | var h = require('hyperscript'); |
3 | var u = require('../util'); |
4 | var ref = require('ssb-ref'); |
5 | |
6 | //render a message |
7 | |
8 | exports.needs = { blob_url: 'first' } |
9 | exports.gives = 'message_content' |
10 | |
11 | exports.create = function (api) { |
12 | return function(msg, sbot) { |
13 | if (msg.value.content.type !== 'music-release-cc') |
14 | return; |
15 | |
16 | var tracks = msg.value.content.tracks; |
17 | return h('div', |
18 | h('img', { "src" : api.blob_url(msg.value.content.cover) }), |
19 | h('h1', msg.value.content.title), |
20 | h('ol', |
21 | Object.keys(tracks).map(function(k) { |
22 | var t = tracks[k]; |
23 | return h('li', t.fname, |
24 | h("br"), |
25 | h('audio', { |
26 | "controls" : true, |
27 | "src" : api.blob_url(t.link) |
28 | })) |
29 | })), |
30 | h('p', |
31 | "More info:", h('a', { href : msg.value.content.archivedotorg }, "archive.org"), |
32 | h("br"), |
33 | "License:", h('a', { href : msg.value.content.license }, "Link"))) |
34 | } |
35 | } |
36 | |
37 | // copied from like.js |
38 | |
39 | // inspiration for waveform range selection |
40 | |
41 | // idea: handout invite codes for upload of tracks to be cached by the pub |
42 | |
43 | // exports.message_meta = function (msg, sbot) { |
44 | |
45 | // var yupps = h('a') |
46 | |
47 | // pull( |
48 | // sbot_links({dest: msg.key, rel: 'vote'}), |
49 | // pull.collect(function (err, votes) { |
50 | // if(votes.length === 1) |
51 | // yupps.textContent = ' 1 yup' |
52 | // if(votes.length) |
53 | // yupps.textContent = ' ' + votes.length + ' yupps' |
54 | // }) |
55 | // ) |
56 | |
57 | // return yupps |
58 | // } |
59 | |
60 | // exports.message_action = function (msg, sbot) { |
61 | // if(msg.value.content.type !== 'vote') |
62 | // return h('a', {href: '#', onclick: function () { |
63 | // var yup = { |
64 | // type: 'vote', |
65 | // vote: { link: msg.key, value: 1, expression: 'yup' } |
66 | // } |
67 | // if(msg.value.content.recps) { |
68 | // yup.recps = msg.value.content.recps.map(function (e) { |
69 | // return e && typeof e !== 'string' ? e.link : e |
70 | // }) |
71 | // yup.private = true |
72 | // } |
73 | // //TODO: actually publish... |
74 | |
75 | // message_confirm(yup) |
76 | // }}, 'yup') |
77 | |
78 | // } |
79 | |
80 | |
81 |
Built with git-ssb-web