~ubuntu-branches/ubuntu/feisty/elinks/feisty-updates

« back to all changes in this revision

Viewing changes to doc/mime.html

  • Committer: Bazaar Package Importer
  • Author(s): Peter Gervai
  • Date: 2004-01-21 22:13:45 UTC
  • Revision ID: james.westby@ubuntu.com-20040121221345-ju33hai1yhhqt6kn
Tags: upstream-0.9.1
Import upstream version 0.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="ISO-8859-1"?>
 
2
 
 
3
<!DOCTYPE html
 
4
  PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
5
 
 
6
 
 
7
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
8
 
 
9
 
 
10
<head>
 
11
 
 
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" />
 
17
 
 
18
<title>Basic instructions for MIME configuration</title>
 
19
 
 
20
</head>
 
21
 
 
22
 
 
23
<body>
 
24
 
 
25
<h1>Introduction</h1>
 
26
 
 
27
<h2>What's all this about?</h2>
 
28
 
 
29
<p>
 
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.
 
38
</p>
 
39
 
 
40
<p>
 
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.
 
47
</p>
 
48
 
 
49
<h2>Acknowledgements</h2>
 
50
 
 
51
<p>
 
52
This document was written by <cite>Jos�&nbsp;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
 
57
welcomed.
 
58
</p>
 
59
 
 
60
<p>
 
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.
 
67
</p>
 
68
 
 
69
<h1>Handling MIME types, the ELinks way</h1>
 
70
 
 
71
<h2>What are MIME types and why may you want to use them?</h2>
 
72
 
 
73
<p>
 
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.
 
80
</p>
 
81
 
 
82
<p>
 
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.
 
89
</p>
 
90
 
 
91
<h2>Associating files to MIME types</h2>
 
92
 
 
93
<p>
 
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
 
99
guess it.
 
100
</p>
 
101
 
 
102
<p>
 
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.
 
106
</p>
 
107
 
 
108
<h2>Managing a given MIME type</h2>
 
109
 
 
110
<p>
 
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.
 
116
</p>
 
117
 
 
118
<h3>Binding it to a handler</h3>
 
119
 
 
120
<p>
 
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.
 
124
</p>
 
125
 
 
126
<p>
 
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.
 
133
</p>
 
134
 
 
135
<h2>Specifying the details for a handler</h2>
 
136
 
 
137
<p>
 
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.
 
141
</p>
 
142
 
 
143
<p>
 
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).
 
151
</p>
 
152
 
 
153
<h3>Attaching a program to it</h3>
 
154
 
 
155
<p>
 
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>.
 
158
</p>
 
159
 
 
160
<h3>Choosing whether you want confirmation before applying it</h3>
 
161
 
 
162
<p>
 
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.
 
173
</p>
 
174
 
 
175
<h3>Choosing whether to block the terminal</h3>
 
176
 
 
177
<p>
 
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.
 
181
</p>
 
182
 
 
183
<h1>Setting up <cite>elinks.conf</cite></h1>
 
184
 
 
185
<p>
 
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
 
191
how.
 
192
</p>
 
193
 
 
194
<h2>Associating a file extension to a MIME type</h2>
 
195
 
 
196
<p>
 
197
You can still do this with the <acronym>UI</acronym>, from the the
 
198
<cite>Setup&rarr;File&nbsp;Extensions</cite> submenu.
 
199
</p>
 
200
 
 
201
<p>
 
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>.
 
207
</p>
 
208
 
 
209
<h2>Defining a handler</h2>
 
210
 
 
211
<p>
 
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>.
 
221
</p>
 
222
 
 
223
<p>
 
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.
 
233
</p>
 
234
 
 
235
<p>
 
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:
 
239
</p>
 
240
 
 
241
<pre>
 
242
<code>
 
243
set mime.handler.image_viewer.unix.ask = 1
 
244
set mime.handler.image_viewer.unix-xwin.ask = 0
 
245
 
 
246
set mime.handler.image_viewer.unix.block = 1
 
247
set mime.handler.image_viewer.unix-xwin.block = 0
 
248
 
 
249
set mime.handler.image_viewer.unix.program = "zgv %"
 
250
set mime.handler.image_viewer.unix-xwin.program = "xli %"
 
251
</code>
 
252
</pre>
 
253
 
 
254
<p>
 
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.
 
261
</p>
 
262
 
 
263
<h2>Associating a MIME type to a handler</h2>
 
264
 
 
265
<p>
 
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>.
 
272
</p>
 
273
 
 
274
 
 
275
<p>
 
276
<tt>$Id: mime.html,v 1.4 2002/11/26 23:14:52 pasky Exp $</tt>
 
277
</p>
 
278
 
 
279
</body>
 
280
 
 
281
 
 
282
</html>