TeamPlain has a goto work-item search that opens up workitems, oddly enough. I wanted to use the Firefox search box to fire this off.
Using the guide: Creating OpenSearch plug-ins for Firefox, I started putting together an XML OpenSearch description in notepad.
Needing an icon, I Gimped out the logo from the TeamPlain site, took it past the data: URI kitchen and popped it in.data:image/png,%89PNG%0D%...
Okay, so it's fugly, but it doesn't look too bad on the search bar.
A glance at the OpenSearch Specification provided final tips when deciding what data should go where. Now I had an XML file and needed someway to consume it
I tried installing the OpenSearch plug-in. I used the Error Console in Firefox, running the command window.external.AddSearchProvider(engineURL);
using a file:///
URI for the engineURL, but kept getting a URL formatting error. Error: Invalid argument passed to
window.sidebar.addSearchEngine:
Unsupported search engine
Source File: file:///C:/Program%20Files/Gran%20Paradiso
/components/nsSidebar.js
Line: 114
Initially I thought this was due to the URL in the XML definition file, so I hacked around with that for a bit, then when that yielded no fruit, I extended the error message in the mentioned .js to include the invalid URL. This was the URL to the XML doc, not the search URL inside the XML. Turns out the URL check in the .js that was throwing the exception was only regexing https?|ftp
, so needed a |file
appended.
Now that Firefox was playing nicely with the XML, it was happy to load it up and prompt me to install it.
And it worked!
Final code: (adjust search URL to your liking)
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>TeamPlain Item</ShortName>
<Description>Load items from local TeamPlain</Description>
<Image width="16"height="16">
data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%10%00%00%00%10%08%06%00%00%00%1F%F3%FFa%00%00%00%06bKGD%00%FF%00%FF%00%FF%A0%BD%A7%93%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%07tIME%07%D7%05%08%14%0D(U%8F%FC%B3%00%00%00%1DtEXtComment%00Created%20with%20The%20GIMP%EFd%25n%00%00%03%D9IDATx%DA%25%CD%D9SUu%1C%00%F0%EFo9%F7%2C%F7%C0%85%CBv7%B8%C8%A6%80%2C%CA%92%2CS%86%25%C94%9A%19%92%8D%CD%80a5M%0F-%D34%95V%0F%3Dd%F1%D0%83H%93%83%93%E2LS4c6%26%88T6%23%13h%0B(%16b%5C%20%05%94%ED%02%F7r%B7s~%BF_%0F%7D%FE%81%0F%02E%D5%B1E%00'%08%B0%10%80%88%80%C7%1F%DD%EB%AA%DB%B5%DB%93%E6pj%CB%8B%F3%A1%BE%8B%DF%DF%BD%DCsn%16!%0E%00%18%B0%84%20*%24%C0FD%60%20%00%1C%10%00%07%E0%04%030%02%C9%DE%7C%C7%E6%ED%0Du%17%2C%B1%AA%EC%EA%9D%B5vO%AE%8B%23%0A%18K%C0%23B0%03%83%14%8D%82D9%A2%98%0B%E0%F0%FF%CE1%80%10%1CVW%FC%B1%D3%96%07%D2%A52%FB%86%85%D1%C1%F5%B8%15%7F%9F%C4%23%20%04%05BM%10%94%80%A1Y%81%98%01%81%85%10%08%13%86%B9%82%00%9B%02%803%B9%B5%B9%B9%ACQM%A9%8E%9FYZmN%CF%F7%B6%B6%B4%94%9A%26%969%05%00L%11%B0(%81p%08%0BF%10y%EE%C57%F2%DF%7C%FB%C3%B2%D9%09%9Fp%3B%5Cq%C7%DA%DA%AB%AA%B7%D5%BC%EE%95Tg%AB%3D%DB%91%A7%258%DD%8E%B4%92-%E5%E5%F7%EENLE%5C%9E%8C%C4%8F%DANV%A4o%C8%B3%5C%BF%FA%E3%02%EA%1E%B8sTNZ4%03%E1%2F%A1%D8%F1~F%92%EEj%00%60%BE_~%EA%BB22%3CL%0B%0A%0B%CD%9D%F5%0D%B5%80h%C1z%C4%E8%1D%EF%B8%F5%3B%2F%B3%A7%80%03kO%D6%E6%B5Q%87%CB%93%B3%E4%AC%1B%84%05%FF%E6%A9%F9%F2%A4%E4%B8%D6%FBG%8E%BC%F5i%E7%E7'%261B~!%C0%F6L%D3%81%C1%F6%8ES%EF%B2%81%90%BF%B8%D3%A5%FC%FC%F1P0k%AC!gc%CD%0E%1By%A8~oE2)u%AF-%07%D5m%B9G%BD%91%08%BB%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y%A9%B3%D3%13%D7%90%14%9A%87%00%07%A1%08%101%9C%E8%CE-%A9%9E%BF%E7%5B6%C3%91aI5BQ*%03%8D%86%C5%7Fs%3B%AAS%D9I.%22%00%00%00%00IEND%AEB%60%82
</Image>
<InputEncoding>UTF-8</InputEncoding>
<Url type="text/html" method="GET"
template="http://05rnb-dev02:8090/workitem.aspx?id={searchTerms}" />
<moz:SearchForm>searchFormURL</moz:SearchForm>
</OpenSearchDescription>
2 comments:
You can't begin to understand the amount of pain that you saved me. I was going mad with the search plugin installation problem (you know, where it cannot be installed from a local file). MAD, i'm telling you!
THANK YOU!
"...the URL check in the .js that was throwing the exception was only regexing https?|ftp, so needed a |file appended."
This is exactly what I needed to manually install XML search engine files saved on the local disk to the searchplugins folder WITHOUT restarting Firefox.
For anyone interested:
The javascript files are:
nsSidebar.js
nsSearchService.js
These are installed in subfolders of the main Firefox directory.
If you follow the javascript calls in Firefox 3.6.17, you can connect them to form this single command:
Components
.classes["@mozilla.org/browser/search-service;1"]
.getService(Components.interfaces
.nsIBrowserSearchService)
.addEngine("file:///path/to/search.xml", Components.interfaces.nsISearchEngine
.DATA_XML, "", true)
Remove any spaces or newlines before periods "." so the entire command is on a single line. Replace "file:///path/to/search.xml" with the path to your own local OpenSearch XML file. Keep the quotation marks around the path.
Open Firefox's Error Console (menu bar > Tools > Error Console or Ctrl+Shift+J ) Paste the command in the Error Console, hit Enter, and a small window should pop up asking whether you want to "Add search Engine".
No restarting necessary!
Post a Comment