git ssb

16+

Dominic / patchbay



Tree: f11783d11c708f64970a272ab558eb7e3ad1820b

Files: f11783d11c708f64970a272ab558eb7e3ad1820b / modules_extra / music-release-cc.js

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

Built with git-ssb-web