<!DOCTYPE book  PUBLIC "-//OASIS//DTD DocBook V4.1//EN"
 [ <!entity index SYSTEM "index.sgml">
<!entity bibliography SYSTEM "myLinuxTips.bib.sgml">
<!entity appendix SYSTEM "appendix.sgml">
<!ENTITY % output.print.png "IGNORE">
<!ENTITY % output.print.pdf "IGNORE">
<!ENTITY % output.print.eps "IGNORE">
<!ENTITY % output.print.bmp "IGNORE">

<!ENTITY file1001 "ck-style.css">
<!ENTITY graph1001 "viman">
<!ENTITY graph1002 "netscape">
<!ENTITY graph1003 "netscape">
<!ENTITY graph1004 "vcss">
<!ENTITY graph1005 "page-area-model">
<!ENTITY graph1006 "Squidlogo2">
<!ENTITY graph1007 "lyx"> ]>

<book lang="en"><!-- DocBook file was created by LyX 1.2
  See http://www.lyx.org/ for more information -->
<bookinfo><title>Linux Tips and Tricks</title><keywordset>
<keyword>Linux</keyword>
<keyword>tips</keyword>
<keyword>tricks</keyword>
<keyword>vi</keyword>
<keyword>syntax highlighting</keyword>
<keyword>smartcase</keyword>
<keyword>incsearch</keyword>
<keyword>scrolloff</keyword>
<keyword>wildmode</keyword>
<keyword>multiple search</keyword>
<keyword>vimrc</keyword>
<keyword>Netscape</keyword>
<keyword>windows resizing</keyword>
<keyword>windows positioning</keyword>
<keyword>roaming profiles</keyword>
<keyword>CSS</keyword>
<keyword>DocBook</keyword>
<keyword>SGML</keyword>
<keyword>transparent proxying</keyword>
<keyword>squid</keyword>
<keyword>html2png</keyword>
<keyword>html2ps</keyword>
<keyword>ps2png</keyword>
<keyword>image capture</keyword>
<keyword>ABAB</keyword>
<keyword>ABAP syntax highlighting</keyword>
<keyword>netscape bugs</keyword>
<keyword>restore HTML sessions</keyword>
<keyword>recover sessions</keyword>
<keyword>remote control</keyword>
<keyword>openURL</keyword>
<keyword>LyX</keyword>
<keyword>cross-reference</keyword>
<keyword>index generation</keyword>
<keyword>automatic index</keyword>
<keyword>mass insertion</keyword>
</keywordset>
<revhistory>
<revision>
     <revnumber>0.09</revnumber>
     <date>18.02..2004</date>
     <authorinitials>CK</authorinitials>
     <revremark>Automatic Index generation with LyX</revremark>
   </revision>
<revision>
     <revnumber>0.08</revnumber>
     <date>22.01..2004</date>
     <authorinitials>CK</authorinitials>
     <revremark>Chapter on LyX, cross-references, Licence section, Appendix</revremark>
   </revision>
<revision>
     <revnumber>0.07</revnumber>
     <date>25.12..2003</date>
     <authorinitials>CK</authorinitials>
     <revremark>Discussion of the CSS for DocBook code, Credits</revremark>
   </revision>
<revision>
     <revnumber>0.06</revnumber>
     <date>01.08..2003</date>
     <authorinitials>CK</authorinitials>
     <revremark>HTML to PNG. ABAP/4 syntax highlighting</revremark>
   </revision>
<revision>
     <revnumber>0.05</revnumber>
     <date>01.07..2003</date>
     <authorinitials>CK</authorinitials>
     <revremark>More on roaming profiles.</revremark>
   </revision>
<revision>
     <revnumber>0.04</revnumber>
     <date>04.06..2003</date>
     <authorinitials>CK</authorinitials>
     <revremark>Added chapter on transparent proxying. Added Index. Alt text and captions for images</revremark>
   </revision>
<revision>
     <revnumber>0.03</revnumber>
     <date>29.05.2003</date>
     <authorinitials>CK</authorinitials>
     <revremark>Added chapters on Netscape and CSS for DocBook.</revremark>
   </revision>
   <revision>
     <revnumber>0.02</revnumber>
     <date>18.12.2002</date>
     <authorinitials>CK</authorinitials>
     <revremark>first version</revremark>
   </revision>
</revhistory>
<author> <firstname>Chris</firstname><surname>Karakas</surname></author><abstract><para>This is a collection of various tips and tricks around Linux. Since they don't fit anywhere else, they are presented here in a more or less loose form. We start on how to get an attractive <ulink url="http://www.vim.org">vi</ulink> by using syntax highlighting (even for ABAP/4®), <ulink url="http://www.vim.org/script.php?script_id=479">multiple search</ulink> and the <ulink url="http://www.linuxjournal.com/article.php?sid=3805">smartcase, incsearch, scrolloff, wildmode</ulink> options in the <emphasis><ulink url="./vimrc">vimrc</ulink></emphasis> file. We continue on various configuration subjects regarding Netscape®, like positioning and sizing of windows, capturing a whole HTML page in an image, or roaming profiles. Further on, I present a CSS file for HTML documents that were created automatically from DocBook SGML. Also a chapter on transparent proxying with <ulink url="http://www.squid-cache.org/">Squid</ulink> and one on <ulink url="http://www.lyx.org">LyX</ulink>, covering mass insertion of cross-references and automatic index generation.</para></abstract></bookinfo>
<chapter id="introduction"><title>Introduction</title><sect1 id="disclaimer"><title>Disclaimer</title><para>No liability for the contents of this documents can be accepted. Use the concepts, examples and other content at your own risk. As this is a new edition of this document, there may be errors and inaccuracies, that may of course be damaging to your system. Proceed with caution, and although this is highly unlikely, the author does not take any responsibility for that. If it breaks, you keep both pieces.</para><para>All copyrights are held by their respective owners, unless specifically noted otherwise. Use of a term in this document should not be regarded as affecting the validity of any trademark or service mark.</para><para>Naming of particular products or brands should not be seen as endorsements.</para></sect1>
<sect1 id="formats"><title>Formats</title><para>This document is available in the following formats:</para><itemizedlist><listitem><para><ulink url="./book1.html">HTML (HyperText Markup Language)</ulink><indexterm><primary>HTML (HyperText Markup Language)]</primary></indexterm>, for viewing with <ulink url="http://www.anybrowser.org/campaign/">any browser</ulink></para></listitem><listitem><para><ulink url="./myLinuxTips.html">HTML (HyperText Markup Language)</ulink><indexterm><primary>HTML (HyperText Markup Language)</primary></indexterm>, one big HTML file</para></listitem><listitem><para><ulink url="./myLinuxTips.txt">TXT (ASCII Text)</ulink><indexterm><primary>TXT (ASCII Text)]</primary></indexterm>, for any text editor</para></listitem><listitem><para><ulink url="./myLinuxTips.rtf">RTF (Rich Text Format)</ulink><indexterm><primary>RTF (Rich Text Format)]</primary></indexterm>, for Word</para></listitem><listitem><para><ulink url="./myLinuxTips.pdf">PDF (Portable Document Format)</ulink><indexterm><primary>PDF (Portable Document Format)]</primary></indexterm>, for printing (and viewing with Acrobat Reader)</para></listitem><listitem><para><ulink url="./myLinuxTips.ps.gz">PS.GZ (Compressed Postscript)</ulink><indexterm><primary>PS.GZ (Compressed Postscript)]</primary></indexterm>, for printing (and viewing with Ghostview)</para></listitem><listitem><para><ulink url="./myLinuxTips.sgml">SGML (Standard Generalized Markup Language)</ulink><indexterm><primary>SGML (Standard Generalized Markup Language)]</primary></indexterm> (with the <ulink url="appendix.sgml">Appendix</ulink>), for creating all the above formats yourself</para></listitem><listitem><para><ulink url="./myLinuxTips.lyx">LYX (LaTeX frontend LyX)</ulink><indexterm><primary>LYX (LaTeX frontend LyX)]</primary></indexterm> (with the <ulink url="appendix.lyx">Appendix</ulink>), for typesetting it with LaTeX</para></listitem></itemizedlist><important>
<title>IMPORTANT: Downloads for offline reading!</title>
<para>
If you want to download the HTML or RTF formats for offline reading, you will need to download the images as well - PNG for HTML and BMP for RTF, including the callouts! To save you the hassle, I have compiled the following zipped tar archives for offline reading:
</para>
</important>
<itemizedlist><listitem><para><ulink url="./myLinuxTips-html.tar.gz"> TAR.GZ (Compressed TAR Archive), many HTML files with images</ulink></para></listitem><listitem><para><ulink url="./myLinuxTips-onehtml.tar.gz"> TAR.GZ (Compressed TAR Archive), one big  HTML file with images</ulink></para></listitem><listitem><para><ulink url="./myLinuxTips-sgml.tar.gz"> TAR.GZ (Compressed TAR Archive), SGML file with images</ulink></para></listitem><listitem><para><ulink url="./myLinuxTips-rtf.tar.gz"> TAR.GZ (Compressed TAR Archive), RTF file with images</ulink></para></listitem></itemizedlist><para>A tarball containing all the above is also available:</para><itemizedlist><listitem><para><ulink url="./myLinuxTips.tar.gz"> TAR.GZ (Compressed TAR Archive), All files</ulink></para></listitem></itemizedlist></sect1>
<sect1 id="licence"><title>Licence</title><para>Copyright &copy; 2003, 2004 <ulink url="http://www.karakas-online.de">Chris Karakas</ulink>. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License<indexterm><primary> GNU Free Documentation License</primary></indexterm>, Version 1.2 or any later version published by the Free Software Foundation<indexterm><primary>Free Software Foundation</primary></indexterm>; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license can be found in <xref linkend="GNU-Free-Documenation-Licence">, as well as at the <ulink url="http://www.gnu.org/copyleft/fdl.html">GNU Free Documentation License</ulink>
<citation role="REFDB">GNU0</citation>
 .</para></sect1>
<sect1 id="availability-of-sources"><title>Availability of sources and support</title><para>See <xref linkend="formats"> for the modifiable sources of this document. </para><important>
<title>Pose your questions in my Linux Forum!</title>
<para>
If you have questions, patches, suggestions,  problems or (better) solutions, come to <ulink url="http://www.karakas-online.de/forum/linux.html">my Linux Forum</ulink> and post them there. I look forward to your feedback!
</para>
</important>
</sect1>
<sect1 id="Credits"><title>Credits</title><para><xref linkend="fig-page-area-model"> is taken from W3C's working draft <ulink url="http://www.w3.org/TR/2003/WD-css3-page-20031218/">CSS3 Paged Media Module</ulink>, version of Dec. 18th 2003 and is Copyright &copy; 2003 <ulink url="http://www.w3.org">W3C</ulink> (<ulink url="http://www.lcs.mit.edu">MIT</ulink>, <ulink url="http://www.ercim.org">ERCIM</ulink>, <ulink url="http://www.keio.ac.jp">Keio</ulink>), All Rights Reserved. Used with permission according to <ulink url="http://www.w3.org/Consortium/Legal/copyright-documents">W3C document licence</ulink>.</para><para>The <ulink url="http://www.karakas-online.de/myLinuxTips/css-for-docbook.html">CSS file for DocBook</ulink> that is used in this document , <ulink url="ck-style.css">ck-style.css</ulink> uses <ulink url="http://www.matterform.com/qbullets/index.php">QBullets</ulink> in links. Thanks to Matterform Media for providing QBullets for free. If you plan to use them on your website, please observe the <ulink url="http://www.matterform.com/qbullets/usage.html">QBullets usage terms</ulink>.</para></sect1>
</chapter>
<chapter id="vi"><title>Sexy vi</title><para>
<figure id="fig-vi-vs-emacs">
   <title>
   vi vs. emacs
   </title>
   <mediaobject>
      <![ %output.print.png; [
      <imageobject>
         <imagedata fileref="./images/&graph1001;.png" format="PNG">
      </imageobject>
      ]]>
      <![ %output.print.pdf; [
      <imageobject>
         <imagedata fileref="&graph1001;.pdf" format="PDF" scale="100">
      </imageobject>
      ]]>
      <![ %output.print.eps; [
      <imageobject>
         <imagedata fileref="&graph1001;.eps" format="EPS">
      </imageobject>
       ]]>
      <![ %output.print.bmp; [
      <imageobject>
         <imagedata fileref="&graph1001;.bmp" format="BMP">
      </imageobject>
       ]]>
      <textobject>
         <phrase>vi vs. emacs</phrase>
      </textobject>
      <caption>
         <para>vi vs. emacs</para>
      </caption>
   </mediaobject>
</figure>
</para><para>You can lend your <ulink url="http://www.vim.org">vi</ulink><indexterm><primary>vi</primary></indexterm> an extra sex appeal, just by tweaking some values in its configuration file, <emphasis><ulink url="./vimrc">vimrc</ulink><indexterm><primary>vimrc</primary></indexterm></emphasis> (usually located in <emphasis>/etc</emphasis>):</para><itemizedlist><listitem><para>Syntax highlighting<indexterm><primary>highlighting</primary></indexterm>: </para><screen><![CDATA[" enable syntax highlighting
]]><![CDATA[so ${VIMRUNTIME}/syntax/syntax.vim
]]></screen></listitem><listitem><para>Having enabled syntax highlighting, you will often find yourself trying hard to find out what is written on your screen, unless you are working on the console, or the background colour of your X terminal<indexterm><primary>X terminal</primary></indexterm> is black. Mine is grey (or red, for root), which makes the colourful text hard to read. In this case, you need to start vi in an xterm<indexterm><primary>xterm</primary></indexterm> with black as the background colour. Save the following one-liner in <emphasis>/usr/local/bin/bt</emphasis> (bt for Black Terminal...):</para><screen><![CDATA[xterm -bg black -fg white -geometry 120x60 -e vi $1 &
]]></screen><para>make it executable (chmod ugo+x /usr/local/bin/bt) and from now on, just do</para><screen><![CDATA[bt filename
]]></screen></listitem><listitem><para>Set <ulink url="http://www.vim.org/script.php?script_id=479">multiple search</ulink>: MultipleSearch<indexterm><primary>MultipleSearch</primary></indexterm> allows you to have the results of multiple searches displayed on the screen at the same time. Each search highlights its results in a different color, and all searches are displayed at once. After the maximum number of colors is used, the script starts over with the first color. The command syntax is </para><screen><![CDATA[:Search <pattern1>
]]></screen><para>which will highlight all occurrences of &lt;pattern1&gt; in the current buffer. A subsequent </para><screen><![CDATA[:Search <pattern2>
]]></screen><para>will highlight all occurrences of &lt;pattern2&gt; in the current buffer<indexterm><primary>buffer</primary></indexterm>, retaining the highlighting of &lt;pattern1&gt; as well. &lt;pattern1&gt; and &lt;pattern2&gt; are any search pattern like you would use in a normal /&lt;pattern&gt; search. </para><para>You enable Multiple Search with the following lines in the <emphasis><ulink url="./vimrc">vimrc</ulink></emphasis> file:</para><screen><![CDATA[" enable MultipleSearch functionality (extra module)
]]><![CDATA[so ${VIMRUNTIME}/MultipleSearch.vim
]]></screen><para>Further,  you will have to copy the <ulink url="http://www.vim.org/script.php?script_id=479">MultipleSearch.vim</ulink>  file from the scripts collection at <ulink url="http://www.vim.org">www.vim.org</ulink> into your local plugins<indexterm><primary>plugins (vi)</primary></indexterm> directory (/usr/share/vim/current on my system) and restart vi.</para></listitem><listitem><para>Set <ulink url="http://www.linuxjournal.com/article.php?sid=3805">smartcase, incsearch, scrolloff, wildmode</ulink> </para><warning>
<title>Be careful:</title> 
<para> 
No spaces between the options! See "longest,list" below - if you write "longest, list" you will get $ signs at the end of every line and the tabs will be shown as &quot;^I &quot;!
</para> 
</warning>
<screen><![CDATA[set smartcase
]]><![CDATA[set incsearch
]]><![CDATA[set scrolloff=2
]]><![CDATA[set wildmode=longest,list
]]></screen></listitem><listitem><para>For those of you who are working in the <ulink url="http://www.sap.com">SAP</ulink>® field: there is an <ulink url="http://help.sap.com/saphelp_46c/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm">ABAP/4</ulink>® syntax highlighting script fo vi available at <ulink url="http://vim.sourceforge.net/scripts/script.php?script_id=359">vim's Sourceforge page</ulink>. Copy the <ulink url="http://vim.sourceforge.net/scripts/download_script.php?src_id=2085">abap.vim</ulink> file into your local syntax plugins<indexterm><primary>plugins (vi), syntax</primary></indexterm> directory (/usr/share/vim/current/syntax on my system) and restart vi. Happy ABAP/4® hacking!</para></listitem></itemizedlist><para>For more vi tips see <ulink url="http://www.vim.org/tips/index.php">http://www.vim.org/tips/index.php</ulink>.</para></chapter>
<chapter id="netscape"><title>Netscape</title><sect1 id="positioning-and-sizing"><title>Positioning and sizing of windows for Netscape Communicator</title><para>
<figure id="fig-netscape">
   <title>
   Netscape.
   </title>
   <mediaobject>
      <![ %output.print.png; [
      <imageobject>
         <imagedata fileref="./images/&graph1002;.png" format="PNG">
      </imageobject>
      ]]>
      <![ %output.print.pdf; [
      <imageobject>
         <imagedata fileref="&graph1002;.pdf" format="PDF" scale="100">
      </imageobject>
      ]]>
      <![ %output.print.eps; [
      <imageobject>
         <imagedata fileref="&graph1002;.eps" format="EPS">
      </imageobject>
       ]]>
      <![ %output.print.bmp; [
      <imageobject>
         <imagedata fileref="&graph1002;.bmp" format="BMP">
      </imageobject>
       ]]>
      <textobject>
         <phrase>Netscape.</phrase>
      </textobject>
      <caption>
         <para>Netscape.</para>
      </caption>
   </mediaobject>
</figure>
</para><para>To customise the size and position of various windows of Netscape<indexterm><primary>Netscape</primary></indexterm> Communicator®<indexterm><primary>Communicator</primary></indexterm> 4.x, you can use the following geometry names. Add all or a part of the following values to the file ~/.Xdefaults in your home directory.</para><screen><![CDATA[! Navigator main window (browser)
]]><![CDATA[Netscape.Navigator.geometry:
]]><![CDATA[! Mail- and news-reader window
]]><![CDATA[Netscape.MailThread.geometry:
]]><![CDATA[! Netscape message centre (list of mail and news folders)
]]><![CDATA[Netscape.MailFolder.geometry:
]]><![CDATA[! Netscape HTML editor
]]><![CDATA[Netscape.Editor.geometry:
]]><![CDATA[! Composition window (writing of new email's and/or news)
]]><![CDATA[Netscape.Composition.geometry:
]]><![CDATA[! Address book
]]><![CDATA[Netscape.AddressBook.geometry:
]]><![CDATA[! Window to edit the bookmarks
]]><![CDATA[Netscape.bookmarks.geometry:
]]></screen><para>The above rules are case sensitive. If you want the above rules to be global for all users, you can add them to the file /path/to/netscape/Netscape.ad. Then change to the directory /usr/X11/lib/X11/app-defaults and add a link to this file here:</para><screen><![CDATA[ln -s /path/to/netscape/Netscape.ad Netscape
]]></screen><para>The above link makes sure, that it points always to the correct version of Netscape.ad, especially if you ever install a new version of Netscpe Communicator.</para><para>(I have adapted this tip from <ulink url="http://members.aon.at/theofilu/ninst.html">http://members.aon.at/theofilu/ninst.html</ulink>)</para></sect1>
<sect1 id="netscape-roaming-profiles"><title>Netscape roaming profiles</title><para>
<figure id="fig-netscape-2">
   <title>
   Netscape.
   </title>
   <mediaobject>
      <![ %output.print.png; [
      <imageobject>
         <imagedata fileref="./images/&graph1003;.png" format="PNG">
      </imageobject>
      ]]>
      <![ %output.print.pdf; [
      <imageobject>
         <imagedata fileref="&graph1003;.pdf" format="PDF" scale="100">
      </imageobject>
      ]]>
      <![ %output.print.eps; [
      <imageobject>
         <imagedata fileref="&graph1003;.eps" format="EPS">
      </imageobject>
       ]]>
      <![ %output.print.bmp; [
      <imageobject>
         <imagedata fileref="&graph1003;.bmp" format="BMP">
      </imageobject>
       ]]>
      <textobject>
         <phrase>Netscape.</phrase>
      </textobject>
      <caption>
         <para>Netscape.</para>
      </caption>
   </mediaobject>
</figure>
</para><para>In Apache's document root (/usr/local/httpd/htdocs), create a directory that will hold the roaming<indexterm><primary>roaming profile</primary></indexterm> data, set the owner and group to the user and group ID of the Apache<indexterm><primary>Apache</primary></indexterm> server and the permissions to 700 (read, write and change permissions only for the owner):</para><screen><![CDATA[mkdir roaming
]]><![CDATA[chown wwwrun.nogroup roaming
]]><![CDATA[chmod 700 roaming
]]></screen><para>In Apache's configuration file, /etc/httpd/httpd.conf, insert the following:</para><screen><![CDATA[#
]]><![CDATA[# roaming profiles
]]><![CDATA[#
]]><![CDATA[PerlModule Apache::Roaming
]]><![CDATA[<Location /roaming>
]]><![CDATA[PerlHandler Apache::Roaming->handler
]]><![CDATA[PerlTypeHandler Apache::Roaming->handler_type
]]><![CDATA[AuthType Basic
]]><![CDATA[AuthName "Roaming User"
]]><![CDATA[AuthUserFile /etc/httpd/passwd
]]><![CDATA[require valid-user
]]><![CDATA[PerlSetVar BaseDir /usr/local/httpd/htdocs/roaming
]]><![CDATA[</Location>
]]></screen><para>This assumes that you want to store the roaming profiles<indexterm><primary>profile, roaming</primary></indexterm> in the directory /roaming under the web server's document root (/usr/local/httpd/htdocs) and that you want to store the passwords in /etc/httpd/passwd. You may choose whatever name you like for the roaming directory and whatever location and name you wish for the password file. The roaming directory has to be located under the document root though. Change the locations above aproppriately to fit your situation.</para><para>You create the password file when you create the first password using the htpasswd<indexterm><primary>htpasswd</primary></indexterm> command:</para><screen><![CDATA[htpasswd -cm /etc/httpd/passwd <username> 
]]></screen><para>The -c flag creates a new file, and is necessary the first time you run htpasswd. The -m flag is optional, and forces MD5 encryption of the password. Omit the -c flag for subsequent users:</para><screen><![CDATA[htpasswd -m /etc/httpd/passwd <username>
]]></screen><para>Next, install the <ulink url="http://www.perl.com/CPAN-local/modules/by-module/Apache/Apache-Roaming-0.1003.tar.gz">Apache::Roaming Perl module</ulink>. Download it from the <ulink url="http://www.perl.com/CPAN-local/modules/by-module/Apache/">CPAN Apache module directory</ulink>. Extract the files from the tar.gz archive:</para><screen><![CDATA[tar -xzvf Apache-Roaming-0.1003.tar.gz
]]></screen><para>change to the newly created directory (in our case Apache-Roaming-0.1003) and type</para><screen><![CDATA[perl Makefile.PL
]]><![CDATA[make
]]><![CDATA[make install
]]></screen><para>Answer the questions about the path of the Apache server (in my case /usr/sbin/httpd), the path of the httpd.conf file (in my case /etc/httpd/httpd.conf), the user and group ID of Apache (wwwrun and nogroup respectively, in my case - you will find those in the web server configuration file /etc/httpd/httpd.conf, as the values to the variables User and Group resp.). You may also configure the Apache::Roaming::LiPrefs module, assigning the default values you wish to preferences.</para><para>At last, you need to enable roaming in Netscape: </para><itemizedlist><listitem><para>Start your communicator and open Preferences/Roaming User. Click the &quot;Enable Roaming Access for this profile&quot; checkbox. </para></listitem><listitem><para>Open Preferences/Roaming User/Server Information. Click the &quot;HTTP Server&quot; checkbox and enter the Base URL http://yourwebserver/roaming/user (in my case http://bacchus/roaming/chris).</para></listitem><listitem><para>Restart Netscape.</para></listitem></itemizedlist><tip> <title>Tip:</title> 
<para> 
If you are having problems, check that your Apache loads the Perl module. In SuSE Linux systems, this is controlled by the extra files /etc/httpd/suse_loadmodule.conf and /etc/httpd/suse_addmodule.conf. If you recompiled Apache after an initial installation, the subsequent SuSEconfig call will not overwrite these two files. Instead it will write its own version in files with the ending .SuSEconfig (e.g. /etc/httpd/suse_addmodule.conf.SuSEconfig). You are strongly advised to check the contents of those two files and copy them to the original ones:
</para>
<screen><![CDATA[
cp /etc/httpd/suse_loadmodule.conf.SuSEconfig /etc/httpd/suse_loadmodule.conf
cp /etc/httpd/suse_addmodule.conf.SuSEconfig /etc/httpd/suse_addmodule.conf
]]>
</screen>
<para>
The reason is that you will be probably missing a line like
</para>
<screen><![CDATA[
LoadModule perl_module /usr/lib/apache/libperl.so
]]>
</screen>
<para>
in your suse_loadmodule.conf file (and a similar one in suse_addmodule.conf).
</para> </tip>
</sect1>
<sect1 id="html2png"><title>How to save a HTML page as an image: from HTML to PNG</title><para>Netscape 4.x is an old browser. It has many bugs (see, for example, <ulink url="http://www.evolt.org/article/Don_t_let_Netscape_cramp_your_styles/17/3268/">Netscape CSS bugs</ulink>, <ulink url="http://www.wowwebdesigns.com/power_guides/worst_nightmare.php">Netscape 4.x: Web Designer's worst nightmare</ulink>, or <ulink url="http://soothfast.topcities.com/writ_netscape4x.html">why Netscape 4.x sucks</ulink>) but I still use it, mainly because I am reluctunt to &quot;change a running system&quot; and I always see a difficulty as a challenge to resolve it. This was the case with the well-known problem of Netscape 4.x not printing the background colours of tables. Now, what if you have a nice table, whose groups of lines are coloured to convey some information about those groups? </para><para>Forget printing<indexterm><primary>printing</primary></indexterm> in colour - it will not work. A solution is to capture<indexterm><primary>capture, screen</primary></indexterm> the screen as an image and print that image instead. This works as long as the table is small enough to fit on the screen - I had one that didn't. </para><para>Since I couldn't find an image capture<indexterm><primary>capture, tool</primary></indexterm> tool for Linux that will let you scroll<indexterm><primary>scroll</primary></indexterm> down and capture the whole page, I had to find some &quot;HTML to PNG<indexterm><primary>HTML to PNG</primary></indexterm>&quot; (or HTML to JPEG, GIF or whatever) tool. </para><para>In fact, there is one: <ulink url="http://marginalhacks.com/Hacks/html2jpg/">html2jpg</ulink>. It converts HTML pages to images (gif, jpg, png, ps, etc..). It is a Perl script<indexterm><primary>Perl script</primary></indexterm>, ran from the command line. It requires</para><itemizedlist><listitem><para><ulink url="http://www.perl.com">Perl</ulink>,</para></listitem><listitem><para>convert<indexterm><primary>convert</primary></indexterm>, from <ulink url="http://www.ImageMagick.org/">ImageMagick</ulink>,</para></listitem><listitem><para>xwininfo<indexterm><primary>xwininfo</primary></indexterm>, xwd<indexterm><primary>xwd</primary></indexterm> (standard Linux utilities),</para></listitem><listitem><para><ulink url="http.//www.opera.com">Opera</ulink><indexterm><primary>Opera</primary></indexterm>, otherwise you have to modify the find_window() function in the script.</para></listitem></itemizedlist><para>The script is clearly written, but the last requirement poses a real problem - which I preferred not to solve. </para><sect2 id="html2ps"><title>Enter html2ps...</title><para>In fact, there is a much simpler way to accomplish the same thing: a pipe of html2ps<indexterm><primary>html2ps</primary></indexterm> and ps2png!</para><para><ulink url="http://www.tdb.uu.se/~jan/html2ps.html">html2ps</ulink> is contained in every distribution. It offers a variety of features:</para><itemizedlist><listitem><para>Many possibilities to control the appearance, mostly done using configuration files.</para></listitem><listitem><para>Support for processing multiple documents, also automatically by recursively following links.</para></listitem><listitem><para>A table of contents can be generated, either from the links in a document, or automatically from document headings.</para></listitem><listitem><para>Configurable page headers/footers, that for example can contain document title, URL, page number, current heading, and date.</para></listitem><listitem><para>When converting the PostScript® document to PDF - using some other program such as version 5.0 or later of Aladdin Ghostscript®<indexterm><primary>Ghostscript</primary></indexterm>, or Adobe AcrobatDistiller®<indexterm><primary>Distiller</primary></indexterm> - the original hyperlinks in the HTML documents will be retained in the PDF document.</para></listitem><listitem><para>Automatic hyphenation and text justification can be selected.</para></listitem></itemizedlist></sect2>
<sect2 id="ps2png"><title>...and ps2png!</title><para>ps2png<indexterm><primary>ps2png</primary></indexterm> can be implemented in many ways, a simple one is the following short script<footnote><para>Commented code is not needed, but is &quot;nice to have&quot; just in case.</para></footnote> (taken from <ulink url="http://stud3.tuwien.ac.at/~e9902644/work/invocation.html">http://stud3.tuwien.ac.at/~e9902644/work/invocation.html</ulink>:</para><screen><![CDATA[#!/bin/sh
]]><![CDATA[# /usr/local/bin/ps2png
]]><![CDATA[for i in "$@"
]]><![CDATA[do
]]><![CDATA[        i_new=`dirname $i`/`basename $i .ps`.png
]]><![CDATA[        echo convert $i to $i_new
]]><![CDATA[        gs -dNOPAUSE -sDEVICE=png256 -sOutputFile=$i_new -q -dBATCH $i
]]><![CDATA[#        convert -rotate 90 $i_new $i_new
]]><![CDATA[#        convert -resize 50% $i_new $i_new
]]><![CDATA[done
]]><![CDATA[#convert -transparent white test.png test.png
]]></screen><para>Now, to output both pages in one (-2 option), switch to landscape mode<footnote><para>Remember that the original HTML page was too large for a screen dump without scrolling.</para></footnote> (-L) and dump the contents in a PNG image with 256 colours (in order to be &quot;<ulink url="http://www.lynda.com/hex.html">web safe</ulink>), we only need to type:</para><screen><![CDATA[html2ps -2 -L http://somesite.com/somepage.html > somepage.ps
]]><![CDATA[ps2png somepage.ps
]]></screen><para>You can write a html2png script containing just these two lines - and you are done! <inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_smile.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_smile.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_smile.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_smile.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject> </para>
</sect2>
</sect1>
<sect1 id="restore-HTML-sessions"><title>Restore HTML sessions</title><para>As said above, Netscape 4.x is old. And every so often it encounters some code it cannot handle , even worse: it crashes. This will of course happen exactly when I will have 20+ HTML sessions<indexterm><primary>HTML sessions</primary></indexterm> open, tracking all hyperlink branches of some original interesting page I have long forgotten. <inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_frown.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_frown.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_frown.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_frown.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject></para>
<para>It is a pain to restore all lost HTML sessions<indexterm><primary>sessions</primary></indexterm> after a browser crash. Wouldn't it be nice if we could keep track of all visited URLs in a text file, then, after restarting the browser, just type a command that will open them all, each one in its own browser window? In fact, this is what the following script does:</para><screen><![CDATA[#! /bin/bash
]]><![CDATA[# Remote invocation of my favorite URLs in netscape.
]]><![CDATA[#
]]><![CDATA[# Motivation: netscape sucks too often. I _had_ to find
]]><![CDATA[# a way to load my lovely URLs without much typing.
]]><![CDATA[# Now, just typing "netscape-recover" will do the trick.
]]><![CDATA[#
]]><![CDATA[# Enter all the URLs you wish to recover in URLS_Netscape,
]]><![CDATA[# one URL per line.
]]><![CDATA[
]]><![CDATA[URLS_Netscape="URLS_Netscape"
]]><![CDATA[for url in `cat $URLS_Netscape`; do
]]><![CDATA[  Netscape -remote "openURL($url,new-window)"
]]><![CDATA[done
]]></screen><para>The remote<indexterm><primary>remote, invocation</primary></indexterm> invocation<indexterm><primary>invocation, remote</primary></indexterm> of Netscape is described in detail in <ulink url="http://wp.netscape.com/newsref/std/x-remote.html">Remote Control of UNIX Netscape</ulink>, by Jamie Zawinski.</para></sect1>
</chapter>
<chapter id="CSS-for-DocBook"><title>CSS for DocBook SGML</title><para>
<figure id="fig-valid-CSS">
   <title>
   Valid CSS.
   </title>
   <mediaobject>
      <![ %output.print.png; [
      <imageobject>
         <imagedata fileref="./images/&graph1004;.png" format="PNG">
      </imageobject>
      ]]>
      <![ %output.print.pdf; [
      <imageobject>
         <imagedata fileref="&graph1004;.pdf" format="PDF" scale="100">
      </imageobject>
      ]]>
      <![ %output.print.eps; [
      <imageobject>
         <imagedata fileref="&graph1004;.eps" format="EPS">
      </imageobject>
       ]]>
      <![ %output.print.bmp; [
      <imageobject>
         <imagedata fileref="&graph1004;.bmp" format="BMP">
      </imageobject>
       ]]>
      <textobject>
         <phrase>Valid CSS.</phrase>
      </textobject>
      <caption>
         <para>Valid CSS.</para>
      </caption>
   </mediaobject>
</figure>
</para><para>You have written your document using <ulink url="http://docbook.org/tdg/en/html/docbook.html">DocBook</ulink><indexterm><primary>DocBook</primary></indexterm> SGML<indexterm><primary>SGML</primary></indexterm>. You have used all the available tools to transform (&quot;render&quot;) your document to various formats, including, of course, HTML. But now you realize that your document looks somewhat &quot;boring&quot;. It's HTML is well-written - no question. But you just can't avoid the feeling that there is still a lot that can be done to produce a more visually appealing vesrion. In fact, you need a Cascading Style Sheet<indexterm><primary>Cascading Style Sheet</primary></indexterm>, a CSS.</para><para>&quot;So what's the problem?&quot; - you might say. &quot;I'll grab the first CSS<indexterm><primary>CSS</primary></indexterm> I can find and I will use it&quot;. Well, the problem is, that you will not be able to. The documents created by Jade &amp;Co. use some classes that you will not find in every CSS file - so you will have to find the right formatting yourself.</para><para>Searching the Internet did not bring many results, see for example the <ulink url="http://docbook.org/wiki/moin.cgi/DocBookCssStylesheets">List of DocBook CSS</ulink> at the DocBook Wiki.</para><para>Those of you who would like to experiment with a CSS that works with DocBook right away may copy the following one which I use for my own documents, including the one you are reading:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1001;" format="linespecific"><![CDATA[
]]></screen><para>It incorporates important elements from the <ulink url="http://newbiedoc.sourceforge.net/nd-style.css">Newbiedoc CSS file for DocBook</ulink> and Mark Pilgrim's influential <ulink url="http://diveintoaccessibility.org">dive into Accessibility</ulink>. It is an integral part of my method of <ulink url="http://www.karakas-online.de/mySGML/">document processing with LyX and SGML</ulink>, which I use for all the documents on <ulink url="http://www.karakas-online.de">my Homepage</ulink>.</para><para>You can control the navigation header style with</para><screen><![CDATA[DIV.NAVHEADER {
]]><![CDATA[        color: #000000;
]]><![CDATA[        background-color: #EFEFF8;
]]><![CDATA[        padding: 5px;
]]><![CDATA[        margin-bottom: 10px;
]]><![CDATA[        width: 100%;
]]><![CDATA[        border: thin solid #a0a0d0;
]]><![CDATA[}
]]></screen><para>and the navigation footer style with</para><screen><![CDATA[DIV.NAVFOOTER {
]]><![CDATA[        color: #000000;
]]><![CDATA[        background-color: #EFEFF8;
]]><![CDATA[        padding: 5px;
]]><![CDATA[        margin-top: 10px;
]]><![CDATA[        width: 100%;
]]><![CDATA[        border: thin solid #a0a0d0;
]]><![CDATA[}
]]></screen><para>The concepts of margin, border and padding follow a page model that is described in W3C's working draft <ulink url="http://www.w3.org/TR/2003/WD-css3-page-20031218/">CSS3 Paged Media Module</ulink>, version of Dec. 18th 2003. <xref linkend="fig-page-area-model">, taken from this document (Copyright &copy; 2003 <ulink url="http://www.w3.org">W3C</ulink> (<ulink url="http://www.lcs.mit.edu">MIT</ulink>, <ulink url="http://www.ercim.org">ERCIM</ulink>, <ulink url="http://www.keio.ac.jp">Keio</ulink>), All Rights Reserved) illustrates the various geometric notions of this page model. Note that the <ulink url="http://www.w3.org/TR/2003/WD-xsl11-20031217/#area_model">XSL area model</ulink> is deliberately very similar to the CSS one.</para><para>
<figure id="fig-page-area-model">
   <title>
   CSS page area model.
   </title>
   <mediaobject>
      <![ %output.print.png; [
      <imageobject>
         <imagedata fileref="./images/&graph1005;.png" format="PNG">
      </imageobject>
      ]]>
      <![ %output.print.pdf; [
      <imageobject>
         <imagedata fileref="&graph1005;.pdf" format="PDF" scale="100">
      </imageobject>
      ]]>
      <![ %output.print.eps; [
      <imageobject>
         <imagedata fileref="&graph1005;.eps" format="EPS">
      </imageobject>
       ]]>
      <![ %output.print.bmp; [
      <imageobject>
         <imagedata fileref="&graph1005;.bmp" format="BMP">
      </imageobject>
       ]]>
      <textobject>
         <phrase>CSS page area model.</phrase>
      </textobject>
      <caption>
         <para>CSS page area model.</para>
      </caption>
   </mediaobject>
</figure>
</para><para>If you output admonitions as tables, rather than graphics (see <ulink url="http://www.karakas-online.de/mySGML/admonitions.html">Admonitions</ulink>), then you can control their style with a code like the following (shown here for the &quot;Important&quot; admonition):</para><screen><![CDATA[TABLE.IMPORTANT
]]><![CDATA[{
]]><![CDATA[        font-style:italic;
]]><![CDATA[        border: solid 2px #ff0000;
]]><![CDATA[        width: 70%;
]]><![CDATA[        margin-left: 15%;
]]><![CDATA[}
]]></screen><para>Screen output (code) is controlled by </para><screen><![CDATA[PRE.SCREEN
]]><![CDATA[{
]]><![CDATA[        font-family:monospace;
]]><![CDATA[        white-space: pre;
]]><![CDATA[        width: 100%;
]]><![CDATA[        background-color: #ffffcc;
]]><![CDATA[        border:solid;
]]><![CDATA[        color: #000000;
]]><![CDATA[        border-color: #009999;
]]><![CDATA[        border-left: solid #009999 2px;
]]><![CDATA[        border-right: solid #009999 2px;
]]><![CDATA[        border-top: solid #009999 2px;
]]><![CDATA[        border-bottom: solid #009999 2px;
]]><![CDATA[        padding-left: 15pt;
]]><![CDATA[}
]]></screen><para>while examples and the Table of Contents by</para><screen><![CDATA[DIV.EXAMPLE,DIV.TOC {
]]><![CDATA[        border: thin dotted #70AAE5;
]]><![CDATA[        padding-left: 10px;
]]><![CDATA[        padding-right: 10px;
]]><![CDATA[        color: #000000;
]]><![CDATA[        background-color: #EFF8F8;
]]><![CDATA[}
]]><![CDATA[DIV.TOC {
]]><![CDATA[        margin-left: 20px;
]]><![CDATA[        margin-right: 20px;
]]><![CDATA[        width: 95%;
]]><![CDATA[}
]]></screen><para>An &quot;external link&quot; icon to absolute links (i.e. links starting with &quot;http:&quot;) is added through</para><screen><![CDATA[/* Add an external-link icon to absolute links */
]]><![CDATA[a[href^="http:"] {
]]><![CDATA[        background: url(images/remote.gif) right center no-repeat;
]]><![CDATA[        padding-right: 12px;
]]><![CDATA[}
]]><![CDATA[a[href^="http:"]:hover {
]]><![CDATA[        background: url(images/remote_a.gif) right center no-repeat;
]]><![CDATA[}
]]></screen><para>However, this alone would put the icon on every link with an absolute URL, including links pointing to the local domain. This is corrected by</para><screen><![CDATA[/* ...but not to absolute links in this domain... */
]]><![CDATA[a[href^="http://www.karakas-online.de"] {
]]><![CDATA[        background: transparent;
]]><![CDATA[        padding-right: 0px;
]]><![CDATA[}
]]><![CDATA[a[href^="http://www.karakas-online.de"]:hover {
]]><![CDATA[        background: transparent;
]]><![CDATA[}
]]></screen><para>&quot;External link&quot; icons tell you what a link will do before you click on it. There are icons specifically designed for this purpose, like <ulink url="http://www.matterform.com/index.php?page=/download/menu.php">QBullets</ulink>. QBullets are a collection of elegant, animated icons that attach to hypertext links to indicate their function. You can <ulink url="http://www.matterform.com/download/files/qbullets.zip">download Qbullets</ulink> for free from matterform media.</para><para>To use this idea for footnotes, the name attribute is used as a selector:</para><screen><![CDATA[/* Add a note icon to footnote links */
]]><![CDATA[a[href^="#FTN"] {
]]><![CDATA[        background: url(images/qbullet-note.gif) right center no-repeat;
]]><![CDATA[        padding-right: 12px;
]]><![CDATA[}
]]><![CDATA[a[href^="#FTN"]:hover {
]]><![CDATA[        background: url(images/qbullet-note_a.gif) right center no-repeat;
]]><![CDATA[}
]]></screen><para>This will select all links whose href attribute starts with &quot;#FTN&quot; and append a note icon to them, which will even show an animated page curl upon passing with the mouse over it (hover). The links whose href attribute starts with &quot;#FTN&quot; look like </para><screen><![CDATA[<a name="AEN1175" href="#FTN.AEN1175">[1]</a>
]]></screen><para>and point to a footnote. The footnote itself also contains a link - which points back to the referring text. That link will not be affected by the above selection, since its href attribute does not start with &quot;#FTN&quot; :</para><screen><![CDATA[<a name="FTN.AEN1175" href="explain-runsed-sed-sedscr.html#AEN1175">[1]</a>
]]></screen><para>To display a back icon besides those links, a selector on the name attribute is used:</para><screen><![CDATA[/* ...and a back icon to the backlinks in the footnotes themselves */
]]><![CDATA[a[name^="FTN"] {
]]><![CDATA[        background: url(images/scrollup.gif) right center no-repeat;
]]><![CDATA[        padding-right: 12px;
]]><![CDATA[}
]]><![CDATA[a[name^="FTN"]:hover {
]]><![CDATA[        background: url(images/scrollup_a.gif) right center no-repeat;
]]><![CDATA[}
]]></screen><note>
<title>String matching on attributes is a CSS3 feature!</title>
<para>
To be able to use string matching on attributes, as we have done in the QBullets examples above, the user must view our document with a browser that supports this CSS3 feature. If you are wondering whether  your browser belongs to this cutting edge category (Mozilla 1.5 does, tip, tip <inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_wink.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_wink.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_wink.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_wink.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject>), you can do this <ulink url="http://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/html/index.html">W3C browser test on CSS selectors</ulink> and test for "Substring matching attribute selector".
</para>
</note>
<para>To get an icon in place of the usual bullet in itemized lists, the list-style property is used for the UL tag:</para><screen><![CDATA[UL {
]]><![CDATA[        margin-bottom: 10px;
]]><![CDATA[        list-style: url(images/tux-bullet.png) square;
]]><![CDATA[    }
]]></screen><para>Last but not least, a cross-browser relative font setting can be achieved with </para><screen><![CDATA[P {
]]><![CDATA[        font-size: 12px;
]]><![CDATA[}
]]><![CDATA[/*/*/A{}
]]><![CDATA[BODY P {
]]><![CDATA[        font-size: x-small;
]]><![CDATA[        voice-family: "\"}\"";
]]><![CDATA[        voice-family: inherit;
]]><![CDATA[        font-size: small;
]]><![CDATA[}
]]><![CDATA[HTML>BODY P {
]]><![CDATA[        font-size: small;
]]><![CDATA[}
]]><![CDATA[/* */
]]></screen><para>which is indeed too complicated to explain here in all its depth. See <ulink url="http://diveintoaccessibility.org/day_26_using_relative_font_sizes.html">Dive into Accessibility, day 26</ulink> for this.</para></chapter>
<chapter id="transparent-proxying"><title>Transparent proxying with Squid</title><para>
<figure id="Squid-logo">
   <title>
   Squid.
   </title>
   <mediaobject>
      <![ %output.print.png; [
      <imageobject>
         <imagedata fileref="./images/&graph1006;.png" format="PNG">
      </imageobject>
      ]]>
      <![ %output.print.pdf; [
      <imageobject>
         <imagedata fileref="&graph1006;.pdf" format="PDF" scale="100">
      </imageobject>
      ]]>
      <![ %output.print.eps; [
      <imageobject>
         <imagedata fileref="&graph1006;.eps" format="EPS">
      </imageobject>
       ]]>
      <![ %output.print.bmp; [
      <imageobject>
         <imagedata fileref="&graph1006;.bmp" format="BMP">
      </imageobject>
       ]]>
      <textobject>
         <phrase>Squid.</phrase>
      </textobject>
      <caption>
         <para>Squid.</para>
      </caption>
   </mediaobject>
</figure>
</para><para>I assume you have already set up a <ulink url="http://www.squid-cache.org/">Squid</ulink> proxy and a firewall and that both work correctly. You may now wish to force all your users to use the Squid proxy for surfing the WWW. This is what &quot;transparent proxying&quot; is about: your users surf, even without having defined a proxy in their browser settings, but they in fact all use the transparent proxy and don't notice it.</para><para>To enable transparent proxying<indexterm><primary>proxying, transparent</primary></indexterm> with Squid<indexterm><primary>Squid</primary></indexterm>, insert the following lines in the configuration file (squid.conf, usually in /etc) at the aproppriate place (search the configuration file for the respective keywords, httpd_accel_host<indexterm><primary>httpd_accel_host</primary></indexterm>, httpd_accel_with_proxy<indexterm><primary>httpd_accel_with_proxy</primary></indexterm> and httpd_accel_uses_host_header<indexterm><primary>httpd_accel_uses_host_header</primary></indexterm>):</para><screen><![CDATA[httpd_accel_host virtual
]]><![CDATA[httpd_accel_with_proxy on
]]><![CDATA[httpd_accel_uses_host_header on
]]></screen><para>You will also need to accept and redirect<indexterm><primary>redirect</primary></indexterm> the WWW traffic to port 3128 of the Squid proxy:</para><screen><![CDATA[ipchains -A input -p TCP -d 127.0.0.1/32 www -j ACCEPT
]]><![CDATA[ipchains -A input -p TCP -d 192.168.0.0/32 www -j ACCEPT
]]><![CDATA[ipchains -A input -p TCP -d any/0 www -j REDIRECT 3128
]]></screen><para>or, if you use SuSEfirewall2<indexterm><primary>SuSEfirewall2</primary></indexterm></para><screen><![CDATA[FW_REDIRECT_TCP="192.168.0.0/24,0/0,tcp,80,3128"
]]></screen><para>Restart Squid and the firewall. Transparent proxying should be working now. However there are some issues associated with the above settings. You can read about them in the corresponding comments in the squid.conf file.</para><para>For more details, see the <ulink url="http://tldp.org/HOWTO/mini/TransparentProxy.html">Transparent Proxy HOWTO</ulink>.</para></chapter>
<chapter id="LyX"><title>LyX</title><para>
<figure id="lyx-logo">
   <title>
   LyX.
   </title>
   <mediaobject>
      <![ %output.print.png; [
      <imageobject>
         <imagedata fileref="./images/&graph1007;.png" format="PNG">
      </imageobject>
      ]]>
      <![ %output.print.pdf; [
      <imageobject>
         <imagedata fileref="&graph1007;.pdf" format="PDF" scale="100">
      </imageobject>
      ]]>
      <![ %output.print.eps; [
      <imageobject>
         <imagedata fileref="&graph1007;.eps" format="EPS">
      </imageobject>
       ]]>
      <![ %output.print.bmp; [
      <imageobject>
         <imagedata fileref="&graph1007;.bmp" format="BMP">
      </imageobject>
       ]]>
      <textobject>
         <phrase>LyX.</phrase>
      </textobject>
      <caption>
         <para>LyX.</para>
      </caption>
   </mediaobject>
</figure>
</para><para>In case you are wondering what LyX is, here is what <ulink url="http://www.lyx.org">http://www.lyx.org</ulink> says on the subject:</para><blockquote><para>LyX is an advanced open source document processor that encourages an approach to writing based on the structure of your documents, not their appearance. LyX lets you concentrate on writing, leaving details of visual layout to the software.</para><para>LyX runs on many Unix platforms, OS/2, and under Windows/Cygwin (this port requires an X server). It can also run natively on Mac OS X, thanks to the Qt/Mac library.</para><para>LyX produces high quality, professional output -- using LaTeX, an industrial strength typesetting engine, in the background; LyX is far more than a front-end to LaTeX, however. No knowledge of LaTeX is necessary to use LyX, although it will give a user more power.</para><para>LyX is stable and fully featured. It has been used for documents as large as a thesis, or as small as a business letter. Despite its simple GUI interface (available in many languages), it supports tables, figures, and hyperlinked cross-references, and has a best-of-breed math editor.</para></blockquote><sect1 id="LyX-mass-insertion-of-cross-references"><title>Mass insertion of cross-references in LyX</title><para>If you have to add hundreds of cross-references in just one section (e.g. more than 500, as in <ulink url="http://www.karakas-online.de/EN-Book/credits-version-2.0.html">Credits for version 2.0 of the PHP-Nuke HOWTO</ulink>), you will soon notice that, although a single cross-reference is inserted very easily in LyX (just choose Insert-&gt;Cross-reference from the menu, then choose the label of the reference you want), it becomes a real pain if you have to enter hundreds of them.</para><para>My solution to this was to write a script that reads a LyX file and outputs another LyX file that contains references to all labels of the first one. It was then easier to copy the references from the file thus created, paste them in <ulink url="http://www.karakas-online.de/EN-Book/credits-version-2.0.html">Credits for version 2.0 of the PHP-Nuke HOWTO</ulink> and then delete the unneeded ones, than try to insert all cross-references by hand using the LyX menu.</para><para>The following script, call it <ulink url="lyxrefs">lyxrefs</ulink>, will print a LyX file in standard output, containing cross-references to each and every label of the LyX file whose name was passed on the command line as argument:</para><screen><![CDATA[#!/bin/bash
]]><![CDATA[#
]]><![CDATA[
]]><![CDATA[AWK="/usr/bin/awk"
]]><![CDATA[
]]><![CDATA[function preample() {
]]><![CDATA[cat <<-EOF
]]><![CDATA[#LyX 1.2 created this file. For more info see http://www.lyx.org/
]]><![CDATA[\lyxformat 220
]]><![CDATA[\textclass article
]]><![CDATA[\language english
]]><![CDATA[\inputencoding auto
]]><![CDATA[\fontscheme default
]]><![CDATA[\graphics default
]]><![CDATA[\paperfontsize default
]]><![CDATA[\papersize Default
]]><![CDATA[\paperpackage a4
]]><![CDATA[\use_geometry 0
]]><![CDATA[\use_amsmath 0
]]><![CDATA[\use_natbib 0
]]><![CDATA[\use_numerical_citations 0
]]><![CDATA[\paperorientation portrait
]]><![CDATA[\secnumdepth 3
]]><![CDATA[\tocdepth 3
]]><![CDATA[\paragraph_separation indent
]]><![CDATA[\defskip medskip
]]><![CDATA[\quotes_language english
]]><![CDATA[\quotes_times 2
]]><![CDATA[\papercolumns 1
]]><![CDATA[\papersides 1
]]><![CDATA[\paperpagestyle default
]]><![CDATA[EOF
]]><![CDATA[}
]]><![CDATA[
]]><![CDATA[function label() {
]]><![CDATA[n=$1
]]><![CDATA[echo ""
]]><![CDATA[echo "\layout Standard"
]]><![CDATA[echo ""
]]><![CDATA[echo ""
]]><![CDATA[echo "\begin_inset LatexCommand \label{cit:$n}"
]]><![CDATA[echo ""
]]><![CDATA[echo "\end_inset"
]]><![CDATA[}
]]><![CDATA[
]]><![CDATA[preample
]]><![CDATA[
]]><![CDATA[# Output LyX commands for Chapter "All references"
]]><![CDATA[cat <<-EOF
]]><![CDATA[\layout Section
]]><![CDATA[
]]><![CDATA[All references
]]><![CDATA[
]]><![CDATA[EOF
]]><![CDATA[
]]><![CDATA[# Output all references.
]]><![CDATA[$AWK 'BEGIN {FS=" "} /\\begin_inset LatexCommand \\label{/ {gsub("label","ref");
]]><![CDATA[printf("\n%s\n\n%s%s\n\n%s\n","\\layout Standard",
]]><![CDATA["\\begin_inset LatexCommand",$3,"\\end_inset")}' $1 > all-references.tmp
]]><![CDATA[
]]><![CDATA[cat all-references.tmp
]]><![CDATA[rm all-references.tmp
]]><![CDATA[
]]><![CDATA[# Output LyX commands for Chapter "All references"
]]><![CDATA[cat <<-EOF
]]><![CDATA[\layout Section
]]><![CDATA[
]]><![CDATA[All figure references
]]><![CDATA[
]]><![CDATA[EOF
]]><![CDATA[
]]><![CDATA[# Output only the figures.
]]><![CDATA[$AWK 'BEGIN {FS=" "} /\\begin_inset LatexCommand \\label{fig-/ {gsub("label","ref");
]]><![CDATA[printf("\n%s\n\n%s%s\n\n%s\n","\\layout Standard",
]]><![CDATA["\\begin_inset LatexCommand",$3,"\\end_inset")}' $1 > fig-references.tmp
]]><![CDATA[
]]><![CDATA[cat fig-references.tmp
]]><![CDATA[rm fig-references.tmp
]]><![CDATA[
]]><![CDATA[# Output LyX commands for Chapter "All references"
]]><![CDATA[cat <<-EOF
]]><![CDATA[\layout Section
]]><![CDATA[
]]><![CDATA[All table references
]]><![CDATA[
]]><![CDATA[EOF
]]><![CDATA[
]]><![CDATA[# Output only the tables.
]]><![CDATA[$AWK 'BEGIN {FS=" "} /\\begin_inset LatexCommand \\label{tab-/ {gsub("label","ref");
]]><![CDATA[printf("\n%s\n\n%s%s\n\n%s\n","\\layout Standard",
]]><![CDATA["\\begin_inset LatexCommand",$3,"\\end_inset")}' $1 > tab-references.tmp
]]><![CDATA[
]]><![CDATA[cat tab-references.tmp
]]><![CDATA[rm tab-references.tmp
]]><![CDATA[
]]><![CDATA[echo "\the_end"
]]></screen><para>The script will even create three sections, with cross-references to all labels, all figures and all tables respectively. If you named it lyxrefs, you would call it as follows:</para><screen><![CDATA[lyxrefs some-LyX-file.lyx > refs.lyx
]]></screen><para>Then refs.lyx will contain cross-references to all labels of some-LyX-file.lyx. You can open refs.lyx with LyX, copy all or part of the cross-references there and paste them in some-LyX-file.lyx. The cross-references in <ulink url="http://www.karakas-online.de/EN-Book/credits-version-2.0.html">Credits for version 2.0 of the PHP-Nuke HOWTO</ulink> were entered this way.</para></sect1>
<sect1 id="LyX-automatic-Index-generation"><title>Automatic Index generation</title><para>LyX provides an easy way to insert an Index<indexterm><primary>Index</primary></indexterm> entry: from the menu, choose either Insert--&gt;&quot;Index entry of preceding word&quot; (which I personally find easier), or Insert--&gt;&quot;Index entry&quot;, then enter the required word. This method works fine - if you have a small document, with only a few keywords to insert. But what if your document has grown to hundreds of pages, with hundreds (or even thousands) of index entries to insert? See the Index of the <ulink url="http://www.karakas-online.de/EN-Book/">PHP-Nuke HOWTO</ulink> for an example of an Index that cannot be generated manually - unless you want to drive yourself crazy!</para><para>Clearly, for a comprehensive Index of large documents, an automatic<indexterm><primary>automatic</primary></indexterm> procedure is necessary. However, the general problem of automatic Index generation is subject of extensive (and still not conclusive) research and I am not going to address it in its full generality here. For our purposes, even a semi-automatic procedure would be very helpful. To this end, I have created the following 4 scripts:</para><itemizedlist><listitem><para><ulink url="sedscr_list_index_items">sedscr_list_index_items</ulink>: lists all index entries contained in a LyX document.</para></listitem><listitem><para><ulink url="sedscr_delete_index_items">sedscr_delete_index_items</ulink>: deletes all index entries from a LyX document.</para></listitem><listitem><para><ulink url="awkscr_create_index_items">awkscr_create_index_items</ulink>: creates a list of words used in a LyX document. The list can be subsequently edited manually, mostly deleting unwanted or uninteresting words, to yield a list of words that are used in the document and are interesting enough to be part of its Index.</para></listitem><listitem><para><ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink>: uses an externally supplied document containing a list of index entries to insert an index entry in a LyX document for every word appearing in that list.</para></listitem></itemizedlist><para>They can be used in the following semi-automatic Index generation procedure: </para><orderedlist><listitem><para>Optional: create a list of all existing index entries in your document. This is useful not only because you are going to eliminate all index entries from the document in the next step, but also as a backup of the index entries that were currently in use - you might want to reuse them in some later step.</para><para>To create a list of all existing index entries in your document, type:</para><screen><![CDATA[sedscr_list_index_items document.lyx > indexitems
]]></screen><para>The generated indexitems file will contain a list of all index entries in document.lyx, one index entry per line.</para></listitem><listitem><para>Remove all previous index entries from the LyX document. You need this preliminary step because, if you forget to remove already existing index entries, a subsequent run of the <ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink> script may substitute even the existing index terms (those already inside the LyX \index commands) with LyX \index commands. This may or may not happen, depending on the regular expressions used in the current implementation of <ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink>, but it is better to err on the side of caution. Besides, a LyX text cluttered with index entries may still be a breeze to read for a computer, but quite a headache to read for humans.</para><para>To remove all index entries from a LyX document, type:</para><screen><![CDATA[sedscr_delete_index_items document.lyx > document-noindexitems.lyx
]]></screen><para>The generated document-noindexitems.lyx will contain everything from document.lyx - except the index entries.</para></listitem><listitem><para>Create a list of all index entries to be used in the LyX document. This is the most difficult part: as said above, this problem is not trivial. We will thus content ourselves with a list of all <emphasis>words</emphasis> used in the document. Once we have all words, we can still edit the list manually and delete all unwanted entries. This is what makes this procedure <emphasis>semi-automatic</emphasis> and not automatic. The idea is that it is still better having to delete 10000 lines from a 12000 line document, than having to insert 2000 index entries from the LyX Insert menu.</para><para>To create a list of all words used in a LyX document, type:</para><screen><![CDATA[awkscr_create_index_items document.lyx > words
]]></screen><para>There is even some code in <ulink url="awkscr_create_index_items">awkscr_create_index_items</ulink> that checks whether the current word is in some &quot;trivia&quot; list of trivial words and discards it. In such a case, you would call the script with two arguments, as follows:</para><screen><![CDATA[awkscr_create_index_items trivia document.lyx > words
]]></screen><para>However, this part of the code is either too slow, or buggy, so it is commented for the moment (feel free to send corrections or suggestions).</para><para>Once the list of all words of your document is created, all you have to do is open it with a text editor and delete all unwanted words or correct the ones that are in plural or have some punctuation at the end and so on. This is still hard if your document is large, but still a faster alternative than targeting the Insert menu with the mouse 8000 times (I guess each one of my 2000 index entries appears 4 times in my document, which gives me an estimate of 8000 menu selections with the mouse - unfortunately no keyboard bindings were found to work on my system).</para></listitem><listitem><para>Once you have a file, say indexitems, with all words that should appear in the Index of a LyX file, type:</para><screen><![CDATA[awkscr_insert_index_items indexitems - < document-noindexitems.lyx > document-indexitems.lyx
]]></screen><para>to create from document-noindexitems.lyx a document with index entries (document-indexitems.lyx) for all words in indexitems. </para></listitem></orderedlist><para>Some notes on <ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink>'s mode of operation: </para><para>The &quot;-&quot; in the above invocation is important: it forces the awk script to continue reading from standard input, after it has read indexitems. This, together with the code</para><screen><![CDATA[FILENAME == "indexitems" {
]]><![CDATA[        n++
]]><![CDATA[        indexentry[$1] = $1
]]><![CDATA[        next
]]><![CDATA[}
]]></screen><para>in <ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink>, causes the words in indexitems to be imported into the indexentry[] associative array.</para><para>The file separator<indexterm><primary>separator</primary></indexterm> in <ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink> is set to the semicolon &quot;;&quot;, instead of the default, which is space. This makes it possible to enter index entries with more than one words. Accordingly, the <ulink url="awkscr_create_index_items">awkscr_create_index_items</ulink> script appends a semicolon at the end of each word it prints.</para><para><ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink> follows a simple algorithm to insert the index entries at the right places in the document: to insert an index entry, we have to know what <ulink url="http://www.karakas-online.de/mySGML/lyx-environments.html">LyX environment</ulink> we are in. In essence, this means we have to parse the LyX document. Since the \layout commands in the LyX file do NOT have what we would call &quot;closing tags&quot; in other markup<indexterm><primary>markup</primary></indexterm> languages, we cannot tell awk &quot;if you are between the start and the end of the Paragraph environment, do the following&quot;, or anything like that - there is no easy way to find the &quot;end &quot; of an environment, given all the environment nestings<indexterm><primary>nestings</primary></indexterm> that are possible. Luckily, another easy way exists: whenever a \layout command is encountered, we are in the environment specified by that \layout command, so we only need to set a variable, call it layout, accordingly:</para><screen><![CDATA[/\\layout SGML/ { layout = "SGML"; print; next }
]]><![CDATA[/\\layout Chapter/ { layout = "Chapter"; print; next }
]]><![CDATA[/\\layout Section/ { layout = "Section"; print; next }
]]><![CDATA[/\\layout Subsection/ { layout = "Subsection"; print; next }
]]><![CDATA[/\\layout Subsubsection/ { layout = "Subsubsection"; print; next }
]]><![CDATA[/\\layout Standard/ { layout = "Standard"; print; next }
]]><![CDATA[
]]><![CDATA[...and so on
]]></screen><para>Clearly, we should not insert index entries everywhere, e.g. in the &quot;Code&quot; environment. That's why we check if we are in the &quot;Standard&quot;, &quot;Itemize&quot;, &quot;Quotation&quot;, &quot;Description&quot; environment (warning: the way <ulink url="sedscr">sedscr</ulink> works currently, you should not insert index entries in the &quot;Caption&quot; environment) and, if we are (and only then), we substiture every word in the indexentry[] array with the LyX &quot;insert index entry&quot; command:</para><screen><![CDATA[{
]]><![CDATA[        if (layout == "Standard" || layout == "Itemize" || layout == "Quotation" 
]]><![CDATA[|| layout == "Description" ) {
]]><![CDATA[                for (item in indexentry) {
]]><![CDATA[                        if (gsub(item "$", item "\n\\begin_inset LatexCommand 
]]><![CDATA[\\index{" indexentry[item] "}\n\n\\end_inset \n")) { print; next }
]]><![CDATA[                        
]]><![CDATA[                        ...other substitutions here
]]><![CDATA[                }
]]><![CDATA[        }
]]><![CDATA[}
]]></screen><para>Some tips regarding the (necessary) manual editing of the words file, the file output by <ulink url="awkscr_create_index_items">awkscr_create_index_items</ulink> above: </para><itemizedlist><listitem><para>You will see a lot of words (or their declinations) that are not useful. It is one thing to have a lot of words and another to have a set of really useful words and phrases. That's the price we pay for the simplicity of our method.</para></listitem><listitem><para>You may need to supply some extra terms you feel are missing from that file. Feel free to do this, <ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink> does not know how you created the indexitems file you give it. </para></listitem><listitem><para>Keep backups of your word lists from subsequent runs of the scripts. Combine word lists from other projects. No matter how long your word list, only the terms that really appear somewhere, will make it to the Index, so don't worry if your list is too long - given enough computing time, that is.</para></listitem><listitem><para>Take care to delete everything in your word list that looks like a regular expression with metacharacters - because it will be interpreted as such, with unpredictable results (unless you really know what you are doing). I once had &quot;.*&quot; on one line and I forgot to delete it. I then wondered how come that my document was full of index entries to &quot;.*&quot; while the text was almost gone! See <ulink url="http://www.karakas-online.de/EN-Book/regular-expressions.html">regular expressions</ulink>, for a brief introduction to regular expressions.</para></listitem><listitem><para>Take out any &quot;:&quot;, &quot;;&quot;, &quot;?&quot; from the end of the words, as well as enclosing double quotes. Those characters are already taken care of when it comes to inserting the entries, i.e. the indexentries file should contain only the &quot;pure&quot; words, without any punctuation signs. </para></listitem><listitem><para>Don't leave in &quot;config&quot; if your LyX file contains &quot;config.php&quot;. If you do, the latter will look ugly in the LyX editor, as it will contain an index entry for &quot;config&quot; just in the middle of it. This will not affect the rendered formats, however.</para></listitem><listitem><para>Don't leave in words that might form parts of a LyX command. I once left &quot;Enumerate&quot; in my word list. The resulting LyX file contained an index entry for &quot;Enumerate&quot; in front of every item in every enumeration list! Clearly, the awk script &quot;sees&quot; the LyX commands in the file that are invisible to you. </para></listitem></itemizedlist></sect1>
</chapter>



&appendix;
&bibliography;
&index;
</book>
