| 1 | """ |
|---|
| 2 | Build a search URL for the supplied argument or just a link to a search |
|---|
| 3 | engine if no args are present. |
|---|
| 4 | |
|---|
| 5 | Defaults to google. Edit the macro to modify the engine(/url). |
|---|
| 6 | |
|---|
| 7 | This script doesn't encode the search string provided. Seems to work fine |
|---|
| 8 | on IE 6 and FireFox 1.0. |
|---|
| 9 | """ |
|---|
| 10 | |
|---|
| 11 | searchurl_prefix="http://www.google.com/search?hl=en&q=" |
|---|
| 12 | searchurl="http://www.google.com/" |
|---|
| 13 | |
|---|
| 14 | from StringIO import StringIO |
|---|
| 15 | |
|---|
| 16 | def execute(hdf, args, env): |
|---|
| 17 | |
|---|
| 18 | url= None |
|---|
| 19 | link= None |
|---|
| 20 | if args: |
|---|
| 21 | text = args |
|---|
| 22 | url = searchurl_prefix + args |
|---|
| 23 | else: |
|---|
| 24 | text = "Search" |
|---|
| 25 | url = searchurl |
|---|
| 26 | |
|---|
| 27 | buf = StringIO() |
|---|
| 28 | buf.write('<a title="Search" href="%s">' % url) |
|---|
| 29 | buf.write(text) |
|---|
| 30 | buf.write('</a>\n') |
|---|
| 31 | |
|---|
| 32 | return buf.getvalue() |
|---|