ta-sa.org - Ta-sa.org

(best viewed in any resolution with any HTML enabled browser)


Main:
Index
Contact
Links

Studies:
Informatics
Scripts
Material

Projects:
Git repository

Programs:
cdplay
ECMS
lip.C
baseclc.c
nfa-util.C
tm.C
termreplace
psi_pw_decode
bummskraut

Perl:
AnyEvent::XMPP
Net::XMPP2
AnyEvent::IRC
Object::Event
AnyEvent::HTTPD
AnyEvent::EditText
MIDI::Sequencer

Music:
Ta-Sa Music
Languages:
LR Grammar Collection

Deliantra:
Deliantra

GNU Smalltalk:
Links

Other:
Laughing man logo
ta-sa.org

Java must DIE


Ta-sa.org - last change: fixed gitweb links., Thu Oct 15 20:27:00 2009 +0200

ta-sa.org website

This page is about the technology behind this website. Until April 2008 I used to use my self written online content management system aka ECMS.

I changed it to a more static approach to improve the integration with the tools I daily use, mostly: rxvt-unicode, vim, Perl and Git.

I have local checkouts of the git repository of this website on mostly all of my computers. I change the content locally usually by using vim and rxvt-unicode. After I'm finished with the changes I commit and push the changes to the git repository on the webserver, where the post-update hook of the git repository there will automatically rebuild the static pages of the website.

In future I plan to add a web interface to edit files and update the git repository via a web browser when I'm not at home or don't have my computer at hand.

The content of this website is put together by my self written Perl macro processor: pmak. It's a fairly small script, only around 200 lines of code. It allows simple macros like {vim} to include a linked link, the code of that macro looks like this:

{!vim( ma(x => 'http://www.vim.org/', 'vim') )}

The syntax is pretty simple, if a '!' follows the '{' the macro is being defined. The contents in the parantheses of {!vim( ... )}} is evaluated as Perl expression which forms the contents of a subroutine which is called when the macro is called via {vim}. The return value of that subroutine is then concationated to the output.

Because '{' is overloaded with the macro syntax it can be escaped by '{{'. Escaping of '}' in normal text is not neccessary, but '}}' will also result in a '}' for more consistency and because I usually balance all parantheses I write.

Macros can also have parameters, see the x macro I use for external links:

{!x(
   @_ > 1
     ? "<a href=\"$_[0]\">$_[1]</a>"
     : "<a href=\"$_[0]\">$_[0]</a>"
)}

To define an external link I write: {x('http://www.google.de')}, or if I want to label the link differently: {x('http://www.google.de','Google')}. The contents of the parantheses in a macro call like that is simply evaluated by Perl.

However, there is also some syntactic sugar for the macro arguments. You can post-fix the macro name with a '~' to tell the processor to evaluate the arguments as comma seperated values:

{x~(http://www.google.de,Google)}

This way you won't have to quote everthing. But another nice thing is that the delimiter can be customized. The character after the ~ (if it is not '(') is used as delimiter of the list (it's just ',' by default). Here an example:

{x~|(http://www.google.de|Google, a nice search machine!)}

Google, a nice search machine!.

Of course another way to quote would be to use the Perl quoting mechanism: {x(qw[http://www.google.de Google])}.

Another nice feature is the ability to embed Perl code in the HTML more directly. For example this will print out a list of the numbers 1 to 10:

<ul>
{: for (1..10) { :}
   <li>{?$_:}</li>
{: } :}
</ul>

Result:

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

You can also call macros from the {perl} code directly via the ma subroutine:

{:ma(x => qw{http://www.google.de/ Google}):}

There are some other subroutines defined for defining macros from perl (dmak) and to escape HTML and URLs: esc_url and esc_html.

I invite you to take a look at the page log template, where I generate the Page Log.

Feel free to use the pmak script and ask me if you got questions. (see Contact).

All logos and trademarks on this site are property of their respective owner. Site admin is: elmex@ta-sa.org