|
|
|
Home » About this page...
|
About this page...
I wanted to put up a lot of code samples in 2001 but somehow
everything stalled (real life work taking far too much time). Now,
after Feb 2005 I basically put up the CV and some basic information
about programming languages etc. I may put in some code in future,
though.
The older Python site (and Jython and others, like MayaVi ) is
built using a tool called ht2html. This was written by "Pythons
Benevolent Dictator for Life", aka the man himself. It uses python
and some skeleton code to build up the site. The actual pages are .ht
files, basically html. Anyway, this was not flexible enough for Ollie
Rutherfurd, who decided to combine the excellent ReST markup
(which still is one of the best pseudo-ascii markups around, see the
quickstart for a quick overview) and ht2html.
This again, wasn't flexible enough for me ;-) who really hates mixing
html and code and rather prefers templating and using plain text.
Therefore at one weekend I decided to use the ht2html + ReST markup +
templating approach. This mainly affected ht2html's code. First of all
, I looked for a template engine. Since I knew HTML::Template from
Perl I was really happy to find the python version, htmltmpl on the
net. But unfortunately it did not work out that nice for nested loops
for whatever reason, therefore I resorted to using Cheetah, which is
a rather nice solution. I could take out Photoshop and play around
until I designed someting nice, then slice and html-hack it in Mozilla
Composer (Yuck) until it was nice and simply put the templating
statements in html-comments (this is an option Cheetah provides ).
Control flow:
+------------------+ +-----------------+ +-----------------+
|Site structure | | | | |
+------------------+ .txt->.ht | | .ht->.html | |
| - articles | | | | |
| | index.txt | \ | .ht files | \ | final |
| | uml_review.txt | ---------/ | in site | ---------/ | html site |
| | vc6_debug.txt | / | | / | |
| | vc6_stl.txt | Python | | ht2html | |
| + cv | docutils + | | (my ver.) | |
| index .txt | rst2ht | | | |
| about.txt | | | / | |
+------------------+ +-----------------+ /|\ +-----------------+
|
+-----------------+ |
| | |
| Cheetah | |
| html |.....|
| template |
| |
| |
| |
| |
| |
| |
+-----------------+
jave rocks! Yeah, hell!!
I wrote a modified version of ht2html which does not use mixin classes
for the site componentents but simply fills in a Cheetah template.
Changing the navigation means putting one new entry into a text file.
The look of the site is completely layouted with an WYSIWYG editor
and is "valid" html with Cheetah template commands in HTML-comments.
This had to be done once. Changing the look means changing one
Template. Here is the first standard template I used. It is not
really valid html in the strong sense, Mozilla Composer happily
destroys the template in my configuration. Anyway, Dreamweaver
should handle it correctly. Check out the .html source code of that
page for the actual Cheetah code. It goes something like this (cut):
<!-- #for $lstEntry in $obTopics.getTopLst()#-->
<br>
<span style="font-style: italic; color: rgb(255, 0, 0);">
<A href="$obTopics.getTopURL($lstEntry)">$lstEntry</A>
</span>
<!-- #for $secondEntry in $obTopics.getSubTop($lstEntry)#-->
<br>
<small style="font-weight: bold;">
<span style="color: rgb(255, 0, 0);">
<A href="$obTopics.getSubURL($lstEntry, $secondEntry)">$secondEntry</A> </span>
</span>
</small>
<!-- #end for#-->
<!-- #end for#-->
This was the nested loop that does all of the hazzle-dazzle. the
$obTopics object is a python object with a few methods that
basically returns the site navigation. It's an instance of a simple
class TopicProvider that reads in a textfile and fills in an
internal data structure containing the navigation. Hell, it's just 5
minutes code. This is how it looks (a list of hashes, in Python called
Dictionaries)...
self._lstTopics = [
{"Title" : "Home",
"TitleLink" : sInBaseURL + "/index.html",
"SubTitles" : ["About", "News", "Contact"],
"SubTitlesLink" : [sInBaseURL + "/about.html",
sInBaseURL + "/news.html",
sInBaseURL + "/contact.html"] }
,
{"Title" : "CV",
"TitleLink" : sInBaseURL + "/cv/index.html",
"SubTitles" : ["download"],
"SubTitlesLink" : [sInBaseURL + "/cv/cv_download.html"] }
,
{"Title" : "Code",
"TitleLink" : sInBaseURL + "/code/index.html",
"SubTitles" : ["C++", "Java", "Python"],
"SubTitlesLink" : [sInBaseURL + "/code/cpp.html",
sInBaseURL + "/code/java.html",
sInBaseURL + "/code/python.html"] }
,
{"Title" : "Articles",
"TitleLink" : sInBaseURL + "/articles/index.html",
"SubTitles" : ["VC6 STL", "VC6 debug tips", "UML review"],
"SubTitlesLink" : [sInBaseURL + "/articles/vc6_stl.html",
sInBaseURL + "/articles/vc6_debug.html",
sInBaseURL + "/articles/uml_review.html"] }
,
{"Title" : "Links",
"TitleLink" : sInBaseURL + "/Links.html",
"SubTitles" : [],
"SubTitlesLink" : [] }
]
getTopLst(), getTopURL , getSubTop and getSubURL are
methods of that class and provide access to this data. Cheetah takes
a hash of things for filling the template , and you can happily put
in an instance of a class and call methods of that class in the
template.
- Adding a new page means creating a .txt file in ReST format within
the sites folder hierarchy. You can see the ReST sourcecode of
every page by clicking on the "View document source" link at the
bottom of every page
- Reinvoking a python script starts up the process described above.
- The old site was created in 2001 using Dreamweaver.
- Then I switched to a combination of Mozilla Composer for general
page layout and some templating stuff (including the navigation bar
into all content pages, a C++ console program written in 20min.)
This is the configuration I use right now (20050219). Mozilla
Composer is nice because it is widely available on all major
platforms, is free and very convenient. I can press Control-E in
mozilla anytime and simply start typing right away.
- Then in August 2005 (20050813) I switched to complete text markup.
20060919: | Changed link pointing to python.org to point to
the web.archive.org archive
|
|
|