Project

General

Profile

Opensearch compatibility for Redmine search

Added by Ted Lilley over 14 years ago

I'm attempting to drive adoption of the knowledgebase aspect of Redmine in my organization, which requires some critical mass before it can really take hold. It's the chicken and the egg syndrome: users will want to use the wiki and other resources when there is useful content, but there will only be useful content when users want to use the wiki etc.

I think a strong way to encourage adoption is to take every opportunity to demonstrate the useful content that is available in Redmine. Usually, this involves a search of some sort by the user to find the info. However, because you have to actively decide to search within Redmine before you do the search, and the user doesn't always know that the information they are seeking is there, they are less likely to find that info.

Opensearch may be one way to make that information more readily available. Opensearch allows you to extend your search results to the search bar within IE and Firefox. By setting up Redmine as a search provider, it can be added to the search bar so that you are one step closer to searching Redmine by default. It's still a separate search in the searchbar dropdown from, say, Google, but if it's there the distance between it and the user is shortened.

Opensearch is really just a way of packaging your search results in a certain format. An atom feed that supports the proper XML markup for Opensearch results is adequate. I've inspected the search_controller.rb file in Redmine, and it looks very simple. If, instead of paginating and rendering the layout of the search results, they could instead be passed to an opensearch function that packages the XML and publishes it using the existing Redmine atom facilities, I'm guessing it wouldn't be too hard.

I've been doing a little Redmine hacking here and there, and while I'm starting to be able to read Ruby, this is still way over my head. I'm willing to take a stab at it if someone could give me a little guidance on how to modify things without actually modifying the core, specifically with regard to search. My initial inspection doesn't show any hooks for customization, so I'm concerned that it may not be possible without modifying the search_controller directly.

Any input is welcome.

Ted


Replies (23)

RE: Opensearch compatibility for Redmine search - Added by Muntek Singh over 14 years ago

http://mycroft.mozdev.org/search-engines.html?name=redmine.org

Looks cool, I've been using the above personally for some time, uploaded for the rest of you :)

RE: Opensearch compatibility for Redmine search - Added by Ted Lilley over 14 years ago

Well that's very promising, but I guess I need to be more specific. I'm not looking to add a Redmine.org search to my Firefox, although kudos to you for making that possible. I'd like to do something similar, but using my internal Redmine site as the search engine. Also, my internal site is not available to the outside world, so if your link is some kind of off-site wrapper to the search results returned by the regular Redmine site, it probably won't work since I'd have to have that wrapper within my intranet.

Very promising though. How does this thing you have work?

RE: Opensearch compatibility for Redmine search - Added by Muntek Singh over 14 years ago

It's just http://www.redmine.org/search/index/redmine?q={searchTerms}

You can easily create it, here is the one from above:

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" 
                       xmlns:moz="http://www.mozilla.org/2006/browser/search/">
    <ShortName>redmine.org</ShortName>
  <Description>Search redmine.org</Description>
  <Url type="text/html" method="get" template="http://www.redmine.org/search/index/redmine?q={searchTerms}"/>
  <Image width="16" height="16">http://domain.tld/path/to/ico/redmine_org.ico</Image>
  <Developer>Muntek Singh</Developer>
  <InputEncoding>UTF-8</InputEncoding>
  <moz:SearchForm>http://www.redmine.org/search/index/redmine</moz:SearchForm>
  <Url type="application/opensearchdescription+xml" rel="self" template="http://mycroft.mozdev.org/updateos.php/id0/redmine_org.xml"/>
  <moz:UpdateUrl>http://mycroft.mozdev.org/updateos.php/id0/redmine_org.xml</moz:UpdateUrl>
</OpenSearchDescription>

RE: Opensearch compatibility for Redmine search - Added by Muntek Singh over 14 years ago

Actually here is a bit cleaner:

<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/" xmlns:os="http://a9.com/-/spec/opensearch/1.1/">
<os:ShortName>Redmine.org Search</os:ShortName>
<os:Description>Search Redmine.org</os:Description>
<os:InputEncoding>UTF-8</os:InputEncoding>
<os:Image width="16" height="16">http://domain.tld/image.ico</os:Image>
<SearchForm>http://www.redmine.org/search/index/redmine</SearchForm>
<os:Url type="text/html" method="GET" template="http://www.redmine.org/search/index/redmine">
  <os:Param name="q" value="{searchTerms}"/>
</os:Url>
</SearchPlugin>

RE: Opensearch compatibility for Redmine search - Added by Ted Lilley over 14 years ago

Thank you for your assistance, Muntek. After some head scratching and review of other tutorials, I was able to get this to work. Very exciting.

I'm writing a blog entry on how it was done at: http://blogs.trekforth.com/2010/04/adding-opensearch-provider-to-redmine.html

I used your template exactly as it stands, with just my site substituted for redmine.org. Thanks again.

RE: Opensearch compatibility for Redmine search - Added by Muntek Singh over 14 years ago

No problem, glad to have helped.

Now that I think about it, this would make a very nice plugin. Maybe you or I could have a go at it sometime :)

RE: Opensearch compatibility for Redmine search - Added by Holger Just over 14 years ago

Hi there,

I just created a simple plugin based on your first snippet to provide a proper Opensearch integration. It is available at http://dev.holgerjust.de/projects/redmine-opensearch/wiki.

Your second snippet is not suitable here, as the MozSearch stuff is only understood by Firefox and should be used only in Firefox plugins according to https://developer.mozilla.org/en/Creating_MozSearch_plugins.

--Holger

RE: Opensearch compatibility for Redmine search - Added by Ted Lilley over 14 years ago

I noticed the same thing about the search snippet. I was able to change it so that it works for both IE and Firefox based on other samples I found on the web. You can see what I ended up using at the blog posting I made.

Thanks, Holger.

RE: Opensearch compatibility for Redmine search - Added by Ted Lilley over 14 years ago

It should also be noted that this particular feature really demands a favicon.ico, as that is the only easy way to tell which search you are using in the search bar. I had to go find my own for my install, which is 0.8.4. I don't know if that has been remedied in later Redmine releases, but it really should be if it isn't.

Your plugin should very well include that feature for any version that doesn't have a favicon. I used the ruby.org one.

RE: Opensearch compatibility for Redmine search - Added by Muntek Singh over 14 years ago

Holger - Cool bro, beat me to it!
Ted - Sorry I left the moz stuff in there, I primarily use FF so it just slipped in :)

Probably it'd be better to create another plugin that let users easily define the favicon using a gui.

RE: Opensearch compatibility for Redmine search - Added by Jan from Planio www.plan.io over 14 years ago

Great work, guys. We've just added this for all users on Planio. Please find attached an improvement based on Holger's plugin for (a) cleaner code and (b) avoiding an error message when you're logged out while trying to add the engine. Thanks heaps!

RE: Opensearch compatibility for Redmine search - Added by Holger Just over 14 years ago

Jan,

Glad you like it :)

However, I think it is a bad idea to include the auto-discovery tags only if a user is logged in. This would prevent anonymous usage on public projects (like on redmine.org). The prettified code is was just committed.

Please note that the frequency of updates is rather high currently. So you might want to update from time to time...

RE: Opensearch compatibility for Redmine search - Added by Jan from Planio www.plan.io over 14 years ago

Glad you like it :)

I agree on the anonymous user issue. However, if you have a "private" Redmine, /login still exposes the opensearch link tags and Firefox fails when one is trying to add the Engine from the login page. I'd suggest you change OpensearchController so that it doesn't require auth for the general /opensearch resource and public projects when logged out.

RE: Opensearch compatibility for Redmine search - Added by Holger Just over 14 years ago

Okay, I just added some before_filter magic to skip authentication for the global search. The information exposed by this is nothing private anyway. The search controller itself performs access checking if necessary.

Project specific search is still only included if the user is properly authorized for that project.

RE: Opensearch compatibility for Redmine search - Added by Ted Lilley over 14 years ago

Just wanted to congratulate Holger, I think this is a great addition to Redmine and it is amazing to see how quickly you picked it up. Thanks!

Ted

RE: Opensearch compatibility for Redmine search - Added by Ted Lilley over 14 years ago

I guess the only suggestion I would make, Holger, is that you mention how to use of a favicon.ico in your documentation page. I still think this is a key feature, and the user is left to figure it out on their own as it stands.

RE: Opensearch compatibility for Redmine search - Added by Holger Just over 14 years ago

I'm still in proress of finding the best way to handle favicon configuration using my favicon plugin. Once this is done (probably this weekend), you can easily select which favicon you want to use.

--Holger

RE: Opensearch compatibility for Redmine search - Added by Ted Lilley over 14 years ago

At the risk of sounding like a jerk (I'm just trying to illustrate a point), I've written the plugin for you. You can install it in /dev/brain:

"Steps:

  1. Choose a favicon icon that you like, either of your own or from the web.
  2. Copy it to <redmine>/apps/redmine/public. Replace the favicon.ico file that is there.
    "

What I mean to say is that writing a plugin is exactly the kind of overkill approach that is the enemy of the giving the user the direct solution.

Knowing how to write a plugin is a nice hammer. When you've got a hammer, though even thumbtacks start to look like nails. Don't use a hammer to drive a thumbtack. Just push it with your thumb and be done with it. Plugins aren't meant for trivial things like this.

Web administrators have been installing favicons for years this way.

I'm trying to be lighthearted here, not a jerk. Take it as you will. :)

Ted

RE: Opensearch compatibility for Redmine search - Added by Holger Just over 14 years ago

Ted Lilley wrote:

  1. Choose a favicon icon that you like, either of your own or from the web.
  2. Copy it to <redmine>/apps/redmine/public. Replace the favicon.ico file that is there.

Web administrators have been installing favicons for years this way.

Well, my approach to Redmine is that there should be very few places that should be written to by a end user. For a basic installation that are four files / directories:
  • config/database.yml
  • config/email.yml
  • config/initializers/session_store.rb (via the rake task)
  • vendor/plugins only for adding plugins. See also #5306

The rest is normally done via the WUI.

Regarding this special issue, I think, the favicon definition should be part of a generalized themeing API (which could be solved by allowing a theme to somehow overwrite predefined assets). In the meantime, I'm trying to give the user a mean to define his favicon. It might be important in a hosted or cloud context (like Jan's) where the user can not directly write to public.

And obviously, there is a need for it as proved by this plugin by someone other than me :)

But yes, the default will always be to use public/favicon.ico if nothing other is defined.

RE: Opensearch compatibility for Redmine search - Added by Muntek Singh over 14 years ago

Something nifty you might not know: If you put an issue number (just the number or with #) it will take you directly to that issue :)

RE: Opensearch compatibility for Redmine search - Added by Jonathan Cormier over 2 years ago

Sorry for resurrecting an old post but this is the first and only result on google so I figured I'd update it with a current solution.

I used the add-custom-search-engine extension in firefox to add a custom search. This provides a form that generates an OpenSearch XML and lets you add it to your browser without having to host it somewhere.

I set the search URL to https://www.redmine.org/redmine/search/?q=%s

A keyword can then be added by going to about:preferences#search after adding the search engine and editing the Keyword column.

RE: Opensearch compatibility for Redmine search - Added by Jonathan Cormier over 2 years ago

This can be done natively in chrome as well. Go to Settings -> Search engine and "Add" a new Site Search

    (1-23/23)