UNPKG

1.93 kBJavaScriptView Raw
1var extend = require('extend');
2
3module.exports = function(options, callback) {
4 return new Construct(options, callback);
5};
6
7module.exports.Construct = Construct;
8
9function Construct(options, callback) {
10 var apos = options.apos;
11 var app = options.app;
12 var self = this;
13 var clientId = options.clientId;
14 self._dirs = (options.dirs || []).concat([ __dirname ]);
15
16 self.pushAsset = function(type, name, optionsArg) {
17 var options = {};
18 extend(true, options, optionsArg);
19 options.fs = __dirname;
20 options.web = '/apos-soundcloud';
21 return apos.pushAsset(type, name, options);
22 };
23
24 self._apos = apos;
25 self._apos.mixinModuleAssets(self, 'soundcloud', __dirname, options);
26
27 // Include our editor template in the markup when aposTemplates is called
28 self.pushAsset('template', 'soundcloudEditor', { when: 'user' });
29 // Make sure that aposScripts and aposStylesheets summon our assets
30 self.pushAsset('script', 'soundcloud', { when: 'always' });
31 self.pushAsset('script', 'content', { when: 'always' });
32 self.pushAsset('script', 'editor', { when: 'user' });
33 self.pushAsset('script', 'waveform', { when: 'always' });
34 self.pushAsset('script', 'soundmanager2', { when: 'always' });
35 self.pushAsset('script', 'berniecode-animator', { when: 'always'});
36 self.pushAsset('script', '360player', { when: 'always' });
37 self.pushAsset('stylesheet', '360player', { when: 'always' });
38 self.pushAsset('stylesheet', 'content', { when: 'always' });
39
40
41 //app.get('/apos-soundcloud/*', apos.static(__dirname + '/public'));
42 apos.itemTypes.soundcloud = {
43 widget: true,
44 label: 'Soundcloud',
45 css: 'soundcloud',
46 icon: 'volume-up',
47 renderWidget: function(data) {
48 data.options.clientId = clientId;
49 return apos.partial('soundcloud', data, self._dirs.map(function(dir) { return dir + '/views'; }) );
50 }
51 };
52
53 return setImmediate(function() { return callback(null); });
54}
55