Commit 7478b5388306a177f85de2b6a0c3bcedf8635c87
nest other modules, remove legacy plugs code
mix irving committed on 1/16/2017, 5:53:25 AMParent: a3d2c0a84691aab64838207f75583d4e86d564b5
Files changed
embedded.js | ||
---|---|---|
@@ -1,9 +1,12 @@ | ||
1 … | +// polyfills | |
2 … | +require('setimmediate') | |
3 … | + | |
1 | 4 … | require('depject')( |
2 | 5 … | require('./modules_embedded'), |
3 | 6 … | require('./modules_basic'), |
4 | 7 … | require('./modules_extra') |
5 | -).plugs.app[0]() | |
8 … | +).app[0]() | |
6 | 9 … | |
7 | 10 … | |
8 | 11 … | |
9 | 12 … |
modules_basic/compose.js | ||
---|---|---|
@@ -5,15 +5,8 @@ | ||
5 | 5 … | const suggest = require('suggest-box') |
6 | 6 … | const mentions = require('ssb-mentions') |
7 | 7 … | const cont = require('cont') |
8 | 8 … | |
9 | -//var plugs = require('../plugs') | |
10 | -//var suggest_mentions= plugs.asyncConcat(exports.suggest_mentions = []) | |
11 | -//var publish = plugs.first(exports.sbot_publish = []) | |
12 | -//var message_content = plugs.first(exports.message_content = []) | |
13 | -//var message_confirm = plugs.first(exports.message_confirm = []) | |
14 | -//var file_input = plugs.first(exports.file_input = []) | |
15 | - | |
16 | 9 … | exports.needs = { |
17 | 10 … | suggest_mentions: 'map', //<-- THIS MUST BE REWRITTEN |
18 | 11 … | publish: 'first', |
19 | 12 … | message_content: 'first', |
modules_basic/feed.js | ||
---|---|---|
@@ -3,14 +3,8 @@ | ||
3 | 3 … | var h = require('hyperscript') |
4 | 4 … | var pull = require('pull-stream') |
5 | 5 … | var u = require('../util') |
6 | 6 … | |
7 | -//var plugs = require('../plugs') | |
8 | -//var sbot_user_feed = plugs.first(exports.sbot_user_feed = []) | |
9 | -//var message_render = plugs.first(exports.message_render = []) | |
10 | -//var avatar_profile = plugs.first(exports.avatar_profile = []) | |
11 | -//var signifier = plugs.first(exports.signifier = []) | |
12 | - | |
13 | 7 … | exports.needs = { |
14 | 8 … | sbot_user_feed: 'first', |
15 | 9 … | message_render: 'first', |
16 | 10 … | avatar_profile: 'first', |
modules_basic/follow.js | ||
---|---|---|
@@ -1,14 +1,8 @@ | ||
1 | 1 … | var h = require('hyperscript') |
2 | 2 … | var u = require('../util') |
3 | 3 … | var pull = require('pull-stream') |
4 | 4 … | |
5 | -//var plugs = require('../plugs') | |
6 | -//var avatar = plugs.first(exports.avatar = []) | |
7 | -//var avatar_name = plugs.first(exports.avatar_name = []) | |
8 | -//var avatar_link = plugs.first(exports.avatar_link = []) | |
9 | -//var message_confirm = plugs.first(exports.message_confirm = []) | |
10 | -//var follower_of = plugs.first(exports.follower_of = []) | |
11 | 5 … | |
12 | 6 … | //render a message when someone follows someone, |
13 | 7 … | //so you see new users |
14 | 8 … | function isRelated(value, name) { |
modules_basic/index.js | |||
---|---|---|---|
@@ -1,35 +1,37 @@ | |||
1 | 1 … | module.exports = { | |
2 | - "about.js": require('./about'), | ||
3 | - "avatar-edit.js": require('./avatar-edit'), | ||
4 | - "avatar-image.js": require('./avatar-image'), | ||
5 | - "avatar-link.js": require('./avatar-link'), | ||
6 | - "avatar-name.js": require('./avatar-name'), | ||
7 | - "avatar-profile.js": require('./avatar-profile'), | ||
8 | - "avatar.js": require('./avatar'), | ||
9 | - "compose.js": require('./compose'), | ||
10 | - "feed.js": require('./feed'), | ||
11 | - "follow.js": require('./follow'), | ||
12 | - "invite.js": require('./invite'), | ||
13 | - "like.js": require('./like'), | ||
14 | - "markdown.js": require('./markdown'), | ||
15 | - message: { | ||
16 | - author: require('./message/author'), | ||
17 | - backlinks: require('./message/backlinks'), | ||
18 | - link: require('./message/link'), | ||
19 | - name: require('./message/name'), | ||
20 | - render: require('./message/render'), | ||
2 … | + 'about': require('./about'), | ||
3 … | + 'avatar': { | ||
4 … | + 'edit': require('./avatar/edit'), | ||
5 … | + 'image': require('./avatar/image'), | ||
6 … | + 'link': require('./avatar/link'), | ||
7 … | + 'name': require('./avatar/name'), | ||
8 … | + 'profile': require('./avatar/profile'), | ||
9 … | + 'avatar': require('./avatar/avatar') | ||
21 | 10 … | }, | |
22 | - "names.js": require('./names'), | ||
23 | - "post.js": require('./post'), | ||
24 | - "private.js": require('./private'), | ||
25 | - "pub.js": require('./pub'), | ||
26 | - "public.js": require('./public'), | ||
27 | - "relationships.js": require('./relationships'), | ||
28 | - "reply.js": require('./reply'), | ||
29 | - "search-box.js": require('./search-box'), | ||
30 | - "setup.js": require('./setup'), | ||
31 | - "suggest-mentions.js": require('./suggest-mentions'), | ||
32 | - "thread.js": require('./thread'), | ||
33 | - "timestamp.js": require('./timestamp') | ||
11 … | + 'compose': require('./compose'), | ||
12 … | + 'feed': require('./feed'), | ||
13 … | + 'follow': require('./follow'), | ||
14 … | + 'invite': require('./invite'), | ||
15 … | + 'like': require('./like'), | ||
16 … | + 'markdown': require('./markdown'), | ||
17 … | + 'message': { | ||
18 … | + 'author': require('./message/author'), | ||
19 … | + 'backlinks': require('./message/backlinks'), | ||
20 … | + 'link': require('./message/link'), | ||
21 … | + 'name': require('./message/name'), | ||
22 … | + 'render': require('./message/render'), | ||
23 … | + }, | ||
24 … | + 'names': require('./names'), | ||
25 … | + 'post': require('./post'), | ||
26 … | + 'private': require('./private'), | ||
27 … | + 'pub': require('./pub'), | ||
28 … | + 'public': require('./public'), | ||
29 … | + 'relationships': require('./relationships'), | ||
30 … | + 'reply': require('./reply'), | ||
31 … | + 'search-box': require('./search-box'), | ||
32 … | + 'setup': require('./setup'), | ||
33 … | + 'suggest-mentions': require('./suggest-mentions'), | ||
34 … | + 'thread': require('./thread'), | ||
35 … | + 'timestamp': require('./timestamp') | ||
34 | 36 … | } | |
35 | 37 … |
modules_basic/invite.js | ||
---|---|---|
@@ -5,13 +5,8 @@ | ||
5 | 5 … | var h = require('hyperscript') |
6 | 6 … | |
7 | 7 … | var Progress = require('hyperprogress') |
8 | 8 … | |
9 | -//var plugs = require('../plugs') | |
10 | -//var sbot_publish = plugs.first(exports.sbot_publish = []) | |
11 | -//var sbot_gossip_connect = plugs.first(exports.sbot_gossip_connect = []) | |
12 | -//var follower_of = plugs.first(exports.follower_of = []) | |
13 | - | |
14 | 9 … | exports.needs = { |
15 | 10 … | sbot_publish: 'first', |
16 | 11 … | sbot_gossip_connect: 'first', |
17 | 12 … | follower_of: 'first', |
modules_basic/like.js | ||
---|---|---|
@@ -2,14 +2,8 @@ | ||
2 | 2 … | var h = require('hyperscript') |
3 | 3 … | var u = require('../util') |
4 | 4 … | var pull = require('pull-stream') |
5 | 5 … | |
6 | -var plugs = require('../plugs') | |
7 | - | |
8 | -//var message_confirm = plugs.first(exports.message_confirm = []) | |
9 | -//var message_link = plugs.first(exports.message_link = []) | |
10 | -//var sbot_links = plugs.first(exports.sbot_links = []) | |
11 | - | |
12 | 6 … | exports.needs = { |
13 | 7 … | avatar_name: 'first', |
14 | 8 … | message_confirm: 'first', |
15 | 9 … | message_link: 'first', |
modules_basic/message/link.js | ||
---|---|---|
@@ -1,11 +1,7 @@ | ||
1 | 1 … | var h = require('hyperscript') |
2 | 2 … | var ref = require('ssb-ref') |
3 | 3 … | |
4 | -//var first = require('../plugs').first | |
5 | -//var sbot_get = first(exports.sbot_get = []) | |
6 | -//var message_name = first(exports.message_name = []) | |
7 | - | |
8 | 4 … | exports.needs = { |
9 | 5 … | message_name: 'first' |
10 | 6 … | } |
11 | 7 … |
modules_basic/names.js | ||
---|---|---|
@@ -5,12 +5,8 @@ | ||
5 | 5 … | function all(stream, cb) { |
6 | 6 … | pull(stream, pull.collect(cb)) |
7 | 7 … | } |
8 | 8 … | |
9 | -//var plugs = require('../plugs') | |
10 | -//var sbot_links2 = plugs.first(exports.sbot_links2 = []) | |
11 | -//var sbot_query = plugs.first(exports.sbot_query = []) | |
12 | -// | |
13 | 9 … | exports.needs = { |
14 | 10 … | sbot_links2: 'first', |
15 | 11 … | sbot_query: 'first' |
16 | 12 … | } |
modules_basic/post.js | ||
---|---|---|
@@ -4,13 +4,8 @@ | ||
4 | 4 … | var ref = require('ssb-ref') |
5 | 5 … | |
6 | 6 … | //render a message |
7 | 7 … | |
8 | -//var plugs = require('../plugs') | |
9 | -//var message_link = plugs.first(exports.message_link = []) | |
10 | -//var markdown = plugs.first(exports.markdown = []) | |
11 | -// | |
12 | - | |
13 | 8 … | exports.needs = { |
14 | 9 … | message_link: 'first', |
15 | 10 … | markdown: 'first' |
16 | 11 … | } |
modules_basic/pub.js | ||
---|---|---|
@@ -1,9 +1,6 @@ | ||
1 | 1 … | var h = require('hyperscript') |
2 | -//var plugs = require('../plugs') | |
3 | -//var avatar_name = plugs.first(exports.avatar_name = []) | |
4 | -//var avatar_link = plugs.first(exports.avatar_link = []) | |
5 | -// | |
2 … | + | |
6 | 3 … | exports.needs = { |
7 | 4 … | avatar_name: 'first', |
8 | 5 … | avatar_link: 'first' |
9 | 6 … | } |
modules_basic/public.js | ||
---|---|---|
@@ -2,13 +2,8 @@ | ||
2 | 2 … | var u = require('../util') |
3 | 3 … | var pull = require('pull-stream') |
4 | 4 … | var Scroller = require('pull-scroll') |
5 | 5 … | |
6 | -//var plugs = require('../plugs') | |
7 | -//var message_render = plugs.first(exports.message_render = []) | |
8 | -//var message_compose = plugs.first(exports.message_compose = []) | |
9 | -//var sbot_log = plugs.first(exports.sbot_log = []) | |
10 | - | |
11 | 6 … | exports.needs = { |
12 | 7 … | message_render: 'first', |
13 | 8 … | message_compose: 'first', |
14 | 9 … | sbot_log: 'first', |
modules_basic/relationships.js | ||
---|---|---|
@@ -1,22 +1,19 @@ | ||
1 | 1 … | var pull = require('pull-stream') |
2 | -//var plugs = require('../plugs') | |
3 | 2 … | |
4 | -//var sbot_query = plugs.first(exports.sbot_query = []) | |
5 | - | |
6 | 3 … | //this is a bit crude, and doesn't actually show unfollows yet. |
7 | 4 … | |
8 | 5 … | function makeQuery (a, b) { |
9 | 6 … | return {"$filter": { |
10 | - value: { | |
11 | - author: a, | |
12 | - content: { | |
13 | - type: 'contact', | |
14 | - contact: b, | |
15 | - following: true | |
16 | - } | |
17 | - }, | |
18 | - }} | |
7 … | + value: { | |
8 … | + author: a, | |
9 … | + content: { | |
10 … | + type: 'contact', | |
11 … | + contact: b, | |
12 … | + following: true | |
13 … | + } | |
14 … | + }, | |
15 … | + }} | |
19 | 16 … | } |
20 | 17 … | |
21 | 18 … | |
22 | 19 … | exports.needs = { sbot_query: 'first' } |
modules_basic/search-box.js | ||
---|---|---|
@@ -3,13 +3,8 @@ | ||
3 | 3 … | var h = require('hyperscript') |
4 | 4 … | var suggest = require('suggest-box') |
5 | 5 … | var pull = require('pull-stream') |
6 | 6 … | |
7 | -//var plugs = require('../plugs') | |
8 | -//var sbot_query = plugs.first(exports.sbot_query = []) | |
9 | -//var sbot_links2 = plugs.first(exports.sbot_links2 = []) | |
10 | -//var suggest_search = plugs.asyncConcat(exports.suggest_search = []) | |
11 | - | |
12 | 7 … | exports.needs = { |
13 | 8 … | sbot_query: 'first', sbot_links2: 'first', |
14 | 9 … | suggest_search: 'map' //REWRITE |
15 | 10 … | } |
modules_basic/setup.js | ||
---|---|---|
@@ -1,17 +1,8 @@ | ||
1 | 1 … | |
2 | 2 … | var h = require('hyperscript') |
3 | 3 … | var pull = require('pull-stream') |
4 | 4 … | |
5 | -//var plugs = require('../plugs') | |
6 | -// | |
7 | -//var avatar_edit = plugs.first(exports.avatar_edit = []) | |
8 | -//var invite_parse = plugs.first(exports.invite_parse = []) | |
9 | -//var invite_accept = plugs.first(exports.invite_accept = []) | |
10 | -//var sbot_progress = plugs.first(exports.sbot_progress = []) | |
11 | -//var sbot_query = plugs.first(exports.sbot_query = []) | |
12 | -//var avatar = plugs.first(exports.avatar = []) | |
13 | - | |
14 | 5 … | exports.needs = { |
15 | 6 … | avatar: 'first', |
16 | 7 … | avatar_edit: 'first', |
17 | 8 … | invite_parse: 'first', |
modules_basic/suggest-mentions.js | ||
---|---|---|
@@ -2,13 +2,8 @@ | ||
2 | 2 … | function isImage (filename) { |
3 | 3 … | return /\.(gif|jpg|png|svg)$/i.test(filename) |
4 | 4 … | } |
5 | 5 … | |
6 | -//var sbot_links2 = require('../plugs').first(exports.sbot_links2 = []) | |
7 | -//var blob_url = require('../plugs').first(exports.blob_url = []) | |
8 | -//var signified = require('../plugs').first(exports.signified = []) | |
9 | -//var builtin_tabs = require('../plugs').map(exports.builtin_tabs = []) | |
10 | - | |
11 | 6 … | exports.needs = { |
12 | 7 … | sbot_links2: 'first', |
13 | 8 … | blob_url: 'first', |
14 | 9 … | signified: 'first', |
modules_basic/thread.js | ||
---|---|---|
@@ -20,18 +20,8 @@ | ||
20 | 20 … | }) |
21 | 21 … | } |
22 | 22 … | } |
23 | 23 … | |
24 | -//var plugs = require('../plugs') | |
25 | -// | |
26 | -//var message_render = plugs.first(exports.message_render = []) | |
27 | -//var message_name = plugs.first(exports.message_name = []) | |
28 | -//var message_compose = plugs.first(exports.message_compose = []) | |
29 | -//var message_unbox = plugs.first(exports.message_unbox = []) | |
30 | -// | |
31 | -//var sbot_get = plugs.first(exports.sbot_get = []) | |
32 | -//var sbot_links = plugs.first(exports.sbot_links = []) | |
33 | - | |
34 | 24 … | exports.needs = { |
35 | 25 … | message_render: 'first', |
36 | 26 … | message_name: 'first', |
37 | 27 … | message_compose: 'first', |
modules_basic/avatar-edit.js | ||
---|---|---|
@@ -1,152 +1,0 @@ | ||
1 | -'use strict' | |
2 | -var dataurl = require('dataurl-') | |
3 | -var hyperfile = require('hyperfile') | |
4 | -var hypercrop = require('hypercrop') | |
5 | -var hyperlightbox = require('hyperlightbox') | |
6 | -var h = require('hyperscript') | |
7 | -var pull = require('pull-stream') | |
8 | -var getAvatar = require('ssb-avatar') | |
9 | -var plugs = require('../plugs') | |
10 | -var ref = require('ssb-ref') | |
11 | -var visualize = require('visualize-buffer') | |
12 | -var self_id = require('../keys').id | |
13 | - | |
14 | -//var confirm = plugs.first(exports.message_confirm = []) | |
15 | -//var sbot_blobs_add = plugs.first(exports.sbot_blobs_add = []) | |
16 | -//var blob_url = plugs.first(exports.blob_url = []) | |
17 | -//var sbot_links = plugs.first(exports.sbot_links = []) | |
18 | -//var avatar_name = plugs.first(exports.avatar_name = []) | |
19 | -// | |
20 | - | |
21 | -function crop (d, cb) { | |
22 | - var data | |
23 | - var canvas = hypercrop(h('img', {src: d})) | |
24 | - | |
25 | - return h('div.column.avatar_pic', | |
26 | - canvas, | |
27 | - //canvas.selection, | |
28 | - h('div.row.avatar_pic__controls', | |
29 | - h('button', 'okay', {onclick: function () { | |
30 | - cb(null, canvas.selection.toDataURL()) | |
31 | - }}), | |
32 | - h('button', 'cancel', {onclick: function () { | |
33 | - cb(new Error('canceled')) | |
34 | - }}) | |
35 | - ) | |
36 | - ) | |
37 | -} | |
38 | - | |
39 | -exports.needs = { | |
40 | - message_confirm: 'first', | |
41 | - sbot_blobs_add: 'first', | |
42 | - blob_url: 'first', | |
43 | - sbot_links: 'first', | |
44 | - avatar_name: 'first' | |
45 | -} | |
46 | - | |
47 | -exports.gives = 'avatar_edit' | |
48 | - | |
49 | -exports.create = function (api) { | |
50 | - return function (id) { | |
51 | - | |
52 | - var img = visualize(new Buffer(id.substring(1), 'base64'), 256) | |
53 | - img.classList.add('avatar--large') | |
54 | - | |
55 | - var lb = hyperlightbox() | |
56 | - var name_input = h('input', {placeholder: 'rename'}) | |
57 | - var name = api.avatar_name(id) | |
58 | - var selected = null, selected_data = null | |
59 | - | |
60 | - getAvatar({links: api.sbot_links}, self_id, id, function (err, avatar) { | |
61 | - if (err) return console.error(err) | |
62 | - //don't show user has already selected an avatar. | |
63 | - if(selected) return | |
64 | - if(ref.isBlob(avatar.image)) | |
65 | - img.src = api.blob_url(avatar.image) | |
66 | - }) | |
67 | - | |
68 | - var also_pictured = h('div.profile__alsopicturedas.wrap') | |
69 | - | |
70 | - pull( | |
71 | - api.sbot_links({dest: id, rel: 'about', values: true}), | |
72 | - pull.map(function (e) { | |
73 | - return e.value.content.image | |
74 | - }), | |
75 | - pull.filter(function (e) { | |
76 | - return e && 'string' == typeof e.link | |
77 | - }), | |
78 | - pull.unique('link'), | |
79 | - pull.drain(function (image) { | |
80 | - also_pictured.appendChild( | |
81 | - h('a', {href:'#', onclick: function (ev) { | |
82 | - ev.stopPropagation() | |
83 | - ev.preventDefault() | |
84 | - selected = image | |
85 | - img.src = api.blob_url(image.link || image) | |
86 | - }}, | |
87 | - h('img.avatar--thumbnail', {src: api.blob_url(image)}) | |
88 | - ) | |
89 | - ) | |
90 | - }) | |
91 | - ) | |
92 | - | |
93 | - return h('div.row.profile', | |
94 | - lb, | |
95 | - img, | |
96 | - h('div.column.profile__info', | |
97 | - h('strong', name), | |
98 | - name_input, | |
99 | - | |
100 | - hyperfile.asDataURL(function (data) { | |
101 | - var el = crop(data, function (err, data) { | |
102 | - if(data) { | |
103 | - img.src = data | |
104 | - var _data = dataurl.parse(data) | |
105 | - pull( | |
106 | - pull.once(_data.data), | |
107 | - api.sbot_blobs_add(function (err, hash) { | |
108 | - //TODO. Alerts are EVIL. | |
109 | - //I use them only in a moment of weakness. | |
110 | - | |
111 | - if(err) return alert(err.stack) | |
112 | - selected = { | |
113 | - link: hash, | |
114 | - size: _data.data.length, | |
115 | - type: _data.mimetype, | |
116 | - width: 512, | |
117 | - height: 512 | |
118 | - } | |
119 | - | |
120 | - }) | |
121 | - ) | |
122 | - } | |
123 | - lb.close() | |
124 | - }) | |
125 | - lb.show(el) | |
126 | - }), | |
127 | - h('button', 'update', {onclick: function () { | |
128 | - if(name_input.value) | |
129 | - name.textContent = name_input.value | |
130 | - | |
131 | - if(selected) | |
132 | - api.message_confirm({ | |
133 | - type: 'about', | |
134 | - about: id, | |
135 | - name: name_input.value || undefined, | |
136 | - image: selected | |
137 | - }) | |
138 | - else if(name_input.value) //name only | |
139 | - api.message_confirm({ | |
140 | - type: 'about', | |
141 | - about: id, | |
142 | - name: name_input.value || undefined, | |
143 | - }) | |
144 | - else | |
145 | - //another moment of weakness | |
146 | - alert('must select a name or image') | |
147 | - }}), | |
148 | - also_pictured | |
149 | - ) | |
150 | - ) | |
151 | - } | |
152 | -} |
modules_basic/avatar/avatar.js | ||
---|---|---|
@@ -1,0 +1,45 @@ | ||
1 … | +var h = require('hyperscript') | |
2 … | +var u = require('../../util') | |
3 … | + | |
4 … | +exports.needs = { | |
5 … | + avatar_name: 'first', | |
6 … | + avatar_image: 'first', | |
7 … | + avatar_link: 'first' | |
8 … | +} | |
9 … | + | |
10 … | +exports.gives = { | |
11 … | + avatar: true, | |
12 … | + avatar_image_name_link: true, | |
13 … | + avatar_image_link: true, | |
14 … | + avatar_name_link: true | |
15 … | +} | |
16 … | + | |
17 … | +exports.create = function (api) { | |
18 … | + return { | |
19 … | + avatar, | |
20 … | + avatar_image_name_link, | |
21 … | + avatar_image_link, | |
22 … | + avatar_name_link | |
23 … | + } | |
24 … | + | |
25 … | + function avatar (author, classes) { | |
26 … | + return exports.avatar_image_name_link(author, classes) | |
27 … | + } | |
28 … | + | |
29 … | + function avatar_image_name_link (author, classes) { | |
30 … | + return api.avatar_link(author, [ | |
31 … | + api.avatar_image(author, classes), | |
32 … | + api.avatar_name(author) | |
33 … | + ]) | |
34 … | + } | |
35 … | + | |
36 … | + function avatar_image_link (author, classes) { | |
37 … | + return api.avatar_link(author, api.avatar_image(author, classes)) | |
38 … | + } | |
39 … | + | |
40 … | + function avatar_name_link (author, classes) { | |
41 … | + return api.avatar_link(author, api.avatar_name(author)) | |
42 … | + } | |
43 … | +} | |
44 … | + | |
45 … | + |
modules_basic/avatar/edit.js | ||
---|---|---|
@@ -1,0 +1,144 @@ | ||
1 … | +'use strict' | |
2 … | +var dataurl = require('dataurl-') | |
3 … | +var hyperfile = require('hyperfile') | |
4 … | +var hypercrop = require('hypercrop') | |
5 … | +var hyperlightbox = require('hyperlightbox') | |
6 … | +var h = require('hyperscript') | |
7 … | +var pull = require('pull-stream') | |
8 … | +var getAvatar = require('ssb-avatar') | |
9 … | +var ref = require('ssb-ref') | |
10 … | +var visualize = require('visualize-buffer') | |
11 … | +var self_id = require('../../keys').id | |
12 … | + | |
13 … | +function crop (d, cb) { | |
14 … | + var data | |
15 … | + var canvas = hypercrop(h('img', {src: d})) | |
16 … | + | |
17 … | + return h('div.column.avatar_pic', | |
18 … | + canvas, | |
19 … | + //canvas.selection, | |
20 … | + h('div.row.avatar_pic__controls', | |
21 … | + h('button', 'okay', {onclick: function () { | |
22 … | + cb(null, canvas.selection.toDataURL()) | |
23 … | + }}), | |
24 … | + h('button', 'cancel', {onclick: function () { | |
25 … | + cb(new Error('canceled')) | |
26 … | + }}) | |
27 … | + ) | |
28 … | + ) | |
29 … | +} | |
30 … | + | |
31 … | +exports.needs = { | |
32 … | + message_confirm: 'first', | |
33 … | + sbot_blobs_add: 'first', | |
34 … | + blob_url: 'first', | |
35 … | + sbot_links: 'first', | |
36 … | + avatar_name: 'first' | |
37 … | +} | |
38 … | + | |
39 … | +exports.gives = 'avatar_edit' | |
40 … | + | |
41 … | +exports.create = function (api) { | |
42 … | + return function (id) { | |
43 … | + | |
44 … | + var img = visualize(new Buffer(id.substring(1), 'base64'), 256) | |
45 … | + img.classList.add('avatar--large') | |
46 … | + | |
47 … | + var lb = hyperlightbox() | |
48 … | + var name_input = h('input', {placeholder: 'rename'}) | |
49 … | + var name = api.avatar_name(id) | |
50 … | + var selected = null, selected_data = null | |
51 … | + | |
52 … | + getAvatar({links: api.sbot_links}, self_id, id, function (err, avatar) { | |
53 … | + if (err) return console.error(err) | |
54 … | + //don't show user has already selected an avatar. | |
55 … | + if(selected) return | |
56 … | + if(ref.isBlob(avatar.image)) | |
57 … | + img.src = api.blob_url(avatar.image) | |
58 … | + }) | |
59 … | + | |
60 … | + var also_pictured = h('div.profile__alsopicturedas.wrap') | |
61 … | + | |
62 … | + pull( | |
63 … | + api.sbot_links({dest: id, rel: 'about', values: true}), | |
64 … | + pull.map(function (e) { | |
65 … | + return e.value.content.image | |
66 … | + }), | |
67 … | + pull.filter(function (e) { | |
68 … | + return e && 'string' == typeof e.link | |
69 … | + }), | |
70 … | + pull.unique('link'), | |
71 … | + pull.drain(function (image) { | |
72 … | + also_pictured.appendChild( | |
73 … | + h('a', {href:'#', onclick: function (ev) { | |
74 … | + ev.stopPropagation() | |
75 … | + ev.preventDefault() | |
76 … | + selected = image | |
77 … | + img.src = api.blob_url(image.link || image) | |
78 … | + }}, | |
79 … | + h('img.avatar--thumbnail', {src: api.blob_url(image)}) | |
80 … | + ) | |
81 … | + ) | |
82 … | + }) | |
83 … | + ) | |
84 … | + | |
85 … | + return h('div.row.profile', | |
86 … | + lb, | |
87 … | + img, | |
88 … | + h('div.column.profile__info', | |
89 … | + h('strong', name), | |
90 … | + name_input, | |
91 … | + | |
92 … | + hyperfile.asDataURL(function (data) { | |
93 … | + var el = crop(data, function (err, data) { | |
94 … | + if(data) { | |
95 … | + img.src = data | |
96 … | + var _data = dataurl.parse(data) | |
97 … | + pull( | |
98 … | + pull.once(_data.data), | |
99 … | + api.sbot_blobs_add(function (err, hash) { | |
100 … | + //TODO. Alerts are EVIL. | |
101 … | + //I use them only in a moment of weakness. | |
102 … | + | |
103 … | + if(err) return alert(err.stack) | |
104 … | + selected = { | |
105 … | + link: hash, | |
106 … | + size: _data.data.length, | |
107 … | + type: _data.mimetype, | |
108 … | + width: 512, | |
109 … | + height: 512 | |
110 … | + } | |
111 … | + | |
112 … | + }) | |
113 … | + ) | |
114 … | + } | |
115 … | + lb.close() | |
116 … | + }) | |
117 … | + lb.show(el) | |
118 … | + }), | |
119 … | + h('button', 'update', {onclick: function () { | |
120 … | + if(name_input.value) | |
121 … | + name.textContent = name_input.value | |
122 … | + | |
123 … | + if(selected) | |
124 … | + api.message_confirm({ | |
125 … | + type: 'about', | |
126 … | + about: id, | |
127 … | + name: name_input.value || undefined, | |
128 … | + image: selected | |
129 … | + }) | |
130 … | + else if(name_input.value) //name only | |
131 … | + api.message_confirm({ | |
132 … | + type: 'about', | |
133 … | + about: id, | |
134 … | + name: name_input.value || undefined, | |
135 … | + }) | |
136 … | + else | |
137 … | + //another moment of weakness | |
138 … | + alert('must select a name or image') | |
139 … | + }}), | |
140 … | + also_pictured | |
141 … | + ) | |
142 … | + ) | |
143 … | + } | |
144 … | +} |
modules_basic/avatar/image.js | ||
---|---|---|
@@ -1,0 +1,111 @@ | ||
1 … | +'use strict' | |
2 … | +var getAvatar = require('ssb-avatar') | |
3 … | +var h = require('hyperscript') | |
4 … | +var ref = require('ssb-ref') | |
5 … | +var path = require('path') | |
6 … | +var visualize = require('visualize-buffer') | |
7 … | + | |
8 … | +var pull = require('pull-stream') | |
9 … | + | |
10 … | +var self_id = require('../../keys').id | |
11 … | + | |
12 … | +exports.needs = { | |
13 … | + sbot_query: 'first', | |
14 … | + blob_url: 'first' | |
15 … | +} | |
16 … | + | |
17 … | +exports.gives = { | |
18 … | + connection_status: true, avatar_image: true | |
19 … | +} | |
20 … | + | |
21 … | +function isFunction (f) { | |
22 … | + return 'function' === typeof f | |
23 … | +} | |
24 … | + | |
25 … | + | |
26 … | +var ready = false | |
27 … | +var waiting = [] | |
28 … | + | |
29 … | +var last = 0 | |
30 … | + | |
31 … | +var cache = {} | |
32 … | + | |
33 … | +exports.create = function (api) { | |
34 … | + var avatars = {} | |
35 … | + | |
36 … | + //blah blah | |
37 … | + return { | |
38 … | + connection_status: function (err) { | |
39 … | + if (err) return | |
40 … | + pull( | |
41 … | + api.sbot_query({ | |
42 … | + query: [{ | |
43 … | + $filter: { | |
44 … | + timestamp: {$gt: last || 0 }, | |
45 … | + value: { content: { | |
46 … | + type: "about", | |
47 … | + about: {$prefix: "@"}, | |
48 … | + image: {link: {$prefix: "&"}} | |
49 … | + }} | |
50 … | + }}, | |
51 … | + { | |
52 … | + $map: { | |
53 … | + id: ["value", "content", "about"], | |
54 … | + image: ["value", "content", "image", "link"], | |
55 … | + by: ["value", "author"], | |
56 … | + ts: 'timestamp' | |
57 … | + }}], | |
58 … | + live: true | |
59 … | + }), | |
60 … | + pull.drain(function (a) { | |
61 … | + if(a.sync) { | |
62 … | + ready = true | |
63 … | + while(waiting.length) waiting.shift()() | |
64 … | + return | |
65 … | + } | |
66 … | + last = a.ts | |
67 … | + //set image for avatar. | |
68 … | + //overwrite another avatar | |
69 … | + //you picked. | |
70 … | + if( | |
71 … | + //if there is no avatar | |
72 … | + (!avatars[a.id]) || | |
73 … | + //if i chose this avatar | |
74 … | + (a.by == self_id) || | |
75 … | + //they chose their own avatar, | |
76 … | + //and current avatar was not chosen by me | |
77 … | + (a.by === a.id && avatars[a.id].by != self_id) | |
78 … | + ) | |
79 … | + avatars[a.id] = a | |
80 … | + | |
81 … | + }) | |
82 … | + ) | |
83 … | + }, | |
84 … | + | |
85 … | + avatar_image: function (author, classes) { | |
86 … | + classes = classes || '' | |
87 … | + if(classes && 'string' === typeof classes) classes = '.avatar--'+classes | |
88 … | + | |
89 … | + function gen (id) { | |
90 … | + if(cache[id]) return h('img', {src: cache[id]}) | |
91 … | + var img = visualize(new Buffer(author.substring(1), 'base64'), 256) | |
92 … | + cache[id] = img.src | |
93 … | + return img | |
94 … | + } | |
95 … | + | |
96 … | + var img = ready && avatars[author] ? h('img', {src: api.blob_url(avatars[author].image)}) : gen(author) | |
97 … | + | |
98 … | + ;(classes || '').split('.').filter(Boolean).forEach(function (c) { | |
99 … | + img.classList.add(c) | |
100 … | + }) | |
101 … | + | |
102 … | + if(!ready) | |
103 … | + waiting.push(function () { | |
104 … | + if(avatars[author]) img.src = api.blob_url(avatars[author].image) | |
105 … | + }) | |
106 … | + | |
107 … | + return img | |
108 … | + } | |
109 … | + } | |
110 … | +} | |
111 … | + |
modules_basic/avatar/link.js | ||
---|---|---|
@@ -1,0 +1,24 @@ | ||
1 … | +var h = require('hyperscript') | |
2 … | + | |
3 … | +exports.needs = { | |
4 … | + signifier: 'first' | |
5 … | +} | |
6 … | + | |
7 … | +exports.gives = 'avatar_link' | |
8 … | + | |
9 … | +exports.create = function (api) { | |
10 … | + return function (id, element) { | |
11 … | + | |
12 … | + var link = h('a.avatar', {href: "#"+id, title: id}, element) | |
13 … | + | |
14 … | + api.signifier(id, function (_, names) { | |
15 … | + if(names.length) | |
16 … | + link.title = names[0].name + '\n '+id | |
17 … | + }) | |
18 … | + | |
19 … | + return link | |
20 … | + } | |
21 … | +} | |
22 … | + | |
23 … | + | |
24 … | + |
modules_basic/avatar/name.js | ||
---|---|---|
@@ -1,0 +1,29 @@ | ||
1 … | +var h = require('hyperscript') | |
2 … | + | |
3 … | +exports.needs = { | |
4 … | + signifier: 'first' | |
5 … | +} | |
6 … | + | |
7 … | +exports.gives = 'avatar_name' | |
8 … | + | |
9 … | +exports.create = function (api) { | |
10 … | + | |
11 … | + return function name (id) { | |
12 … | + var n = h('span', id ? id.substring(0, 10) : "") | |
13 … | + | |
14 … | + //choose the most popular name for this person. | |
15 … | + //for anything like this you'll see I have used sbot.links2 | |
16 … | + //which is the ssb-links plugin. as you'll see the query interface | |
17 … | + //is pretty powerful! | |
18 … | + //TODO: "most popular" name is easily gameable. | |
19 … | + //must come up with something better than this. | |
20 … | + | |
21 … | + api.signifier(id, function (_, names) { | |
22 … | + if(names.length) n.textContent = names[0].name | |
23 … | + }) | |
24 … | + | |
25 … | + return n | |
26 … | + } | |
27 … | + | |
28 … | +} | |
29 … | + |
modules_basic/avatar/profile.js | ||
---|---|---|
@@ -1,0 +1,80 @@ | ||
1 … | +var h = require('hyperscript') | |
2 … | +var pull = require('pull-stream') | |
3 … | + | |
4 … | +exports.needs = { | |
5 … | + avatar_image_link: 'first', | |
6 … | + avatar_action: 'map', | |
7 … | + avatar_edit: 'first', | |
8 … | + follows: 'first', | |
9 … | + followers: 'first' | |
10 … | +} | |
11 … | + | |
12 … | +exports.gives = 'avatar_profile' | |
13 … | + | |
14 … | +function streamToList(stream, el) { | |
15 … | + pull( | |
16 … | + stream, | |
17 … | + pull.drain(function (item) { | |
18 … | + if(item) el.appendChild(item) | |
19 … | + }) | |
20 … | + ) | |
21 … | + return el | |
22 … | +} | |
23 … | + | |
24 … | +exports.create = function (api) { | |
25 … | + | |
26 … | + function image_link (id) { | |
27 … | + return api.avatar_image_link(id, 'thumbnail') | |
28 … | + } | |
29 … | + | |
30 … | + return function (id) { | |
31 … | + | |
32 … | + var follows_el = h('div.profile__follows.wrap') | |
33 … | + var friends_el = h('div.profile__friendss.wrap') | |
34 … | + var followers_el = h('div.profile__followers.wrap') | |
35 … | + var a, b | |
36 … | + | |
37 … | + pull(api.follows(id), pull.unique(), pull.collect(function (err, ary) { | |
38 … | + a = ary || []; next() | |
39 … | + })) | |
40 … | + pull(api.followers(id), pull.unique(), pull.collect(function (err, ary) { | |
41 … | + b = ary || {}; next() | |
42 … | + })) | |
43 … | + | |
44 … | + function next () { | |
45 … | + if(!(a && b)) return | |
46 … | + var _c = [], _a = [], _b = [] | |
47 … | + | |
48 … | + a.forEach(function (id) { | |
49 … | + if(!~b.indexOf(id)) _a.push(id) | |
50 … | + else _c.push(id) | |
51 … | + }) | |
52 … | + b.forEach(function (id) { | |
53 … | + if(!~_c.indexOf(id)) _b.push(id) | |
54 … | + }) | |
55 … | + function add (ary, el) { | |
56 … | + ary.forEach(function (id) { el.appendChild(image_link(id)) }) | |
57 … | + } | |
58 … | + | |
59 … | + add(_a, follows_el) | |
60 … | + add(_c, friends_el) | |
61 … | + add(_b, followers_el) | |
62 … | + } | |
63 … | + | |
64 … | + | |
65 … | + return h('div.column.profile', | |
66 … | + api.avatar_edit(id), | |
67 … | + api.avatar_action(id), | |
68 … | + h('div.profile__relationships.column', | |
69 … | + h('strong', 'follows'), | |
70 … | + follows_el, | |
71 … | + h('strong', 'friends'), | |
72 … | + friends_el, | |
73 … | + h('strong', 'followers'), | |
74 … | + followers_el | |
75 … | + ) | |
76 … | + ) | |
77 … | + } | |
78 … | + | |
79 … | +} | |
80 … | + |
modules_basic/avatar-image.js | ||
---|---|---|
@@ -1,117 +1,0 @@ | ||
1 | -'use strict' | |
2 | -var getAvatar = require('ssb-avatar') | |
3 | -var h = require('hyperscript') | |
4 | -var ref = require('ssb-ref') | |
5 | -var path = require('path') | |
6 | -var visualize = require('visualize-buffer') | |
7 | - | |
8 | -var pull = require('pull-stream') | |
9 | - | |
10 | -var self_id = require('../keys').id | |
11 | - | |
12 | -//var plugs = require('../plugs') | |
13 | -//var sbot_query = plugs.first(exports.sbot_query = []) | |
14 | -//var blob_url = require('../plugs').first(exports.blob_url = []) | |
15 | -// | |
16 | - | |
17 | -exports.needs = { | |
18 | - sbot_query: 'first', | |
19 | - blob_url: 'first' | |
20 | -} | |
21 | - | |
22 | -exports.gives = { | |
23 | - connection_status: true, avatar_image: true | |
24 | -} | |
25 | - | |
26 | - | |
27 | -function isFunction (f) { | |
28 | - return 'function' === typeof f | |
29 | -} | |
30 | - | |
31 | - | |
32 | -var ready = false | |
33 | -var waiting = [] | |
34 | - | |
35 | -var last = 0 | |
36 | - | |
37 | -var cache = {} | |
38 | - | |
39 | -exports.create = function (api) { | |
40 | - var avatars = {} | |
41 | - | |
42 | - //blah blah | |
43 | - return { | |
44 | - connection_status: function (err) { | |
45 | - if (err) return | |
46 | - pull( | |
47 | - api.sbot_query({ | |
48 | - query: [{ | |
49 | - $filter: { | |
50 | - timestamp: {$gt: last || 0 }, | |
51 | - value: { content: { | |
52 | - type: "about", | |
53 | - about: {$prefix: "@"}, | |
54 | - image: {link: {$prefix: "&"}} | |
55 | - }} | |
56 | - }}, | |
57 | - { | |
58 | - $map: { | |
59 | - id: ["value", "content", "about"], | |
60 | - image: ["value", "content", "image", "link"], | |
61 | - by: ["value", "author"], | |
62 | - ts: 'timestamp' | |
63 | - }}], | |
64 | - live: true | |
65 | - }), | |
66 | - pull.drain(function (a) { | |
67 | - if(a.sync) { | |
68 | - ready = true | |
69 | - while(waiting.length) waiting.shift()() | |
70 | - return | |
71 | - } | |
72 | - last = a.ts | |
73 | - //set image for avatar. | |
74 | - //overwrite another avatar | |
75 | - //you picked. | |
76 | - if( | |
77 | - //if there is no avatar | |
78 | - (!avatars[a.id]) || | |
79 | - //if i chose this avatar | |
80 | - (a.by == self_id) || | |
81 | - //they chose their own avatar, | |
82 | - //and current avatar was not chosen by me | |
83 | - (a.by === a.id && avatars[a.id].by != self_id) | |
84 | - ) | |
85 | - avatars[a.id] = a | |
86 | - | |
87 | - }) | |
88 | - ) | |
89 | - }, | |
90 | - | |
91 | - avatar_image: function (author, classes) { | |
92 | - classes = classes || '' | |
93 | - if(classes && 'string' === typeof classes) classes = '.avatar--'+classes | |
94 | - | |
95 | - function gen (id) { | |
96 | - if(cache[id]) return h('img', {src: cache[id]}) | |
97 | - var img = visualize(new Buffer(author.substring(1), 'base64'), 256) | |
98 | - cache[id] = img.src | |
99 | - return img | |
100 | - } | |
101 | - | |
102 | - var img = ready && avatars[author] ? h('img', {src: api.blob_url(avatars[author].image)}) : gen(author) | |
103 | - | |
104 | - ;(classes || '').split('.').filter(Boolean).forEach(function (c) { | |
105 | - img.classList.add(c) | |
106 | - }) | |
107 | - | |
108 | - if(!ready) | |
109 | - waiting.push(function () { | |
110 | - if(avatars[author]) img.src = api.blob_url(avatars[author].image) | |
111 | - }) | |
112 | - | |
113 | - return img | |
114 | - } | |
115 | - } | |
116 | -} | |
117 | - |
modules_basic/avatar-link.js | ||
---|---|---|
@@ -1,22 +1,0 @@ | ||
1 | -var h = require('hyperscript') | |
2 | - | |
3 | -exports.needs = {signifier: 'first'} | |
4 | - | |
5 | -exports.gives = 'avatar_link' | |
6 | - | |
7 | -exports.create = function (api) { | |
8 | - return function (id, element) { | |
9 | - | |
10 | - var link = h('a.avatar', {href: "#"+id, title: id}, element) | |
11 | - | |
12 | - api.signifier(id, function (_, names) { | |
13 | - if(names.length) | |
14 | - link.title = names[0].name + '\n '+id | |
15 | - }) | |
16 | - | |
17 | - return link | |
18 | - } | |
19 | -} | |
20 | - | |
21 | - | |
22 | - |
modules_basic/avatar-name.js | ||
---|---|---|
@@ -1,29 +1,0 @@ | ||
1 | - | |
2 | -var signifier = require('../plugs').first(exports.signifier = []) | |
3 | -var h = require('hyperscript') | |
4 | - | |
5 | -exports.needs = { signifier: 'first' } | |
6 | - | |
7 | -exports.gives = 'avatar_name' | |
8 | - | |
9 | -exports.create = function (api) { | |
10 | - | |
11 | - return function name (id) { | |
12 | - var n = h('span', id ? id.substring(0, 10) : "") | |
13 | - | |
14 | - //choose the most popular name for this person. | |
15 | - //for anything like this you'll see I have used sbot.links2 | |
16 | - //which is the ssb-links plugin. as you'll see the query interface | |
17 | - //is pretty powerful! | |
18 | - //TODO: "most popular" name is easily gameable. | |
19 | - //must come up with something better than this. | |
20 | - | |
21 | - api.signifier(id, function (_, names) { | |
22 | - if(names.length) n.textContent = names[0].name | |
23 | - }) | |
24 | - | |
25 | - return n | |
26 | - } | |
27 | - | |
28 | -} | |
29 | - |
modules_basic/avatar-profile.js | ||
---|---|---|
@@ -1,88 +1,0 @@ | ||
1 | -var h = require('hyperscript') | |
2 | -var pull = require('pull-stream') | |
3 | - | |
4 | -//var plugs = require('../plugs') | |
5 | -//var avatar_image_link = plugs.first(exports.avatar_image_link = []) | |
6 | -//var avatar_action = plugs.map(exports.avatar_action = []) | |
7 | -//var avatar_edit = plugs.first(exports.avatar_edit = []) | |
8 | - | |
9 | -//var follows = plugs.first(exports.follows = []) | |
10 | -//var followers = plugs.first(exports.followers = []) | |
11 | -// | |
12 | -exports.needs = { | |
13 | - avatar_image_link: 'first', | |
14 | - avatar_action: 'map', | |
15 | - avatar_edit: 'first', | |
16 | - follows: 'first', | |
17 | - followers: 'first' | |
18 | -} | |
19 | - | |
20 | -exports.gives = 'avatar_profile' | |
21 | - | |
22 | -function streamToList(stream, el) { | |
23 | - pull( | |
24 | - stream, | |
25 | - pull.drain(function (item) { | |
26 | - if(item) el.appendChild(item) | |
27 | - }) | |
28 | - ) | |
29 | - return el | |
30 | -} | |
31 | - | |
32 | -exports.create = function (api) { | |
33 | - | |
34 | - function image_link (id) { | |
35 | - return api.avatar_image_link(id, 'thumbnail') | |
36 | - } | |
37 | - | |
38 | - return function (id) { | |
39 | - | |
40 | - var follows_el = h('div.profile__follows.wrap') | |
41 | - var friends_el = h('div.profile__friendss.wrap') | |
42 | - var followers_el = h('div.profile__followers.wrap') | |
43 | - var a, b | |
44 | - | |
45 | - pull(api.follows(id), pull.unique(), pull.collect(function (err, ary) { | |
46 | - a = ary || []; next() | |
47 | - })) | |
48 | - pull(api.followers(id), pull.unique(), pull.collect(function (err, ary) { | |
49 | - b = ary || {}; next() | |
50 | - })) | |
51 | - | |
52 | - function next () { | |
53 | - if(!(a && b)) return | |
54 | - var _c = [], _a = [], _b = [] | |
55 | - | |
56 | - a.forEach(function (id) { | |
57 | - if(!~b.indexOf(id)) _a.push(id) | |
58 | - else _c.push(id) | |
59 | - }) | |
60 | - b.forEach(function (id) { | |
61 | - if(!~_c.indexOf(id)) _b.push(id) | |
62 | - }) | |
63 | - function add (ary, el) { | |
64 | - ary.forEach(function (id) { el.appendChild(image_link(id)) }) | |
65 | - } | |
66 | - | |
67 | - add(_a, follows_el) | |
68 | - add(_c, friends_el) | |
69 | - add(_b, followers_el) | |
70 | - } | |
71 | - | |
72 | - | |
73 | - return h('div.column.profile', | |
74 | - api.avatar_edit(id), | |
75 | - api.avatar_action(id), | |
76 | - h('div.profile__relationships.column', | |
77 | - h('strong', 'follows'), | |
78 | - follows_el, | |
79 | - h('strong', 'friends'), | |
80 | - friends_el, | |
81 | - h('strong', 'followers'), | |
82 | - followers_el | |
83 | - ) | |
84 | - ) | |
85 | - } | |
86 | - | |
87 | -} | |
88 | - |
modules_basic/avatar.js | ||
---|---|---|
@@ -1,45 +1,0 @@ | ||
1 | -var h = require('hyperscript') | |
2 | -var u = require('../util') | |
3 | - | |
4 | -exports.needs = { | |
5 | - avatar_name: 'first', | |
6 | - avatar_image: 'first', | |
7 | - avatar_link: 'first' | |
8 | -} | |
9 | - | |
10 | -exports.gives = { | |
11 | - avatar: true, | |
12 | - avatar_image_name_link: true, | |
13 | - avatar_image_link: true, | |
14 | - avatar_name_link: true | |
15 | -} | |
16 | - | |
17 | -exports.create = function (api) { | |
18 | - return { | |
19 | - avatar, | |
20 | - avatar_image_name_link, | |
21 | - avatar_image_link, | |
22 | - avatar_name_link | |
23 | - } | |
24 | - | |
25 | - function avatar (author, classes) { | |
26 | - return exports.avatar_image_name_link(author, classes) | |
27 | - } | |
28 | - | |
29 | - function avatar_image_name_link (author, classes) { | |
30 | - return api.avatar_link(author, [ | |
31 | - api.avatar_image(author, classes), | |
32 | - api.avatar_name(author) | |
33 | - ]) | |
34 | - } | |
35 | - | |
36 | - function avatar_image_link (author, classes) { | |
37 | - return api.avatar_link(author, api.avatar_image(author, classes)) | |
38 | - } | |
39 | - | |
40 | - function avatar_name_link (author, classes) { | |
41 | - return api.avatar_link(author, api.avatar_name(author)) | |
42 | - } | |
43 | -} | |
44 | - | |
45 | - |
modules_core/app.js | ||
---|---|---|
@@ -1,5 +1,4 @@ | ||
1 | -var plugs = require('../plugs') | |
2 | 1 … | var h = require('hyperscript') |
3 | 2 … | var insertCss = require('insert-css') |
4 | 3 … | |
5 | 4 … | module.exports = { |
modules_core/index.js | ||
---|---|---|
@@ -1,17 +1,18 @@ | ||
1 | 1 … | module.exports = { |
2 | -// "_screen_view.js": require('./_screen_view.js'), | |
3 | - "app.js": require('./app'), | |
4 | - "blob-url.js": require('./blob-url'), | |
5 | - "crypto.js": require('./crypto'), | |
6 | - "external-confirm.js": require('./external-confirm'), | |
7 | - "file-input.js": require('./file-input'), | |
8 | - "menu.js": require('./menu'), | |
9 | - message: { | |
10 | - confirm: require('./message/confirm') | |
2 … | + 'app': require('./app'), | |
3 … | + 'blob-url': require('./blob-url'), | |
4 … | + 'crypto': require('./crypto'), | |
5 … | + 'external-confirm': require('./external-confirm'), | |
6 … | + 'file-input': require('./file-input'), | |
7 … | + 'menu': require('./menu'), | |
8 … | + 'message': { | |
9 … | + 'confirm': require('./message/confirm') | |
11 | 10 … | }, |
12 | - "tabs.js": require('./tabs'), | |
13 | - "sbot.js": require('./sbot'), | |
14 | - "styles.js": require('./styles'), | |
15 | - "style-mixins.js": require('./style-mixins') | |
11 … | + 'tabs': require('./tabs'), | |
12 … | + 'sbot': require('./sbot'), | |
13 … | + 'style': { | |
14 … | + 'styles': require('./style/styles'), | |
15 … | + 'mixins': require('./style/mixins') | |
16 … | + } | |
16 | 17 … | } |
17 | 18 … |
modules_core/menu.js | ||
---|---|---|
@@ -1,13 +1,12 @@ | ||
1 | -var plugs = require('../plugs') | |
2 | 1 … | var h = require('hyperscript') |
3 | 2 … | |
4 | 3 … | module.exports = { |
5 | 4 … | needs: {menu_items: 'map'}, |
6 | 5 … | gives: {connection_status: true, menu: true}, |
7 | 6 … | create: function (api) { |
8 | 7 … | |
9 | - var menu_items = api.menu_items //plugs.map(exports.menu_items = []) | |
8 … | + var menu_items = api.menu_items | |
10 | 9 … | |
11 | 10 … | var status = h('div.status.error') //start off disconnected |
12 | 11 … | var list = h('div.menu.column', {style: 'display: none;'}) |
13 | 12 … |
modules_core/tabs.js | ||
---|---|---|
@@ -10,15 +10,15 @@ | ||
10 | 10 … | if(el.tagName !== 'A') return ancestor(el.parentElement) |
11 | 11 … | return el |
12 | 12 … | } |
13 | 13 … | |
14 | -//var plugs = require('../plugs') | |
15 | -//var screen_view = plugs.first(exports._screen_view = []) | |
16 | -//var search_box = plugs.first(exports.search_box = []) | |
17 | -//var menu = plugs.first(exports.menu = []) | |
14 … | +exports.needs = { | |
15 … | + screen_view: 'first', | |
16 … | + search_box: 'first', | |
17 … | + menu: 'first', | |
18 … | + 'external_confirm':'first' | |
19 … | +} | |
18 | 20 … | |
19 | -exports.needs = {screen_view: 'first', search_box: 'first', menu: 'first', 'external_confirm':'first'} | |
20 | - | |
21 | 21 … | exports.gives = 'screen_view' |
22 | 22 … | |
23 | 23 … | exports.create = function (api) { |
24 | 24 … | return function (path) { |
modules_core/style-mixins.js | ||
---|---|---|
@@ -1,22 +1,0 @@ | ||
1 | - | |
2 | -const mixins = ` | |
3 | - $textPrimary { | |
4 | - color: #222 | |
5 | - } | |
6 | - | |
7 | - $textSubtle { | |
8 | - color: gray | |
9 | - } | |
10 | -` | |
11 | - | |
12 | -module.exports = { | |
13 | - gives: { | |
14 | - mcss: true | |
15 | - }, | |
16 | - create: function (api) { | |
17 | - return { | |
18 | - mcss: () => mixins | |
19 | - } | |
20 | - } | |
21 | -} | |
22 | - |
modules_core/style/mixins.js | ||
---|---|---|
@@ -1,0 +1,22 @@ | ||
1 … | + | |
2 … | +const mixins = ` | |
3 … | + $textPrimary { | |
4 … | + color: #222 | |
5 … | + } | |
6 … | + | |
7 … | + $textSubtle { | |
8 … | + color: gray | |
9 … | + } | |
10 … | +` | |
11 … | + | |
12 … | +module.exports = { | |
13 … | + gives: { | |
14 … | + mcss: true | |
15 … | + }, | |
16 … | + create: function (api) { | |
17 … | + return { | |
18 … | + mcss: () => mixins | |
19 … | + } | |
20 … | + } | |
21 … | +} | |
22 … | + |
modules_core/style/styles.js | ||
---|---|---|
@@ -1,0 +1,34 @@ | ||
1 … | +var h = require('../../h') | |
2 … | +var compile = require('micro-css') | |
3 … | +var fs = require('fs') | |
4 … | +var Path = require('path') | |
5 … | + | |
6 … | +// TODO distribute these styles across all | |
7 … | +// the relevant modules, not as a core style. | |
8 … | +var coreStyle = fs.readFileSync(Path.join(__dirname, '../../style.css')) | |
9 … | + | |
10 … | +module.exports = { | |
11 … | + needs: { | |
12 … | + mcss: 'map', | |
13 … | + css: 'map' | |
14 … | + }, | |
15 … | + gives: { | |
16 … | + mcss: true, | |
17 … | + css: true, | |
18 … | + styles: true | |
19 … | + }, | |
20 … | + create: function (api) { | |
21 … | + var styles = '' | |
22 … | + process.nextTick(function () { | |
23 … | + var mcss = api.mcss().join('\n') | |
24 … | + var css = api.css().join('\n') | |
25 … | + styles = coreStyle + compile(mcss) + css | |
26 … | + }) | |
27 … | + return { | |
28 … | + styles: function () { return styles }, | |
29 … | + // export empty styles | |
30 … | + mcss: function () { return '' }, | |
31 … | + css: function () { return '' } | |
32 … | + } | |
33 … | + } | |
34 … | +} |
modules_core/styles.js | ||
---|---|---|
@@ -1,34 +1,0 @@ | ||
1 | -var h = require('../h') | |
2 | -var compile = require('micro-css') | |
3 | -var fs = require('fs') | |
4 | -var Path = require('path') | |
5 | - | |
6 | -// TODO distribute these styles across all | |
7 | -// the relevant modules, not as a core style. | |
8 | -var coreStyle = fs.readFileSync(Path.join(__dirname, '../style.css')) | |
9 | - | |
10 | -module.exports = { | |
11 | - needs: { | |
12 | - mcss: 'map', | |
13 | - css: 'map' | |
14 | - }, | |
15 | - gives: { | |
16 | - mcss: true, | |
17 | - css: true, | |
18 | - styles: true | |
19 | - }, | |
20 | - create: function (api) { | |
21 | - var styles = '' | |
22 | - process.nextTick(function () { | |
23 | - var mcss = api.mcss().join('\n') | |
24 | - var css = api.css().join('\n') | |
25 | - styles = coreStyle + compile(mcss) + css | |
26 | - }) | |
27 | - return { | |
28 | - styles: function () { return styles }, | |
29 | - // export empty styles | |
30 | - mcss: function () { return '' }, | |
31 | - css: function () { return '' } | |
32 | - } | |
33 | - } | |
34 | -} |
modules_embedded/index.js | ||
---|---|---|
@@ -1,11 +1,12 @@ | ||
1 | 1 … | module.exports = { |
2 | - "_screen_view.js": require('../modules_core/_screen_view.js'), | |
3 | - "app.js": require('../modules_core/app.js'), | |
4 | - "blob-url.js": require('../modules_core/blob-url.js'), | |
5 | - "crypto.js": require('../modules_core/crypto.js'), | |
6 | - "file-input.js": require('../modules_core/file-input.js'), | |
7 | - "menu.js": require('../modules_core/menu.js'), | |
8 | - "message-confirm.js": require('../modules_core/message-confirm.js'), | |
9 | - "tabs.js": require('../modules_core/tabs.js'), | |
10 | - "sbot.js": require('./sbot.js') | |
2 … | + "_screen_view.": require('../modules_core/_screen_view.'), | |
3 … | + "app.": require('../modules_core/app.'), | |
4 … | + "blob-url.": require('../modules_core/blob-url.'), | |
5 … | + "crypto.": require('../modules_core/crypto.'), | |
6 … | + "file-input.": require('../modules_core/file-input.'), | |
7 … | + "menu.": require('../modules_core/menu.'), | |
8 … | + "message-confirm.": require('../modules_core/message-confirm.'), | |
9 … | + "tabs.": require('../modules_core/tabs.'), | |
10 … | + "sbot.": require('./sbot.') | |
11 | 11 … | } |
12 … | + |
modules_extra/audio-mp3.js | ||
---|---|---|
@@ -4,14 +4,8 @@ | ||
4 | 4 … | var ref = require('ssb-ref'); |
5 | 5 … | |
6 | 6 … | //render a message |
7 | 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 | 8 … | exports.needs = { |
15 | 9 … | // message_link: 'first', |
16 | 10 … | // message_confirm: 'first', |
17 | 11 … | // sbot_links: 'first', |
modules_extra/emoji.js | ||
---|---|---|
@@ -1,11 +1,7 @@ | ||
1 | 1 … | var emojis = require('emoji-named-characters') |
2 | 2 … | var emojiNames = Object.keys(emojis) |
3 | 3 … | |
4 | -//var plugs = require('../plugs') | |
5 | -//var blob_url = plugs.first(exports.blob_url = []) | |
6 | -// | |
7 | - | |
8 | 4 … | exports.needs = { blob_url: 'first' } |
9 | 5 … | exports.gives = { emoji_names: true, emoji_url: true } |
10 | 6 … | |
11 | 7 … | exports.create = function (api) { |
modules_extra/git-ssb.js | ||
---|---|---|
@@ -2,13 +2,8 @@ | ||
2 | 2 … | var u = require('../util') |
3 | 3 … | var pull = require('pull-stream') |
4 | 4 … | var Scroller = require('pull-scroll') |
5 | 5 … | |
6 | -//var plugs = require('../plugs') | |
7 | -//var message_render = plugs.first(exports.message_render = []) | |
8 | -//var message_compose = plugs.first(exports.message_compose = []) | |
9 | -//var sbot_log = plugs.first(exports.sbot_log = []) | |
10 | - | |
11 | 6 … | exports.needs = { |
12 | 7 … | message_render: 'first', |
13 | 8 … | message_compose: 'first', |
14 | 9 … | sbot_log: 'first' |
modules_extra/git.js | ||
---|---|---|
@@ -9,17 +9,8 @@ | ||
9 | 9 … | var getAvatar = require('ssb-avatar') |
10 | 10 … | var KVGraph = require('kvgraph') |
11 | 11 … | var mergeRepo = require('ssb-git/merge') |
12 | 12 … | |
13 | -//var plugs = require('../plugs') | |
14 | -//var message_link = plugs.first(exports.message_link = []) | |
15 | -//var message_confirm = plugs.first(exports.message_confirm = []) | |
16 | -//var message_compose = plugs.first(exports.message_compose = []) | |
17 | -//var sbot_links = plugs.first(exports.sbot_links = []) | |
18 | -//var sbot_links2 = plugs.first(exports.sbot_links2 = []) | |
19 | -//var sbot_get = plugs.first(exports.sbot_get = []) | |
20 | -//var avatar_name = plugs.first(exports.avatar_name = []) | |
21 | -//var markdown = plugs.first(exports.markdown = []) | |
22 | 13 … | |
23 | 14 … | exports.needs = { |
24 | 15 … | message_link: 'first', |
25 | 16 … | message_confirm: 'first', |
modules_extra/index.js | ||
---|---|---|
@@ -1,23 +1,25 @@ | ||
1 | 1 … | module.exports = { |
2 | - // "audio-mp3.js": require('./audio-mp3.js'), | |
3 | - "blob.js": require('./blob.js'), | |
4 | - "channel.js": require('./channel.js'), | |
5 | - "emoji.js": require('./emoji.js'), | |
6 | - "suggest-emoji.js": require('./suggest-emoji.js'), | |
7 | - "dns.js": require('./dns.js'), | |
8 | - "git.js": require('./git.js'), | |
9 | - "git-ssb.js": require('./git-ssb.js'), | |
10 | - "key.js": require('./key.js'), | |
11 | - "notifications.js": require('./notifications.js'), | |
12 | - "meta-image.js": require('./meta-image.js'), | |
13 | - "music-release-cc.js": require('./music-release-cc.js'), | |
14 | - "music-release.js": require('./music-release.js'), | |
15 | - "network.js": require('./network.js'), | |
16 | - "query.js": require('./query.js'), | |
17 | - "raw.js": require('./raw.js'), | |
18 | - "search.js": require('./search'), | |
19 | - "split.js": require('./split.js'), | |
20 | - "versions.js": require('./versions.js') | |
2 … | + // 'audio-mp3': require('./audio-mp3'), | |
3 … | + 'blob': require('./blob'), | |
4 … | + 'channel': require('./channel'), | |
5 … | + 'emoji': require('./emoji'), | |
6 … | + 'suggest-emoji': require('./suggest-emoji'), | |
7 … | + 'dns': require('./dns'), | |
8 … | + 'git': require('./git'), | |
9 … | + 'git-ssb': require('./git-ssb'), | |
10 … | + 'key': require('./key'), | |
11 … | + 'notifications': require('./notifications'), | |
12 … | + 'meta-image': require('./meta-image'), | |
13 … | + 'music': { | |
14 … | + 'release-cc': require('./music/release-cc'), | |
15 … | + 'release': require('./music/release') | |
16 … | + }, | |
17 … | + 'network': require('./network'), | |
18 … | + 'query': require('./query'), | |
19 … | + 'raw': require('./raw'), | |
20 … | + 'search': require('./search'), | |
21 … | + 'split': require('./split'), | |
22 … | + 'versions': require('./versions') | |
21 | 23 … | } |
22 | 24 … | |
23 | 25 … |
modules_extra/key.js | ||
---|---|---|
@@ -2,16 +2,12 @@ | ||
2 | 2 … | var u = require('../util') |
3 | 3 … | var pull = require('pull-stream') |
4 | 4 … | var Scroller = require('pull-scroll') |
5 | 5 … | |
6 | -//var plugs = require('../plugs') | |
7 | -// var message_render = plugs.first(exports.message_render = []) | |
8 | -// var message_compose = plugs.first(exports.message_compose = []) | |
9 | -// var sbot_log = plugs.first(exports.sbot_log = []) | |
10 | 6 … | |
11 | - | |
12 | 7 … | exports.gives = { |
13 | - menu_items: true, screen_view: true | |
8 … | + menu_items: true, | |
9 … | + screen_view: true | |
14 | 10 … | } |
15 | 11 … | |
16 | 12 … | exports.create = function (api) { |
17 | 13 … | return { |
modules_extra/meta-image.js | ||
---|---|---|
@@ -4,14 +4,8 @@ | ||
4 | 4 … | var ref = require('ssb-ref'); |
5 | 5 … | |
6 | 6 … | //render a message |
7 | 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 | 8 … | exports.needs = { blob_url: 'first' } |
15 | 9 … | exports.gives = 'message_content' |
16 | 10 … | |
17 | 11 … | exports.create = function (api) { |
modules_extra/network.js | ||
---|---|---|
@@ -7,12 +7,8 @@ | ||
7 | 7 … | Struct, Value, Dict, |
8 | 8 … | dictToCollection, map: mutantMap, when, computed |
9 | 9 … | } = require('@mmckegg/mutant') |
10 | 10 … | |
11 | -//var avatar = plugs.first(exports.avatar = []) | |
12 | -//var sbot_gossip_peers = plugs.first(exports.sbot_gossip_peers = []) | |
13 | -//var sbot_gossip_connect = plugs.first(exports.sbot_gossip_connect = []) | |
14 | - | |
15 | 11 … | exports.needs = { |
16 | 12 … | avatar_image_link: 'first', |
17 | 13 … | avatar_name_link: 'first', |
18 | 14 … | sbot_gossip_peers: 'first', |
modules_extra/notifications.js | ||
---|---|---|
@@ -3,18 +3,11 @@ | ||
3 | 3 … | var u = require('../util') |
4 | 4 … | var pull = require('pull-stream') |
5 | 5 … | var Scroller = require('pull-scroll') |
6 | 6 … | var paramap = require('pull-paramap') |
7 | -var plugs = require('../plugs') | |
8 | 7 … | var cont = require('cont') |
9 | 8 … | var ref = require('ssb-ref') |
10 | 9 … | |
11 | -//var message_render = plugs.first(exports.message_render = []) | |
12 | -//var sbot_log = plugs.first(exports.sbot_log = []) | |
13 | -//var sbot_get = plugs.first(exports.sbot_get = []) | |
14 | -//var sbot_user_feed = plugs.first(exports.sbot_user_feed = []) | |
15 | -//var message_unbox = plugs.first(exports.message_unbox = []) | |
16 | - | |
17 | 10 … | exports.needs = { |
18 | 11 … | message_render: 'first', |
19 | 12 … | sbot_log: 'first', |
20 | 13 … | sbot_get: 'first', |
modules_extra/query.js | ||
---|---|---|
@@ -1,10 +1,8 @@ | ||
1 | 1 … | var h = require('hyperscript') |
2 | 2 … | var pull = require('pull-stream') |
3 | 3 … | var HJSON = require('hjson') |
4 | 4 … | |
5 | -//var sbot_query = require('../plugs').first(exports.sbot_query = []) | |
6 | - | |
7 | 5 … | exports.needs = { sbot_query: 'first' } |
8 | 6 … | |
9 | 7 … | exports.gives = { |
10 | 8 … | menu_items: true, |
modules_extra/raw.js | ||
---|---|---|
@@ -2,12 +2,8 @@ | ||
2 | 2 … | var u = require('../util') |
3 | 3 … | var pull = require('pull-stream') |
4 | 4 … | var Scroller = require('pull-scroll') |
5 | 5 … | |
6 | -var plugs = require('../plugs') | |
7 | -//var message_render = plugs.first(exports.message_render = []) | |
8 | -//var message_compose = plugs.first(exports.message_compose = []) | |
9 | - | |
10 | 6 … | // from ssb-ref |
11 | 7 … | var refRegex = /((?:@|%|&)[A-Za-z0-9\/+]{43}=\.[\w\d]+)/g |
12 | 8 … | |
13 | 9 … | exports.gives = 'message_meta' |
modules_extra/search.js | ||
---|---|---|
@@ -3,12 +3,8 @@ | ||
3 | 3 … | var pull = require('pull-stream') |
4 | 4 … | var Scroller = require('pull-scroll') |
5 | 5 … | var TextNodeSearcher = require('text-node-searcher') |
6 | 6 … | |
7 | -//var plugs = require('../plugs') | |
8 | -//var message_render = plugs.first(exports.message_render = []) | |
9 | -//var sbot_log = plugs.first(exports.sbot_log = []) | |
10 | - | |
11 | 7 … | exports.needs = { |
12 | 8 … | message_render: 'first', |
13 | 9 … | sbot_log: 'first' |
14 | 10 … | } |
modules_extra/split.js | ||
---|---|---|
@@ -1,10 +1,6 @@ | ||
1 | 1 … | var h = require('hyperscript') |
2 | 2 … | |
3 | -//var screen_view = | |
4 | -// require('../plugs').first(exports._screen_view = []) | |
5 | - | |
6 | - | |
7 | 3 … | exports.needs = { |
8 | 4 … | screen_view: 'first' |
9 | 5 … | } |
10 | 6 … |
modules_extra/suggest-emoji.js | ||
---|---|---|
@@ -1,7 +1,4 @@ | ||
1 | -//var plugs = require('../plugs') | |
2 | -//var emoji_url = plugs.first(exports.emoji_url = []) | |
3 | -//var emoji_names = plugs.first(exports.emoji_names = []) | |
4 | 1 … | |
5 | 2 … | exports.needs = { |
6 | 3 … | emoji_url: 'first', |
7 | 4 … | emoji_names: 'first' |
modules_extra/music-release-cc.js | ||
---|---|---|
@@ -1,87 +1,0 @@ | ||
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 | -//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 | - | |
15 | -exports.needs = { blob_url: 'first' } | |
16 | -exports.gives = 'message_content' | |
17 | - | |
18 | -exports.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 | - |
modules_extra/music/release-cc.js | ||
---|---|---|
@@ -1,0 +1,87 @@ | ||
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 = { | |
9 … | + blob_url: 'first' | |
10 … | +} | |
11 … | + | |
12 … | +exports.gives = 'message_content' | |
13 … | + | |
14 … | +exports.create = function (api) { | |
15 … | + return function(msg, sbot) { | |
16 … | + if (msg.value.content.type !== 'music-release-cc') | |
17 … | + return; | |
18 … | + | |
19 … | + var tracks = msg.value.content.tracks; | |
20 … | + return h('div', | |
21 … | + h('img', { "src" : api.blob_url(msg.value.content.cover) }), | |
22 … | + h('h1', msg.value.content.title), | |
23 … | + h('ol', | |
24 … | + Object.keys(tracks).map(function(k) { | |
25 … | + var t = tracks[k]; | |
26 … | + return h('li', t.fname, | |
27 … | + h("br"), | |
28 … | + h('audio', { | |
29 … | + "controls" : true, | |
30 … | + "src" : api.blob_url(t.link) | |
31 … | + }) | |
32 … | + ) | |
33 … | + }) | |
34 … | + ), | |
35 … | + h('p', | |
36 … | + "More info:", h('a', { href : msg.value.content.archivedotorg }, "archive.org"), | |
37 … | + h("br"), | |
38 … | + "License:", h('a', { href : msg.value.content.license }, "Link") | |
39 … | + ) | |
40 … | + ) | |
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 … | + |
modules_extra/music/release.js | ||
---|---|---|
@@ -1,0 +1,43 @@ | ||
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.gives = 'message_content' | |
9 … | + | |
10 … | +exports.create = function () { | |
11 … | + | |
12 … | + return function(msg, sbot) { | |
13 … | + if (msg.value.content.type !== 'music-release') | |
14 … | + return; | |
15 … | + | |
16 … | + var v = msg.value.content; | |
17 … | + return h('div', [ | |
18 … | + // h('img', { "src" : "http://localhost:7777/" + encodeURIComponent(v.cover) }), | |
19 … | + h('h1', v.Title), | |
20 … | + h("p", v.Description), | |
21 … | + h("dl", [ | |
22 … | + h("dt", "Creator"), | |
23 … | + h("dd", v.Creator), | |
24 … | + | |
25 … | + h("dt", "Identifier"), | |
26 … | + h("dd", v.Identifier), | |
27 … | + | |
28 … | + h("dt", "Published"), | |
29 … | + h("dd", v.Publicdate), | |
30 … | + | |
31 … | + h("dt", "Runtime"), | |
32 … | + h("dd", v.Runtime), | |
33 … | + | |
34 … | + h("dt", "Source"), | |
35 … | + h("dd", v.Source), | |
36 … | + | |
37 … | + h("dt", "License"), | |
38 … | + h("dd", h('a', { href : v.Licenseurl }, "Link")) | |
39 … | + ]) | |
40 … | + ]) | |
41 … | + } | |
42 … | +} | |
43 … | + |
modules_extra/music-release.js | ||
---|---|---|
@@ -1,46 +1,0 @@ | ||
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 | -//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 | -// | |
13 | -exports.gives = 'message_content' | |
14 | - | |
15 | -exports.create = function () { | |
16 | - | |
17 | - return function(msg, sbot) { | |
18 | - if (msg.value.content.type !== 'music-release') | |
19 | - return; | |
20 | - | |
21 | - var v = msg.value.content; | |
22 | - return h('div', | |
23 | - // h('img', { "src" : "http://localhost:7777/" + encodeURIComponent(v.cover) }), | |
24 | - h('h1', v.Title), | |
25 | - h("p", v.Description), | |
26 | - h("dl", | |
27 | - | |
28 | - h("dt", "Creator"), | |
29 | - h("dd", v.Creator), | |
30 | - | |
31 | - h("dt", "Identifier"), | |
32 | - h("dd", v.Identifier), | |
33 | - | |
34 | - h("dt", "Published"), | |
35 | - h("dd", v.Publicdate), | |
36 | - | |
37 | - h("dt", "Runtime"), | |
38 | - h("dd", v.Runtime), | |
39 | - | |
40 | - h("dt", "Source"), | |
41 | - h("dd", v.Source), | |
42 | - | |
43 | - h("dt", "License"), | |
44 | - h("dd", h('a', { href : v.Licenseurl }, "Link")))) | |
45 | - } | |
46 | -} |
Built with git-ssb-web