1
<?xml version="1.0" encoding="ISO-8859-1"?>
4
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
7
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
12
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
13
<meta name="robots" content="index,follow" />
14
<meta name="author" content="Jos� Luis Gonz�lez Gonz�lez" />
15
<meta name="description" content="how to setup MIME handlers for ELinks" />
16
<meta name="keywords" content="ELinks MIME handler images view" />
18
<title>Basic instructions for MIME configuration</title>
27
<h2>What's all this about?</h2>
30
At some time along the 0.4 prereleases, ELinks replaced the old Links file
31
configuration system with its own one. Now, the configuration is stored
32
in <cite>elinks.conf</cite>, much more complete and featuring a new
33
syntax. You can set most options from the <acronym title="User
34
Interface">UI</acronym> (so usually there is no need to deal with
35
<cite>elinks.conf</cite>), and that used to be true for setting MIME
36
handlers and extensions as well; but now the associations menu is gone
37
temporarily, forcing you to set the handlers from the configuration file.
41
The comments provided within <cite>elinks.conf</cite> for the MIME
42
options are not much helpful, and those options may seem a bit obscure
43
or confusing at first. This document is a basic introduction to setting of
44
MIME associations for ELinks. If you want to know how to automatically
45
launch a program to view some kind of file (like images), then read
46
on. Some basic knowledge of MIME is recommended.
49
<h2>Acknowledgements</h2>
52
This document was written by <cite>Jos� Luis Gonz�lez
53
Gonz�lez</cite> out of despair due to the lack of documentation
54
regarding the new way to configure MIME in recent ELinks prereleases.
55
You may reach him at <a href="mailto:jlg80@mi.madritel.es">
56
jlg80@mi.madritel.es</a>. Suggestions, fixes and contributions are
61
I'd like to thank <a href="mailto:zas@norz.org">Laurent Monin</a>,
62
who pointed me the syntax for the <code>mime.type</code> and
63
<code>mime.handler</code> options. Thanks also to
64
<a href="mailto:pasky@ucw.cz">Petr Baudis</a> for suggesting to
65
use the Links to ELinks configuration conversion script from
66
<cite>contrib/</cite> and in general for keeping up improving ELinks.
69
<h1>Handling MIME types, the ELinks way</h1>
71
<h2>What are MIME types and why may you want to use them?</h2>
74
If, while browsing with ELinks, you need to display files that it can't
75
show (like images or PDF documents), then you will likely want to pass
76
them to other programs that are suitable for this task. While you may
77
do it manually (saving the file to disk, running the auxiliar program to
78
show it and then removing the file when finished), ELinks provides a
79
method to do this automatically using MIME types.
83
ELinks usually knows what the MIME type is for any file (which is a kind
84
of description of its format), thus you only need to specify how to
85
manage the MIME types for the files you want to open. If you don't tell
86
ELinks how to manage a given MIME type then it will show you on screen
87
the contents of the file (as if it was ASCII text) instead
88
of calling an external program to show them.
91
<h2>Associating files to MIME types</h2>
94
If the file is fetched from a web server then this web server should
95
tell ELinks what its MIME type is, so you should have generally no need to
96
care about it. However, the web server might send an incorrect type, or
97
you may be retrieving it by <acronym title="File Transfer Protocol">FTP
98
</acronym> or from your local filesystem, so sometimes ELinks needs to
103
The easiest method to guess a MIME type for a file is to just look at its
104
name trusting it was given the right extension. ELinks supports this,
105
letting you to specify a type for any given extension.
108
<h2>Managing a given MIME type</h2>
111
This usually means specifying programs to open files of this type and
112
the conditions in which those programs may be used. For instance, you
113
may want to use <cite>zgv</cite> (a popular svgalib image viewer) when
114
you are using the text console, but <cite>xli</cite> (a image viewer for
115
X) when running the X window system.
118
<h3>Binding it to a handler</h3>
121
Instead of directly attaching a program to a MIME type, ELinks lets you
122
associate an abstract <cite>handler</cite> to each type. Then you can
123
specify which programs implement the handler and how are they used.
127
For instance, you may create an <code>image_viewer</code> handler and
128
assign it to MIME types <cite>image/jpeg</cite>, <cite>image/png</cite>
129
and <cite>image/gif</cite>. Then you would associate to <code>
130
image_viewer</code> the programs you would like to use for viewing
131
images and the details on how to use them. This is less cumbersome than
132
repeating all these details for each MIME type.
135
<h2>Specifying the details for a handler</h2>
138
There are three issues to specify for a handler: the program associated
139
to it, whether you want confirmation before using it and whether you
140
want the terminal to be blocked while it is being used.
144
When specifying any of these issues, you must tell ELinks the situation
145
in which it gets applied, which is typically either the text console or
146
the X window sytem. So you can specify that you don't want confirmation
147
before running the program when running X, and that you want it
148
otherwise. Similarly, when you are attaching a program (name it
149
<cite>foo</cite>) to this handler you must tell if it's for X or not
150
(you can attach a second program for the other choice if you want).
153
<h3>Attaching a program to it</h3>
156
You must tell ELinks the exact command for running it (with any options
157
you wish). In place of the filename you must enter <kbd>%</kbd>.
160
<h3>Choosing whether you want confirmation before applying it</h3>
163
This is rather simple. If you choose not to do so, then the handler
164
will be automatically called upon when you demand ELinks to show
165
something attached to this handler. Otherwise, if you ask for
166
confirmation, you will be prompted to open it with a external program,
167
with additional choices that include cancelling the operation and
168
viewing it with ELinks. E.g: you may use this option for programs
169
written in <cite title="the C programming language">C</cite> so that you
170
may always choose if you want to read the source with ELinks, or if you
171
want to save it, or if you want to use <cite title="The indent program
172
beautifier">indent</cite> to display it with less.
175
<h3>Choosing whether to block the terminal</h3>
178
If you don't want to allow going back to ELinks (or any other program
179
from the same terminal) before the external program ends, then you
180
should ask to block the terminal.
183
<h1>Setting up <cite>elinks.conf</cite></h1>
186
If you have old configuration files from old ELinks versions or from
187
Links, then you may use the <cite>conf-links2elinks.pl</cite> script
188
(which is placed at <cite>contrib/conv/</cite> on the source
189
distribution) to convert them to the new format. If you don't use it
190
you will need to edit the configuration file, and here you will find
194
<h2>Associating a file extension to a MIME type</h2>
197
You can still do this with the <acronym>UI</acronym>, from the the
198
<cite>Setup→File Extensions</cite> submenu.
202
If you want to do so from the configuration file, enter <kbd>set
203
mime.extension.<var>ext</var> = "<var>type</var>"</kbd>, replacing
204
<var>ext</var> with the appropiate file extension, and <var>type</var>
205
with its MIME type. E.g. you may want to have <samp>set
206
mime.extension.jpg = "image/jpeg"</samp>.
209
<h2>Defining a handler</h2>
212
For each handler you must define three items, specifying in what
213
context the value of the item should be applied. You must enter <kbd>set
214
mime.handler.<var>handler-name</var>.<var>item</var>.<var>context</var>
215
= <var>value</var></kbd>, replacing <var>handler-name</var> with the
216
name for the handler you are defining, <var>item</var> with the item you
217
are defining for this handler, <var>context</var> with the context this
218
item value is to be applied, and <var>value</var> with the value you
219
want to assign to the item. You must do so for each of the available
220
items: <code>program</code>, <code>ask</code> and <code>block</code>.
224
The value for <code>program</code> is a string with the exact command
225
you want to be issued to view the file, placing <kbd>%</kbd> were you
226
would put the file name. The values for <code>ask</code> and
227
<code>block</code> are either 0 (no) or 1 (yes). Available contexts
228
include <code>unix</code> and <code>unix-xwin</code>, which mean UNIX text
229
terminal and X respectively (others can be os2, win32, beos, riscos, ...).
230
The latter does not mean you are running ELinks from X, just that the
231
<code>DISPLAY</code> variable is set so
232
that ELinks may run an X program.
236
To illustrate it, here is an example. Suppose you want to define the
237
<cite>image_viewer</cite> handler which should be used to view images.
238
The configuration file may look like this:
243
set mime.handler.image_viewer.unix.ask = 1
244
set mime.handler.image_viewer.unix-xwin.ask = 0
246
set mime.handler.image_viewer.unix.block = 1
247
set mime.handler.image_viewer.unix-xwin.block = 0
249
set mime.handler.image_viewer.unix.program = "zgv %"
250
set mime.handler.image_viewer.unix-xwin.program = "xli %"
255
In this example the <cite>image_viewer</cite> handler uses the
256
<cite>svgalib</cite> image viewer <cite>zgv</cite> when X is not
257
available, and the X image viewer <cite>xli</cite> when it is.
258
The terminal would be blocked when X is not available and it would not
259
be when it's available. Finally, ELinks would ask for confirmation
260
before using the handler only with X not available.
263
<h2>Associating a MIME type to a handler</h2>
266
Just enter <kbd>set mime.type.<var>class</var>.<var>name</var> =
267
"<var>handler</var>"</kbd>, replacing <var>class</var> with the class
268
for the mime type, <var>name</var> with the specific name within that
269
class, and <var>handler</var> with the name for the handler you want to
270
assign to the MIME type. E.g. you may want to have <samp>set
271
mime.type.image.jpeg = "image_viewer"</samp>.
276
<tt>$Id: mime.html,v 1.4 2002/11/26 23:14:52 pasky Exp $</tt>