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

Proposed by Marcus Tomlinson on 2015-10-23
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) 2015-10-23 Approve on 2015-10-23
PS Jenkins bot (community) continuous-integration 2015-10-23 Approve on 2015-10-23
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.
Alexandre Abreu (abreu-alexandre) wrote : Posted in a previous version of this proposal

a few comments, inline

Marcus Tomlinson (marcustomlinson) wrote : Posted in a previous version of this proposal

> a few comments, inline

fixed

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

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2015-09-14 09:28:53 +0000
3+++ .bzrignore 2015-10-23 07:30:32 +0000
4@@ -2,3 +2,5 @@
5 ./deps/v8-cpp
6 ./CMakeLists.txt.user
7 ./examples/simple-click/CMakeLists.txt.user
8+./examples/simple-click/src/etc
9+./examples/simple-click/src/node_modules
10
11=== modified file 'CMakeLists.txt'
12--- CMakeLists.txt 2015-10-01 14:46:56 +0000
13+++ CMakeLists.txt 2015-10-23 07:30:32 +0000
14@@ -61,5 +61,8 @@
15
16 add_subdirectory(src)
17
18-install(DIRECTORY examples
19+install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/examples
20 DESTINATION ${CMAKE_INSTALL_DATADIR}/unity-js-scopes)
21+
22+install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/qtc-templates/scope-js
23+ DESTINATION /usr/share/qtcreator/templates/wizards/ubuntu)
24
25=== modified file 'debian/control'
26--- debian/control 2015-10-13 13:07:02 +0000
27+++ debian/control 2015-10-23 07:30:32 +0000
28@@ -22,8 +22,8 @@
29 Multi-Arch: foreign
30 Depends: ${misc:Depends},
31 ${shlibs:Depends},
32-Description: Javascript bindings to unity scopes library
33- Provides a means for developers to develop Ubuntu Scopes in Javascript
34+Description: JavaScript bindings to Unity Scopes API
35+ Provides a means for developers to develop Ubuntu Scopes in JavaScript
36 by providing bindings to the Unity Scopes API.
37
38 Package: unity-js-scopes-launcher
39@@ -32,8 +32,8 @@
40 Depends: ${misc:Depends},
41 ${shlibs:Depends},
42 unity-js-scopes-bindings (= ${binary:Version}),
43-Description: Scope launcher for unity javascript scopes
44- Provides a means for developers to launch their Javascript Ubuntu Scopes.
45+Description: Scope launcher for Unity JavaScript Scopes
46+ Provides a means for developers to launch their JavaScript Ubuntu Scopes.
47
48 Package: unity-js-scopes-tool
49 Architecture: any
50@@ -42,14 +42,17 @@
51 ${shlibs:Depends},
52 unity-js-scopes-bindings (= ${binary:Version}),
53 unity-js-scopes-launcher (= ${binary:Version}),
54-Description: Scope tool for unity javascript scopes
55- Provides a means for developers to configure their Javascript Ubuntu Scopes.
56+Description: Scope tool for Unity JavaScript Scopes
57+ Provides a means for developers to configure their JavaScript Ubuntu Scopes.
58
59-Package: unity-js-scopes-examples
60+Package: unity-js-scopes-dev
61 Architecture: any
62 Multi-Arch: foreign
63 Depends: ${misc:Depends},
64 ${shlibs:Depends},
65 unity-js-scopes-bindings (= ${binary:Version}),
66-Description: Examples for javascript unity scopes
67- Provides a set of examples for unity scopes written in javascript.
68+ unity-js-scopes-launcher (= ${binary:Version}),
69+ unity-js-scopes-tool (= ${binary:Version}),
70+Description: Development files for Unity JavaScript Scopes
71+ Provides a set of Qt Creator templates and examples for Ubuntu Scopes
72+ written in JavaScript.
73
74=== renamed file 'debian/unity-js-scopes-examples.install' => 'debian/unity-js-scopes-dev.install'
75--- debian/unity-js-scopes-examples.install 2015-09-30 19:54:57 +0000
76+++ debian/unity-js-scopes-dev.install 2015-10-23 07:30:32 +0000
77@@ -1,1 +1,2 @@
78 usr/share/unity-js-scopes/examples/
79+usr/share/qtcreator/templates/wizards/ubuntu/
80
81=== added directory 'qtc-templates'
82=== added directory 'qtc-templates/scope-js'
83=== added file 'qtc-templates/scope-js/.bzrignore'
84--- qtc-templates/scope-js/.bzrignore 1970-01-01 00:00:00 +0000
85+++ qtc-templates/scope-js/.bzrignore 2015-10-23 07:30:32 +0000
86@@ -0,0 +1,5 @@
87+./CMakeLists.txt.user
88+./po/Makefile.in.in
89+./po/POTFILES.in
90+./src/etc
91+./src/node_modules
92
93=== added file 'qtc-templates/scope-js/CMakeLists.txt'
94--- qtc-templates/scope-js/CMakeLists.txt 1970-01-01 00:00:00 +0000
95+++ qtc-templates/scope-js/CMakeLists.txt 2015-10-23 07:30:32 +0000
96@@ -0,0 +1,57 @@
97+project(%ProjectName:l%)
98+cmake_minimum_required(VERSION 2.8.10)
99+
100+# This is required to ensure the correct node modules are included in the project
101+execute_process(COMMAND unity-js-scopes-tool install ${CMAKE_SOURCE_DIR}/src/node_modules unity-js-scopes)
102+@if "%ContentType%" == "http+xml"
103+execute_process(COMMAND unity-js-scopes-tool install ${CMAKE_SOURCE_DIR}/src/node_modules pixl-xml)
104+@endif
105+add_custom_target(build_modules ALL COMMAND unity-js-scopes-tool build ${CMAKE_SOURCE_DIR}/src/node_modules)
106+
107+# Do not remove this, its required for the correct functionality of the Ubuntu-SDK
108+set(UBUNTU_MANIFEST_PATH "manifest.json.in" CACHE INTERNAL "Tells QtCreator location and name of the manifest file")
109+set(UBUNTU_PROJECT_TYPE "Scope" CACHE INTERNAL "Tells QtCreator this is a Scope project")
110+
111+# Important project paths
112+set(CMAKE_INSTALL_PREFIX /)
113+set(SCOPE_INSTALL_DIR "/%ClickHookName:l%")
114+set(GETTEXT_PACKAGE "%ProjectName:l%")
115+set(PACKAGE_NAME "%ProjectName:l%.%ClickDomain:l%")
116+set(SCOPE_NAME "${PACKAGE_NAME}_%ClickHookName:l%")
117+
118+# This command figures out the target architecture and puts it into the manifest file
119+execute_process(
120+ COMMAND dpkg-architecture -qDEB_HOST_ARCH
121+ OUTPUT_VARIABLE CLICK_ARCH
122+ OUTPUT_STRIP_TRAILING_WHITESPACE
123+)
124+
125+# Install the manifest and apparmor files
126+configure_file(manifest.json.in ${CMAKE_CURRENT_BINARY_DIR}/manifest.json)
127+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.json DESTINATION "/")
128+install(FILES "%ClickHookName:l%.apparmor" DESTINATION "/")
129+
130+# Make these files show up in QtCreator
131+file(GLOB_RECURSE
132+ _PO_JS_FILES
133+ "po/*.po"
134+ "*.js"
135+)
136+add_custom_target(hidden_files
137+ ALL
138+ SOURCES
139+ manifest.json.in
140+ %ClickHookName:l%.apparmor
141+ src/data/%ClickHookName:l%.ini.in
142+ src/data/%ClickHookName:l%-settings.ini.in
143+ po/POTFILES.in.in
144+ po/${GETTEXT_PACKAGE}.pot
145+ ${_PO_JS_FILES}
146+)
147+
148+# Search for our dependencies
149+find_package(Intltool)
150+
151+# Add our main directories
152+add_subdirectory(po)
153+add_subdirectory(src)
154
155=== added file 'qtc-templates/scope-js/displayName.apparmor'
156--- qtc-templates/scope-js/displayName.apparmor 1970-01-01 00:00:00 +0000
157+++ qtc-templates/scope-js/displayName.apparmor 2015-10-23 07:30:32 +0000
158@@ -0,0 +1,6 @@
159+{
160+ "template": "%ConfinementType%",
161+ "policy_groups": [],
162+ "policy_version": %ClickAAPolicyVersion%
163+}
164+
165
166=== added file 'qtc-templates/scope-js/manifest.json.in'
167--- qtc-templates/scope-js/manifest.json.in 1970-01-01 00:00:00 +0000
168+++ qtc-templates/scope-js/manifest.json.in 2015-10-23 07:30:32 +0000
169@@ -0,0 +1,15 @@
170+{
171+ "description": "A simple Unity scope written in JavaScript",
172+ "maintainer": "%ClickMaintainer%",
173+ "architecture": "@CLICK_ARCH@",
174+ "name": "%ProjectName:l%.%ClickDomain:l%",
175+ "title": "%ProjectName:l%",
176+ "framework" : "%ClickFrameworkVersion%",
177+ "hooks": {
178+ "%ClickHookName:l%": {
179+ "scope": "%ClickHookName:l%",
180+ "apparmor": "%ClickHookName:l%.apparmor"
181+ }
182+ }
183+}
184+
185
186=== added directory 'qtc-templates/scope-js/po'
187=== added file 'qtc-templates/scope-js/po/CMakeLists.txt'
188--- qtc-templates/scope-js/po/CMakeLists.txt 1970-01-01 00:00:00 +0000
189+++ qtc-templates/scope-js/po/CMakeLists.txt 2015-10-23 07:30:32 +0000
190@@ -0,0 +1,14 @@
191+intltool_update_potfile(
192+ ALL
193+ KEYWORDS "tr" "tr:1,2" "dtr:2" "dtr:2,3" "N_"
194+ COPYRIGHT_HOLDER ""
195+ POTFILES_TEMPLATE "POTFILES.in.in"
196+ GETTEXT_PACKAGE ${GETTEXT_PACKAGE}
197+)
198+
199+intltool_install_translations(
200+ ALL
201+ GETTEXT_PACKAGE ${GETTEXT_PACKAGE}
202+)
203+
204+
205
206=== added file 'qtc-templates/scope-js/po/POTFILES.in.in'
207--- qtc-templates/scope-js/po/POTFILES.in.in 1970-01-01 00:00:00 +0000
208+++ qtc-templates/scope-js/po/POTFILES.in.in 2015-10-23 07:30:32 +0000
209@@ -0,0 +1,3 @@
210+[type: gettext/ini] src/data/%ClickHookName:l%.ini.in
211+[type: gettext/ini] src/data/%ClickHookName:l%-settings.ini.in
212+@GENERATED_POTFILES@
213
214=== added file 'qtc-templates/scope-js/po/displayName.pot'
215=== added directory 'qtc-templates/scope-js/src'
216=== added file 'qtc-templates/scope-js/src/CMakeLists.txt'
217--- qtc-templates/scope-js/src/CMakeLists.txt 1970-01-01 00:00:00 +0000
218+++ qtc-templates/scope-js/src/CMakeLists.txt 2015-10-23 07:30:32 +0000
219@@ -0,0 +1,61 @@
220+# Put the ini, image, and js files in the build directory next
221+# to the scope .so file so test tools can find them easily.
222+intltool_merge_translations(
223+ "data/%ClickHookName:l%.ini.in"
224+ "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}.ini"
225+ ALL UTF8
226+)
227+intltool_merge_translations(
228+ "data/%ClickHookName:l%-settings.ini.in"
229+ "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}-settings.ini"
230+ ALL UTF8
231+)
232+
233+configure_file(
234+ "data/icon.png"
235+ "${CMAKE_CURRENT_BINARY_DIR}/icon.png"
236+ @ONLY COPYONLY
237+)
238+configure_file(
239+ "data/logo.png"
240+ "${CMAKE_CURRENT_BINARY_DIR}/logo.png"
241+ @ONLY COPYONLY
242+)
243+
244+configure_file(
245+ "%ClickHookName:l%.js"
246+ "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}.js"
247+ @ONLY COPYONLY
248+)
249+
250+add_custom_target(
251+ copy_modules ALL
252+ COMMAND ${CMAKE_COMMAND} -E create_symlink
253+ "${CMAKE_CURRENT_SOURCE_DIR}/node_modules"
254+ "${CMAKE_CURRENT_BINARY_DIR}/node_modules"
255+)
256+
257+# Install the scope ini, image, and js files
258+install(
259+ FILES
260+ "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}.ini"
261+ "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}-settings.ini"
262+ "${CMAKE_CURRENT_BINARY_DIR}/icon.png"
263+ "${CMAKE_CURRENT_BINARY_DIR}/logo.png"
264+ DESTINATION
265+ ${SCOPE_INSTALL_DIR}
266+)
267+
268+install(
269+ DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
270+ DESTINATION ${SCOPE_INSTALL_DIR}
271+ FILES_MATCHING PATTERN "*.js"
272+)
273+
274+install(
275+ DIRECTORY
276+ "${CMAKE_CURRENT_SOURCE_DIR}/node_modules"
277+ DESTINATION
278+ ${SCOPE_INSTALL_DIR}
279+ USE_SOURCE_PERMISSIONS
280+)
281
282=== added directory 'qtc-templates/scope-js/src/data'
283=== added file 'qtc-templates/scope-js/src/data/displayName-settings.ini.in'
284--- qtc-templates/scope-js/src/data/displayName-settings.ini.in 1970-01-01 00:00:00 +0000
285+++ qtc-templates/scope-js/src/data/displayName-settings.ini.in 2015-10-23 07:30:32 +0000
286@@ -0,0 +1,21 @@
287+@if "%ContentType%" != "empty"
288+# Below are some example settings. You can access your scope's
289+# settings by calling settings() from the Query::run() method.
290+# E.g. auto location = settings().at("location").get_string();
291+
292+#[location]
293+#type = string
294+#defaultValue = London,uk
295+#_displayName = Default Location
296+
297+#[units]
298+#type = list
299+#_displayName = Temperature Units
300+#_displayValues = Metric;Imperial
301+#defaultValue = 0
302+
303+#[forecast]
304+#type = boolean
305+#defaultValue = true
306+#_displayName = Show Forecast
307+@endif
308
309=== added file 'qtc-templates/scope-js/src/data/displayName.ini.in'
310--- qtc-templates/scope-js/src/data/displayName.ini.in 1970-01-01 00:00:00 +0000
311+++ qtc-templates/scope-js/src/data/displayName.ini.in 2015-10-23 07:30:32 +0000
312@@ -0,0 +1,9 @@
313+[ScopeConfig]
314+ScopeRunner=./node_modules/unity-js-scopes/bin/unity-js-scopes-launcher %S %R
315+_DisplayName=%ProjectName:c% Scope
316+_Description=This is a %ProjectName:c% scope
317+Author = %ClickMaintainer%
318+Icon = icon.png
319+
320+[Appearance]
321+PageHeader.Logo = logo.png
322
323=== added file 'qtc-templates/scope-js/src/data/icon.png'
324Binary 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
325=== added file 'qtc-templates/scope-js/src/data/logo.png'
326Binary 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
327=== added file 'qtc-templates/scope-js/src/displayName.js.in'
328--- qtc-templates/scope-js/src/displayName.js.in 1970-01-01 00:00:00 +0000
329+++ qtc-templates/scope-js/src/displayName.js.in 2015-10-23 07:30:32 +0000
330@@ -0,0 +1,224 @@
331+var scopes = require('unity-js-scopes')
332+@if "%ContentType%" != "empty"
333+var http = require('http');
334+@if "%ContentType%" == "http+xml"
335+var XML = require('pixl-xml');
336+@endif
337+
338+var query_host = "api.openweathermap.org"
339+@if "%ContentType%" == "http+xml"
340+var current_weather_path = "/data/2.5/weather?units=metric&APPID=2b12bf09b4e0ab0c1aa5e32a9a3f0cdc&mode=xml&q="
341+var forecast_weather_path = "/data/2.5/forecast/daily/?units=metric&cnt=7&APPID=2b12bf09b4e0ab0c1aa5e32a9a3f0cdc&mode=xml&q="
342+@elsif "%ContentType%" == "http+json"
343+var current_weather_path = "/data/2.5/weather?units=metric&APPID=2b12bf09b4e0ab0c1aa5e32a9a3f0cdc&q="
344+var forecast_weather_path = "/data/2.5/forecast/daily/?units=metric&cnt=7&APPID=2b12bf09b4e0ab0c1aa5e32a9a3f0cdc&q="
345+@endif
346+
347+var CURRENT_TEMPLATE =
348+{
349+ "schema-version": 1,
350+ "template": {
351+ "category-layout": "grid",
352+ "card-size": "medium"
353+ },
354+ "components": {
355+ "title": "title",
356+ "art": {
357+ "field": "art"
358+ },
359+ "subtitle": "subtitle"
360+ }
361+}
362+
363+var FORECAST_TEMPLATE =
364+{
365+ "schema-version": 1,
366+ "template": {
367+ "category-layout": "grid",
368+ "card-layout": "horizontal",
369+ "card-size": "small"
370+ },
371+ "components": {
372+ "title": "title",
373+ "art" : {
374+ "field": "art"
375+ },
376+ "subtitle": "subtitle"
377+ }
378+}
379+@endif
380+
381+scopes.self.initialize(
382+ {}
383+ ,
384+ {
385+ run: function() {
386+ console.log('Running...')
387+ },
388+ start: function(scope_id) {
389+ console.log('Starting scope id: '
390+ + scope_id
391+ + ', '
392+ + scopes.self.scope_config)
393+ },
394+ search: function(canned_query, metadata) {
395+ return new scopes.lib.search_query(
396+ canned_query,
397+ metadata,
398+ // run
399+ function(search_reply) {
400+@if "%ContentType%" != "empty"
401+ var qs = canned_query.query_string();
402+ if (!qs) {
403+ qs = "London,uk"
404+ }
405+
406+ var current_weather_cb = function(response) {
407+ var res = '';
408+
409+ // Another chunk of data has been recieved, so append it to res
410+ response.on('data', function(chunk) {
411+ res += chunk;
412+ });
413+
414+ // The whole response has been recieved
415+ response.on('end', function() {
416+@if "%ContentType%" == "http+xml"
417+ r = XML.parse(res);
418+
419+ var category_renderer = new scopes.lib.category_renderer(JSON.stringify(CURRENT_TEMPLATE));
420+ var category = search_reply.register_category("current", r.city.name + ", " + r.city.country, "", category_renderer);
421+
422+ var categorised_result = new scopes.lib.categorised_result(category);
423+ categorised_result.set_uri(r.city.id.toString());
424+ categorised_result.set_title(r.temperature.value.toString() + "°C");
425+ categorised_result.set_art("http://openweathermap.org/img/w/" + r.weather.icon + ".png");
426+ categorised_result.set("subtitle", r.weather.value);
427+ categorised_result.set("description", "A description of the result");
428+@elsif "%ContentType%" == "http+json"
429+ r = JSON.parse(res);
430+
431+ var category_renderer = new scopes.lib.category_renderer(JSON.stringify(CURRENT_TEMPLATE));
432+ var category = search_reply.register_category("current", r.name + ", " + r.sys.country, "", category_renderer);
433+
434+ var categorised_result = new scopes.lib.categorised_result(category);
435+ categorised_result.set_uri(r.id.toString());
436+ categorised_result.set_title(r.main.temp.toString() + "°C");
437+ categorised_result.set_art("http://openweathermap.org/img/w/" + r.weather[0].icon + ".png");
438+ categorised_result.set("subtitle", r.weather[0].description);
439+ categorised_result.set("description", "A description of the result");
440+@endif
441+
442+ search_reply.push(categorised_result);
443+
444+ // Now call back into the API for a 7 day forecast
445+ http.request({host: query_host, path: forecast_weather_path + qs}, forecase_weather_cb).end();
446+ });
447+ }
448+
449+ var forecase_weather_cb = function(response) {
450+ var res = '';
451+
452+ // Another chunk of data has been recieved, so append it to res
453+ response.on('data', function(chunk) {
454+ res += chunk;
455+ });
456+
457+ // The whole response has been recieved
458+ response.on('end', function() {
459+ try {
460+@if "%ContentType%" == "http+xml"
461+ r = XML.parse(res);
462+
463+ var category_renderer = new scopes.lib.category_renderer(JSON.stringify(FORECAST_TEMPLATE));
464+ var category = search_reply.register_category("forecast", "7 day forecast", "", category_renderer);
465+
466+ var weather_id = 1000000;
467+ for (i = 0; i < r.forecast.time.length; i++) {
468+ var categorised_result = new scopes.lib.categorised_result(category);
469+ categorised_result.set_uri((weather_id++).toString());
470+ categorised_result.set_title(r.forecast.time[i].temperature.min.toString() + "°C to "
471+ + r.forecast.time[i].temperature.max.toString() + "°C");
472+ categorised_result.set_art("http://openweathermap.org/img/w/" + r.forecast.time[i].symbol.var + ".png");
473+ categorised_result.set("subtitle", r.forecast.time[i].symbol.name);
474+ categorised_result.set("description", "A description of the result");
475+
476+ search_reply.push(categorised_result);
477+ }
478+@elsif "%ContentType%" == "http+json"
479+ r = JSON.parse(res);
480+
481+ var category_renderer = new scopes.lib.category_renderer(JSON.stringify(FORECAST_TEMPLATE));
482+ var category = search_reply.register_category("forecast", "7 day forecast", "", category_renderer);
483+
484+ for (i = 0; i < r.list.length; i++) {
485+ var categorised_result = new scopes.lib.categorised_result(category);
486+ categorised_result.set_uri(r.list[i].weather[0].id.toString());
487+ categorised_result.set_title(r.list[i].temp.min.toString() + "°C to "
488+ + r.list[i].temp.max.toString() + "°C");
489+ categorised_result.set_art("http://openweathermap.org/img/w/" + r.list[i].weather[0].icon + ".png");
490+ categorised_result.set("subtitle", r.list[i].weather[0].description);
491+ categorised_result.set("description", "A description of the result");
492+
493+ search_reply.push(categorised_result);
494+ }
495+@endif
496+
497+ // We are done, call finished() on our search_reply
498+ search_reply.finished();
499+ }
500+ catch(e) {
501+ // Forecast not available
502+ console.log("Forecast for '" + qs + "' is unavailable: " + e)
503+ }
504+ });
505+ }
506+
507+ http.request({host: query_host, path: current_weather_path + qs}, current_weather_cb).end();
508+@endif
509+ },
510+ // cancelled
511+ function() {
512+ });
513+ },
514+ preview: function(result, action_metadata) {
515+ return new scopes.lib.preview_query(
516+ result,
517+ action_metadata,
518+ // run
519+ function(preview_reply) {
520+@if "%ContentType%" != "empty"
521+ var layout1col = new scopes.lib.column_layout(1);
522+ var layout2col = new scopes.lib.column_layout(2);
523+ var layout3col = new scopes.lib.column_layout(3);
524+ layout1col.add_column(["image", "header", "summary"]);
525+
526+ layout2col.add_column(["image"]);
527+ layout2col.add_column(["header", "summary"]);
528+
529+ layout3col.add_column(["image"]);
530+ layout3col.add_column(["header", "summary"]);
531+ layout3col.add_column([]);
532+
533+ preview_reply.register_layout([layout1col, layout2col, layout3col]);
534+
535+ var header = new scopes.lib.preview_widget("header", "header");
536+ header.add_attribute_mapping("title", "title");
537+ header.add_attribute_mapping("subtitle", "subtitle");
538+
539+ var image = new scopes.lib.preview_widget("image", "image");
540+ image.add_attribute_mapping("source", "art");
541+
542+ var description = new scopes.lib.preview_widget("summary", "text");
543+ description.add_attribute_mapping("text", "description");
544+
545+ preview_reply.push([image, header, description ]);
546+ preview_reply.finished();
547+@endif
548+ },
549+ // cancelled
550+ function() {
551+ });
552+ }
553+ }
554+ );
555
556=== added file 'qtc-templates/scope-js/wizard.xml'
557--- qtc-templates/scope-js/wizard.xml 1970-01-01 00:00:00 +0000
558+++ qtc-templates/scope-js/wizard.xml 2015-10-23 07:30:32 +0000
559@@ -0,0 +1,96 @@
560+<?xml version="1.0" encoding="UTF-8"?>
561+<wizard version="1" kind="project" firstpage="10" id="C_UbuntuUnityJsScope" category="A.UbuntuProject"
562+ platformIndependent="true"
563+ class="ubuntu-project-cmake"
564+ featuresRequired=""
565+ >
566+ <icon>../share/ubuntu.png</icon>
567+ <description>A simple JavaScript based Unity Scope</description>
568+ <displayname>Unity Scope (JavaScript)</displayname>
569+ <displaycategory>Ubuntu</displaycategory>
570+ <files>
571+ <file source="po/CMakeLists.txt"/>
572+ <file source="po/displayName.pot" target="po/%ProjectName:l%.pot"/>
573+ <file source="po/POTFILES.in.in"/>
574+
575+ <file source="src/data/displayName.ini.in" target="src/data/%ClickHookName:l%.ini.in"/>
576+ <file source="src/data/displayName-settings.ini.in" target="src/data/%ClickHookName:l%-settings.ini.in"/>
577+ <file source="src/data/icon.png" binary="true"/>
578+ <file source="src/data/logo.png" binary="true"/>
579+
580+ <file source="src/displayName.js.in" target="src/%ClickHookName:l%.js"/>
581+ <file source="src/CMakeLists.txt"/>
582+
583+ <file source="CMakeLists.txt" openproject="true"/>
584+ <file source="displayName.apparmor" target="%ClickHookName:l%.apparmor"/>
585+ <file source="manifest.json.in" openeditor="true"/>
586+ <file source=".bzrignore"/>
587+ </files>
588+
589+ <!-- Create a 2nd wizard page with click package parameters -->
590+ <fieldpagetitle>Click package parameters</fieldpagetitle>
591+ <fields>
592+ <field mandatory="true" name="ClickDomain">
593+ <fieldcontrol class="QLineEdit" validator='^[A-Za-z0-9-]+$'
594+ defaulttext="" placeholdertext="Nickname"/>
595+ <fielddescription>Nickname:</fielddescription>
596+ </field>
597+ <field mandatory="true" name="ClickMaintainer">
598+ <fieldcontrol class="QLineEdit" validator='^[^"]+$'
599+ defaulttext="" placeholdertext="Maintainer"/>
600+ <fielddescription>Maintainer:</fielddescription>
601+ </field>
602+ <field mandatory="true" name="ClickHookName">
603+ <fieldcontrol class="QLineEdit" validator='^[A-Za-z0-9.-]+$'
604+ defaulttext="%ProjectName%" placeholdertext="scope hook name"/>
605+ <fielddescription>Scope name:</fielddescription>
606+ </field>
607+ <field name="ClickFrameworkVersion">
608+ <fieldcontrol class="QComboBox" defaultindex="0">
609+ <comboentries>
610+ <!-- 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 -->
611+ <comboentry value="ubuntu-sdk-dummy-framework">
612+ <comboentrytext>Dummy Framework</comboentrytext>
613+ </comboentry>
614+ </comboentries>
615+ </fieldcontrol>
616+ <fielddescription>Framework:</fielddescription>
617+ </field>
618+ <field name="ConfinementType">
619+ <fieldcontrol class="QComboBox" defaultindex="0">
620+ <comboentries>
621+ <comboentry value="ubuntu-scope-network">
622+ <comboentrytext>Scope with network access</comboentrytext>
623+ </comboentry>
624+ <!--
625+ <comboentry value="ubuntu-scope-local-content">
626+ <comboentrytext>Scope with local content</comboentrytext>
627+ </comboentry>
628+ -->
629+ </comboentries>
630+ </fieldcontrol>
631+ <fielddescription>Confinement type:</fielddescription>
632+ </field>
633+ <field name="ContentType">
634+ <fieldcontrol class="QComboBox" defaultindex="0">
635+ <comboentries>
636+ <comboentry value="http+json">
637+ <comboentrytext>JavaScript scope using HTTP and JSON</comboentrytext>
638+ </comboentry>
639+ <comboentry value="http+xml">
640+ <comboentrytext>JavaScript scope using HTTP and XML</comboentrytext>
641+ </comboentry>
642+ <comboentry value="empty">
643+ <comboentrytext>Empty scope</comboentrytext>
644+ </comboentry>
645+ </comboentries>
646+ </fieldcontrol>
647+ <fielddescription>Template type:</fielddescription>
648+ </field>
649+ </fields>
650+ <validationrules>
651+ <validationrule condition='/^(.*)\s+&lt;(.*@.*)&gt;$/.test("%ClickMaintainer%")'>
652+ <message>Invalid format for maintainer (should be like "Joe Bloggs &lt;joe.bloggs@isp.com&gt;")</message>
653+ </validationrule>
654+ </validationrules>
655+</wizard>
656
657=== modified file 'src/tool/main.cc'
658--- src/tool/main.cc 2015-10-16 07:06:35 +0000
659+++ src/tool/main.cc 2015-10-23 07:30:32 +0000
660@@ -30,42 +30,54 @@
661 #include <boost/algorithm/string/predicate.hpp>
662 #include <boost/filesystem.hpp>
663
664-std::string get_arch() {
665+std::string exec_cmd(std::string const& cmd) {
666 std::string result = "";
667
668- {
669- FILE* pipe = popen("dpkg-architecture -qDEB_HOST_ARCH", "r");
670- if (!pipe) throw std::runtime_error("'dpkg-architecture' command failed");
671- char buffer[128];
672- while (!feof(pipe)) {
673- if (fgets(buffer, 128, pipe) != NULL)
674- result += buffer;
675- }
676- result.pop_back();
677- pclose(pipe);
678- }
679-
680- result += "-";
681-
682- {
683- FILE* pipe = popen("lsb_release -rs", "r");
684- if (!pipe) throw std::runtime_error("'lsb_release' command failed");
685- char buffer[128];
686- while (!feof(pipe)) {
687- if (fgets(buffer, 128, pipe) != NULL)
688- result += buffer;
689- }
690- result.pop_back();
691- pclose(pipe);
692- }
693+ FILE* pipe = popen(cmd.c_str(), "r");
694+ if (!pipe) throw std::runtime_error("'" + cmd + "' command failed");
695+ char buffer[128];
696+ while (!feof(pipe)) {
697+ if (fgets(buffer, 128, pipe) != NULL)
698+ result += buffer;
699+ }
700+ result.pop_back();
701+ pclose(pipe);
702
703 return result;
704 }
705
706+std::string get_arch() {
707+ return exec_cmd("dpkg-architecture -qDEB_HOST_ARCH") + "-" + exec_cmd("lsb_release -rs");
708+}
709+
710+int setup_chroot(std::string const& fw)
711+{
712+ if (exec_cmd("click chroot -a armhf -f ubuntu-sdk-" + fw + " maint echo 1") == "1")
713+ {
714+ std::string setup_script;
715+ setup_script += "click chroot -a armhf -f ubuntu-sdk-" + fw + " maint apt-get install software-properties-common -y --force-yes \n";
716+ setup_script += "click chroot -a armhf -f ubuntu-sdk-" + fw + " maint add-apt-repository ppa:ubuntu-sdk-team/staging -y \n";
717+
718+ setup_script += "click chroot -a armhf -f ubuntu-sdk-" + fw + " maint sh -c \"find /etc/apt/sources.list.d//*.list \
719+ -exec apt-get update -o Dir::Etc::sourcelist='{}' -o Dir::Etc::sourceparts='-' -o APT::Get::List-Cleanup='0' \\;\" \n";
720+
721+ setup_script += "click chroot -a armhf -f ubuntu-sdk-" + fw + " maint apt-get install unity-js-scopes-bindings:armhf -y --force-yes \n";
722+ setup_script += "click chroot -a armhf -f ubuntu-sdk-" + fw + " maint apt-get install unity-js-scopes-launcher:armhf -y --force-yes \n";
723+ setup_script += "click chroot -a armhf -f ubuntu-sdk-" + fw + " maint apt-get install unity-js-scopes-tool -y --force-yes \n";
724+
725+ std::cout << "Setting up " << fw << " chroot ..." << std::endl;
726+ return system(setup_script.c_str());
727+ }
728+ return EXIT_SUCCESS;
729+}
730+
731 void usage() {
732 std::cout << "Usage:"
733 << std::endl
734 << executable_name()
735+ << " setup "
736+ << std::endl
737+ << executable_name()
738 << " [re]install "
739 << "<path/to/node_modules> "
740 << "[<npm_module>]"
741@@ -333,6 +345,53 @@
742
743 return result;
744 }
745+ else if (std::string(argv[1]) == "setup") {
746+ if (argc > 2) {
747+ usage();
748+ return EXIT_FAILURE;
749+ }
750+
751+ std::cout << "Setup started." << std::endl;
752+
753+ // Set up 15.04 chroot
754+ try
755+ {
756+ if (setup_chroot("15.04") == EXIT_FAILURE)
757+ {
758+ std::cout << "Setup failed." << std::endl;
759+ return EXIT_FAILURE;
760+ }
761+ }
762+ catch (std::exception const& e)
763+ {
764+ std::cout << "Failed to detect 15.04 chroot: " << e.what() << " ..." << std::endl;
765+ }
766+
767+ // Set up 15.10 chroot
768+ try
769+ {
770+ if (setup_chroot("15.10") == EXIT_FAILURE)
771+ {
772+ std::cout << "Setup failed." << std::endl;
773+ return EXIT_FAILURE;
774+ }
775+ }
776+ catch (std::exception const& e)
777+ {
778+ std::cout << "Failed to detect 15.10 chroot: " << e.what() << " ..." << std::endl;
779+ }
780+
781+ // Remount chroots
782+ std::cout << "Remounting chroots ..." << std::endl;
783+ if (system("click-chroot-agent --reload") == EXIT_FAILURE)
784+ {
785+ std::cout << "Setup failed." << std::endl;
786+ return EXIT_FAILURE;
787+ }
788+
789+ std::cout << "Setup complete." << std::endl;
790+ return EXIT_SUCCESS;
791+ }
792 else {
793 return node::Start(argc, argv);
794 }

Subscribers

People subscribed via source and target branches

to all changes: