triptico.com: Angel Ortega's Site

2009-03-12

Gruta version 2.2.0 released

Version 2.2.0 of the Gruta CMS, codenamed "Osmannoro", has been released. This release needs Artemus version 4.1.2. The following changes were made:

  • Story rendering is cached, resulting in faster page loading.
  • An existing story can be copied to another topic from the story edition form.
  • The template stories_by_date has changed the order of their output values; now they are topic_id, id and date.
  • The RSS template now accepts an optional CGI argument tag, to get feeds on stories by tag.
  • Multiple sources are no longer supported; it never really worked well, made the code cumbersome and had no real advantage after all. The cgi caller needs not to be changed, as the sources argument is still supported (only the first one is used, though), but the scalar source is preferred now.
  • The file format in the FS source has changed; the .META extension has been changed to .M, and .TAGS to .T. Also, new files appear in the stories directory with the .A and .B extensions, holding the rendered abstract and story body, respectively. The transition is made automatically on the first run, no manual operation is needed.
  • New argument hard_top_ten_limit to Gruta::Source::FS, to set the maximum number of stories to be tested when generating the top read stories index (previously hardcoded to 100).
  • New argument min_size_for_gzip to Gruta::CGI, to set the minimum size for the output body to be Gzip compressed (previously hardcoded to 10000).
  • If a story pointed by a story:// pseudo-url has a publication date in the future, only the title is shown (i.e., it's not clickable).
  • The Mbox source is officially deprecated.
  • Static URLs are also generated for the CSS, RSS and SITEMAP pages. The following mod_rewrite rule must be added to the ones suggested in the previous version:

 RewriteRule ^/style\.css$     /?t=CSS              [PT]

2009-03-03

Nueva edición impresa de «Terra Incognita»

La segunda edición en papel de mi libro Terra Incognita (1997) está lista para comprarla en la tienda Lulu.com.

El texto incluye algunas correcciones de fallos tipográficos y estilo. Pero lo más interesante es la nueva presentación y diseño hecho por Marisa Ortega, gran profesional que además es mi hermana.

Una vez más, se demuestra que el aspecto es fundamental y lo que antes parecía un panfleto sin el menor interés ahora parece un libro de verdad.

2009-01-29

Overriding mod_rewrite if a file exists

I use mod_rewrite intensively on this site, mainly to make the transition from the old static files layout to this new, dynamic one based on my Gruta CMS. Following the premise that URLs must be eternal, I've used mod_rewrite magic to make old URLs like

http://triptico.com/software/mp.html

still be accesible, but be interally redirected to

http://triptico.com/?t=STORY;topic=software;id=mp

Anyway, it may prove useful to only do this redirection if a file with that path and name does not already exist in the filesystem. This can be used, for example, to serve special, manually crafted HTML pages, statistics made by other software, or to 'freeze' a special page to avoid too much server load.

So these are the magic words:

 RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}      -f
 RewriteRule ^ %{DOCUMENT_ROOT}%{REQUEST_URI}    [L]

They must be entered before any other rewriting directives.

What they mean is, if a file exists (-f) with a path formed by the site's document root plus the requested uri, rewrite the query to it and stop rewriting ([L]).

2009-01-20

Traducción: Una amistosa introdución a la codificación de vídeo, parte 3: sonido con pérdida

Una amistosa introdución a la codificación de vídeo, parte 3: sonido con pérdida, por Mark Pilgrim.

Grutatxt 2.0.15 released

Version 2.0.15 of the Grutatxt text conversion package has been released. The following changes were made:

  • New parameter url-label-max to the HTML driver to set a maximum size for URLs.
  • New script pod2grutatxt, to convert Perl documentation in POD format to Grutatxt.
  • The pre mode is really verbatim, so bold / italic markup is not processed.

2009-01-17

File locking in Perl

File locking in Perl is done with the flock() function. It's portable among architectures, is advisory-only and locks full files.

It accepts two arguments: a file handle and an operation id. As expected, it allows only one writer or many simultaneous readers, with no wait. Locks are automatically released on closing. The usage is simple:

  1. Open the file (for reading or writing).
  2. Call flock() with the file handle, and a second argument of 1 (if reading) or 2 (if writing).
  3. Do whatever operations you do to the file.
  4. Close it.

And that's it. The magic numbers 1 and 2 can also be used as LOCK_* constants imported from the Flock module. The perldoc documentation is comprehensive, take a look at it.

Example reader:

 open F, 'index.db'; # open for reading
 
 # lock file. If a writer has it locked, it will
 # wait until released. Many readers will read the
 # file simultaneously without blocking.
 flock F, 1;
 
 while (<F>) {
    # do things...
 }
 
 # lock is released
 close F;

And a writer:

 open F, '>index.db'; # open for writing
 
 # lock file for writing. If there is another reader
 # or writer using the lock, it will block until
 # released.
 flock F, 2;
 
 # file is now locked
 # write stuff to the file...
 
 # lock is released; any readers or writers waiting
 # will unblock and go on with its business
 close F;

As these locking semantics are advisory-only, anyone can screw everything by writing without locking, so take care.

2009-01-16

Traducción de Linux Weekly News: Btrfs apunta a su inclusión

LWN: Btrfs apunta a su inclusión, por Jonathan Corbet.

2009-01-15

Las Tijeras del Viajero, una al día

Desde hoy hasta mediados de febrero de 2009, y sin ninguna razón en especial, he decidido publicar cada día uno de los relatos o poemas de mi libro Las Tijeras del Viajero (1996).

La forma más cómoda de leerlos es mediante un lector RSS. Están por todas partes: Mozilla Firefox, Google Reader ó KDE Akregator. Tan sólo hay que usar el siguiente URL:

http://triptico.com/?t=RSS;tag=las%20tijeras%20del%20viajero

2009-01-09

Traducción: Una amistosa introdución a la codificación de vídeo, parte 1: contenedores

Una amistosa introdución a la codificación de vídeo, parte 1: contenedores, por Mark Pilgrim.

Traducción: Una amistosa introdución a la codificación de vídeo, parte 2: vídeo con pérdida

Una amistosa introdución a la codificación de vídeo, parte 2: vídeo con pérdida, por Mark Pilgrim.

2009-01-08

Traducción de Linux Weekly News: Btrfs, ¿incorporarlo al núcleo principal?

LWN: Btrfs, ¿incorporarlo al núcleo principal?, por Jake Edge.

2009-01-03

Nuevo artículo: sobre el algoritmo Diffie-Hellman

He escrito el siguiente artículo: El algoritmo Diffie-Hellman, una breve descripción del mecanismo en el que se basa el cifrado de clave pública.