Merge lp:~marcustomlinson/unity-js-scopes/tool-setup into lp:unity-js-scopes

Proposed by Marcus Tomlinson
Status: Merged
Merged at revision: 88
Proposed branch: lp:~marcustomlinson/unity-js-scopes/tool-setup
Merge into: lp:unity-js-scopes
Diff against target: 794 lines (+615/-36)
16 files modified
.bzrignore (+2/-0)
CMakeLists.txt (+4/-1)
debian/control (+12/-9)
debian/unity-js-scopes-dev.install (+1/-0)
qtc-templates/scope-js/.bzrignore (+5/-0)
qtc-templates/scope-js/CMakeLists.txt (+57/-0)
qtc-templates/scope-js/displayName.apparmor (+6/-0)
qtc-templates/scope-js/manifest.json.in (+15/-0)
qtc-templates/scope-js/po/CMakeLists.txt (+14/-0)
qtc-templates/scope-js/po/POTFILES.in.in (+3/-0)
qtc-templates/scope-js/src/CMakeLists.txt (+61/-0)
qtc-templates/scope-js/src/data/displayName-settings.ini.in (+21/-0)
qtc-templates/scope-js/src/data/displayName.ini.in (+9/-0)
qtc-templates/scope-js/src/displayName.js.in (+224/-0)
qtc-templates/scope-js/wizard.xml (+96/-0)
src/tool/main.cc (+85/-26)
To merge this branch: bzr merge lp:~marcustomlinson/unity-js-scopes/tool-setup
Reviewer Review Type Date Requested Status
Alexandre Abreu (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+275493@code.launchpad.net

This proposal supersedes a proposal from 2015-10-22.

Commit message

* Added a "setup" option to unity-js-scopes-tool to configure chroots for js scopes dev.
* Added qtc templates to be installed with unity-js-scopes-dev

Description of the change

* Added a "setup" option to unity-js-scopes-tool to configure chroots for js scopes dev.
* Added qtc templates to be installed with unity-js-scopes-dev

With these changes we make setup for js scope development much easier.

3 easy steps to get everything ready:

1. sudo add-apt-repository ppa:ubuntu-sdk-team/staging
2. sudo apt update && sudo apt install unity-js-scopes-dev
3. unity-js-scopes-tool setup

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote : Posted in a previous version of this proposal

a few comments, inline

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote : Posted in a previous version of this proposal

> a few comments, inline

fixed

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

K, I've removed my dependancy on the /doc branch. Please could you review and merge this branch independent of that one. Thanks

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandre Abreu (abreu-alexandre) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2015-09-14 09:28:53 +0000
+++ .bzrignore 2015-10-23 07:30:32 +0000
@@ -2,3 +2,5 @@
2./deps/v8-cpp2./deps/v8-cpp
3./CMakeLists.txt.user3./CMakeLists.txt.user
4./examples/simple-click/CMakeLists.txt.user4./examples/simple-click/CMakeLists.txt.user
5./examples/simple-click/src/etc
6./examples/simple-click/src/node_modules
57
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2015-10-01 14:46:56 +0000
+++ CMakeLists.txt 2015-10-23 07:30:32 +0000
@@ -61,5 +61,8 @@
6161
62add_subdirectory(src)62add_subdirectory(src)
6363
64install(DIRECTORY examples64install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/examples
65 DESTINATION ${CMAKE_INSTALL_DATADIR}/unity-js-scopes)65 DESTINATION ${CMAKE_INSTALL_DATADIR}/unity-js-scopes)
66
67install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/qtc-templates/scope-js
68 DESTINATION /usr/share/qtcreator/templates/wizards/ubuntu)
6669
=== modified file 'debian/control'
--- debian/control 2015-10-13 13:07:02 +0000
+++ debian/control 2015-10-23 07:30:32 +0000
@@ -22,8 +22,8 @@
22Multi-Arch: foreign22Multi-Arch: foreign
23Depends: ${misc:Depends},23Depends: ${misc:Depends},
24 ${shlibs:Depends},24 ${shlibs:Depends},
25Description: Javascript bindings to unity scopes library25Description: JavaScript bindings to Unity Scopes API
26 Provides a means for developers to develop Ubuntu Scopes in Javascript26 Provides a means for developers to develop Ubuntu Scopes in JavaScript
27 by providing bindings to the Unity Scopes API.27 by providing bindings to the Unity Scopes API.
2828
29Package: unity-js-scopes-launcher29Package: unity-js-scopes-launcher
@@ -32,8 +32,8 @@
32Depends: ${misc:Depends},32Depends: ${misc:Depends},
33 ${shlibs:Depends},33 ${shlibs:Depends},
34 unity-js-scopes-bindings (= ${binary:Version}),34 unity-js-scopes-bindings (= ${binary:Version}),
35Description: Scope launcher for unity javascript scopes35Description: Scope launcher for Unity JavaScript Scopes
36 Provides a means for developers to launch their Javascript Ubuntu Scopes.36 Provides a means for developers to launch their JavaScript Ubuntu Scopes.
3737
38Package: unity-js-scopes-tool38Package: unity-js-scopes-tool
39Architecture: any39Architecture: any
@@ -42,14 +42,17 @@
42 ${shlibs:Depends},42 ${shlibs:Depends},
43 unity-js-scopes-bindings (= ${binary:Version}),43 unity-js-scopes-bindings (= ${binary:Version}),
44 unity-js-scopes-launcher (= ${binary:Version}),44 unity-js-scopes-launcher (= ${binary:Version}),
45Description: Scope tool for unity javascript scopes45Description: Scope tool for Unity JavaScript Scopes
46 Provides a means for developers to configure their Javascript Ubuntu Scopes.46 Provides a means for developers to configure their JavaScript Ubuntu Scopes.
4747
48Package: unity-js-scopes-examples48Package: unity-js-scopes-dev
49Architecture: any49Architecture: any
50Multi-Arch: foreign50Multi-Arch: foreign
51Depends: ${misc:Depends},51Depends: ${misc:Depends},
52 ${shlibs:Depends},52 ${shlibs:Depends},
53 unity-js-scopes-bindings (= ${binary:Version}),53 unity-js-scopes-bindings (= ${binary:Version}),
54Description: Examples for javascript unity scopes54 unity-js-scopes-launcher (= ${binary:Version}),
55 Provides a set of examples for unity scopes written in javascript.55 unity-js-scopes-tool (= ${binary:Version}),
56Description: Development files for Unity JavaScript Scopes
57 Provides a set of Qt Creator templates and examples for Ubuntu Scopes
58 written in JavaScript.
5659
=== renamed file 'debian/unity-js-scopes-examples.install' => 'debian/unity-js-scopes-dev.install'
--- debian/unity-js-scopes-examples.install 2015-09-30 19:54:57 +0000
+++ debian/unity-js-scopes-dev.install 2015-10-23 07:30:32 +0000
@@ -1,1 +1,2 @@
1usr/share/unity-js-scopes/examples/1usr/share/unity-js-scopes/examples/
2usr/share/qtcreator/templates/wizards/ubuntu/
23
=== added directory 'qtc-templates'
=== added directory 'qtc-templates/scope-js'
=== added file 'qtc-templates/scope-js/.bzrignore'
--- qtc-templates/scope-js/.bzrignore 1970-01-01 00:00:00 +0000
+++ qtc-templates/scope-js/.bzrignore 2015-10-23 07:30:32 +0000
@@ -0,0 +1,5 @@
1./CMakeLists.txt.user
2./po/Makefile.in.in
3./po/POTFILES.in
4./src/etc
5./src/node_modules
06
=== added file 'qtc-templates/scope-js/CMakeLists.txt'
--- qtc-templates/scope-js/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ qtc-templates/scope-js/CMakeLists.txt 2015-10-23 07:30:32 +0000
@@ -0,0 +1,57 @@
1project(%ProjectName:l%)
2cmake_minimum_required(VERSION 2.8.10)
3
4# This is required to ensure the correct node modules are included in the project
5execute_process(COMMAND unity-js-scopes-tool install ${CMAKE_SOURCE_DIR}/src/node_modules unity-js-scopes)
6@if "%ContentType%" == "http+xml"
7execute_process(COMMAND unity-js-scopes-tool install ${CMAKE_SOURCE_DIR}/src/node_modules pixl-xml)
8@endif
9add_custom_target(build_modules ALL COMMAND unity-js-scopes-tool build ${CMAKE_SOURCE_DIR}/src/node_modules)
10
11# Do not remove this, its required for the correct functionality of the Ubuntu-SDK
12set(UBUNTU_MANIFEST_PATH "manifest.json.in" CACHE INTERNAL "Tells QtCreator location and name of the manifest file")
13set(UBUNTU_PROJECT_TYPE "Scope" CACHE INTERNAL "Tells QtCreator this is a Scope project")
14
15# Important project paths
16set(CMAKE_INSTALL_PREFIX /)
17set(SCOPE_INSTALL_DIR "/%ClickHookName:l%")
18set(GETTEXT_PACKAGE "%ProjectName:l%")
19set(PACKAGE_NAME "%ProjectName:l%.%ClickDomain:l%")
20set(SCOPE_NAME "${PACKAGE_NAME}_%ClickHookName:l%")
21
22# This command figures out the target architecture and puts it into the manifest file
23execute_process(
24 COMMAND dpkg-architecture -qDEB_HOST_ARCH
25 OUTPUT_VARIABLE CLICK_ARCH
26 OUTPUT_STRIP_TRAILING_WHITESPACE
27)
28
29# Install the manifest and apparmor files
30configure_file(manifest.json.in ${CMAKE_CURRENT_BINARY_DIR}/manifest.json)
31install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.json DESTINATION "/")
32install(FILES "%ClickHookName:l%.apparmor" DESTINATION "/")
33
34# Make these files show up in QtCreator
35file(GLOB_RECURSE
36 _PO_JS_FILES
37 "po/*.po"
38 "*.js"
39)
40add_custom_target(hidden_files
41 ALL
42 SOURCES
43 manifest.json.in
44 %ClickHookName:l%.apparmor
45 src/data/%ClickHookName:l%.ini.in
46 src/data/%ClickHookName:l%-settings.ini.in
47 po/POTFILES.in.in
48 po/${GETTEXT_PACKAGE}.pot
49 ${_PO_JS_FILES}
50)
51
52# Search for our dependencies
53find_package(Intltool)
54
55# Add our main directories
56add_subdirectory(po)
57add_subdirectory(src)
058
=== added file 'qtc-templates/scope-js/displayName.apparmor'
--- qtc-templates/scope-js/displayName.apparmor 1970-01-01 00:00:00 +0000
+++ qtc-templates/scope-js/displayName.apparmor 2015-10-23 07:30:32 +0000
@@ -0,0 +1,6 @@
1{
2 "template": "%ConfinementType%",
3 "policy_groups": [],
4 "policy_version": %ClickAAPolicyVersion%
5}
6
07
=== added file 'qtc-templates/scope-js/manifest.json.in'
--- qtc-templates/scope-js/manifest.json.in 1970-01-01 00:00:00 +0000
+++ qtc-templates/scope-js/manifest.json.in 2015-10-23 07:30:32 +0000
@@ -0,0 +1,15 @@
1{
2 "description": "A simple Unity scope written in JavaScript",
3 "maintainer": "%ClickMaintainer%",
4 "architecture": "@CLICK_ARCH@",
5 "name": "%ProjectName:l%.%ClickDomain:l%",
6 "title": "%ProjectName:l%",
7 "framework" : "%ClickFrameworkVersion%",
8 "hooks": {
9 "%ClickHookName:l%": {
10 "scope": "%ClickHookName:l%",
11 "apparmor": "%ClickHookName:l%.apparmor"
12 }
13 }
14}
15
016
=== added directory 'qtc-templates/scope-js/po'
=== added file 'qtc-templates/scope-js/po/CMakeLists.txt'
--- qtc-templates/scope-js/po/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ qtc-templates/scope-js/po/CMakeLists.txt 2015-10-23 07:30:32 +0000
@@ -0,0 +1,14 @@
1intltool_update_potfile(
2 ALL
3 KEYWORDS "tr" "tr:1,2" "dtr:2" "dtr:2,3" "N_"
4 COPYRIGHT_HOLDER ""
5 POTFILES_TEMPLATE "POTFILES.in.in"
6 GETTEXT_PACKAGE ${GETTEXT_PACKAGE}
7)
8
9intltool_install_translations(
10 ALL
11 GETTEXT_PACKAGE ${GETTEXT_PACKAGE}
12)
13
14
015
=== added file 'qtc-templates/scope-js/po/POTFILES.in.in'
--- qtc-templates/scope-js/po/POTFILES.in.in 1970-01-01 00:00:00 +0000
+++ qtc-templates/scope-js/po/POTFILES.in.in 2015-10-23 07:30:32 +0000
@@ -0,0 +1,3 @@
1[type: gettext/ini] src/data/%ClickHookName:l%.ini.in
2[type: gettext/ini] src/data/%ClickHookName:l%-settings.ini.in
3@GENERATED_POTFILES@
04
=== added file 'qtc-templates/scope-js/po/displayName.pot'
=== added directory 'qtc-templates/scope-js/src'
=== added file 'qtc-templates/scope-js/src/CMakeLists.txt'
--- qtc-templates/scope-js/src/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ qtc-templates/scope-js/src/CMakeLists.txt 2015-10-23 07:30:32 +0000
@@ -0,0 +1,61 @@
1# Put the ini, image, and js files in the build directory next
2# to the scope .so file so test tools can find them easily.
3intltool_merge_translations(
4 "data/%ClickHookName:l%.ini.in"
5 "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}.ini"
6 ALL UTF8
7)
8intltool_merge_translations(
9 "data/%ClickHookName:l%-settings.ini.in"
10 "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}-settings.ini"
11 ALL UTF8
12)
13
14configure_file(
15 "data/icon.png"
16 "${CMAKE_CURRENT_BINARY_DIR}/icon.png"
17 @ONLY COPYONLY
18)
19configure_file(
20 "data/logo.png"
21 "${CMAKE_CURRENT_BINARY_DIR}/logo.png"
22 @ONLY COPYONLY
23)
24
25configure_file(
26 "%ClickHookName:l%.js"
27 "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}.js"
28 @ONLY COPYONLY
29)
30
31add_custom_target(
32 copy_modules ALL
33 COMMAND ${CMAKE_COMMAND} -E create_symlink
34 "${CMAKE_CURRENT_SOURCE_DIR}/node_modules"
35 "${CMAKE_CURRENT_BINARY_DIR}/node_modules"
36)
37
38# Install the scope ini, image, and js files
39install(
40 FILES
41 "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}.ini"
42 "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}-settings.ini"
43 "${CMAKE_CURRENT_BINARY_DIR}/icon.png"
44 "${CMAKE_CURRENT_BINARY_DIR}/logo.png"
45 DESTINATION
46 ${SCOPE_INSTALL_DIR}
47)
48
49install(
50 DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
51 DESTINATION ${SCOPE_INSTALL_DIR}
52 FILES_MATCHING PATTERN "*.js"
53)
54
55install(
56 DIRECTORY
57 "${CMAKE_CURRENT_SOURCE_DIR}/node_modules"
58 DESTINATION
59 ${SCOPE_INSTALL_DIR}
60 USE_SOURCE_PERMISSIONS
61)
062
=== added directory 'qtc-templates/scope-js/src/data'
=== added file 'qtc-templates/scope-js/src/data/displayName-settings.ini.in'
--- qtc-templates/scope-js/src/data/displayName-settings.ini.in 1970-01-01 00:00:00 +0000
+++ qtc-templates/scope-js/src/data/displayName-settings.ini.in 2015-10-23 07:30:32 +0000
@@ -0,0 +1,21 @@
1@if "%ContentType%" != "empty"
2# Below are some example settings. You can access your scope's
3# settings by calling settings() from the Query::run() method.
4# E.g. auto location = settings().at("location").get_string();
5
6#[location]
7#type = string
8#defaultValue = London,uk
9#_displayName = Default Location
10
11#[units]
12#type = list
13#_displayName = Temperature Units
14#_displayValues = Metric;Imperial
15#defaultValue = 0
16
17#[forecast]
18#type = boolean
19#defaultValue = true
20#_displayName = Show Forecast
21@endif
022
=== added file 'qtc-templates/scope-js/src/data/displayName.ini.in'
--- qtc-templates/scope-js/src/data/displayName.ini.in 1970-01-01 00:00:00 +0000
+++ qtc-templates/scope-js/src/data/displayName.ini.in 2015-10-23 07:30:32 +0000
@@ -0,0 +1,9 @@
1[ScopeConfig]
2ScopeRunner=./node_modules/unity-js-scopes/bin/unity-js-scopes-launcher %S %R
3_DisplayName=%ProjectName:c% Scope
4_Description=This is a %ProjectName:c% scope
5Author = %ClickMaintainer%
6Icon = icon.png
7
8[Appearance]
9PageHeader.Logo = logo.png
010
=== added file 'qtc-templates/scope-js/src/data/icon.png'
1Binary files qtc-templates/scope-js/src/data/icon.png 1970-01-01 00:00:00 +0000 and qtc-templates/scope-js/src/data/icon.png 2015-10-23 07:30:32 +0000 differ11Binary files qtc-templates/scope-js/src/data/icon.png 1970-01-01 00:00:00 +0000 and qtc-templates/scope-js/src/data/icon.png 2015-10-23 07:30:32 +0000 differ
=== added file 'qtc-templates/scope-js/src/data/logo.png'
2Binary files qtc-templates/scope-js/src/data/logo.png 1970-01-01 00:00:00 +0000 and qtc-templates/scope-js/src/data/logo.png 2015-10-23 07:30:32 +0000 differ12Binary files qtc-templates/scope-js/src/data/logo.png 1970-01-01 00:00:00 +0000 and qtc-templates/scope-js/src/data/logo.png 2015-10-23 07:30:32 +0000 differ
=== added file 'qtc-templates/scope-js/src/displayName.js.in'
--- qtc-templates/scope-js/src/displayName.js.in 1970-01-01 00:00:00 +0000
+++ qtc-templates/scope-js/src/displayName.js.in 2015-10-23 07:30:32 +0000
@@ -0,0 +1,224 @@
1var scopes = require('unity-js-scopes')
2@if "%ContentType%" != "empty"
3var http = require('http');
4@if "%ContentType%" == "http+xml"
5var XML = require('pixl-xml');
6@endif
7
8var query_host = "api.openweathermap.org"
9@if "%ContentType%" == "http+xml"
10var current_weather_path = "/data/2.5/weather?units=metric&APPID=2b12bf09b4e0ab0c1aa5e32a9a3f0cdc&mode=xml&q="
11var forecast_weather_path = "/data/2.5/forecast/daily/?units=metric&cnt=7&APPID=2b12bf09b4e0ab0c1aa5e32a9a3f0cdc&mode=xml&q="
12@elsif "%ContentType%" == "http+json"
13var current_weather_path = "/data/2.5/weather?units=metric&APPID=2b12bf09b4e0ab0c1aa5e32a9a3f0cdc&q="
14var forecast_weather_path = "/data/2.5/forecast/daily/?units=metric&cnt=7&APPID=2b12bf09b4e0ab0c1aa5e32a9a3f0cdc&q="
15@endif
16
17var CURRENT_TEMPLATE =
18{
19 "schema-version": 1,
20 "template": {
21 "category-layout": "grid",
22 "card-size": "medium"
23 },
24 "components": {
25 "title": "title",
26 "art": {
27 "field": "art"
28 },
29 "subtitle": "subtitle"
30 }
31}
32
33var FORECAST_TEMPLATE =
34{
35 "schema-version": 1,
36 "template": {
37 "category-layout": "grid",
38 "card-layout": "horizontal",
39 "card-size": "small"
40 },
41 "components": {
42 "title": "title",
43 "art" : {
44 "field": "art"
45 },
46 "subtitle": "subtitle"
47 }
48}
49@endif
50
51scopes.self.initialize(
52 {}
53 ,
54 {
55 run: function() {
56 console.log('Running...')
57 },
58 start: function(scope_id) {
59 console.log('Starting scope id: '
60 + scope_id
61 + ', '
62 + scopes.self.scope_config)
63 },
64 search: function(canned_query, metadata) {
65 return new scopes.lib.search_query(
66 canned_query,
67 metadata,
68 // run
69 function(search_reply) {
70@if "%ContentType%" != "empty"
71 var qs = canned_query.query_string();
72 if (!qs) {
73 qs = "London,uk"
74 }
75
76 var current_weather_cb = function(response) {
77 var res = '';
78
79 // Another chunk of data has been recieved, so append it to res
80 response.on('data', function(chunk) {
81 res += chunk;
82 });
83
84 // The whole response has been recieved
85 response.on('end', function() {
86@if "%ContentType%" == "http+xml"
87 r = XML.parse(res);
88
89 var category_renderer = new scopes.lib.category_renderer(JSON.stringify(CURRENT_TEMPLATE));
90 var category = search_reply.register_category("current", r.city.name + ", " + r.city.country, "", category_renderer);
91
92 var categorised_result = new scopes.lib.categorised_result(category);
93 categorised_result.set_uri(r.city.id.toString());
94 categorised_result.set_title(r.temperature.value.toString() + "°C");
95 categorised_result.set_art("http://openweathermap.org/img/w/" + r.weather.icon + ".png");
96 categorised_result.set("subtitle", r.weather.value);
97 categorised_result.set("description", "A description of the result");
98@elsif "%ContentType%" == "http+json"
99 r = JSON.parse(res);
100
101 var category_renderer = new scopes.lib.category_renderer(JSON.stringify(CURRENT_TEMPLATE));
102 var category = search_reply.register_category("current", r.name + ", " + r.sys.country, "", category_renderer);
103
104 var categorised_result = new scopes.lib.categorised_result(category);
105 categorised_result.set_uri(r.id.toString());
106 categorised_result.set_title(r.main.temp.toString() + "°C");
107 categorised_result.set_art("http://openweathermap.org/img/w/" + r.weather[0].icon + ".png");
108 categorised_result.set("subtitle", r.weather[0].description);
109 categorised_result.set("description", "A description of the result");
110@endif
111
112 search_reply.push(categorised_result);
113
114 // Now call back into the API for a 7 day forecast
115 http.request({host: query_host, path: forecast_weather_path + qs}, forecase_weather_cb).end();
116 });
117 }
118
119 var forecase_weather_cb = function(response) {
120 var res = '';
121
122 // Another chunk of data has been recieved, so append it to res
123 response.on('data', function(chunk) {
124 res += chunk;
125 });
126
127 // The whole response has been recieved
128 response.on('end', function() {
129 try {
130@if "%ContentType%" == "http+xml"
131 r = XML.parse(res);
132
133 var category_renderer = new scopes.lib.category_renderer(JSON.stringify(FORECAST_TEMPLATE));
134 var category = search_reply.register_category("forecast", "7 day forecast", "", category_renderer);
135
136 var weather_id = 1000000;
137 for (i = 0; i < r.forecast.time.length; i++) {
138 var categorised_result = new scopes.lib.categorised_result(category);
139 categorised_result.set_uri((weather_id++).toString());
140 categorised_result.set_title(r.forecast.time[i].temperature.min.toString() + "°C to "
141 + r.forecast.time[i].temperature.max.toString() + "°C");
142 categorised_result.set_art("http://openweathermap.org/img/w/" + r.forecast.time[i].symbol.var + ".png");
143 categorised_result.set("subtitle", r.forecast.time[i].symbol.name);
144 categorised_result.set("description", "A description of the result");
145
146 search_reply.push(categorised_result);
147 }
148@elsif "%ContentType%" == "http+json"
149 r = JSON.parse(res);
150
151 var category_renderer = new scopes.lib.category_renderer(JSON.stringify(FORECAST_TEMPLATE));
152 var category = search_reply.register_category("forecast", "7 day forecast", "", category_renderer);
153
154 for (i = 0; i < r.list.length; i++) {
155 var categorised_result = new scopes.lib.categorised_result(category);
156 categorised_result.set_uri(r.list[i].weather[0].id.toString());
157 categorised_result.set_title(r.list[i].temp.min.toString() + "°C to "
158 + r.list[i].temp.max.toString() + "°C");
159 categorised_result.set_art("http://openweathermap.org/img/w/" + r.list[i].weather[0].icon + ".png");
160 categorised_result.set("subtitle", r.list[i].weather[0].description);
161 categorised_result.set("description", "A description of the result");
162
163 search_reply.push(categorised_result);
164 }
165@endif
166
167 // We are done, call finished() on our search_reply
168 search_reply.finished();
169 }
170 catch(e) {
171 // Forecast not available
172 console.log("Forecast for '" + qs + "' is unavailable: " + e)
173 }
174 });
175 }
176
177 http.request({host: query_host, path: current_weather_path + qs}, current_weather_cb).end();
178@endif
179 },
180 // cancelled
181 function() {
182 });
183 },
184 preview: function(result, action_metadata) {
185 return new scopes.lib.preview_query(
186 result,
187 action_metadata,
188 // run
189 function(preview_reply) {
190@if "%ContentType%" != "empty"
191 var layout1col = new scopes.lib.column_layout(1);
192 var layout2col = new scopes.lib.column_layout(2);
193 var layout3col = new scopes.lib.column_layout(3);
194 layout1col.add_column(["image", "header", "summary"]);
195
196 layout2col.add_column(["image"]);
197 layout2col.add_column(["header", "summary"]);
198
199 layout3col.add_column(["image"]);
200 layout3col.add_column(["header", "summary"]);
201 layout3col.add_column([]);
202
203 preview_reply.register_layout([layout1col, layout2col, layout3col]);
204
205 var header = new scopes.lib.preview_widget("header", "header");
206 header.add_attribute_mapping("title", "title");
207 header.add_attribute_mapping("subtitle", "subtitle");
208
209 var image = new scopes.lib.preview_widget("image", "image");
210 image.add_attribute_mapping("source", "art");
211
212 var description = new scopes.lib.preview_widget("summary", "text");
213 description.add_attribute_mapping("text", "description");
214
215 preview_reply.push([image, header, description ]);
216 preview_reply.finished();
217@endif
218 },
219 // cancelled
220 function() {
221 });
222 }
223 }
224 );
0225
=== added file 'qtc-templates/scope-js/wizard.xml'
--- qtc-templates/scope-js/wizard.xml 1970-01-01 00:00:00 +0000
+++ qtc-templates/scope-js/wizard.xml 2015-10-23 07:30:32 +0000
@@ -0,0 +1,96 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<wizard version="1" kind="project" firstpage="10" id="C_UbuntuUnityJsScope" category="A.UbuntuProject"
3 platformIndependent="true"
4 class="ubuntu-project-cmake"
5 featuresRequired=""
6 >
7 <icon>../share/ubuntu.png</icon>
8 <description>A simple JavaScript based Unity Scope</description>
9 <displayname>Unity Scope (JavaScript)</displayname>
10 <displaycategory>Ubuntu</displaycategory>
11 <files>
12 <file source="po/CMakeLists.txt"/>
13 <file source="po/displayName.pot" target="po/%ProjectName:l%.pot"/>
14 <file source="po/POTFILES.in.in"/>
15
16 <file source="src/data/displayName.ini.in" target="src/data/%ClickHookName:l%.ini.in"/>
17 <file source="src/data/displayName-settings.ini.in" target="src/data/%ClickHookName:l%-settings.ini.in"/>
18 <file source="src/data/icon.png" binary="true"/>
19 <file source="src/data/logo.png" binary="true"/>
20
21 <file source="src/displayName.js.in" target="src/%ClickHookName:l%.js"/>
22 <file source="src/CMakeLists.txt"/>
23
24 <file source="CMakeLists.txt" openproject="true"/>
25 <file source="displayName.apparmor" target="%ClickHookName:l%.apparmor"/>
26 <file source="manifest.json.in" openeditor="true"/>
27 <file source=".bzrignore"/>
28 </files>
29
30 <!-- Create a 2nd wizard page with click package parameters -->
31 <fieldpagetitle>Click package parameters</fieldpagetitle>
32 <fields>
33 <field mandatory="true" name="ClickDomain">
34 <fieldcontrol class="QLineEdit" validator='^[A-Za-z0-9-]+$'
35 defaulttext="" placeholdertext="Nickname"/>
36 <fielddescription>Nickname:</fielddescription>
37 </field>
38 <field mandatory="true" name="ClickMaintainer">
39 <fieldcontrol class="QLineEdit" validator='^[^"]+$'
40 defaulttext="" placeholdertext="Maintainer"/>
41 <fielddescription>Maintainer:</fielddescription>
42 </field>
43 <field mandatory="true" name="ClickHookName">
44 <fieldcontrol class="QLineEdit" validator='^[A-Za-z0-9.-]+$'
45 defaulttext="%ProjectName%" placeholdertext="scope hook name"/>
46 <fielddescription>Scope name:</fielddescription>
47 </field>
48 <field name="ClickFrameworkVersion">
49 <fieldcontrol class="QComboBox" defaultindex="0">
50 <comboentries>
51 <!-- Do not add any other frameworks here, they are populated at runtime, this is just a dummy framework to make sure we can find the combobox -->
52 <comboentry value="ubuntu-sdk-dummy-framework">
53 <comboentrytext>Dummy Framework</comboentrytext>
54 </comboentry>
55 </comboentries>
56 </fieldcontrol>
57 <fielddescription>Framework:</fielddescription>
58 </field>
59 <field name="ConfinementType">
60 <fieldcontrol class="QComboBox" defaultindex="0">
61 <comboentries>
62 <comboentry value="ubuntu-scope-network">
63 <comboentrytext>Scope with network access</comboentrytext>
64 </comboentry>
65 <!--
66 <comboentry value="ubuntu-scope-local-content">
67 <comboentrytext>Scope with local content</comboentrytext>
68 </comboentry>
69 -->
70 </comboentries>
71 </fieldcontrol>
72 <fielddescription>Confinement type:</fielddescription>
73 </field>
74 <field name="ContentType">
75 <fieldcontrol class="QComboBox" defaultindex="0">
76 <comboentries>
77 <comboentry value="http+json">
78 <comboentrytext>JavaScript scope using HTTP and JSON</comboentrytext>
79 </comboentry>
80 <comboentry value="http+xml">
81 <comboentrytext>JavaScript scope using HTTP and XML</comboentrytext>
82 </comboentry>
83 <comboentry value="empty">
84 <comboentrytext>Empty scope</comboentrytext>
85 </comboentry>
86 </comboentries>
87 </fieldcontrol>
88 <fielddescription>Template type:</fielddescription>
89 </field>
90 </fields>
91 <validationrules>
92 <validationrule condition='/^(.*)\s+&lt;(.*@.*)&gt;$/.test("%ClickMaintainer%")'>
93 <message>Invalid format for maintainer (should be like "Joe Bloggs &lt;joe.bloggs@isp.com&gt;")</message>
94 </validationrule>
95 </validationrules>
96</wizard>
097
=== modified file 'src/tool/main.cc'
--- src/tool/main.cc 2015-10-16 07:06:35 +0000
+++ src/tool/main.cc 2015-10-23 07:30:32 +0000
@@ -30,42 +30,54 @@
30#include <boost/algorithm/string/predicate.hpp>30#include <boost/algorithm/string/predicate.hpp>
31#include <boost/filesystem.hpp>31#include <boost/filesystem.hpp>
3232
33std::string get_arch() {33std::string exec_cmd(std::string const& cmd) {
34 std::string result = "";34 std::string result = "";
3535
36 {36 FILE* pipe = popen(cmd.c_str(), "r");
37 FILE* pipe = popen("dpkg-architecture -qDEB_HOST_ARCH", "r");37 if (!pipe) throw std::runtime_error("'" + cmd + "' command failed");
38 if (!pipe) throw std::runtime_error("'dpkg-architecture' command failed");38 char buffer[128];
39 char buffer[128];39 while (!feof(pipe)) {
40 while (!feof(pipe)) {40 if (fgets(buffer, 128, pipe) != NULL)
41 if (fgets(buffer, 128, pipe) != NULL)41 result += buffer;
42 result += buffer;42 }
43 }43 result.pop_back();
44 result.pop_back();44 pclose(pipe);
45 pclose(pipe);
46 }
47
48 result += "-";
49
50 {
51 FILE* pipe = popen("lsb_release -rs", "r");
52 if (!pipe) throw std::runtime_error("'lsb_release' command failed");
53 char buffer[128];
54 while (!feof(pipe)) {
55 if (fgets(buffer, 128, pipe) != NULL)
56 result += buffer;
57 }
58 result.pop_back();
59 pclose(pipe);
60 }
6145
62 return result;46 return result;
63}47}
6448
49std::string get_arch() {
50 return exec_cmd("dpkg-architecture -qDEB_HOST_ARCH") + "-" + exec_cmd("lsb_release -rs");
51}
52
53int setup_chroot(std::string const& fw)
54{
55 if (exec_cmd("click chroot -a armhf -f ubuntu-sdk-" + fw + " maint echo 1") == "1")
56 {
57 std::string setup_script;
58 setup_script += "click chroot -a armhf -f ubuntu-sdk-" + fw + " maint apt-get install software-properties-common -y --force-yes \n";
59 setup_script += "click chroot -a armhf -f ubuntu-sdk-" + fw + " maint add-apt-repository ppa:ubuntu-sdk-team/staging -y \n";
60
61 setup_script += "click chroot -a armhf -f ubuntu-sdk-" + fw + " maint sh -c \"find /etc/apt/sources.list.d//*.list \
62 -exec apt-get update -o Dir::Etc::sourcelist='{}' -o Dir::Etc::sourceparts='-' -o APT::Get::List-Cleanup='0' \\;\" \n";
63
64 setup_script += "click chroot -a armhf -f ubuntu-sdk-" + fw + " maint apt-get install unity-js-scopes-bindings:armhf -y --force-yes \n";
65 setup_script += "click chroot -a armhf -f ubuntu-sdk-" + fw + " maint apt-get install unity-js-scopes-launcher:armhf -y --force-yes \n";
66 setup_script += "click chroot -a armhf -f ubuntu-sdk-" + fw + " maint apt-get install unity-js-scopes-tool -y --force-yes \n";
67
68 std::cout << "Setting up " << fw << " chroot ..." << std::endl;
69 return system(setup_script.c_str());
70 }
71 return EXIT_SUCCESS;
72}
73
65void usage() {74void usage() {
66 std::cout << "Usage:"75 std::cout << "Usage:"
67 << std::endl76 << std::endl
68 << executable_name()77 << executable_name()
78 << " setup "
79 << std::endl
80 << executable_name()
69 << " [re]install "81 << " [re]install "
70 << "<path/to/node_modules> "82 << "<path/to/node_modules> "
71 << "[<npm_module>]"83 << "[<npm_module>]"
@@ -333,6 +345,53 @@
333345
334 return result;346 return result;
335 }347 }
348 else if (std::string(argv[1]) == "setup") {
349 if (argc > 2) {
350 usage();
351 return EXIT_FAILURE;
352 }
353
354 std::cout << "Setup started." << std::endl;
355
356 // Set up 15.04 chroot
357 try
358 {
359 if (setup_chroot("15.04") == EXIT_FAILURE)
360 {
361 std::cout << "Setup failed." << std::endl;
362 return EXIT_FAILURE;
363 }
364 }
365 catch (std::exception const& e)
366 {
367 std::cout << "Failed to detect 15.04 chroot: " << e.what() << " ..." << std::endl;
368 }
369
370 // Set up 15.10 chroot
371 try
372 {
373 if (setup_chroot("15.10") == EXIT_FAILURE)
374 {
375 std::cout << "Setup failed." << std::endl;
376 return EXIT_FAILURE;
377 }
378 }
379 catch (std::exception const& e)
380 {
381 std::cout << "Failed to detect 15.10 chroot: " << e.what() << " ..." << std::endl;
382 }
383
384 // Remount chroots
385 std::cout << "Remounting chroots ..." << std::endl;
386 if (system("click-chroot-agent --reload") == EXIT_FAILURE)
387 {
388 std::cout << "Setup failed." << std::endl;
389 return EXIT_FAILURE;
390 }
391
392 std::cout << "Setup complete." << std::endl;
393 return EXIT_SUCCESS;
394 }
336 else {395 else {
337 return node::Start(argc, argv);396 return node::Start(argc, argv);
338 }397 }

Subscribers

People subscribed via source and target branches

to all changes: