Blame tools/djvuserve.1

Packit df99a1
.\" Copyright (c) 2001-2003 Leon Bottou, Yann Le Cun, Patrick Haffner,
Packit df99a1
.\" Copyright (c) 2001 AT&T Corp., and Lizardtech, Inc.
Packit df99a1
.\"
Packit df99a1
.\" This is free documentation; you can redistribute it and/or
Packit df99a1
.\" modify it under the terms of the GNU General Public License as
Packit df99a1
.\" published by the Free Software Foundation; either version 2 of
Packit df99a1
.\" the License, or (at your option) any later version.
Packit df99a1
.\"
Packit df99a1
.\" The GNU General Public License's references to "object code"
Packit df99a1
.\" and "executables" are to be interpreted as the output of any
Packit df99a1
.\" document formatting or typesetting system, including
Packit df99a1
.\" intermediate and printed output.
Packit df99a1
.\"
Packit df99a1
.\" This manual is distributed in the hope that it will be useful,
Packit df99a1
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit df99a1
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit df99a1
.\" GNU General Public License for more details.
Packit df99a1
.\"
Packit df99a1
.\" You should have received a copy of the GNU General Public
Packit df99a1
.\" License along with this manual. Otherwise check the web site
Packit df99a1
.\" of the Free Software Foundation at http://www.fsf.org.
Packit df99a1
.TH DJVUSERVE 1 "01/22/2002" "DjVuLibre-3.5" "DjVuLibre-3.5"
Packit df99a1
.SH NAME
Packit df99a1
djvuserve \- Generate indirect DjVu documents on the fly.
Packit df99a1
Packit df99a1
.SH DESCRIPTION
Packit df99a1
Program 
Packit df99a1
.B djvuserve 
Packit df99a1
is a 
Packit df99a1
.SM CGI
Packit df99a1
program that can be executed by a 
Packit df99a1
.SM HTTP 
Packit df99a1
server for serving DjVu documents.
Packit df99a1
This program is able to convert a bundled multi-page document
Packit df99a1
into an indirect document on the fly.  
Packit df99a1
Packit df99a1
.SH USING DJVUSERVE
Packit df99a1
Program
Packit df99a1
.B djvuserve
Packit df99a1
must first be installed as a 
Packit df99a1
.SM CGI
Packit df99a1
program for your web server.
Packit df99a1
There are several ways to achieve this.   The Apache web server, 
Packit df99a1
for instance, often defines a specific directory for
Packit df99a1
.SM CGI 
Packit df99a1
programs using the 
Packit df99a1
.B ScriptAlias
Packit df99a1
directive.
Packit df99a1
Assume that the file
Packit df99a1
.B httpd.conf
Packit df99a1
contains the following line:
Packit df99a1
.IP "" 3
Packit df99a1
.BI "ScriptAlias /cgi\(enbin/ " """/var/www/cgi\(enbin"""
Packit df99a1
.PP
Packit df99a1
It is then sufficient to create a small executable shell script 
Packit df99a1
.IB /var/www/cgi\(enbin/ djvuserve
Packit df99a1
containing the following lines:
Packit df99a1
.IP "" 3
Packit df99a1
.B #!/bin/sh
Packit df99a1
.br
Packit df99a1
.BI "exec " "/full/path/to/" "djvuserve"
Packit df99a1
.PP
Packit df99a1
Suppose that a large bundled multi-page DjVu document
Packit df99a1
is available at the following
Packit df99a1
.SM URL.
Packit df99a1
.IP "" 3
Packit df99a1
.IB http "" ://server/dir/doc.djvu
Packit df99a1
.PP
Packit df99a1
The
Packit df99a1
.SM CGI 
Packit df99a1
program
Packit df99a1
.B djvuserve
Packit df99a1
lets you access this same document 
Packit df99a1
as an indirect multi-page DjVu document
Packit df99a1
using the following 
Packit df99a1
.SM URL.
Packit df99a1
.IP "" 3
Packit df99a1
.IB http "" ://server /cgi\(enbin/djvuserve/ dir/doc.djvu /index.djvu
Packit df99a1
.PP
Packit df99a1
Serving indirect multi-page DjVu documents provides
Packit df99a1
for efficiently browsing large document without
Packit df99a1
transferring unnecessary pages over the network.
Packit df99a1
See 
Packit df99a1
.BR djvu(1)
Packit df99a1
for more information.
Packit df99a1
.PP
Packit df99a1
Furthermore 
Packit df99a1
.B djvuserve 
Packit df99a1
searches certain keywords among the
Packit df99a1
.SM CGI 
Packit df99a1
arguments of the 
Packit df99a1
.SM URL.
Packit df99a1
The keyword
Packit df99a1
.B bundled
Packit df99a1
forces serving a bundled document using
Packit df99a1
.IP "" 3
Packit df99a1
.IB http "" ://server /cgi\(enbin/djvuserve/ dir/doc.djvu ?bundled
Packit df99a1
.PP
Packit df99a1
The keyword
Packit df99a1
.B download
Packit df99a1
inserts a content disposition 
Packit df99a1
.SM HTTP
Packit df99a1
header that suggests to display a save dialog
Packit df99a1
instead of displaying the document.
Packit df99a1
.IP "" 3
Packit df99a1
.IB http "" ://server /cgi\(enbin/djvuserve/ dir/doc.djvu ?download
Packit df99a1
.PP
Packit df99a1
Packit df99a1
.SH USING DJVUSERVE AS A HANDLER
Packit df99a1
Packit df99a1
The Apache web server provides a way to automatically execute
Packit df99a1
.B djvuserve
Packit df99a1
for all DjVu documents.
Packit df99a1
This can be achieved using the following
Packit df99a1
directives in either the Apache configuration file
Packit df99a1
or the 
Packit df99a1
.BR .htaccess
Packit df99a1
files.
Packit df99a1
.IP "" 3
Packit df99a1
.B Action djvu-server /cgi\(enbin/djvuserve/
Packit df99a1
.br
Packit df99a1
.B AddHandler djvu-server .djvu
Packit df99a1
.PP
Packit df99a1
Apache then executes program
Packit df99a1
.B djvuserve
Packit df99a1
for serving all DjVu files. 
Packit df99a1
Providing the 
Packit df99a1
.SM URL
Packit df99a1
of DjVu file serves this DjVu file as usual,
Packit df99a1
except that bundled multipage documents are converted
Packit df99a1
to indirect documents on the fly.
Packit df99a1
This convenience comes at the expense
Packit df99a1
of the computational cost of executing
Packit df99a1
.B djvuserve
Packit df99a1
whenever a DjVu file is requested.
Packit df99a1
Packit df99a1
.SH TECHNICAL DETAILS
Packit df99a1
Packit df99a1
Program
Packit df99a1
.B djvuserve
Packit df99a1
provides a mean to directly access any component
Packit df99a1
of a bundled multi-page DjVu document can be accessed using an extended 
Packit df99a1
.SM URL.
Packit df99a1
Suppose that the component file representing page 1
Packit df99a1
is named
Packit df99a1
.BR p0001.djvu .
Packit df99a1
The following 
Packit df99a1
.SM URL
Packit df99a1
provides a direct access to this page:
Packit df99a1
.IP "" 3
Packit df99a1
.IB http "" ://server /cgi\(enbin/djvuserve/ dir/doc.djvu /p0001.djvu
Packit df99a1
.PP
Packit df99a1
It is preferred however to access individual pages using the 
Packit df99a1
.B CGI
Packit df99a1
style arguments described in 
Packit df99a1
.BR nsdejavu (1),
Packit df99a1
as in the following 
Packit df99a1
.SM URL.
Packit df99a1
.IP "" 3
Packit df99a1
.IB http "" ://server /cgi\(enbin/djvuserve/ dir/doc.djvu ?djvuopts&page=12
Packit df99a1
.PP
Packit df99a1
The special component file name
Packit df99a1
.B index.djvu
Packit df99a1
is recognized as a request for the index of the corresponding
Packit df99a1
indirect multi-page document.  In fact, when you access a bundled
Packit df99a1
document using 
Packit df99a1
.BR djvuserve ,
Packit df99a1
the browser gets redirected to the following 
Packit df99a1
.SM URL:
Packit df99a1
.IP "" 3
Packit df99a1
.IB http "" ://server /cgi\(enbin/djvuserve/ dir/doc.djvu /index.djvu
Packit df99a1
.PP
Packit df99a1
and then behaves as if the bundled file was a directory containing 
Packit df99a1
the various component files of an equivalent indirect document.
Packit df99a1
Packit df99a1
.SH ACCESS CONTROL
Packit df99a1
Packit df99a1
Program
Packit df99a1
.BR djvuserve ,
Packit df99a1
like many
Packit df99a1
.SM CGI
Packit df99a1
programs, 
Packit df99a1
bypasses a number of access protections established in a web server.
Packit df99a1
Assume for instance that your web site contains DjVu files protected by a
Packit df99a1
password.  
Packit df99a1
Program
Packit df99a1
.B djvuserve
Packit df99a1
knows nothing about this protection and will happily serve
Packit df99a1
any DjVu file associated with a valid
Packit df99a1
.SM URL.
Packit df99a1
Packit df99a1
Access control with 
Packit df99a1
.B djvuserve 
Packit df99a1
can be implemented by first remembering that the web server 
Packit df99a1
always executes program 
Packit df99a1
.B djvuserve
Packit df99a1
via shell script
Packit df99a1
.IB /var/www/cgi\(enbin/ djvuserve.
Packit df99a1
Packit df99a1
This script can decide to execute the real program
Packit df99a1
.B djvuserve
Packit df99a1
on the basis of the target filename available in 
Packit df99a1
the environment variable
Packit df99a1
.SM PATH_TRANSLATED.  
Packit df99a1
Packit df99a1
There can be several such scripts providing access to various 
Packit df99a1
collections of DjVu files.  Each of these scripts can be 
Packit df99a1
password protected using the usual methods supported by
Packit df99a1
your web server.
Packit df99a1
Packit df99a1
.SH KNOWN BUGS
Packit df99a1
Packit df99a1
Hyperlinks specified using a relative 
Packit df99a1
.SM URL 
Packit df99a1
may not work with 
Packit df99a1
.BR djvuserve.  
Packit df99a1
These 
Packit df99a1
.SM URLs 
Packit df99a1
are relative to the 
Packit df99a1
.SM URL 
Packit df99a1
of the DjVu document. Yet 
Packit df99a1
.BR djvuserve
Packit df99a1
changes the apparent document 
Packit df99a1
.SM URL
Packit df99a1
.IB http://server/dir/doc.djvu
Packit df99a1
into the more complicated 
Packit df99a1
.SM URL
Packit df99a1
.IB http://server /cgi\(enbin/djvuserve/ dir/doc.djvu /index.djvu.
Packit df99a1
The extra components change the interpretation of relative 
Packit df99a1
.SM URLs.
Packit df99a1
Packit df99a1
.SH CREDITS
Packit df99a1
This program was written by Leon Bottou <leonb@users.sourceforge.com>.
Packit df99a1
Packit df99a1
.SH SEE ALSO
Packit df99a1
.BR djvu (1),
Packit df99a1
.BR djvmcvt (1),
Packit df99a1
.BR nsdejavu (1)
Packit df99a1