Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

Do the Right Thing

Summary: Link shortcuts to custom searches for your browser
Version: 20110408
Prerequisites:
Status: beta
Maintainer: Petko
Categories: Links, PIM, Cloud
Users: +2 (View / Edit)

Description

Use a wiki page to create and edit link shortcuts to a number of predefined custom searches.. The feature is similar to the InterMap feature, but is directly embedded in your browser.

This is a productivity enhancement for those who use Internet a lot and PmWiki for Personal Information Management. The user can type a "keyword" and some "search terms" in her browser address bar, and the browser will automatically open the search results page based on the keyword. For example, typing in the address bar g some search will search Google, w some term will search Wikipedia, php some function will search the PHP.net documentation, and so on.

There is a benefit to use a wiki page instead of browser "bookmark shortcuts" if you use more than one computer or more than one browser. Your shortcuts are very easy to add and edit, and will always be up-to-date in all browsers.

Installation

  • Copy dtrt.phpΔ to your /cookbook/ directory (alt. download: dtrt.php).
  • Add to a selected file local/Main.DTRT.php such a line:
    <?php
    include_once("$FarmD/cookbook/dtrt.php");

(You can select any page you wish. This page will contain your shortcut definitions.)

Shortcut configuration

In your selected wiki page, for example Main.DTRT, add the link shortcuts in this format:

 gi:       http://images.google.com/images?q=$1 : Google images
 fm:       http://freshmeat.net/search/?section=projects&q=$1 : Freshmeat (software)
 php:      http://php.net/search.php?lang=en&show=quickref&pattern=$1 : PHP manual
 map,maps: http://www.google.com/maps?q=$1 : Search Google Maps
 pm:       http://www.pmwiki.org/wiki/?action=search&q=$1 : search PmWiki.org
 imdb:     http://www.imdb.com/find?s=all&q=$1 : search IMDB for movies

On the shortcut line, there is a "keyword" followed by a ":" colon, spaces and the url address of the search related to this keyword. The address contains "$1" which will be replaced with the search terms. At last, after another colon, you can have some optional comment.

You can have more than one shortcut for an address, separate them with commas like the map,maps: line in the example, or put them on different lines.

The recipe has 3 default shortcuts built-in: "g" to search Google, "w" for Wikipedia in English, and a "_default" search when no shortcut was recognized. You can change the default shortcuts by simply redefining them in the Main.DTRT page:

 _default: https://ssl.scroogle.org/cgi-bin/nbbwssl.cgi?Gw=$1 : Set Scroogle as default

On that same page, you can add a form allowing searches from browsers that are not configured. For example, you can place at the top of the page:

(:input form action="{$PageUrl}" method=get:)
(:input hidden action dtrt:)(:input text q size=40:)(:input submit value="Do!":)
(:input end:)

Browser configuration

You need to instruct your browser to send searches to your Main.DTRT wiki page (the recipe will then redirect to the selected search).

Your custom address is that of the Main.DTRT page followed by ?action=dtrt&q= for example, http://yourwiki.net/wiki/Main/DTRT?action=dtrt&q= .

  • Mozilla, Firefox : type in the address bar "about:config", double-click on the line keyword.URL and replace the default url with your custom address.
  • Konqueror : Settings - Configure Konqueror - Web Shortcuts - New. In the box select a name ("DTRT"), pick a keyword ("d"), entrer your custom address followed by "\{@}" like "...?action=dtrt&q=\{@}", pick a keyword ("d"), press "Ok". Select Default search engine - DTRT and Keyword delimiter - Space, press Apply and Ok.
  • Midori : Tools - Manage search engines - Add. In the dialog box fill in Name: DTRT, Address: your custom address followed by "%s" like "...?action=dtrt&q=%s". Press Add, then Use as default.
  • Chromium, Google Chrome : Wrench - Settings -or- Preferences - Default search Manage - Add. In the box select a name ("DTRT"), pick a keyword ("d"), entrer your custom address followed by "%s" like "...?action=dtrt&q=%s", press "Save", then press "Make Default".
  • MS Internet Explorer 8 : go here. In the URL box paste your custom address followed by "TEST" like "...?action=dtrt&q=TEST", in the Name box enter DTRT, press on "Install Search Provider". In the program interface at the top right, press the arrow after the search field, select "Manage Search Providers", in the box select DTRT and press "Set as default".
  • Opera : Settings - Preferences - Search - Add. In the box select a name ("DTRT"), pick a keyword ("d"), entrer your custom address followed by "%s" like "...?action=dtrt&q=%s", check the two checkboxes about a default search engine.

Usage

To search Internet, in your browser press F6 or Ctrl+T to focus the address bar, then enter the search shortcut, a space, then the search terms, and press Enter. For example, entering fm PmWiki will search the Freshmeat software catalog for "PmWiki". The "fm" keyword is defined in the DTRT wiki page.

Notes

  • In an open wiki, your Main.DTRT wiki page should probably be password-protected for editing.
  • Some browsers have built-in search shortcuts. If you enter a shortcut which is defined in your browser, your browser will take care of the search, and not your DTRT wiki page. In most cases you can disable or change the conflicting shortcut in your browser settings.

Release notes

  • 20110408 - the keyword definitions can now be regular expressions if they are wrapped with '/' and an optional 'i' modifier.
  • 20110112 - first public release after several months of usage by the author

See also

Contributors

Petko is the author and the maintainer of the recipe. I've been using and advocating in-browser search shortcuts for years but the idea to use a wiki page came to me when I found "DTRT: A CGI Script to Do The Right Thing" by Gerald Oskoboiny.

Comments

See discussion at DoTheRightThing-Talk

User notes +2: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.

Edit - History - Print - Recent Changes - Search
Page last modified on May 21, 2012, at 05:21 AM