Software: Apache/2.0.54 (Fedora). PHP/5.0.4 uname -a: Linux mina-info.me 2.6.17-1.2142_FC4smp #1 SMP Tue Jul 11 22:57:02 EDT 2006 i686 uid=48(apache) gid=48(apache) groups=48(apache) Safe-mode: OFF (not secure) /usr/share/doc/elinks-0.10.3/manual-0.82-en/ drwxr-xr-x |
Viewing file: Select action/file-type: File: links-configure-extns.html, Node: File Extensions, Content-Types ..., Next: Other Configuration Options, Prev: Colour, Up: Configuring Links 2.4 File Extensions, Content-Types and Associations[Version 0.82]This section describes how Links handles content-types, and the appropriate use of file extensions and associations. For a quick and simple solution, see the the examples in the sections "Passing Files to External Applications" [3.3] and "Installing and Configuring WWW Plug-ins" [3.2]. Page Contents
2.4.1 General DefinitionsThese general definitions will help in understanding the explanations and reasoning of the following sections. File ExtensionsA suffix preceded by a dot separator appended to a filename, which can be used to identify the format of the file. Examples are: .html and .html ... HyperText Markup Language format .ps ... PostScript document text .jpg ... JPEG image data .png ... PNG image data Content-TypesA definition of a format type derived from a file extension code. Examples are: HyperText Markup Language ... text/html PostScript text ... application/postscript JPEG image data ... image/jpeg PNG image data ... image/png AssociationsA formatted entry in a database or file which is readable by some browsing programme (like Links), which associates a local application with a content-type. Examples for Links (in the Links.cfg file), could include: association "Images Console" "image/jpeg" "zgv %" 5 1 association "Postscript Documents" "application/postscript" "gv %" 2 1 These examples associate the content-type image/jpeg with the programme "zgv", and the content-type application/postscript with the programme "gv". 2.4.2 Links and content-type handlingAt a general level, each file request Links makes with a http://, ftp://, or file:// request should at some stage pass through a process that provides a content-type definition for the requested file. HTTP requestsFor HTTP, content-type definition occurs on the server side, so Links parses the HTTP header (returned prepended to the requested file) and uses that content-type value for the current file.
FTP and local file requestsFor FTP and local file requests two processes take place to find definitions for content-types: 1. Links checks the filename for either of the suffixes .htm and .html. If the filename contains one of these extensions, the content-type is defined as "text/html". 2. Links will check the list of extension entries from the Links.cfg file, and will accept any valid content-type definitions. If Links does not find any content-type definition for the current requested file, the file will be "displayed" as plain text, even if it a image or other kind of binary file. It therefore makes sense to set up file extensions for any content-types you regularly invoke through Links while browsing your file systems.
The above example will define for any FTP or local file requests, that filenames ending with .ps, .ai, or .eps belong to content-type "application/postscript". SummaryWhen making an HTTP request to a web server, the web server provides the content-type definition for Links in the HTTP header. When making a FTP or local file request, Links needs a local set of definitions to have been set up in the form of extension entries in the Links.cfg for any extensions except .html and .htm. HTTP requests and associations1. The final part of content-handling is a "destination application", i.e. an association entry in the Links.cfg file. 2. In cases of the text/html content-type, Links handles the rendering and display of this type by itself. For any other text types requested by HTTP, Links will render and display the file. 3. For all other content-type requests, an external application ("association") is required. FTP and local file requests, and associations1. For the text/html content-type, Links will render and display the file, as expected. (You will have to set up an extension entry for HTML files not ending in .htm or .html, or rename those files to end in the latter.) 2. For other text files requested from FTP or local files, you can alter the behaviour of Links by setting up a content-type and an association, so for example, you can get a pager programme to handle the display and rendering of non-html text types. 3. If any other content-types have been defined with an extension entry, you can associate a programme with that content-type. This works for HTTP requests as well, so you only have to do it once. 2.4.3 Setting up file extensionsAs the above discussion demonstrated, file extensions are used to deliver content-type definitions to Links for files returned from FTP and local file requests. While it is advisable to stick to the formal definitions given by MIME type specifications, it is not a compulsory requirement. You can quite easily invent your own content-types for your own usage (see the example in [3.3.3]). When adding one or two content-type definitions to Links, the menu system provides a convenient and easy method. 1. Go to Menu --> Setup --> File extensions --> Add, (or press <ESC>-s-e-a). 2. Enter the "extension(s)" for one content type. 3. Enter the content-type, in the form image/blobby. 4. Confirm the creation of the entry by pressing return or clicking on "[OK]". 5. If you want to set up an association, follow the next sections' instructions. If not, save the changes now by pressing <ESC>-s-s ("Save options"). Alternatively, you can directly edit your Links.cfg file, where extensions take the following form, including the quote marks: extension "img" "image/image" ^^^^^^^^^ ^^^ ^^^^^^^^^^^ (1) (2) (3) These, respectively, represent:
There is a file in the appendix of this manual which might prove to be useful for the purpose of editing the Links.cfg file. "101 Extensions and MIME-types" [A.2] contains more than 100 extensions and their content-types in a Links-compatible format. Just cut and paste or grep(1) the entries without the commented lines to your Links.cfg file. When you are finished, save the changes to the file and restart Links. 2.4.4 Setting up associationsAssociation entries in Links establish a relationship between a content-type and an application external to Links; for example, an image viewer. Included in each entry is a command entry which is used to invoke a programme. For associations which will be used for HTTP requests, you need to stick to the formal definitions of content-types given in generally used MIME type lists, otherwise they will not work. For local and FTP file requests, you have a little more freedom because you can define your own content-types by using file extensions. An important exception in Links, is that is cannot deal with compound file suffixes as is commonly found with gzipped file extensions (e.g. filename.tar.gz). The reason is that when Links generates the tempfile name, it only preserves the characters including and after the last dot separator. For example, the filename "postscript-gzipped.ps.gz" will be converted to something like links01322aaa.gz, so although it is easy to identify that this is a gzipped file, the "I am a postscript file" information is stripped away. To set up an association between one or more content-types and an application using the menu system, 1. Go to Menu --> Setup --> Association --> Add, (or press <ESC>-s-a-a. 2. Enter a generic label description like Image Display in X-Windows. 3. Enter the content-type(s) to be handled by the associated programme. More than one content-type can be listed separated by commas in the form image/blobby,image/wobbly,image/blurred 4. Enter the associated application name with any command options, in the form where "%" is expanded to the /tmp filename that Links generates. 5. Choose a combination of the checkboxes: [X] Run on terminal [X] Run in X-Window [X] Ask before opening to control how Links will behave in relation to the associated application. (See the table below, [2.4.5] for Links' behaviour with every possible combination.) 6. Press [OK] to confirm. 7. Save the changes now by pressing <ESC>-s-s ("Save options"). You can also directly edit your Links.cfg file to produce an association entry, which are written in the following form. association "Images Console" "image/image,image/blobby" "progname -option1 -option2 %" num num ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^ (1) (2) (3) (4) (5) These, respectively, represent:
When you are finished, save the changes to the file and restart Links. Prior to setting up an "association" entry, it is probably wise to test how your command really works. Take the whole of the command (marked as (4), above) and replace the Links expansion character with a real filename of the appropriate content type, and run it from a command line prompt. Do note that if an application runs in the terminal window that you invoke it from, Links will be pushed into the background when the application is invoked as a Links association. 2.4.5 Associations and flagsLinks permits some measure of control over its behaviour when handling the invocation of associated applications, by using flags. The flags for association entries show up in the menu system (Setup--> Association --> Add) as a combination of three checked / unchecked boxes, while in the Links.cfg file, you will find the flags as two digits at the end of each entry, for example: association "jpg" "image/jpeg" "xv %" 2 1 ^^^ This table shows all eight legal flags and checkbox combinations (2^3) and the associated behaviour. (Note: the second digit of the flag entry refers to the operating system: 1 = Unix, 2 = OS/2, 3 = MS Win32.)
Copyright (C) 2000 Cliff Cunnington, <cliff@ccnet.demon.nl> Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. |
:: Command execute :: | |
--[ c99shell v. 1.0 pre-release build #16 powered by Captain Crunch Security Team | http://ccteam.ru | Generation time: 0.0032 ]-- |