% latex generated by the script '/home/project-web/bumble/cgi-bin/text2latex.cgi' % with help from the sed script 'text2latex.sed' % query string: 'books/linux-web/linux-web-book' % sFileName= 'linux-web-book' % sDirName = 'books/linux-web' % sName = '' --> % latex by http://bumble.sourceforge.net/scripts/text2latex.sed % this script is a work in progress \documentclass[11pt]{article} \usepackage[hmargin=2cm, vmargin=2cm]{geometry} \usepackage{url} \usepackage{hyperref} \begin{document} \\&\\& Web Development using Linux ------------------------------ This book seeks to provide recipes for developing web sites using the Linux operating system, with an emphasis on command line tools. This book is not about html and css since that is covered in the html-css-book.txt VISUAL PAGE CREATION WYSIWYG @@ kompozer a graphical tool for creating pages. successor of nvu @@ bluefish an html editor IMAGES @@ linux-image-book.txt more comprehensive information about managing images with tools available for the Linux operating system. IMAGE COMPRESSION .... \title{} \author{bumble.sourceforge.net} \maketitle \tableofcontents tools for image compression .. webpack - .. pngout - .. \title{} \author{bumble.sourceforge.net} \maketitle \tableofcontents image tools .. IMAGE RESIZING .... * convert a all '.html' files from iso-8859-1 to utf-8 file ------------------------------------------------------------- for x in \\$(find . -name '*.html') do iconv -f ISO-8859-1 -t UTF-8 \\$x > "\\$x.utf8"; rm \\$x; mv "\\$x.utf8" \\$x; done ,,, MANAGING IMAGES .... Feh is a flexible and fast tool for managing images which will be included in a web-site. See the linux-image-book for more details. * use feh >> feh ASCII IMAGES .... Converting images to 'ascii' (normal text characters) may in some circumstances be aethetically interesting. They could then be displayed within
 tags with an extremely small font.
 
 * convert an image to ascii 
 >> jp2a --size=40x20 imagefile.jpg

SVG SCALABLE VECTOR GRAPHICS ....
 
VIDEO

 @@ ffmpeg
 recode video files into different formats


\title{} 
\author{bumble.sourceforge.net} 
\maketitle 
\tableofcontents video formats
 .. DivX
 .. Digital video - used by camcorders
 .. avi
 .. mpeg
 ..


\title{} 
\author{bumble.sourceforge.net} 
\maketitle 
\tableofcontents video tools for web-development
 .. stills2dv - creates videos from still images
 .. kino - edit digital video data
 .. 

 * install kino on linux
 >> sudo apt-get install kino

USING UNICODE CHARACTERS 

 Unicode characters can be used in web-pages but this technique
 requires that the viewer of the webpage has an adequate font 
 installed in order to be able to view the character.


\title{} 
\author{bumble.sourceforge.net} 
\maketitle 
\tableofcontents some special chars
 .. U+260E - \\&\\#x260E; \\&\\#9742; ☎ BLACK TELEPHONE
 .. U+260F - \\&\\#x260F; \\&\\#9743; ☏ WHITE TELEPHONE
 .. U+265B - \\&\\#x265B; \\&\\#9819; ♛ BLACK CHESS QUEEN
 .. U+265C - \\&\\#x265C; \\&\\#9820; ♜ BLACK CHESS ROOK
 .. U+265D - \\&\\#x265D; \\&\\#9821; ♝ BLACK CHESS BISHOP
 .. U+265E - \\&\\#x265E; \\&\\#9822; ♞ BLACK CHESS KNIGHT
 .. U+265F - \\&\\#x265F; \\&\\#9823; ♟ BLACK CHESS PAWN
 .. U+2660 - \\&\\#x2660; \\&\\#9824; ♠ BLACK SPADE SUIT
 ..

 * The unicode page 'miscelaneous characters' runs from
 >> 9728-9865 (decimal) or x2600-x2689

 * print out 9 random entities from the miscelaneous unicode page
 >> echo "\\&\\#"\{9728..9865\}";" | xargs shuf -e | head -9 

 * create a little tabble of random miscelaneous entities 
 >> echo "\\&\\#"\{9728..9865\}";" | xargs shuf -e | head -15 | (echo ""; cat -; echo "
") ANIMATIONS @@ synfig studio a tool to create animations without 'tweening' (that is, drawing every image) FILE TRANSFER \title{} \author{bumble.sourceforge.net} \maketitle \tableofcontents tools for file transfer over the net .. ftp - the old file transfer tool .. rsync - transfer only changed or new files .. sftp - an interactive secure version of sftp .. scp - a non-interactive secure ftp .. sitecopy - synchronize a remote site with what is local .. WEB SITE MIRRORING * Download all images from a site >> wget -r -l1 --no-parent -nH -nd -P/tmp -A"http://example.com/images" .gif,.jpg TRANSFERING FILES An important part of creating a website is the process of moving file to and from the server. One wants to do this in a simple and efficient manner, while guarding against the possibility of accidentally overwriting files with older or bad versions. Unix and Linux have a wide smorgasboard of tools for the purpose of achieving these transfers. \title{} \author{bumble.sourceforge.net} \maketitle \tableofcontents command line file transfer tools .. rsync - powerful and complicated, synchronise files .. scp - fast and simple, securely copy .. sftp - an interactive way to copy files across the web .. \title{} \author{bumble.sourceforge.net} \maketitle \tableofcontents older tools .. ftp - an insecure copy method, use sftp instead .. \title{} \author{bumble.sourceforge.net} \maketitle \tableofcontents graphical tools .. the firefox copy ?? .. SSH FILE SYSTEM .... Linux has a special file system available called the 'sshfs' which allows the user to mount a remote folder tree as if it was a local file system (although the accesses will seem a little slower). This may be more enjoyable than using an ssh shell since the remote file system 'seems' to be local. The only requirement is that the remote computer be running an 'ssh' secure shell server and that you have a login name and password for that system. * install the sshfs remote file system. >> sudo apt-get install sshfs * mount an ssh (remote) file system >> sshfs name@server:/path/to/folder \texttt{/path/to/mount/point} * unmount an ssh file system >> fusermount -u \\$\\verb|~|/sshfs\\_mounted\\_directory SCP .... Scp stands for 'secure copy program'. It is a non-interactive tool well suited for including in scripts. * bash function to upload a file via scp to the 'rpike' a/c on the server >> upfile() \{ scp \\$1 rpike@server.net:\\$1 \} * upload and overwrite all '.txt' files to the 'doc/' folder on far.net >> scp *.txt eva@far.net:doc/ * download 2 files from the server using the account 'user' >> scp user@server.net:"chap1.txt chap2.txt" \\$\\verb|~|/books POSTING DATA * Submit data to a HTML form with POST method and save the response >> curl -sd 'rid=value\\&submit=SUBMIT' > out.html * post with a proxy and authentication >> curl -F name='../htdocs/notes/'\\$1 -F contents='<'\\$1 -u user:upass -x prox.net:8080 -U bob:proxpass \url{http://serv.net/save.cgi} HTML STUFF HTML LINKS .... * extract the hyperlinks ( tags) from a webpage >> lynx -dump -listonly \url{http://www.server.net/page.html} * find most of the urls within an html file >> egrep 'https?://([[:alpha:]]([-[:alnum:]]+[[:alnum:]])*\\$\\backslash\\$.)+[[:alpha:]]\{2,3\}(: \\$\\backslash\\$d+)?(/([-\\$\\backslash\\$w/\\_\\$\\backslash\\$.]*(\\$\\backslash\\$?\\$\\backslash\\$S+)?)?)?' ENTITIES * encode HTML entities >> perl -MHTML::Entities -ne 'print encode\\_entities(\\$\\_)' \texttt{/tmp/subor.txt} * or use xmlstarlet to encode entities. BASH AND WEB DEVELOPMENT Using the bash shell to develop web-sites maybe quite efficient, if unconventional. * possibly the simplest way to create a web-page from text >> cat file.txt | (echo '
'; cat -; echo '
') * a simpler way >> echo '
'; cat file.txt; echo '
') TEMPLATING WITH BASH .... * a simple template technique with bash >> export a=b; echo -e 'one\\$\\backslash\\$ntwo\\$\\backslash\\$nand ' | (echo 'cat << EE';sed 's//\\$a/g'; echo 'EE') | bash * use the technique above to substitute the date into the template >> cat template | (echo 'cat << EE';sed 's//\\$(date)/g'; echo 'EE') | bash FOLDER LISTINGS .... * list only folders >> ls -d */ | (echo '
    '; cat -; echo '
') * make an html directory listing out of the current folder >> echo "echo -e \\$\\backslash\\$"\{\\$(echo * | tr ' ' ',')\}"\\$\\backslash\\$" | bash * list all files and folders, no links >> a=\\$(echo *); echo 'echo -e "\\$\\backslash\\$n
  • "\{'\\$\{a//" "/,\}'\}"
  • "' | bash * list only folders, no links >> a=\\$(echo */); echo 'echo -e "\\$\\backslash\\$n
  • "\{'\\$\{a//" "/,\}'\}"
  • "' | bash * a for loop method to list only sub-folders as an html list ------------------------------------------------------------ echo "
      " for d in \\$(ls -d */); do echo "
    • \\$d
    • " done echo "
    " ,,, * another for loop method to list only sub-folders as an html list ------------------------------------------------------------ echo "
      " for d in */; do echo "
    • \\$d
    • " done echo "
    " ,,, * list subfolders as html links ------------------------------- echo "
    " ,,, * list subfolders as html links using a brace loop -------------------------------------------------- echo "" ,,, BASH CGI PROGRAMMING While it is most common for Cgi web-scripts to be written in the Perl language, it is also possible to write them using the normal Bash shell scripting language. Whether this is a good idea is completely another question... @@ \url{http://en.wikipedia.org/wiki/Internet\\_media\\_type\\#List\\_of\\_common\\_media\\_types} A list of common "media types" (such as "text/html") which are used in the "Content-Type:" field of the Cgi script. \begin{enumerate} \item use the "2>\\&1" idiom at the end of script lines to redirect an error message to the "standard output" (which in the case of a Cgi script is the web-browser of the script visitor). This allows you, the developer to see what is going wrong with your bash cgi script. \item using "here" documents with a bash cgi script is a simple way to produce content. \item \end{enumerate} THE BASH CGI GOTCHAS .... \begin{enumerate} \item the content-type line has to be before \texttt{/anything/} or else nothing is printed. \end{enumerate} * there must be an empty line after the "content-type" line. ------------------------------------------------------------- echo "Content-Type: text/html" echo "...the query string is \\$QUERY\\_STRING" 2>\\&1 ,,, * a bash cgi script indicating that the character set is "utf8" --------------------------------------------------------------- \\#!/bin/bash echo "Content-Type: text/html; charset=utf-8" echo echo "A Bash UTF8 Cgi Script!" 2>\\&1 ,,, * show error messages in the browser generated by a cgi script line >> ech "this is a mistake" 2>\\&1 * show error messages in the browser with output redirection >> ech "this is a mistake" 2>\\&1 >save.txt \\#\\#(note that the 2>\\&1 should come before the file redirection) * a cgi script which displays several environment variables ---------------------------------------------------------- \\#!/bin/bash cat << ENDxxx Content-Type: text/html; charset=utf-8