Create a Flex2 search plugin toolbar in Firefox2

follow url With the release of Firefox 2.0 we had many new features and one of these is the go Enhanced search capabilities:
Search term suggestions will now appear as users type in the integrated search box when using the Google, Yahoo! or Answers.com search engines. A new search engine manager makes it easier to add, remove and re-order search engines, and users will be alerted when Firefox encounters a website that offers new search engines that the user may wish to install.”

For example you can add more search engines from here. I’ve take a look at the google built-in search plugin and I managed to create a search engine for AS3/Flex2 which uses the livedocs as target result site, but which uses a “search term suggestion” too.

windows xp pro windows xp pro cost You can install in Firefox2 this search plugin just clicking here.
This is the XML I used to generate this search engine:

<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/" xmlns:os="http://a9.com/-/spec/opensearch/1.1/"> <os:ShortName>Actionscript 3.0</os:ShortName> <os:Description>ActionScript 3.0 search on livedocs</os:Description> <os:InputEncoding>UTF-8</os:InputEncoding> <os:Image width="16" height="16">data:image/x-icon;base64,AAABAAEAEBAAAAAAAABoAwAAFgAAACgAAAAQAAAAIAAAAAEAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///7//v///v/+/v7//v/+/v7//v/9///7/P+DZN9SLtZ4Vdv09v7////9//////77/f77//7+/v7//////v39//////7///7YzPYxA8skAMeTeeT////+/v7///z08Pve0vb//v/////9//7+/v74/fz//////v+IZuIlAMg7EM/j3vv+//3//v/9//+5p+ySdeP+/f/////+/f/8+/+TeeRtUNt0U94+D88lAsh3Ud/////9///////+/f9vSNpIG8/z7/v+/f///v/+/v6YhOUkAMgoAckyAMouAsvEtvD///z////////h2fczBc0mAMq5p+z9/////v/////u6PtCENIvAckvAcpcM9X8+////f////////+YgOYfAMgkAMtrRdv////9///9/P7///+JbN8oAckoAMqqlun//v////7///759P1MH9MiAcgvAMs2CcrVy/b9//7//v/9//7YzPY0Ac1AEtDp4Pr6//7///////+6rO4zAMwqAcgvAcomAcmLa+H///7//v///v////9fNdaDYuL+//v9//7//////v9uSN0sAMopAsovAM0vAMtEGNHw7fz////////9//6+rfDOwvT///7//v///v/Zz/M1Bs4xAcsqAMkvAco1AMwsAMqwm+r8/v7////9//7//v/////////+//3//v+OcuMqAMkyAcksAMovAMoyAMoqAMpgNtf3+v/+/f///v3//v/////////////y6vtGHtEsAMo0Ac0sAMwvAMswAM0xAsowAsrQx/L//////////v////7//////v+4oewpAMcxAM8yAMsrAcotAcoxAMw1AMwqAMyGZOH9///+//3///7///7//v/9/f1jOtktAM01AcoyAMsqAMkxAsoyAM00AMsuAcxCEtDm4vv9/////////v/////SyfQ1CM0wAMszAM4zAMwsAMo/Dc89Ds4+D889Ds43D8yqkur9//////7///////6OdeU0Dsw+D889Ds89Ds45Ds0AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//</os:Image> <SearchForm>http://livedocs.macromedia.com/cfusion/search/index.cfm</SearchForm> <os:Url type="application/x-suggestions+json" method="GET" template="http://suggestqueries.google.com/complete/search?output=firefox&client=firefox&qu={searchTerms}"></os:Url> <!--<os:Url type="application/x-suggestions+json" method="GET" template="http://localhost/as3-static/search.php?q={searchTerms}"></os:Url>--> <os:Url type="text/html" method="GET" template="http://livedocs.macromedia.com/cfusion/search/index.cfm"> <os:Param name="loc" value="en_US"/> <os:Param name="termPrefix" value="site:livedocs.macromedia.com/flex/2 "/> <os:Param name="term" value="site:livedocs.macromedia.com/flex/2 &quot;{searchTerms}&quot;"/> <os:Param name="area" value=""/> <os:Param name="search_text" value="{searchTerms}"/> <os:Param name="action" value="Search"/> <os:Param name="client" value="firefox"/> </os:Url> </SearchPlugin>

http://www.aftlv.com/cultural-identity-essay/ cultural identity essay You can also install it just by creating  an xml with this code and save into your:
here {UserAppDataDir}\Mozilla\Firefox\Profiles\{ProfileName}\searchplugins\

http://www.callforassistance.com/?it-masters-thesis it masters thesis Using this search plugin as it is now, it just will redirect all the queries to the http://livedocs.macromedia.com site, and uses the google suggestion search engine to display the suggestions.
See an example on how suggestions works here. As you can see the results are encoded using JSON.
This is the output you will see there: [“mx.core.”,[“mx.core.view”]]

see enter site But since I wanted to have a “pure” flex2 suggestion search engine I grabbed all the contents from the Flex2 Language Reference site using python, saved the results in a local Mysql database and finally created a little search engine in PHP which returns the same json-encoded results, to be used with my search plugin.

Replacing the original search plugin xml file into:

<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/" xmlns:os="http://a9.com/-/spec/opensearch/1.1/"> <os:ShortName>Actionscript 3.0</os:ShortName> <os:Description>ActionScript 3.0 search on livedocs</os:Description> <os:InputEncoding>UTF-8</os:InputEncoding> <os:Image width="16" height="16">data:image/x-icon;base64,AAABAAEAEBAAAAAAAABoAwAAFgAAACgAAAAQAAAAIAAAAAEAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///7//v///v/+/v7//v/+/v7//v/9///7/P+DZN9SLtZ4Vdv09v7////9//////77/f77//7+/v7//////v39//////7///7YzPYxA8skAMeTeeT////+/v7///z08Pve0vb//v/////9//7+/v74/fz//////v+IZuIlAMg7EM/j3vv+//3//v/9//+5p+ySdeP+/f/////+/f/8+/+TeeRtUNt0U94+D88lAsh3Ud/////9///////+/f9vSNpIG8/z7/v+/f///v/+/v6YhOUkAMgoAckyAMouAsvEtvD///z////////h2fczBc0mAMq5p+z9/////v/////u6PtCENIvAckvAcpcM9X8+////f////////+YgOYfAMgkAMtrRdv////9///9/P7///+JbN8oAckoAMqqlun//v////7///759P1MH9MiAcgvAMs2CcrVy/b9//7//v/9//7YzPY0Ac1AEtDp4Pr6//7///////+6rO4zAMwqAcgvAcomAcmLa+H///7//v///v////9fNdaDYuL+//v9//7//////v9uSN0sAMopAsovAM0vAMtEGNHw7fz////////9//6+rfDOwvT///7//v///v/Zz/M1Bs4xAcsqAMkvAco1AMwsAMqwm+r8/v7////9//7//v/////////+//3//v+OcuMqAMkyAcksAMovAMoyAMoqAMpgNtf3+v/+/f///v3//v/////////////y6vtGHtEsAMo0Ac0sAMwvAMswAM0xAsowAsrQx/L//////////v////7//////v+4oewpAMcxAM8yAMsrAcotAcoxAMw1AMwqAMyGZOH9///+//3///7///7//v/9/f1jOtktAM01AcoyAMsqAMkxAsoyAM00AMsuAcxCEtDm4vv9/////////v/////SyfQ1CM0wAMszAM4zAMwsAMo/Dc89Ds4+D889Ds43D8yqkur9//////7///////6OdeU0Dsw+D889Ds89Ds45Ds0AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//</os:Image> <SearchForm>http://livedocs.macromedia.com/cfusion/search/index.cfm</SearchForm> <os:Url type="application/x-suggestions+json" method="GET" template="http://localhost/as3-static/search.php?q={searchTerms}"></os:Url> <os:Url type="text/html" method="GET" template="http://livedocs.macromedia.com/cfusion/search/index.cfm"> <os:Param name="loc" value="en_US"/> <os:Param name="termPrefix" value="site:livedocs.macromedia.com/flex/2 "/> <os:Param name="term" value="site:livedocs.macromedia.com/flex/2 &quot;{searchTerms}&quot;"/> <os:Param name="area" value=""/> <os:Param name="search_text" value="{searchTerms}"/> <os:Param name="action" value="Search"/> <os:Param name="client" value="firefox"/> </os:Url> </SearchPlugin>

now the search plugin engine will query http://localhost/as3-static/search.php?q={searchTerms} for displaying the suggestions (so you need to have a php script there which can return something).
What I did at this point is:
1. Grab the flex2 reference using this python script. This script will output a file mysql.sql.
non accountant assignment help 2. Import this sql file into my Mysql database using:

mysql  flex2_reference < mysql.sql

where “flex2_reference” is a database I previously created.
Customer Service Department Business Plan 3. Create this php script (sorry, it’s not really a good example of php script…) and saved into my localhost at this address: http://localhost/as3-static/search.php
and I’ve got a fully ActionScript 3.0 search engine with suggestion!

  • Patrick

    The second xml snippet seems to be the same as the first. Should the tags be pointing to localhost?

  • The first snippet has the “localhost” tag commented, while the second one hasn’t the “google suggest” tag, but only the localhost one.

  • Patrick

    I guess I was still sleeping… need more coffee ;-). Anyway THNX for the code. I modified the pythonscript and the mysqlschema a bit so that is also grabs the url part. I then downloaded the flex2_docs zipfile from ‘labs.adobe.com’ and copied it to my webroot. I added a result.php -> just a tweakeed copy of search.php but it does a header(location:url) on the the urlfield.So now I have everything local. Sure speeds it all up a bit.

  • Yeah, you’re right. That’s a better solution indeed!

  • I was wondering why your local queries brought also results from outside, at least that what it seemed, instead probably it was bringing results from google, btw the xml is wrong, line 11 of the second (12 of the first) should be:
    without “”, now I get only results from my db 🙂

  • Nate Chatellier

    This is awesome!! Man I love the stuff you keep putting out Alessandro. Thanks so much for this.

  • Thanks for the inspiration, today I was able to create a suggestion for our internal wiki which search engine seems to suck (wikiMedia).

  • Alessandro, your example is so advanced I even a bit afraid posting the following link here… well, I’ve created very simple Firefox search plug-ins for Flex 2, Flex 3, Actionscript 3 LiveDocs and Adobe Labs.