Merge lp:~george-edison55/askubuntu-lens/added-au-data-server into lp:~stefano-palazzo/askubuntu-lens/trunk

Proposed by Stefano Palazzo
Status: Merged
Merged at revision: 44
Proposed branch: lp:~george-edison55/askubuntu-lens/added-au-data-server
Merge into: lp:~stefano-palazzo/askubuntu-lens/trunk
Diff against target: 848 lines (+341/-295)
15 files modified
askubuntu-logo.svg (+57/-0)
askubuntu.lens (+12/-0)
askubuntu.place (+0/-17)
askubuntu_bridge.py (+65/-58)
debian/changelog (+6/-0)
debian/compat (+1/-0)
debian/control (+24/-0)
debian/copyright (+33/-0)
debian/rules (+4/-0)
debian/source/format (+1/-0)
debian/watch.ex (+2/-0)
setup.py (+9/-6)
unity-askubuntu-daemon (+124/-211)
unity-lens-askubuntu.service (+3/-0)
unity-place-askubuntu.service (+0/-3)
To merge this branch: bzr merge lp:~george-edison55/askubuntu-lens/added-au-data-server
Reviewer Review Type Date Requested Status
Stefano Palazzo Pending
Review via email: mp+79741@code.launchpad.net

Commit message

Mark's port to 11.10, George's fixes. Full of awesome.

Description of the change

Mark's port to 11.10, George's fixes. Full of awesome.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'askubuntu-logo.svg'
2--- askubuntu-logo.svg 1970-01-01 00:00:00 +0000
3+++ askubuntu-logo.svg 2011-10-18 22:01:23 +0000
4@@ -0,0 +1,57 @@
5+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
6+<!-- Created with Inkscape (http://www.inkscape.org/) -->
7+
8+<svg
9+ xmlns:dc="http://purl.org/dc/elements/1.1/"
10+ xmlns:cc="http://creativecommons.org/ns#"
11+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
12+ xmlns:svg="http://www.w3.org/2000/svg"
13+ xmlns="http://www.w3.org/2000/svg"
14+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
15+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
16+ id="svg3039"
17+ version="1.1"
18+ inkscape:version="0.48.1 r9760"
19+ width="150"
20+ height="150"
21+ sodipodi:docname="askubuntu-place.svg">
22+ <metadata
23+ id="metadata3045">
24+ <rdf:RDF>
25+ <cc:Work
26+ rdf:about="">
27+ <dc:format>image/svg+xml</dc:format>
28+ <dc:type
29+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
30+ <dc:title />
31+ </cc:Work>
32+ </rdf:RDF>
33+ </metadata>
34+ <defs
35+ id="defs3043" />
36+ <sodipodi:namedview
37+ pagecolor="#ffffff"
38+ bordercolor="#666666"
39+ borderopacity="1"
40+ objecttolerance="10"
41+ gridtolerance="10"
42+ guidetolerance="10"
43+ inkscape:pageopacity="0"
44+ inkscape:pageshadow="2"
45+ inkscape:window-width="1366"
46+ inkscape:window-height="744"
47+ id="namedview3041"
48+ showgrid="false"
49+ inkscape:zoom="1.11"
50+ inkscape:cx="0"
51+ inkscape:cy="0"
52+ inkscape:window-x="0"
53+ inkscape:window-y="24"
54+ inkscape:window-maximized="1"
55+ inkscape:current-layer="svg3039" />
56+ <path
57+ style="fill:#ffffff"
58+ d="M 63.390987,139.63313 C 38.078487,134.71419 17.213007,116.42987 10.473927,93.262164 6.3529375,79.09497 5.9621275,73.72447 8.2258275,62.368702 14.767297,29.553578 38.921757,8.0473283 70.890987,6.5739343 88.659307,5.7550293 102.6916,10.078909 116.2751,20.558499 c 23.7431,18.317676 32.16782,54.960212 18.73222,81.474091 l -2.51454,4.9622 4.46387,16.28559 c 2.45513,8.95707 4.33341,16.41604 4.17396,16.57549 -0.15945,0.15945 -4.3286,-0.82324 -9.26477,-2.18377 -4.93617,-1.36052 -12.23468,-3.36985 -16.21891,-4.46517 l -7.24406,-1.99148 -4.04317,2.06267 c -8.341083,4.2553 -16.156173,6.09729 -27.468713,6.47427 -6.05,0.2016 -12.125,0.14794 -13.5,-0.11926 z m -11.749999,-44.012816 3.75,-0.61983 0,-14.418822 c 0,-16.025126 -0.85815,-19.160544 -5.96727,-21.802572 -3.28906,-1.700836 -13.536791,-2.036184 -17.395141,-0.56924 -2.11444,0.80391 -2.3823,1.360162 -1.7655,3.66644 0.71177,2.661398 0.87534,2.713944 7.75405,2.490845 7.578631,-0.245801 8.692931,0.333818 9.901871,5.150623 l 0.6888,2.744406 -6.04331,0 c -10.755241,0 -16.173501,3.923544 -16.173501,11.711764 0,5.468936 1.21954,7.841549 5.31382,10.338006 3.31838,2.02336 12.117041,2.60081 19.936181,1.30838 z m -16.050001,-7.55815 c -1.57179,-1.571788 -1.54062,-6.282606 0.05,-7.555166 2.19495,-1.756062 5.823971,-2.453537 9.336931,-1.794502 3.3387,0.626342 3.41307,0.748255 3.41307,5.594981 l 0,4.954687 -5.8,0 c -3.190001,0 -6.340001,-0.54 -7.000001,-1.2 z m 45.78895,6.70571 c 3.96591,-2.050852 6.01105,-5.284971 6.01105,-9.50571 0,-5.22562 -2.41406,-7.846763 -10.70778,-11.626335 -6.78867,-3.093694 -7.3971,-3.612607 -7.10818,-6.062413 0.39364,-3.337851 4.39374,-4.640879 10.22481,-3.330723 2.2203,0.498869 4.15693,0.78702 4.30361,0.640336 0.14669,-0.146684 0.54668,-1.666561 0.88886,-3.377505 0.5895,-2.947502 0.43013,-3.146834 -3.03593,-3.797071 -2.01195,-0.377444 -6.18783,-0.476477 -9.27973,-0.220073 -4.74922,0.393842 -6.06114,0.958073 -8.45365,3.635763 -3.18908,3.569196 -3.842469,9.373884 -1.42699,12.677252 0.77277,1.05682 4.71027,3.505329 8.75,5.44113 6.71228,3.216455 7.34498,3.778061 7.34498,6.519639 0,2.922772 -0.13821,3.007887 -5.36889,3.306382 -2.95288,0.168511 -6.68576,-0.152685 -8.29529,-0.713768 -3.06891,-1.069831 -3.4044,-0.791371 -4.03832,3.3519 -0.19106,1.248778 0.59698,2.406335 2.2025,3.235256 3.44054,1.77635 14.42277,1.67008 17.98895,-0.17406 z m 19.011053,-7.50571 c 0,-4.4 0.38842,-8 0.86316,-8 0.97042,0 8.32641,7.776712 12.13684,12.831007 2.25789,2.994943 2.92235,3.284763 6.86107,2.992543 l 4.36107,-0.32355 L 120.0099,88.52 c -2.53178,-3.43319 -6.35598,-7.994901 -8.49821,-10.137137 l -3.89497,-3.894973 7.38713,-7.337836 c 4.06293,-4.035809 7.38714,-7.686598 7.38714,-8.112863 0,-0.426266 -1.90461,-0.775028 -4.23247,-0.775028 -3.96955,0 -4.64992,0.450389 -10.95212,7.250001 l -6.71963,7.25 -0.0479,-16.250001 -0.0479,-16.249999 -2.800003,0 c -5.11384,0 -5.2,0.464525 -5.2,28.033333 0,14.098334 0.3,25.933334 0.66666,26.299997 0.36667,0.36667 2.16667,0.66667 4.00001,0.66667 l 3.333333,0 0,-8 z"
59+ id="path3068"
60+ inkscape:connector-curvature="0" />
61+</svg>
62
63=== removed file 'askubuntu-place.png'
64Binary files askubuntu-place.png 2011-04-15 19:46:56 +0000 and askubuntu-place.png 1970-01-01 00:00:00 +0000 differ
65=== added file 'askubuntu.lens'
66--- askubuntu.lens 1970-01-01 00:00:00 +0000
67+++ askubuntu.lens 2011-10-18 22:01:23 +0000
68@@ -0,0 +1,12 @@
69+[Lens]
70+DBusName=net.launchpad.AskUbuntuLens
71+DBusPath=/net/launchpad/lens/askubuntulens
72+
73+Icon=/usr/share/unity/lenses/askubuntu/askubuntu-logo.svg
74+Name=Ask Ubuntu
75+Description=Ask Questions and Get Answers on Ask Ubuntu
76+SearchHint=Search Ask Ubuntu
77+Shortcut=u
78+
79+[Desktop Entry]
80+X-Ubuntu-Gettext-Domain=askubuntu-lens
81
82=== removed file 'askubuntu.place'
83--- askubuntu.place 2011-04-09 18:30:55 +0000
84+++ askubuntu.place 1970-01-01 00:00:00 +0000
85@@ -1,17 +0,0 @@
86-
87-[Place]
88-DBusName=net.launchpad.AskUbuntuPlace
89-DBusObjectPath=/net/launchpad/askubuntuplace
90-
91-
92-[Entry:Stuff]
93-DBusObjectPath=/net/launchpad/askubuntuplace/mainentry
94-Icon=/usr/share/unity-place-askubuntu/askubuntu-place.png
95-Name=Ask Ubuntu
96-Description=Ask Questions and Get Answers on Ask Ubuntu
97-SearchHint=Search Ask Ubuntu
98-Shortcut=u
99-
100-[Desktop Entry]
101-X-Ubuntu-Gettext-Domain=askubuntu-place
102-
103
104=== modified file 'askubuntu_bridge.py'
105--- askubuntu_bridge.py 2011-04-28 17:52:51 +0000
106+++ askubuntu_bridge.py 2011-10-18 22:01:23 +0000
107@@ -24,7 +24,7 @@
108 import json
109 import functools
110 import time
111-
112+import random
113
114 DEFAULT_SITE = "askubuntu.com"
115 SE_API_KEY = "BmtlCGm1UU-Cmn8FAvfT4Q"
116@@ -32,58 +32,59 @@
117 ICONS = {}
118 NUMS = "0123456789"
119 SITES = (
120- ("@meta", "meta." + DEFAULT_SITE),
121- ("@so", "stackoverflow.com"),
122- ("@su", "superuser.com"),
123- ("@sf", "serverfault.com"),
124- ("@stackoverflow", "stackoverflow.com"),
125- ("@serverfault", "serverfault.com"),
126- ("@superuser", "superuser.com"),
127- ("@webapps", "webapps.stackexchange.com"),
128- ("@gaming", "gaming.stackexchange.com"),
129- ("@webmasters", "webmasters.stackexchange.com"),
130- ("@cooking", "cooking.stackexchange.com"),
131- ("@gamedev", "gamedev.stackexchange.com"),
132- ("@photo", "photo.stackexchange.com"),
133- ("@stats", "stats.stackexchange.com"),
134- ("@math", "math.stackexchange.com"),
135- ("@diy", "diy.stackexchange.com"),
136- ("@gis", "gis.stackexchange.com"),
137- ("@tex", "tex.stackexchange.com"),
138- ("@money", "money.stackexchange.com"),
139- ("@english", "english.stackexchange.com"),
140- ("@stackapps", "stackapps.com"),
141- ("@ux", "ux.stackexchange.com"),
142- ("@unix", "unix.stackexchange.com"),
143- ("@wordpress", "wordpress.stackexchange.com"),
144- ("@cstheory", "cstheory.stackexchange.com"),
145- ("@apple", "apple.stackexchange.com"),
146- ("@rpg", "rpg.stackexchange.com"),
147- ("@bicycles", "bicycles.stackexchange.com"),
148- ("@programmers", "programmers.stackexchange.com"),
149- ("@electronics", "electronics.stackexchange.com"),
150- ("@android", "android.stackexchange.com"),
151- ("@onstartups", "onstartups.stackexchange.com"),
152- ("@boardgames", "boardgames.stackexchange.com"),
153- ("@physics", "physics.stackexchange.com"),
154- ("@homebrew", "homebrew.stackexchange.com"),
155- ("@security", "security.stackexchange.com"),
156- ("@writers", "writers.stackexchange.com"),
157- ("@audio", "audio.stackexchange.com"),
158- ("@graphicdesign", "graphicdesign.stackexchange.com"),
159- ("@dba", "dba.stackexchange.com"),
160- ("@scifi", "scifi.stackexchange.com"),
161- ("@guitars", "guitars.stackexchange.com"),
162- ("@codereview", "codereview"),
163- ("@codegolf", "codegolf.stackexchange.com"),
164- ("@quant", "quant.stackexchange.com"),
165- ("@pm", "pm.stackexchange.com"),
166- ("@skeptics", "skeptics.stackexchange.com"),
167- ("@fitness", "fitness.stackexchange.com"),
168- ("@drupal", "drupal.stackexchange.com"),
169- ("@mechanics", "mechanics.stackexchange.com"),
170- ("@parenting", "parenting.stackexchange.com"),
171- ("@sharepoint", "sharepoint.stackexchange.com"),
172+ ("@au", DEFAULT_SITE, "Ask Ubuntu"),
173+ ("@so", "stackoverflow.com", ""),
174+ ("@su", "superuser.com", ""),
175+ ("@sf", "serverfault.com", ""),
176+ ("@stackoverflow", "stackoverflow.com", "Stack Overflow"),
177+ ("@serverfault", "serverfault.com", "Server Fault"),
178+ ("@superuser", "superuser.com", "Super User"),
179+ ("@webapps", "webapps.stackexchange.com", "Web Applications"),
180+ ("@gaming", "gaming.stackexchange.com", "Gaming"),
181+ ("@webmasters", "webmasters.stackexchange.com", "Webmasters"),
182+ ("@cooking", "cooking.stackexchange.com", "Cooking"),
183+ ("@gamedev", "gamedev.stackexchange.com", "Game Development"),
184+ ("@photo", "photo.stackexchange.com", "Photography"),
185+ ("@stats", "stats.stackexchange.com", "Statistics"),
186+ ("@math", "math.stackexchange.com", "Mathematics"),
187+ ("@diy", "diy.stackexchange.com", "DIY"),
188+ ("@gis", "gis.stackexchange.com", "GIS"),
189+ ("@tex", "tex.stackexchange.com", "TeX - LaTeX"),
190+ ("@money", "money.stackexchange.com", "Personal Finance and Money "),
191+ ("@english", "english.stackexchange.com", "English Language & Usage"),
192+ ("@stackapps", "stackapps.com", "Stack Apps"),
193+ ("@ux", "ux.stackexchange.com", "User Experience"),
194+ ("@unix", "unix.stackexchange.com", "Unix and Linux"),
195+ ("@wordpress", "wordpress.stackexchange.com", "Wordpress"),
196+ ("@cstheory", "cstheory.stackexchange.com", "Theoretical Computer Science"),
197+ ("@apple", "apple.stackexchange.com", "Apple"),
198+ ("@rpg", "rpg.stackexchange.com", "Role Playing Games"),
199+ ("@bicycles", "bicycles.stackexchange.com", "Bicycles"),
200+ ("@programmers", "programmers.stackexchange.com", "Programmers"),
201+ ("@electronics", "electronics.stackexchange.com", "Electronics"),
202+ ("@android", "android.stackexchange.com", "Android"),
203+ ("@onstartups", "onstartups.stackexchange.com", "OnStartups"),
204+ ("@boardgames", "boardgames.stackexchange.com", "Board & Card Games"),
205+ ("@physics", "physics.stackexchange.com", "Physics"),
206+ ("@homebrew", "homebrew.stackexchange.com", "Homebrew"),
207+ ("@security", "security.stackexchange.com", "IT Security"),
208+ ("@writers", "writers.stackexchange.com", "Writers"),
209+ ("@audio", "audio.stackexchange.com", "Audio-Video Production"),
210+ ("@graphicdesign", "graphicdesign.stackexchange.com", "Graphic Design"),
211+ ("@dba", "dba.stackexchange.com", "Database Administration"),
212+ ("@scifi", "scifi.stackexchange.com", "Science Fiction"),
213+ ("@guitars", "guitars.stackexchange.com", "Guitars"),
214+ ("@codereview", "codereview", "Code Review"),
215+ ("@codegolf", "codegolf.stackexchange.com", "Code Golf"),
216+ ("@quant", "quant.stackexchange.com", "Quantitative Finance"),
217+ ("@pm", "pm.stackexchange.com", "Project Management"),
218+ ("@skeptics", "skeptics.stackexchange.com", "Skeptics"),
219+ ("@fitness", "fitness.stackexchange.com", "Fitness & Nutrition"),
220+ ("@drupal", "drupal.stackexchange.com", "Drupal"),
221+ ("@mechanics", "mechanics.stackexchange.com", "Motor Vehicle Maintenence"),
222+ ("@parenting", "parenting.stackexchange.com", "Parenting"),
223+ ("@sharepoint", "sharepoint.stackexchange.com", "Sharepoint"),
224+ ("@meta", "meta." + DEFAULT_SITE, "Ask Ubuntu Meta"),
225 )
226
227
228@@ -102,10 +103,16 @@
229 print "api.%s/\33[1;31m%s\33[m" % (site, query)
230 if query.startswith("similar?title") and site == "askubuntu.com":
231 try:
232- result = json.loads(urllib2.urlopen(
233- "http://50.19.108.78:8080/%s" % query.replace(" ", "%20"),
234- timeout=0.5).read())
235- print "\33[1mused ec2 service\33[m"
236+ if random.random() > 0.5:
237+ result = json.loads(urllib2.urlopen(
238+ "http://50.19.108.78:8080/%s" % query.replace(" ", "%20"),
239+ timeout=0.5).read())
240+ print "\33[1mused ec2 service\33[m"
241+ else:
242+ result = json.loads(urllib2.urlopen(
243+ "http://audata.quickmediasolutions.com:8046/%s" % query.replace(" ", "%20"),
244+ timeout=0.5).read())
245+ print "\33[1mused AU Data Server service\33[m"
246 return result
247 except Exception as e:
248 print "\33[1;31m%s\33[m" % repr(e)
249@@ -127,7 +134,7 @@
250 def detect_site(search):
251 global BADGES
252 site = DEFAULT_SITE
253- for modifier, url in SITES:
254+ for modifier, url, sitename in SITES:
255 if search.startswith(modifier):
256 search = search.replace(modifier, "").strip()
257 site = url
258
259=== added directory 'debian'
260=== added file 'debian/changelog'
261--- debian/changelog 1970-01-01 00:00:00 +0000
262+++ debian/changelog 2011-10-18 22:01:23 +0000
263@@ -0,0 +1,6 @@
264+unity-askubuntu-lens (0.2) oneiric; urgency=low
265+
266+ * Updated to work with Ubuntu 11.10 - Oneiric Ocelot
267+
268+ -- Mark Tully <markjtully@gmail.com> Thu, 15 Sep 2011 19:53:10 +0100
269+
270
271=== added file 'debian/compat'
272--- debian/compat 1970-01-01 00:00:00 +0000
273+++ debian/compat 2011-10-18 22:01:23 +0000
274@@ -0,0 +1,1 @@
275+7
276
277=== added file 'debian/control'
278--- debian/control 1970-01-01 00:00:00 +0000
279+++ debian/control 2011-10-18 22:01:23 +0000
280@@ -0,0 +1,24 @@
281+Source: unity-askubuntu-lens
282+Section: gnome
283+Priority: optional
284+Maintainer: Stefano Palazzo <stefano.palazzo@gmail.com>
285+Build-Depends: debhelper (>= 7),
286+ pkg-config,
287+ libglib2.0-dev (>= 2.29),
288+ libdee-dev (>= 0.5.18),
289+ libunity-dev (>= 4.0.2),
290+ python-all,
291+ python-distutils-extra
292+Standards-Version: 3.9.1
293+X-Python-Version: >= 2.5
294+Homepage: https://launchpad.net/askubuntu-lens
295+
296+Package: unity-askubuntu-lens
297+Architecture: all
298+Depends: ${shlibs:Depends},
299+ ${misc:Depends},
300+ ${python:Depends},
301+ gir1.2-unity-4.0,
302+ gir1.2-dee-0.5
303+Description: Unity Ask Ubuntu Lens
304+ A Unity Lens to Ask Questions and Get Answers at AskUbuntu.com, from your Desktop.
305
306=== added file 'debian/copyright'
307--- debian/copyright 1970-01-01 00:00:00 +0000
308+++ debian/copyright 2011-10-18 22:01:23 +0000
309@@ -0,0 +1,33 @@
310+Format: http://dep.debian.net/deps/dep5
311+Name: unity-askubuntu-lens
312+Source: https://launchpad.net/askubuntu-lens
313+Maintainer: Stefano Palazzo <stefano.palazzo@gmail.com>
314+
315+Files: *
316+Copyright: 2011 Stefano Palazzo <stefano.palazzo@gmail.com>
317+
318+License: GPL-2.0+
319+
320+Files: debian/*
321+Copyright: 2011 Stefano Palazzo <stefano.palazzo@gmail.com>
322+License: GPL-2.0+
323+
324+License: GPL-2.0+
325+ This package is free software; you can redistribute it and/or modify
326+ it under the terms of the GNU General Public License as published by
327+ the Free Software Foundation; either version 2 of the License, or
328+ (at your option) any later version.
329+ .
330+ This package is distributed in the hope that it will be useful,
331+ but WITHOUT ANY WARRANTY; without even the implied warranty of
332+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
333+ GNU General Public License for more details.
334+ .
335+ You should have received a copy of the GNU General Public License
336+ along with this program. If not, see <http://www.gnu.org/licenses/>
337+ .
338+ On Debian systems, the complete text of the GNU General
339+ Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
340+
341+# Please also look if there are files or directories which have a
342+# different copyright/license attached and list them here.
343
344=== added file 'debian/rules'
345--- debian/rules 1970-01-01 00:00:00 +0000
346+++ debian/rules 2011-10-18 22:01:23 +0000
347@@ -0,0 +1,4 @@
348+#!/usr/bin/make -f
349+
350+%:
351+ dh --buildsystem=python_distutils --with python2 $*
352
353=== added directory 'debian/source'
354=== added file 'debian/source/format'
355--- debian/source/format 1970-01-01 00:00:00 +0000
356+++ debian/source/format 2011-10-18 22:01:23 +0000
357@@ -0,0 +1,1 @@
358+3.0 (native)
359
360=== added file 'debian/watch.ex'
361--- debian/watch.ex 1970-01-01 00:00:00 +0000
362+++ debian/watch.ex 2011-10-18 22:01:23 +0000
363@@ -0,0 +1,2 @@
364+version=3
365+https://launchpad.net/unity-askubuntu-lens/+download .*/unity-askubuntu-lens-([0-9.]+)\.tar\.gz
366
367=== modified file 'setup.py'
368--- setup.py 2011-03-30 01:21:52 +0000
369+++ setup.py 2011-10-18 22:01:23 +0000
370@@ -2,17 +2,20 @@
371 #
372 from distutils.core import setup
373 from DistUtilsExtra.command import *
374+import os
375
376 setup(name="askubuntu-lens",
377- version="0.0.1",
378+ version="0.2",
379 author="Stefano Palazzo",
380 author_email="stefano.palazzo@gmail.com",
381 url="http://launchpad.net/askubuntu-lens/",
382 license="GNU General Public License (GPL)",
383 data_files=[
384- ('share/unity-place-askubuntu', ['askubuntu-place.png']),
385- ('share/unity/places', ['askubuntu.place']),
386- ('share/dbus-1/services', ['unity-place-askubuntu.service']),
387- ('lib/unity-place-askubuntu', ['askubuntu_bridge.py']),
388- ('lib/unity-place-askubuntu', ['unity-askubuntu-daemon']),
389+ ('share/unity/lenses/askubuntu', ['askubuntu.lens']),
390+ ('share/dbus-1/services', ['unity-lens-askubuntu.service']),
391+ ('lib/unity-lens-askubuntu', ['askubuntu_bridge.py']),
392+ ('lib/unity-lens-askubuntu', ['unity-askubuntu-daemon']),
393+ ('share/unity-lens-askubuntu', ['askubuntu-logo.svg']),
394 ], cmdclass={"build": build_extra.build_extra, })
395+
396+os.system('setsid unity')
397
398=== modified file 'unity-askubuntu-daemon'
399--- unity-askubuntu-daemon 2011-04-21 16:57:41 +0000
400+++ unity-askubuntu-daemon 2011-10-18 22:01:23 +0000
401@@ -37,28 +37,18 @@
402
403
404 #
405-# The primary bus name we grab *must* match what we specify in our .place file
406+# The primary bus name we grab *must* match what we specify in our .lens file
407 #
408-BUS_NAME = "net.launchpad.AskUbuntuPlace"
409+BUS_NAME = "net.launchpad.AskUbuntuLens"
410
411 # Group ids. Must match the offset into the group models
412 # These are the groups of results, separated by a horizontal
413 # rule. They have their own icons, which should be monochrome(?).
414-GROUP_QUESTIONS = 0
415-GROUP_TAGS = 1
416-GROUP_EVERYTHING = 2 # EVERYTHING is probably a misnomer here, it's default.
417-GROUP_USERS = 3
418-GROUP_BADGES = 4
419-
420-# Section ids. Must match the offset into the section model
421-# These are the sections you see by clicking the arror to the
422-# right of the search field.
423-SECTION_EVERYTHING = 0
424-SECTION_QUESTIONS = 1
425-SECTION_TAGS = 2
426-SECTION_USERS = 3
427-SECTION_BADGES = 4
428-
429+EVERYTHING = 0
430+QUESTIONS = 1
431+TAGS = 2
432+USERS = 3
433+BADGES = 4
434
435 def interesting():
436 blacklist = ["nautilus",
437@@ -93,222 +83,148 @@
438
439 class Daemon (object):
440
441- active_section = 0
442 special_searches = ["me", "chat", "meta", "au", "help", "lens"]
443
444 def __init__(self):
445 # Safe for the signal handlers, I don't know what any of the things
446 # in this method mean. Should have to ask someone.
447
448- self._entry = Unity.PlaceEntryInfo.new(
449- "/net/launchpad/askubuntuplace/mainentry")
450-
451- #
452- # Set up all the datamodels we'll share with the Unity process
453- # See https://wiki.ubuntu.com/Unity/Places
454- #
455- # Terminology:
456- #
457- # - "sections" A set of disjoint browsable categories.
458- # Fx. "Books", "Film", and "Music"
459- #
460- # - "groups" A set of labels that partition the result set into
461- # user-visible chunks. "Popular Books", "Recent Books"
462- #
463- sections_model = Dee.SharedModel.new(BUS_NAME + ".SectionsModel")
464- sections_model.set_schema("s", "s")
465- self._entry.props.sections_model = sections_model
466-
467- groups_model = Dee.SharedModel.new(BUS_NAME + ".GroupsModel")
468- groups_model.set_schema("s", "s", "s")
469- self._entry.props.entry_renderer_info.props.groups_model = groups_model
470-
471- global_groups_model = Dee.SharedModel.new(BUS_NAME +
472- ".GlobalGroupsModel")
473- global_groups_model.set_schema("s", "s", "s")
474- self._entry.props.global_renderer_info.props.groups_model = (
475- global_groups_model)
476-
477- results_model = Dee.SharedModel.new(BUS_NAME + ".ResultsModel")
478- results_model.set_schema("s", "s", "u", "s", "s", "s")
479- self._entry.props.entry_renderer_info.props.results_model = (
480- results_model)
481-
482- global_results_model = Dee.SharedModel.new(BUS_NAME +
483- ".GlobalResultsModel")
484- global_results_model.set_schema("s", "s", "u", "s", "s", "s")
485- self._entry.props.global_renderer_info.props.results_model = (
486- global_results_model)
487-
488- #
489- # Populate the sections and groups once we are in sync with Unity
490- #
491- sections_model.connect("notify::synchronized",
492- self._on_sections_synchronized)
493- groups_model.connect("notify::synchronized",
494- self._on_groups_synchronized)
495- global_groups_model.connect("notify::synchronized",
496- self._on_global_groups_synchronized)
497-
498- #
499- # Set up the signals we'll receive when Unity starts to talk to us
500- #
501-
502- # The 'active-search' property is changed when the users searches
503- # within this particular place
504- self._entry.connect("notify::active-search", self._on_search_changed)
505-
506- # The 'active-global-search' property is changed when the user searches
507- # from the Dash aka Home Screen
508- self._entry.connect("notify::active-global-search",
509- self._on_global_search_changed)
510-
511- # Listen for changes to the secion (Everything, Questions, Tags...)
512- self._entry.connect("notify::active-section", self._on_section_change)
513- #
514- # PlaceEntries are housed by PlaceControllers.
515- # You may have mutiple entries per controller if you like.
516- # The controller *must* have the DBus Object path you specify
517- # in your .place file
518- #
519- self._entry.connect("notify::active", self.on_active_change)
520- self.search = ""
521- self._ctrl = Unity.PlaceController.new("/net/launchpad/askubuntuplace")
522- self._ctrl.add_entry(self._entry)
523- self._ctrl.export()
524-
525- def on_active_change(self, entry, section):
526- # FIXME "active" is NOT reliable to check for lens closing/opening.
527- # It can be sent during long or slow searches.
528- if entry.get_property("active") and not self.search:
529- model = self._entry.props.entry_renderer_info.props.results_model
530- print "on_active_change"
531- search = None
532- model.clear()
533- for i in interesting():
534- self.add_tags_results(i, model, _max=1)
535- model.flush_revision_queue()
536- print i
537- self.add_default_results("", model)
538+ self._lens = Unity.Lens.new ("/net/launchpad/lens/askubuntulens", "askubuntu")
539+ self._scope = Unity.Scope.new ("/net/launchpad/scope/askubuntulens/main")
540+
541+ self._lens.props.search_hint = "Search Ask Ubuntu"
542+ self._lens.props.visible = True;
543+ self._lens.props.search_in_global = False;
544+
545+ # Populate categories
546+ cats = []
547+ cats.append (Unity.Category.new ("Everything",
548+ Gio.ThemedIcon.new("help"),
549+ Unity.CategoryRenderer.HORIZONTAL_TILE))
550+ cats.append (Unity.Category.new ("Questions",
551+ Gio.ThemedIcon.new("help"),
552+ Unity.CategoryRenderer.HORIZONTAL_TILE))
553+ cats.append (Unity.Category.new ("Tags",
554+ Gio.ThemedIcon.new("help"),
555+ Unity.CategoryRenderer.VERTICAL_TILE))
556+ cats.append (Unity.Category.new ("Users",
557+ Gio.ThemedIcon.new("stock-person"),
558+ Unity.CategoryRenderer.VERTICAL_TILE))
559+ cats.append (Unity.Category.new ("Badges",
560+ Gio.ThemedIcon.new("help"),
561+ Unity.CategoryRenderer.VERTICAL_TILE))
562+
563+ self._lens.props.categories = cats
564+
565+ filters = []
566+ f = Unity.RadioOptionFilter.new ("sites",
567+ "Other Stack Exchange Sites",
568+ Gio.ThemedIcon.new("input-keyboard-symbolic"),
569+ False)
570+ for site in askubuntu_bridge.SITES:
571+ if site[2] != "":
572+ f.add_option (site[0], site[2], None)
573+ filters.append (f)
574+
575+ self._lens.props.filters = filters
576+
577+ # Listen for changes and requests
578+ self._scope.connect ("notify::active-search", self._on_search_changed)
579+ self._scope.connect ("notify::active-global-search", self._on_global_search_changed)
580+ self._scope.connect ("filters-changed", self._on_search_changed)
581+ self._lens.add_local_scope (self._scope);
582+ self._lens.export ();
583
584 def get_search_string(self):
585- search = self._entry.props.active_search
586- return search.get_search_string() if search else None
587+ search = self._scope.props.active_search
588+ return search.props.search_string if search else ""
589
590 def get_global_search_string(self):
591- print "get global search string"
592- search = self._entry.props.active_global_search
593- return search.get_search_string() if search else None
594-
595- def _on_section_change(self, entry_info, section):
596- print "section change"
597- self.active_section = self._entry.props.active_section
598-
599- def _on_sections_synchronized(self, sections_model, *args):
600- print "sections synchronized"
601- # Column0: display name
602- # Column1: GIcon in string format
603- sections_model.clear()
604- sections_model.append("Everything",
605- Gio.ThemedIcon.new("help").to_string())
606- sections_model.append("Questions",
607- Gio.ThemedIcon.new("help").to_string())
608- sections_model.append("Tags",
609- Gio.ThemedIcon.new("help").to_string())
610- sections_model.append("Users",
611- Gio.ThemedIcon.new("stock-person").to_string())
612- sections_model.append("Badges",
613- Gio.ThemedIcon.new("help").to_string())
614-
615- def _on_groups_synchronized(self, groups_model, *args):
616- # Column0: group renderer
617- # Column1: display name
618- # Column2: GIcon in string format
619- groups_model.clear()
620-
621- print "groups synchronized"
622- # !! The row offsets must match the GROUP_* constants !!
623- groups_model.append("UnityHorizontalTileRenderer",
624- "Questions",
625- Gio.ThemedIcon.new("gtg-panel").to_string())
626- groups_model.append("UnityDefaultRenderer",
627- "Tags",
628- Gio.ThemedIcon.new("ubuntuone-client-idle").to_string())
629- groups_model.append("UnityDefaultRenderer",
630- "Ask Ubuntu",
631- Gio.ThemedIcon.new("applications-chat-panel").to_string())
632- groups_model.append("UnityShowcaseRenderer",
633- "Users",
634- Gio.ThemedIcon.new("stock_person-panel").to_string())
635- groups_model.append("UnityDefaultRenderer",
636- "Badges",
637- Gio.ThemedIcon.new("account-logged-in").to_string())
638-
639- def _on_global_groups_synchronized(self, global_groups_model, *args):
640- # Just the same as the normal groups
641- print "global groups synchronized"
642- self._on_groups_synchronized(global_groups_model)
643+ search = self._scope.props.active_global_search
644+ return search.props.search_string if search else ""
645
646 def _on_search_changed(self, *args):
647 search = self.get_search_string()
648 self.search = search
649- results = self._entry.props.entry_renderer_info.props.results_model
650+ results = self._scope.props.results_model
651 print "Search changed to: '%s'" % search
652 self._update_results_model(search, results)
653
654 def _on_global_search_changed(self, entry, param_spec):
655 search = self.get_global_search_string()
656- results = self._entry.props.global_renderer_info.props.results_model
657+ results = self._scope.props.results_model
658 print "Global search changed to: '%s'" % search
659 self._update_results_model(search, results, _global=True)
660
661 def add_default_results(self, search, model):
662 if not search.startswith("@"):
663 icon_hint = Gio.ThemedIcon.new("distributor-logo").to_string()
664+
665 if search.lower() not in self.special_searches:
666 model.append("http://askubuntu.com/questions/ask",
667- Gio.ThemedIcon.new("help-faq").to_string(),
668- GROUP_EVERYTHING,
669- "text/html", "Ask your own question",
670- "Ask a Question")
671+ Gio.ThemedIcon.new("help-faq").to_string(),
672+ EVERYTHING,
673+ "text/html",
674+ "Ask your own question",
675+ "Ask a Question",
676+ "")
677+
678 if search and search.lower() not in self.special_searches:
679 model.append("http://askubuntu.com/search?q=" + search.strip(),
680- Gio.ThemedIcon.new("search").to_string(), GROUP_EVERYTHING,
681- "text/html", "Search on Ask Ubuntu",
682- "Find '%s' on Ask Ubuntu" % search)
683+ Gio.ThemedIcon.new("search").to_string(),
684+ EVERYTHING,
685+ "text/html",
686+ "Search on Ask Ubuntu",
687+ "Find '%s' on Ask Ubuntu" % search,
688+ "")
689+
690 if "chat" in search.lower():
691 model.append("http://chat.stackexchange.com/rooms/201/",
692- Gio.ThemedIcon.new("applications-chat").to_string(),
693- GROUP_EVERYTHING,
694- "text/html", "Join the Ask Ubuntu Chat",
695- "Join the Ask Ubuntu General Chat Room")
696+ Gio.ThemedIcon.new("applications-chat").to_string(),
697+ EVERYTHING,
698+ "text/html",
699+ "Join the Ask Ubuntu Chat",
700+ "Join the Ask Ubuntu General Chat Room",
701+ "")
702+
703 if "meta" in search.lower():
704 model.append("http://meta.askubuntu.com/",
705- Gio.ThemedIcon.new("gnome-fs-bookmark-missing").to_string(),
706- GROUP_EVERYTHING,
707- "text/html", "Visit Ask Ubuntu - Meta",
708- "Visit Ask Ubuntu - Meta")
709+ Gio.ThemedIcon.new("gnome-fs-bookmark-missing").to_string(),
710+ EVERYTHING,
711+ "text/html",
712+ "Visit Ask Ubuntu - Meta",
713+ "Visit Ask Ubuntu - Meta",
714+ "")
715+
716 if (any(i in search.lower() for i in ["askubuntu", "ask"]) or
717 search.lower() == "au"):
718 model.append("http://askubuntu.com/",
719- Gio.ThemedIcon.new("distributor-logo").to_string(),
720- GROUP_EVERYTHING,
721- "text/html", "Ask Ubuntu",
722- "Ask Ubuntu")
723+ Gio.ThemedIcon.new("distributor-logo").to_string(),
724+ EVERYTHING,
725+ "text/html",
726+ "Ask Ubuntu",
727+ "Ask Ubuntu",
728+ "")
729+
730 if (any(i in search.lower() for i in ["profile", "recent"]) or
731 search.lower() == "me"):
732 model.append("http://askubuntu.com/users/recent",
733- Gio.ThemedIcon.new("user-info").to_string(),
734- GROUP_EVERYTHING,
735- "text/html", "Your Responses",
736- "Your Responses")
737+ Gio.ThemedIcon.new("user-info").to_string(),
738+ EVERYTHING,
739+ "text/html",
740+ "Your Responses",
741+ "Your Responses",
742+ "")
743+
744 if ("askubuntu" in search.lower() and "lens" in search.lower() or
745 search.lower() == "help" or search.lower() == "wtf"):
746 model.append("http://askubuntu.com/questions/31712",
747- Gio.ThemedIcon.new("help").to_string(),
748- GROUP_EVERYTHING,
749- "text/html", "Help about this Lens",
750- "")
751+ Gio.ThemedIcon.new("help").to_string(),
752+ EVERYTHING,
753+ "text/html",
754+ "Help about this Lens",
755+ "",
756+ "")
757
758 # These next four methods should be merged into one, but only after
759 # it's clear that there are no more changes to the API, requiring me
760@@ -316,15 +232,13 @@
761
762 def add_questions_results(self, search, model):
763 for url, icon, title, text in askubuntu_bridge.get_questions(search):
764- model.append(url, icon, GROUP_QUESTIONS,
765- "text/html", title, text)
766+ model.append(url, icon, QUESTIONS, "text/html", title, text, url)
767 model.flush_revision_queue()
768
769 def add_tags_results(self, search, model, _max=None):
770 icon_hint = Gio.ThemedIcon.new("tag-new").to_string() # Tags Icon
771 for n, (url, title) in enumerate(askubuntu_bridge.get_tags(search)):
772- model.append(url, icon_hint, GROUP_TAGS,
773- "text/html", title, title)
774+ model.append(url, icon_hint, TAGS, "text/html", title, title, url)
775 if _max and n + 1 == _max:
776 break
777 if not _max:
778@@ -333,35 +247,33 @@
779 def add_badges_results(self, search, model):
780 icon_hint = Gio.ThemedIcon.new("help").to_string() # Badge Icon
781 for url, title in askubuntu_bridge.get_badges(search):
782- model.append(url, icon_hint, GROUP_BADGES,
783- "text/html", title, title)
784+ model.append(url, icon_hint, BADGES, "text/html", title, title, url)
785
786 def add_users_results(self, search, model):
787 for url, icon, title in askubuntu_bridge.get_users(search):
788- model.append(url, icon, GROUP_USERS,
789- "text/html", title, title)
790+ model.append(url, icon, USERS, "text/html", title, title, url)
791 model.flush_revision_queue()
792
793 def _update_results_model(self, search, model, _global=False):
794- print "update results model"
795 if _global and search:
796- print "\33[1;34m%s\33[m" % "This is a global search"
797 if search != "au": # for the "au" search, we *do* show a result
798 model.clear() # in the global dash. Why not? ;-)
799 return
800 model.clear()
801- if self.active_section == SECTION_EVERYTHING:
802- if _global == False or search in self.special_searches:
803+
804+ f = self._scope.get_filter("sites")
805+ if f != None:
806+ o = f.get_active_option()
807+ if o != None:
808+ search = o.props.id + " " + search
809+
810+ if _global == False or search in self.special_searches:
811 self.add_default_results(search, model)
812 if search and not search.lower() in self.special_searches:
813- if self.active_section in (SECTION_EVERYTHING, SECTION_QUESTIONS):
814- self.add_questions_results(search, model)
815- if self.active_section in (SECTION_EVERYTHING, SECTION_TAGS):
816- self.add_tags_results(search, model)
817- if self.active_section in (SECTION_EVERYTHING, SECTION_BADGES):
818- self.add_badges_results(search, model)
819- if self.active_section in (SECTION_EVERYTHING, SECTION_USERS):
820- self.add_users_results(search, model)
821+ self.add_questions_results(search, model)
822+ self.add_tags_results(search, model)
823+ self.add_badges_results(search, model)
824+ self.add_users_results(search, model)
825
826 if __name__ == "__main__":
827 session_bus_connection = Gio.bus_get_sync(Gio.BusType.SESSION, None)
828@@ -381,3 +293,4 @@
829 daemon = Daemon()
830 print "entering the main loop"
831 GObject.MainLoop().run()
832+b
833
834=== added file 'unity-lens-askubuntu.service'
835--- unity-lens-askubuntu.service 1970-01-01 00:00:00 +0000
836+++ unity-lens-askubuntu.service 2011-10-18 22:01:23 +0000
837@@ -0,0 +1,3 @@
838+[D-BUS Service]
839+Name=net.launchpad.AskUbuntuLens
840+Exec=/usr/lib/unity-lens-askubuntu/unity-askubuntu-daemon
841
842=== removed file 'unity-place-askubuntu.service'
843--- unity-place-askubuntu.service 2011-03-22 18:21:08 +0000
844+++ unity-place-askubuntu.service 1970-01-01 00:00:00 +0000
845@@ -1,3 +0,0 @@
846-[D-BUS Service]
847-Name=net.launchpad.AskUbuntuPlace
848-Exec=/usr/lib/unity-place-askubuntu/unity-askubuntu-daemon

Subscribers

People subscribed via source and target branches

to all changes: