After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 528184 - Write OpenSearch module
Write OpenSearch module
Status: RESOLVED FIXED
Product: deskbar-applet
Classification: Deprecated
Component: Modules
unspecified
Other Linux
: Normal enhancement
: 2.26
Assigned To: Arthur Perton
Deskbar Applet Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2008-04-15 10:15 UTC by Sebastian Pölsterl
Modified: 2009-01-30 20:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
beta (12.02 KB, text/plain)
2008-06-09 21:25 UTC, Arthur Perton
Details
beta (2) (15.82 KB, text/plain)
2008-06-13 13:02 UTC, Arthur Perton
Details
beta (3) (16.89 KB, text/plain)
2008-07-08 21:23 UTC, Arthur Perton
Details

Description Sebastian Pölsterl 2008-04-15 10:15:01 UTC
The module should be able to search any OpenSearch compliant site given the OpenSearch description document, parse the results and present them.

The googlecodesearch module already parses results in Atom format.

The OpenSearch specification is available at http://www.opensearch.org/Specifications/OpenSearch/1.1/Draft_3
A guide on how to write Deskbar-Applet modules is available at http://www.k-d-w.org/deskbar/new-style_modules.html
Comment 1 Arthur Perton 2008-04-18 11:55:14 UTC
I would like to solve this one, but I could use some mentoring as I am new to OpenSource development (not new to programming of course :) ). This bug was tagged with gnome-love, so are you willing to mentor me for this 'bug'?
Comment 2 Sebastian Pölsterl 2008-04-18 15:27:24 UTC
That's great. The task is yours ;)

I'll try to answer all your questions. You can contact me via e-mail or #deskbar on GimpNet, too. If you have any code, please attach it here and I'll review it.
Comment 3 Sebastian Pölsterl 2008-06-02 10:46:45 UTC
How's the status of the module?
Comment 4 Arthur Perton 2008-06-02 12:46:21 UTC
Development of the module is going okay. 

Right now I have got the following working:
- Parsing and presenting search results (both Atom and RSS)
- Adding, editing and removing search sites using dialogs

To do:
- Parsing description documents
- Error handling
- Perhaps tweaking the looks

I might be able to submit a beta version for review at the end of this week.  

Comment 5 Sebastian Pölsterl 2008-06-02 16:48:10 UTC
That's awesome!

I'd love to see some code.
Comment 6 Arthur Perton 2008-06-09 21:25:33 UTC
Created attachment 112437 [details]
beta
Comment 7 Arthur Perton 2008-06-09 21:26:25 UTC
Please find the code for the module attached. It is not the final product, but
it has all the basic functionality. Have a look at the code and toy around with
the module. I'd be glad to hear your feedback.
Comment 8 Sebastian Pölsterl 2008-06-10 17:17:06 UTC
Wow, thanks a lot for all your work. I had a look at your code and played with it a little bit. Here are some issues I came across (in no particular order). Maybe you came across some of them already yourself.

1) When pressing "More..." in preferences when the module is _not_ enabled:

  • File "/home/sebp/workspace/build/deskbar/handlers/opensearch.py", line 232 in load_settings
    file = open(SETTINGS_FILE, 'rb')
9) Using http://suche.golem.de/golem_osdd.xml it doesn't appear at all. That's because there's no template attribute in the Url. Don't know what the spec says here.

10) Currently, you're only replacing {searchTerms} in the template Url, but there are more placeholders. You should choose reasonable default values if applicable.

This seems like a lot, but it's a rather complex issue where many things can go wrong. Nevertheless, it's already a very good start. If you need some assistance in coding, let me know.
Comment 9 Arthur Perton 2008-06-10 19:14:07 UTC
Thank you for your (quick) feedback Sebastian. This is very useful. I will handle these ten issues one by one in the coming days. When the next version is ready for testing I will post it here.

Any tips for logging, besides writing to a file? Perhaps something more 'direct'?
Comment 10 Sebastian Pölsterl 2008-06-10 19:17:19 UTC
That's awesome!

I'm using the logging module[1]. E.g. the beagle-live module makes use of it.

[1]: http://docs.python.org/lib/module-logging.html
Comment 11 Arthur Perton 2008-06-13 13:02:11 UTC
Created attachment 112676 [details]
beta (2)

Applied changes to solve the issues in Comment #8. Please review.
Comment 12 Sebastian Pölsterl 2008-06-14 23:32:03 UTC
Thanks!

This version is almost perfect. There are some minor issues:

1) When selecting an item in preferences and deselecting it the icons aren't marked in sensitive. Use treeview.get_selection().connect("changed", ...)

2) When an RSS item contains a description field display it with Match.set_snippet

3) You should use MessageDialog with gtk.MESSAGE_ERROR instead of WARNING.

4) Don't hard code .gnome2/deskbar-applet use deskbar.USER_DESKBAR_DIR instead

5) Don't use custom logger, but the logging module.

6) In preferences put url entry first and put the pointer by default in there

7) The icon for OpenSearchMatch is currently gtk-file and category actions. This doesn't fit at all. You should use the websearch category with it's default icon. Some description files seem to provide a URL to icon. What would really rock is if the module would download the icon use it instead of the default one.

Beside that it's excellent work!
Comment 13 Arthur Perton 2008-07-08 21:23:24 UTC
Created attachment 114217 [details]
beta (3)

I solved the issues as far as I could, but I have difficulties in three
remaining cases:

1. Match.set_snippet() gives me trouble (it looks so simple!). If I uncomment the code in line 64 the program fails. Please advise.

2. Showing the image from the description document: It was not easy to get this working, and when it worked it did not look great (the Image does not necessarily look like an icon, it is often a larger image). I'm not sure if this is a desired feature after all. If you want to check it out, uncomment the code in lines 98-108

3. Somehow I can't get the python logging module to work. It just doesn't log, whatever I try. Could you show me how to set it up, please?
Comment 14 Sebastian Pölsterl 2008-07-09 21:01:31 UTC
1. Do you have deskbar-applet from svn trunk?

2. Your right, I didn't consider that. We should just ignore the image then.

3. Put this at the top of the file:
import logging
LOGGER = logging.getLogger (__name__)

then you can do LOGGER.info(), LOGGER.warning(), LOGGER.debug() and so on.

I discovered a problem when the template url contains the count parameter (e.g. http://wikitravel.org/en/Special:OpenSearch/description). Currently, you set the value for all additional parameters to 0. That's not a good idea. In this particular case no results are returned. You should check which optional parameters exist and choose sane default values for each of them (e.g. 20 for count).

All other issues I mentioned before are fixed in this version. Thanks a lot for your work.

If you have an updated version please upload it here.
Comment 15 Sebastian Pölsterl 2008-08-21 18:02:59 UTC
Are you still working on this? I would love to include it in 2.24.
Comment 16 Sebastian Pölsterl 2009-01-30 20:16:43 UTC
I fixed the remaining bugs and did some cleanup. It's now part of svn trunk.