A Simple Content Management System for my Webpage

Sachverstand2 @ Geocities.com

15. Oktober 2005


Inhalt

1. Intro

My webpage at www.geocities.com/sachverstand2 is full of files (html, gif, jpeg, pdf). They are crazy named, and its hard to maintain an up-to-date index.

So I set up 2 Scripts and a directory structure to maintain this automagically.

2. Files and Folders

I decided to use the following webpage layout:

2.1 Example Webfile

This file cms.tex has the following description:

  I set up a simple yet effective Content Management System for my
  webpage with a folder structure, 2 scripts and help by latex2html.

This file cms.tex has the following keywords:


  content management system CMS webpage simple shell scripts

Its in Chapter LaTeX.

It has no pictures, but if it had, they would be called

cms0001.gif, cms0002.gif, cms0003.gif, ... you got the idea.

3. On my Computer

I decided to use the following local layout:

3.1 Example Local file


  homepage
    Chapters
      Mopped___allgemein
        mop
      ...(other chapters - dvips allows NO COLON in path)
      LaTeX
        l4l
          l4l.html, l4l.tex, anhan1.tex, anhan2.tex, bilder.tex, ...
        cms
          cms.html, cms.tex

4. Doing the work

To manage this, I must follow 2 steps:
  1. Set up the files to be published.

    Create a folder in the right chapter.

    Write them in html or LaTeX.

    Run the LaTeX files through l2h (see next chapter).

  2. Update index.html with p.sh (see second next chapter.

5. l2h

Heres how it works:

  if no file foldername.tex, then create a raw one
  change "png" in all tex files to "ps"
  convert fig files to ps
  convert jpg files to ps
  convert jpeg files to ps
  convert gif files to ps
  convert png files to ps
  convert to foldername/foldername.html
  change all foldername/img* to foldername/foldername*
  change "ps" in all tex files to "png"
  clean up

The result of l2h is a subfolder with files like I want them.

5.1 They who do the work

5.1.1 l2h


#!/bin/sh
#/usr/bin/l2h
# sachverstand2 @ geocities.com:
echo starting l2h by sachverstand2...

###################################################################
# to stay happy, you must remove all X from this script.
# i had to put them in there, or the script itself would have messed
# with this verbatim copy.
###################################################################


d1=$(date)
pwd=$(pwd)
file2="$(basename $(pwd))"
file=$(echo $file2.tex)

[ -d $file2 ] && rm $file2/*

[ -f $file ] || cp ~/homepage/template.tex ./$file

for i in *.tex ; do
  cat $i | sed s/pXXXng}/pXXXs}/ > tmp
  mv tmp $i
done

if ls *.fig 2> /dev/null ; then
	for i in *.fig ; do
		j=$(echo $i | sed s/.fig/.ps/)
		if [ $i -nt $j ] || [ ! -f $j ] ; then 		
     	        	fig2ps $i
                	echo $j created.
		fi
	done
fi

if ls *.jpg 2> /dev/null ; then
	for i in *.jpg ; do
		j=$(echo $i | sed s/.jpg/.ps/)
		if [ $i -nt $j ] || [ ! -f $j ] ; then
			djpeg -pnm $i > tmp
			pnmtops tmp > $j
			rm tmp
			echo $j created.
		fi
	done
fi

if ls *.jpeg 2> /dev/null ; then
	for i in *.jpeg ; do
		j=$(echo $i | sed s/.jpeg/.ps/)
		if [ $i -nt $j ] || [ ! -f $j ] ; then
			djpeg -pnm $i > tmp
			pnmtops tmp > $j
			rm tmp
			echo $j created.
		fi
	done
fi


if ls *.gif 2> /dev/null ; then
	for i in *.gif ; do
		j=$(echo $i | sed s/.gif/.ps/)
		if [ $i -nt $j ] || [ ! -f $j ] ; then
			giftopnm $i | pnmtops -noturn > $j
			echo $j created
		fi
	done
fi

if ls *.png 2> /dev/null ; then
	for i in *.png ; do
		j=$(echo $i | sed s/.png/.ps/)
		if [ $i -nt $j ] || [ ! -f $j ] ; then
			pngtopnm $i | pnmtops -noturn > $j
			echo $j created
		fi
	done
fi

###latex2html -no_navigation -split 0 $file && \
latex2html -no_navigation -show_section_numbers -split 0  \
  -no_parbox_images $file && \

echo $d1
date


play /usr/share/sounds/error.wav

for i in *.css index.html *.aux *.log *.pl WARN* images.tex ; do
  rm -f $file2/$i
done

### now, make img* to $file2*
echo "Renaming images..."
cd $file2
for i in $(ls *gif) ; do
  j=$(echo $i | cut -c 4- )
  mv -f $i $file2$j
done

echo "Renaming images in html file..."
for i in *.html ; do
  cat $i | sed s/SRC=\"img/SRC=\"$file2/ > tmp
  mv tmp $i
done
rm -f images*


echo "cleaning up html file..."
echo "<HTXML> <HEXAD>" >> head
cfile=$(basename $(pwd))
cfile=$(echo $cfile.html)
grep TIXTLE $cfile >> head

### count the line of the file
linescount=$(cat $cfile | wc -l)

### throw away first 21 lines
tail -n $(($linescount - 21)) $cfile > body

echo -e "<META NAME=description \
  CONTENT=\"\n$(cat ../descXription)\n\">" >> head

echo -e "<META NAME=keywords \
  CONTENT=\"\n$(cat ../keyXwords)\n\">" >> head

cat head body > $cfile
rm head
rm body
echo "Cleaning done."


### oops. cd back
cd ..
for i in *.tex ; do
  cat $i | sed s/pXs}/pnXg}/ > tmp
  mv tmp $i
done

echo "Removing junk..."
rm *aux
rm *dvi
rm *log
rm *toc
rm *ps
echo "Copying file."
cp $file2/$file2.html .

echo "Done."

[ -z $DISPLAY ] || Netscape $file2/$file2.html

###################################################################

5.1.2  /homepage/template.tex


\documentclass [12pt, a4paper] {article}

\usepackage {german, umlaut}
\usepackage {graphicx}
\pagestyle {headings}
\parindent 0.mm
\parskip=1mm
\fboxsep=5mm
\fboxrule=0.5mm

\begin{document}

\author {Sachverstand2 @ Geocities.com}
\title  {title goes here}
\date   {\today}
\maketitle

\tableofcontents

\section{First section}
bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla

\section{Second section}
bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla

\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

6. Creating index.html

Heres how it works:

  for all chapters
    create top of index page
  for all chapters
    for all folders
      create link and description
  cleanup

6.1 They who do the work

6.1.1 q.sh


#!/bin/sh
#~/homepage/q.sh

./p.sh > i.html ; Netscape i.html
###################################################################

6.1.2 p.sh


#!/bin/sh
#~/homepage/p.sh

echo > chapters
for i in $(ls Chapter) ; do
  echo "    <li><a href=#$i>$i</a>" >> chapters
done

cat toppage1
cat chapters
rm -f chapters
cat toppage2

for i in $(ls Chapter) ; do
  echo "<a name=$i></a>"
  echo "<h2>$i</h2>"
  echo "<ul>"
  for j in $(ls Chapter/$i) ; do
    echo "  <li>"
    if [ -f Chapter/$i/$j/$j.html ] ; then
      echo "    <a href=$j.html>$j.html</a>"
    fi
    if [ -f Chapter/$i/$j/$j.pdf ] ; then
      echo "    <a href=$j.pdf>$j.pdf</a>"
    fi
    if [ -f Chapter/$i/$j/$j.txt ] ; then
      echo "    <a href=$j.html>$j.txt</a>"
    fi
    cat Chapter/$i/$j/description
  done
  echo "  <li><a href=#top>Back to top</a>"
  echo "</ul> <hr>"
done
echo "create your own free homepage at <a href=www.geocities.com>"
echo "www.geocities.com</a>!"
###################################################################

6.1.3 toppage1


<HTML><HEAD>
        <TIXTLE>Sachverstand2 @ Geocities.com</TIXTLE>
        <META name=description content="Sachverstand2 @ Geocities.com">
        <META name=keywords content="Sachverstand2's keywords">
</HEAD>

<BODY> <FONT face=verdana,arial>
<a name=top></a>
<center>
  <h1>
    welcome 2 sachverstand2 @ geocities.com.
  </h1>
<table> <td>
  <img src=t.jpg width=300>
  <h3>
    these are the fastest pages of the web.
      <p>
    no frames, no scripts, no shit.
  </h3>
  </td> <td>
  <ul>

6.1.4 toppage2


  </ul>
  </td>
</table>
</center>
<hr>

7. Caveats and Further Enhancements

7.1 dvips dislikes Colons in path

I would have liked to use not only folders, but subfolders. As you see, I used a workaround.

Chapter GS400 is broken down into GS400:Elektrik, GS400:Reisen, GS400:Schraubereien.

Though these dont look nicely indented, I always have an Overview over the whole folder strukture by a simple ls in Chapters.

I would have liked to use the Colon (:) to divide Subfolders, but then dvips comes up with a weird error message and creates no images. I use UNDERSCORE instead. Took me 1 hour to find that out.

7.2 Brushing up html

To be searched better by search engines, each html file should have a title (done), a description (not yet done) and some keywords (not yet done, too). The keywords could most easy be carved from the section names.

I heard this can be done with the hthtml package. I will publish if one day I have found out.

7.3 Later

Meanwhile I have found out that hthtml is useless, and put the according changes right into l2h. Which in turn got improved to use template.tex. The use of description and keywords is visible in the source of l2h.

The title line is extracted by grep, so your documents may not contain the letters ''TITXLE'' (without the X, of course).

Über dieses Dokument ...

A Simple Content Management System for my Webpage

This document was generated using the LaTeX2HTML translator Version 99.1 release (March 30, 1999)

Copyright © 1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999, Ross Moore, Mathematics Department, Macquarie University, Sydney.

The command line arguments were:
latex2html -no_navigation -show_section_numbers -split 0 -no_parbox_images cms.tex

The translation was initiated by on 2005-10-15



2005-10-15