content_handlers

When you browse to a document of a content-type that Mozilla cannot view internally, Conkeror normally prompts you for an action to take on the content. You can customize this on a per-mime-type basis to automatically do what you like by registering a content handler:

content_handlers.set("application/pdf", content_handler_open);

content_handlers is a mime-type table associating mime-types and mime-type patterns with content handler functions. The following handlers are predefined for your convenience:

content_handler_save
Save the document, prompting for path.
content_handler_open
Open the document, promting for a command.
content_handler_open_default_viewer

Open the document in the viewer registered in external_content_handlers for this mime-type, or prompt if none.

content_handler_open_url
Prompt for a command, and run it with the URL of the document as its argument.
content_handler_copy_url
Copy the URL of the document.
content_handler_view_internally
content_handler_view_as_text
content_handler_prompt
The default prompt---the same as if no handler was defined.

If you set a give null instead of a content handler to content_handlers.set, it will unset the handler for the given mime type.

You can also use the mime-type wildcard "*". A mime-type of "*" will match any mime-type. A mime-type of, for example, "application/*" will match any mime type whose major type is "application".

external_content_handlers

This variable is a mime-type table that associates mime types with command names of viewer programs. Manipulation of the table works just as for content_handlers.

external_content_handlers.set("application/pdf", "xpdf");
external_content_handlers.set("image/*", "display");

The default table is:

{
    "*": getenv("EDITOR"),
    text: { "*": getenv("EDITOR") },
    image: { "*": "feh" },
    video: { "*": "mplayer" },
    audio: { "*": "mplayer" },
    application: {
        pdf: "evince",
        postscript: "evince",
        "x-dvi": "evince"
    }
}

If you want to discard the defaults and set the entire table in one go, you can do that as follows:

external_content_handlers =
    {
        "*": "gvim",
        text: { "*": "kate" },
        image: { "*": "display" },
        application: {
            pdf: "xpdf",
            postscript: "gv",
            "x-dvi": "xdvi"
        }
    };

That trick works for content_handlers too.

ContentHandlers (last edited 2009-10-13 00:44:51 by JohnFoerch)