Ubuntu Pastebin

Paste from krampstudio at Thu, 23 Jun 2016 09:28:42 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const scopes = require('unity-js-scopes');
const boomarkService = require('./service/bookmark.js');
const noop = () => {};

const categoryRenderer = new scopes.lib.CategoryRenderer(JSON.stringify({
    'schema-version': 1,
    'template': {
        'category-layout': 'grid',
        'card-size': 'medium'
    },
    'components': {
        'title': 'title',
        'art': {
            'field': 'art',
            'aspect-ratio': 1,
            'fallback': 'icon.png'
        },
        'subtitle': 'subtitle'
    }
}));

const scopeOptions = {};

scopes.self.initialize(scopeOptions, {

    search: function(cannedQuery, metadata) {
        return new scopes.lib.SearchQuery(cannedQuery, metadata, searchReply => {
            const serviceOptions = {
                connectivity : metadata.internet_connectivity() === 'Connected',
                limit : metadata.cardinality() > 0 ? metadata.cardinality() : -1
            };


             var filter = new scopes.lib.OptionSelectorFilter("brand", "Brand", false);
             filter.add_option('foo', 'Foo');
             filter.add_option('bar', 'Bar');
             
             //HOW DO I REGISTER THE FILTER ????


         boomarkService(serviceOptions)
                .getBookmarks(cannedQuery.query_string()).then(bookmarks => {
                    var category = searchReply.register_category('bookmarks', 'Bookmarks', 'icon.png', categoryRenderer);

                    bookmarks.forEach(bookmark => {
                        var result = new scopes.lib.CategorisedResult(category);
                        result.set_uri(bookmark.url);
                        result.set_dnd_uri(bookmark.url);
                        result.set_title(bookmark.title);
                        result.set_art(bookmark.icon);
                        result.set_intercept_activation();
                        searchReply.push(result);
                    });

                    searchReply.finished();
                })
                .catch(err => {
                    console.error(err);
                    console.log(err.stack);
                });
        }, noop);
    },

    activate: function(result, metadata) {
        return new scopes.lib.ActivationQuery(result, metadata, 'open browser', 'open', noop, noop);
    }

});
Download as text