Contents

Examples

  1. Adding entries from multiple tags to an RSS feed



Chapter 1
Introduction

Rassmalog is a static blog engine based on YAML, eRuby, and Rake. It transforms blog entries written in Textile or other formatting systems into valid XHTML files that you can view on your computer or upload to your website.

Rassmalog is open-source software (see Section 1.2. License) inspired by the Rog, hobix, and nanoblogger blog engines. Its name is derived from the word Rasmalai and somewhat resembles the words “RSS”, “YAML”, and “blog”.

1.1  Features

Noteworthy: Standard:
  • Categorization by tags (also known as folksonomy).
  • Automatic archives by date, month, year, etc.
  • Automatic RSS feeds for blog entires, tags, etc.
  • Automated blog import from any RSS feed.

1.2  License

Copyright 2006 Suraj N. Kurapati <SNK at GNA dot ORG>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

  • All copies and substantial portions of the Software (the "Derivatives") and their corresponding machine-readable source code (the "Code") must include the above copyright notice and this permission notice.
  • Upon distribution, the Derivatives must be accompanied by either the Code or—provided that the Code is obtainable for no more than the cost of distribution plus a nominal fee—information on how to obtain the Code.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1.3  Motivation

Although dynamic blog engines are popular nowadays, static blog engines like Rassmalog are still relevant. The following sections attempt to explain why.

1.3.1  Server requirements

Dynamic blog engine Rassmalog
Requires a web server that supports CGI or a server-side scripting language.

Another typical requirement is access to a relational database.
Requires nothing because all web servers are, by definition, capable of serving files over HTTP.

In fact, even a web server is not necessary if you just want to view your blog locally, on your own computer.

1.3.2  Content ownership

Dynamic blog engine Rassmalog
Your content is locked away within a relational database, to which you might not have access. Thus, it is difficult to backup your content. Your content is stored locally, on your computer. Thus, it is easy to backup and share with a good friend.
You are vulnerable to data loss when your web hosting service accidentally crashes or erases your blog. You are safe from data loss when your web hosting service accidentally crashes or erases your blog.

1.3.3  Content portability

  Dynamic blog engine Rassmalog
How is your content kept? Scattered across a relational database on the web server. In plain text files on your computer.
How do you migrate to another blog engine? Assuming that you have SQL access to your blog’s relational database, you must first understand the database schema before you can extract your content.

Afterwards, you still need to convert the extracted content into the new blog’s format.
Your content is readily converted into the new blog’s format using standard text processing tools or languages such as Perl and Ruby.

1.3.4  Speed and scalability

Dynamic blog engine Rassmalog
Responsiveness depends on speed of web server and speed of the server-side scripting language in which the blog software is written. Responsiveness depends only on speed of web server.
Scales poorly because it generates web pages on demand. Scales perfectly because all content is generated only once and only before it is ever uploaded to your web server!

1.3.5  Comments and spam control

Dynamic blog engine Rassmalog
Provides web based comments that typically burden users with CAPTCHA tests and/or become vulnerable to comment spam.

You will have to clean up the spam eventually, using a clunky web-based comment management interface.
Provides e-mail based comments (which can be disabled if you want) while taking special care to avoid e-mail spam by obfuscating your e-mail address in such a way that address harvesters won’t bother trying to figure it out.

If you prefer web based comments instead, then JavaScript-based comments are available.

1.4  Background

The basic unit of content in Rassmalog is the blog entry. Entries are collected into sections. Pages are collected into chapters.

As you can see, there is a hierarchical relationship here:

  • Chapter
    • Section
      • Entry
For example,
  • a chapter shows all available tags
  • a section shows all entries that have a particular tag
  • an entry just shows its content

Furthermore, a listing is just a list of blog entries.

Chapter 2
Setup

2.1  Requirements

Your system needs the following software to run Rassmalog.

Software Notes
Ruby version 1.8.x or newer is required
Rake version 0.7 or newer is required
RedCloth not required if you want to use a different formatting system
CodeRay not required if you want to use a different formatting system
ruby-locale required if you want to use the locale parameter. This library is also available in Debian and Ubuntu under the name “liblocale-ruby”.

If your system has RubyGems, then you can install Rake, RedCloth, and CodeRay by running the following command:

gem install rake RedCloth coderay

2.2  Installation

  1. Download the newest release package from the download area.
  2. Extract the release package anywhere you want on your system.
  3. Go inside the extracted directory and run the following command:
    rake regen

If the installation was successful, then you will see output like this:

(in /home/sun/tmp/rassmalog)
        copy  output/styles/print.css
        copy  output/styles/screen.css
        copy  output/images/feed-icon-14x14.png
       Entry  output/example-paths.html
       Entry  output/2006-12-14-formatting-with-textile.html
       Entry  output/2006-12-20-automatic-image-resizing-for-thumbnails.html
       Entry  output/2007-09-25-dynamic-web-based-comments.html
       Entry  output/2007-03-25-automatic-tagging-of-directory-names.html
       Entry  output/blog-entry-file-format.html
       Entry  output/2007-09-25-an-entry-from-the-entries-directory.html
       Entry  output/2007-11-02-version-8-0-1.html
       Entry  output/2006-12-14-version-2-0-0.html
       Entry  output/2007-12-09-version-9-0-1.html
       Entry  output/2007-10-23-version-7-1-0.html
       Entry  output/2007-09-25-version-6-0-0.html
       Entry  output/2007-01-22-version-2-3-0.html
       Entry  output/2007-01-27-version-2-4-0.html
       Entry  output/2006-12-18-version-2-1-1.html
       Entry  output/2007-04-16-version-4-0-0.html
       Entry  output/2008-06-08-version-11-1-0.html
       Entry  output/2007-11-12-version-8-0-2.html
       Entry  output/2007-05-25-version-5-0-0.html
       Entry  output/2008-01-11-version-10-0-0.html
       Entry  output/2006-12-11-version-1-0-0.html
       Entry  output/2007-10-05-version-7-0-1.html
       Entry  output/2007-03-25-version-3-2-0.html
       Entry  output/2007-03-04-version-3-0-0.html
       Entry  output/2007-11-01-version-8-0-0.html
       Entry  output/2007-05-05-version-4-1-0.html
       Entry  output/2007-10-24-version-7-1-1.html
       Entry  output/2008-05-02-version-11-0-1.html
       Entry  output/2006-12-15-version-2-1-0.html
       Entry  output/2007-03-05-version-3-1-0.html
       Entry  output/2008-01-21-version-10-1-0.html
       Entry  output/2007-01-13-version-2-2-0.html
       Entry  output/2007-10-04-version-7-0-0.html
       Entry  output/2007-07-04-version-5-1-0.html
       Entry  output/2007-12-05-version-9-0-0.html
       Entry  output/2008-05-18-version-11-0-2.html
       Entry  output/2008-05-01-version-11-0-0.html
       Entry  output/2007-06-05-version-5-0-1.html
     Section  output/tags-examples.html
     Section  output/tags-history.html
     Section  output/tags-reference.html
     Section  output/tags-tricks.html
     Chapter  output/tags.html
     Section  output/archives-december-2006.html
     Section  output/archives-january-2007.html
     Section  output/archives-march-2007.html
     Section  output/archives-april-2007.html
     Section  output/archives-may-2007.html
     Section  output/archives-june-2007.html
     Section  output/archives-july-2007.html
     Section  output/archives-september-2007.html
     Section  output/archives-october-2007.html
     Section  output/archives-november-2007.html
     Section  output/archives-december-2007.html
     Section  output/archives-january-2008.html
     Section  output/archives-may-2008.html
     Section  output/archives-june-2008.html
     Chapter  output/archives.html
     Listing  output/all-entries.html
     Listing  output/new-entries.html
  front_page  output/new-entries.html
       Entry  output/search.html
        feed  output/feed.xml
        feed  output/tricks.xml

2.3  Manifest

Now that Rassmalog is installed on your system, let us examine its installation directory. Inside, you will see (among other things) the following items:

  • rassmalog.rb – the core of Rassmalog.
  • doc/ – documentation for Rassmalog users
    • doc/guide.erb – source code of this user guide
  • config/ – directory that contains all configuration files.
    • config/blog.yaml – the primary configuration file for your blog.
    • config/feed.erb – template for generating RSS feeds for the blog.
    • config/html.erb – template for generating a complete HTML web page.
    • config/chapter.erb – template for generating HTML for lists of tags and archives.
    • config/section.erb – template for generating HTML for individual tags and archives.
    • config/listing.erb – template for generating the recent/all lists of blog entries.
    • config/entry.erb – template for generating HTML for a blog entry.
    • config/format.rb – defines how text is transformed into HTML.
    • config/lang/ – directory that contains translations of English text used in the core of Rassmalog. These translations do not include English text used in the templates (config/*.erb) because those are already separate from the core of Rassmalog.
  • config/lang/de.yaml (German)
  • config/lang/el.yaml (Greek; Modern)
  • config/lang/es.yaml (Spanish; Castilian)
  • config/lang/fr.yaml (French)
  • config/lang/id.yaml (Indonesian)
  • config/lang/it.yaml (Italian)
  • config/lang/ja.yaml (Japanese)
  • config/lang/ko.yaml (Korean)
  • config/lang/nl.yaml (Dutch; Flemish)
  • config/lang/no.yaml (Norwegian)
  • config/lang/pt.yaml (Portuguese)
  • config/lang/ru.yaml (Russian)
  • config/lang/sv.yaml (Swedish)
  • config/lang/te.yaml (Telugu)
  • config/lang/zh-TW.yaml (Chinese (Taiwan))
  • config/lang/zh.yaml (Chinese)
  • output/ – directory that contains your generated blog.
  • input/ – directory that contains (1) source files for blog entries and (2) additional resources, such as images and stylesheets, that are used by your blog. Everything inside this directory, except source files for blog entries, is automatically copied into the output/ directory (relative paths are preserved) when your blog is generated.

    A blog entry source file’s name must end with a .yaml extension. By default, a source file’s corresponding output file has (1) the same name and relative path as the source file but (2) ends with a .html extension.

    For example, the input/foo/bar/moz.yaml source file’s corresponding output file is output/foo/bar/moz.html. You can override this default behavior by adding the output_file parameter to your blog entry.

    • input/styles/screen.css – the default CSS stylesheet provided with Rassmalog.
    • input/styles/print.css – the default CSS stylesheet provided with Rassmalog.
    • input/rassmalog/entry.yaml – reference of the blog entry file format.
  • entries/ – directory that contains blog entry source files whose output files are automatically calculated by Rassmalog.

    A blog entry source file’s name must end with a .yaml extension. By default, all source files in this directory will have a corresponding output file with a name in the form: “date-name.html”.

    For example, the entries/foo/bar/moz.yaml source file, which was written on 19 July 2006 and has a name of “hello world”, will have a corresponding output file at output/2006-07-19-hello-world.html. You can override this default behavior by adding the output_file parameter to your blog entry.

    As you can see, unlike the blog entries in the input/ directory, blog entries in the entries/ directory do not have to worry about their original file name influencing the output file name. As a result, you can organize your blog entry files however you want.

    For example, I like to put all blog entry files related to Ruby programming within the entries/code/ruby/ subdirectory. The names of these subdirectories do not have any special meaning to Rassmalog, so you can name them however you like.

2.3.1  plugins/

This directory contains Ruby source files which define additional Rake tasks for Rassmalog.

2.3.1.1  plugins/import.rb

Command Description
rake import_rss Import blog entries from RSS feed on STDIN.
Rake tasks for importing blog entries from feeds.

2.3.1.2  plugins/new.rb

Command Description
rake new Create a new blog entry file for editing.

Provides a Rake task to facilitate “Lazy Blogging” [1] where you can easily create a new blog entry source file without having to:

  • think of and manage unique file names every time
  • supply the current date and time
  • remember the entire syntax of a blog entry file
  • remember the names of all tags you have used thus far

The name of the created file follows this format:

"entries/{today's date}+{serial number}.yaml"

To create a new blog entry file that is ready for editing:

rake new

To override the default values of blog entry fields:

rake new name='hello world' date='2008 march 17' tags='foo,bar' text='hey!'

To override the tags field (values must be separated by commas):

rake new tags='foo,bar,hello world'

To override the default location of the created file:

rake new file='hello_world.yaml'

[1] Josef ‘Jupp’ Schugt, “Lazy Blogging”, 2008 March 16, available at http://cip.physik.uni-bonn.de/~jupp/2008-03-16-lazy-blogging.html

2.3.1.3  plugins/validate.rb

Command Description
rake tidy show tidy html validation errors and warnings
rake tidy:warn show tidy diagnostic warnings
rake validate show w3c validation errors and warnings (must be online)

Provides Rake tasks to validate and correct HTML files.

This code was adapted by Greg Weber, and is originally by Scott Raymond. See http://redgreenblu.com/svn/projects/assert_valid_markup/

2.4  Version numbering system

Rassmalog uses the RubyGems rational versioning policy to number its releases. This major.minor.patch numbering policy is summarized as follows.

Version number components: Major Minor Patch
Backwards compatible? no yes yes
New features? yes yes no
Bug fixes? yes yes yes

Chapter 3
Configuration

Start by editing the config/blog.yaml file. It has plentiful comments and documentation to help guide you through you the configuration process. Next, proceed to editing the other files in the config/ directory to suit your taste.

You are encouraged to generate your blog at each step of the configuration process to see how your choices affect the generated output. This gives you a good sense of how Rassmalog works and how your blog can be shaped to suit your specific needs.

3.1  Parameters

The following subsections describe the configuration parameters available for use in the config/blog.yaml file.

3.1.1  name (eRuby) (HTML)

The name of your blog.

3.1.2  info (eRuby) (HTML)

Description of your blog.

3.1.3  author (eRuby) (HTML)

The name of the blog author.

3.1.4  email (eRuby)

The e-mail address that will receive comments about your blog entries.

This address will be obfuscated into HTML entities so that e-mail address harvesters won’t bother to figure out what it is. For example, the address “xxx@yyy.zzz” will be converted into the following before it is written to a HTML file:

xxx@yyy.zzz

If you do not wish to receive comments about your blog entries, or if you absolutely do not want your e-mail address to be included in the output (even in the obfuscated form), then you can simply leave this parameter blank, as follows:

email:   # nothing here!

Examples:

email: your@email.here
email: your+blog@email.here
email: your+comments@email.here

3.1.5  url (eRuby)

The URL of your published blog.

Examples:

url: http://your_host.com/~you/path/to/your/blog/
url: http://you.your_host.com/path/to/your/blog/

3.1.6  uploader (eRuby)

An eRuby template for the command that uploads your blog to your website.

The following predefined variables are available:

<%= whole %> is a path to the output/ directory which must be uploaded.
<%= parts %> is a sequence of quoted paths to files that must be uploaded.
             For example, the result of this directive is something like:
             "output/foo" "output/bar" "output/baz qux moz"

SSH examples:

These examples assume that your website is located in a directory named “public_html” on a server named “host” that is accessible by a user named “user” via SSH or SFTP.

uploader: scp -prC <%= parts %> user@host:public_html
uploader: rsync -e ssh -auvz <%= whole %>/ user@host:public_html
uploader: lftp sftp://user@host -e 'mirror -Ra --ignore-time <%= whole %>/ public_html; exit'

FTP examples:

These examples assume that your website is located in a directory named “public_html” on a server named “host” that is accessible by a user named “user” with a password of “password” via FTP.

uploader: lftp host -u 'user,password' -e 'mirror -Ra --ignore-time <%= whole %>/ public_html; exit'

3.1.7  encoding (eRuby)

The character set used in your entries.

Examples:

encoding: utf-8       # Unicode (for all languages)
encoding: x-sjis      # Shift JIS (for Japanese only)
encoding: x-iscii-te  # Telugu ISCII (for Telugu only)

3.1.8  language (eRuby)

The ISO-639 code and (optionally) the ISO-3166 country code for the primary language used in your entries.

For a list of ISO-639 language codes, see:

http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes

For a list of ISO-3166 country codes, see:

http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Current_codes

Examples:

language: en    # English
language: en-us # English (United States)
language: en-gb # English (Great Britain)

3.1.9  locale (eRuby)

This parameter specifies the locale corresponding to the language in which dates, times, and currency will be formatted by Ruby. See http://en.wikipedia.org/wiki/Locale for more information.

Here are some examples of how the choice of locale affects the formatting of dates and times:

$ irb -r locale
>> Time.now
=> Tue Oct 23 13:12:20 -0700 2007

# in German:
>> Locale.setlocale(Locale::LC_TIME, "de_DE"); Time.now
=> Di Okt 23 13:12:32 -0700 2007

# in Spanish:
>> Locale.setlocale(Locale::LC_TIME, "es_ES"); Time.now
=> mar oct 23 13:15:19 -0700 2007

# in Italian:
>> Locale.setlocale(Locale::LC_TIME, "it_IT"); Time.now
=> mar ott 23 13:15:27 -0700 2007

To use the default POSIX (U.S. English) locale, leave this parameter blank:

locale:   # nothing here!

To see a list of available locales on your system, run the following command:

locale -a

3.1.10  front_page (eRuby)

Path to a file in the output/ directory that should be displayed when somebody visits your blog. This is called the “front page” of your blog.

To have an automatic listing of the most recent entries on the front page, simply leave this parameter blank:

front_page:   # nothing here!

3.1.11  new_entries

Maximum number of entries to display on the “new entries” page.

If you want all entries to be displayed (no maximum limit), then simply leave this parameter blank:

new_entries:   # nothing here!

3.1.12  summarize_entries

Controls whether entries are summarized in tag pages, archive pages, and the recent entries page.

The config/entry.erb template controls how an entry is summarized. By default, only the first paragraph of an entry is shown when summarization is enabled.

To disable this parameter, set its value to “false” like this:

summarize_entries: false

3.1.13  generate_toc

Controls whether a table of contents is generated, by default, for all blog entries.

A blog entry can override this parameter by specifying its own “generate_toc” parameter in its source file.

3.1.14  archive_frequency

Controls how frequently archives are created.

To have one archive per unique year, specify:

archive_frequency: %Y

To have one archive per unique month, specify:

archive_frequency: %Y-%m

To have one archive per unique day, specify:

archive_frequency: %Y-%m-%d

To have one archive per some other criteria, specify your own value:

archive_frequency: put your own value here

For more information, see the documentation of the Time.strftime method:

http://www.rubycentral.com/pickaxe/ref_c_time.html#Time.strftime

3.1.15  links (eRuby) (HTML)

Hierarchical menu of links.

By default, this menu is shown in all generated HTML pages. To change this behavior, edit the config/html.erb template.

You can use eRuby directives in both the NAME and URL portions (the left and right-hand sides of the equation).

In addition, the NAME portion will be converted into HTML using the standard mechanism defined in the config/format.rb file.

4dff565b98d6eb66e25a62004a71d0c56efc4c862bf3258dc1f5603264fd072ee64cb43c83eda8fcf94b8c0175c6d7b1a4f5281815060077a15a99dc1fec717205e0cae5408c6906bdcfb510bfcb64fa0ede8475e1838d774cfb1d5ad80b3b83fd0c65e834a42aae41b444be7d259189b91f9d5578bcefdf16aca3f90c03d2ed1ba1547f7e03dcdc663ee2cd484957f37718482eff713b2767761d3ce1b17b88d552488d9a330e3938efa7fbb11069e9b5bf17767ba8c31b8f06e53ecfc4ca0661c7bfdc19756b290859d50dbdd3c3b158fd52a23c0e14003e471260f60ce606eede040d112b9d2157c8c3b8361b0f972e352cad144521b7e3c42f34427e1dec2cb760f36012ca17c85acb275c5f0aa087957e4dc06bab4cd4d0d372687fb9f09ccd5634d634c21240045f79

3.2  Localization for foreign languages

The core of Rassmalog is easily localized (L10N / I18N / M17N) through translation files, which consist of simple key-value pairs. For instance, the translation file for Spanish appears like this:

# es (Spanish; Castilian)
All entries: Todas las entradas
Archives: Archivos
Authored by %s.: Sido autor por %s.
Generated by %s.: Generado por %s.
Navigation: Navegación
New entries: Nuevas entradas
Newer: Más nuevo
Next: Después
Older: Más viejo
Previous: Anterior
Read more...: Lea más...
Search: Búsqueda
Subscribe: Suscriba
Tagged as %s.: Marcado con etiqueta como %s.
Tags: Etiquetas
Written on %s.: Escrito en %s.
You are now being redirected to %s.: Le ahora están volviendo a dirigir a %s.
You may {send comments by e-mail}.: Usted puede {envíe los comentarios por E-mail}.

Here, English phrases are written on the left and their corresponding Spanish phrases are written on the right.

3.2.1  Enabling a translation file

The config/lang/ directory contains translation files (there are 16 of them, at present) for English text used in the core of Rassmalog. To enable one of these files, set the value of the language parameter in the config/blog.yaml file to the name of the translation file.

For example, if you wish to enable the config/lang/foobar.yaml translation file, then you would set the language parameter as follows:

language: foobar

In this manner, you can add or edit translation files for your own languages and use them in your blog. However, please consider contributing your translation files so that other users can also enjoy your translations! :-)

3.3  Using another text formatting system

To use another text formatting system, simply replace the String.to_html method, which is defined in the config/format.rb file, to make use of your desired text formatting scheme.

For example, if you replace the entire config/format.rb file with the following code, then all entries will appear within red boxes in the output.

class String
  def to_html
    '<p style="border: thin solid red">' + self + '</p>'
  end
end

In this manner, you can make Rassmalog use any formatting system you wish!

3.4  Disabling parts of a blog

Suppose you wanted to disable the generation of the RSS feed for your blog. In order to do this,

  1. Open the Rakefile in your text editor.
  2. You should now see a line of code similar to this:
    task :gen => [:copy, :entry, :entry_meta, :entry_list, :feed]
  3. Remove the :feed element from the line of code.

In this manner, you can disable other parts of the blog generation process. Furthermore, you can edit the source code in the “output generation stage” section to suit your needs.

3.5  Disabling the search page

The search page is just a blog entry; there is nothing special about it.

  1. Delete the input/search.yaml file.
  2. Remove the HTML search form in the config/html.erb template.
  3. Regenerate your blog.

Chapter 4
Usage

In the location where you installed Rassmalog, run the following command to see a list of available tasks:

rake -T

For example, here is the output you would see when you run the above command:

(in /home/sun/tmp/rassmalog)
rake clean       # Remove any temporary products.
rake clobber     # Remove any generated file.
rake copy        # Copy files from input/ into output/
rake entry       # Generate HTML for blog entries.
rake entry_list  # Generate HTML for recent/all entry lists.
rake entry_meta  # Generate HTML for tags and archives.
rake feed        # Generate RSS feeds for the blog.
rake gen         # Generate the blog.
rake import_rss  # Import blog entries from RSS feed on STDIN.
rake new         # Create a new blog entry file for editing.
rake preview     # Preview your blog while writing.
rake regen       # Regenerate the blog from scratch.
rake search      # Generate the blog search page.
rake upload      # Upload the blog to your website.

4.1  Creating a blog entry file

The new plugin allows you to easily create a new blog entry source file without having to:
  • think of and manage unique file names every time
  • supply the current date and time
  • remember the entire syntax of a blog entry file
  • remember the names of all tags you have used thus far

To use this plugin, run the following command:

rake new

After it executes, the command will report the name of the file it created. You can then edit the created file using your favorite text editor and fill in all the juicy details.

4.2  Generating your blog

To generate your blog, run the following command:

rake

Or alternatively, you can run:

rake gen

To regenerate your blog from scratch (delete all existing output and generate everything again), run the following command:

rake regen

4.3  Removing generated files

To remove all output files that were generated by Rassmalog, run the following command:

rake clean

To remove everything inside the output/ directory, run the following command:

rake clobber

4.4  Publishing your blog

To upload your blog to your website, run the following command:

rake upload

4.5  Preview while you write

To continuously preview a blog entry as you write it, run the following command:

rake preview

Now, whenever you save your blog entry file, its HTML page will be generated for preview in your web browser.

4.6  Importing blog entries from RSS feed

The import task allows you to import blog entries from an RSS feed, which must be provided on the standard input stream.

For example, if you have an RSS feed file named feed.xml then you would import it into Rassmalog like this:

rake import < feed.xml

4.7  Creating RSS feeds

  1. Open the Rakefile in your text editor.
  2. You should now see a some code similar to this:
    feed 'feed.xml', NEW_ENTRIES, BLOG.name, BLOG.info
    
    This code invokes the feed method to create an RSS feed.
  3. Add your own invocation of the feed method to the bottom of the file (see the API documentation in Section 6.1. API documentation for help).

Example 1.  Adding entries from multiple tags to an RSS feed

The second parameter of the feed method is an arry of Entry objects. You can take advantage of this fact with some Ruby magic:

# gather the desired entries
entries = TAGS['foo'] + TAGS['bar'] + TAGS['moz']

# remove duplicate entries
entries.uniq!

# create the feed
feed 'example.xml', entries

Here we gather all blog entries that have the ‘foo’, ‘bar’, or ‘moz’ tag into an array, and keep track of it in the entries variable.

Next, we call the uniq method on the entries variable to ensure that all entries occur only once in the array (since the same entry could have both ‘foo’ and ‘bar’ tags, and would thus appear twice in the array).

Finally, we create the news feed by calling the feed method.

Chapter 5
Writing blog entries

This chapter deals with things related to the writing, formatting, and scripting of blog entries.

5.1  Parameters

The following subsections describe the parameters you can use in a blog entry file. For an example of usage, see the input/rassmalog/entry.yaml file.

5.1.1  name (Required) (eRuby) (HTML)

The title of this blog entry.

5.1.2  date (Optional) (eRuby)

The date when this blog entry written.

Here are some examples:

date: Thu, 01 Jan 1970 08:00:00 GMT
date: 1970-01-01 8:00am
date: 1/1/1970 8:00am
date: jan 1st 1970 16:00 -08:00
date: 1 january 1970
date: Wed Dec 13 21:31:04 PST 2006

You can also specify dates in other languages. For example, the following date

date: Thursday, 01 January 1970 03:15:00 PM

can be written in German as:

date: Donnerstag, 01 Januar 1970 15:15:00

For more information about the format of this parameter, see the documentation for the Time.parse method by typing the following command at your terminal:

ri Time.parse

or by visiting the following URL:

http://www.ruby-doc.org/core/classes/Time.html#M000297

If you do not specify this parameter, then Rassmalog will use the modification time of this source file instead.

5.1.3  tags (Optional)

The categories/labels which classify this blog entry.

5.1.4  output_file (Optional) (eRuby)

A relative path (with respect to the output/ directory) to the output HTML file for this blog entry.

5.1.5  hide (Optional)

Controls whether this entry is displayed in the lists of tags, archives, and recent/all entries.

5.1.6  generate_toc (Optional)

Overrides the generate_toc parameter that is defined in the main blog configuration file (config/blog.yaml). This parameter controls whether a table of contents is generated for this blog entry.

5.1.7  summary (Optional) (eRuby) (HTML)

Overrides the automatic summarization mechanism, which is defined in the config/entry.erb template, by allowing you to specify a predefined summary for this blog entry.

5.1.8  your_own_parameter1 (Example)

This is an example of how you can specify your own custom parameters and use them in the content of this blog entry.

5.1.9  text (Required) (eRuby) (HTML)

The content of this blog entry.

In this parameter, you can use the following predefined variables inside eRuby directives:

  • BLOG – data from the blog configuration file
  • LANG – data from the translation file
  • ENTRIES – array of all blog entries (Entry objects)
  • NEW_ENTRIES – array of recent blog entries (Entry objects)
  • TAGS – array of all tags (Section objects)
  • ARCHIVES – array of all archives (Section objects)
  • @entry – an Entry object representing THIS blog entry
2439913b6226e8b8045aefda15c383409471697dbcf313f5b90d4b0c591928eaf3f6cf88efca37db2e8e048138d6a9b7579603a52fa9b8f9c7ea33e6d957a6b82445b6a2ce4f73b36df913e6caa287dd5b16772c7d958c43d664071c4078e51c7b7af10b5df28b8974a79e3f19fb4e9b71d788983dcfd69d27eb304ccd2732b116c6c9dbb16fa74ea2aafe46cabbed1001ac6cc6d4f4f48bbed51ecec5bd7b8321c551ccaa8978e289c3ebeb5fe129c5957c5ce3

5.2  eRuby directives

The text of a blog entry is treated as an eRuby template. Thus, you can use eRuby directives (which appear within <% and %> tags) in the text of your blog entries.

For example, putting the following text in a blog entry:

<% 3.times do %>

* Hello World!
<% end %>

Produces the following result:

  • Hello World!
  • Hello World!
  • Hello World!

5.2.1  Including the content of another file

To include the content of another file inside the text of a blog entry, you can use the following eRuby directive:

<%= File.read('path-to-your-file') %>

If the included file contains characters that might be interpreted as HTML, then we should properly escape those characters using the ERB::Util#h method:

<%= h File.read('path-to-your-file') %>

5.3  Relative URLs to output files

Rassmalog adjusts all relative URLs in the final HTML output to be relative to the output/ directory. This is done to give all blog entries (regardless of how deep they are inside the input/ directory) a common way to access files. As a result, some extra work is necessary to access files that are relative to a blog entry itself.

For example, suppose that (1) we have the following directory structure and that (2) the input/food/fruit/banana.yaml blog entry contains the ../nuts/walnut.html relative URL.

  • input/
    • food/
      • fruit/
        • banana.yaml
      • nuts/
        • walnut.yaml
  • output/
    • food/
      • fruit/
        • banana.html
      • nuts/
        • walnut.html

Rassmalog will change ../nuts/walnut.html into ../../../nuts/walnut.html by adding a ../../ prefix. As a result, the changed URL is now referring to a nonexistent nuts/walnut.html file that resides one level above the output/ directory!

One solution is to manually rewrite to rewrite the original URL to be relative to the output/ directory: ../nuts/walnut.html becomes food/nuts/walnut.html.

Another solution is to use an eRuby directive to add the blog entry source file’s parent directory’s path to the relative URL: ../nuts/walnut.html becomes

<%= File.dirname(@entry.output_url) %>/../nuts/walnut.html

5.4  Table of contents generation

A table of contents is automatically generated from headings (<h1> through <h6> for HTML and h1. through h6. for Textile) found in the text of a blog entry.

Headings are numbered in the style of LaTeX; these numbers contain a hyperlink back to the table of contents for easier navigation.

If you want to disable the table of contents for a particular blog entry, then see the generate_toc parameter in the list of parameters above.

If you want to disable the table of contents globally, for all blog entries, then see the generate_toc parameter in your config/blog.yaml configuration file.

5.5  Syntax coloring for source code

Syntax coloring is automatically added to source code found inside the <code> and </code> HTML tags. Note that in Textile, any text enclosed within a pair of at-signs (@ and @) is also considered to be source code.

The following programming languages are currently supported by CodeRay, the default syntax coloring software used in Rassmalog:
  • Ruby
  • C
  • Delphi
  • HTML
  • RHTML (Rails)
  • Nitro-XHTML

This feature can be disabled or changed by editing the config/format.rb file accordingly.

5.5.1  Specifying the programming language

Because different programming languages have different syntax coloring schemes, you can specify the language of your source code using the lang attribute to ensure that only the appropriate coloring scheme is used. Note that unless the lang attribute is specified, Ruby is assumed to be the programming language of all source code by default.

For example, here is some source code without the lang attribute:

# Ruby ###########################
def hello
  puts "Hello world!"
end


/* C ****************************/
#include <stdio.h>
int main(int argc, char **argv) {
  printf("Hello world!\n");
  return 0;
}


<!-- HTML ----------------------->
<html>
  <body>
    Hello world!
  <body>
</html>

And here is the same source code with a lang="c" attribute:

# Ruby ###########################
def hello
  puts "Hello world!"
end


/* C ****************************/
#include <stdio.h>
int main(int argc, char **argv) {
  printf("Hello world!\n");
  return 0;
}


<!-- HTML ----------------------->
<html>
  <body>
    Hello world!
  <body>
</html>

And here is the same source code with a lang="html" attribute:

# Ruby ###########################
def hello
  puts "Hello world!"
end


/* C ****************************/
#include <stdio.h>
int main(int argc, char **argv) {
  printf("Hello world!\n");
  return 0;
}


<!-- HTML ----------------------->
<html>
  <body>
    Hello world!
  <body>
</html>

5.5.2  Smart sizing of source code

Source code is automatically sized to be displayed as either a line or paragraph of text, depending on whether it contains line breaks.

For example, here is a single line of code:

life = true or false

And here is a paragraph of code:

life =
true or false

This feature can be disabled or changed by editing the config/format.rb file accordingly.

5.6  Protecting verbatim text

Sometimes you just need to protect some text from being mangled by the text-to-HTML conversion process (which is governed by config/format.rb). In such cases, you can wrap the text you want to proctect within <noformat> and </noformat> tags.

Note that this is a feature of the default config/format.rb file provided with Rassmalog. If you defined your own text-to-HTML conversion scheme, then this feature might not work.

Chapter 6
Hacking

You can obtain the latest source code from the Darcs repository:

darcs get http://rassmalog.rubyforge.org/src/ rassmalog

6.1  API documentation

Method declaration Description
Entry#parent()
Entry::new(aData = {})
aData:the content of this Entry
Entry#hide?()

Returns true if this entry is hidden (the ‘hide’ parameter is enabled).

Entry#summary()

Returns the summarized HTML content of this blog entry. If there is no summary or summarization is not possible, then returns nil.

Entry#absolute_url()

Returns the absolute URL to this entry.

Entry#<=>(aOther)

Sort chronologically.

Entry#html()

Transforms the text of this entry into HTML and returns it.

Entry#comment_url()

Returns a URL for submiting comments about this entry.

Chapter::new(aName)
Chapter#[](aName, *args)

Allows you to access a section using its name or through the usual Ruby array access idioms.

Node#title()

Returns the user-defined title for this node‘s content.

Node#id()

Returns the user-defined indentifer for this node.

Node#url()

Returns a unique URI fragment for this node.

Node#list_url()

Returns the URI fragment for the location in the table of contents / list of figures that points this node.

Icon#css_class()

Returns the CSS class for this icon.

Hash#to_html_atts()

Transforms this hash into a string of HTML attribute key=value pairs.

Language::new(aData = {})
Language#[](aPhrase, *aArgs)

Translates the given string and then formats (see String#format) the translation with the given placeholder arguments. If the translation is not available, then the given string will be used instead.

Template::new(aName, *args)
aName:String that replaces the ambiguous ’(erb)’ identifier in stack traces, so that the user can better determine the source of an error.
args:Arguments for ERB::new
Template#render_with(aInstVars = {})

Renders this template within a fresh object that is populated with the given instance variables.

Section#url()

Path (relative to the output/ directory) to the HTML output file of this object.

Section::new(aName, aChapter)
Section#<=>(aOther)

Sort alphabetically.

String#to_html_entities()

Transforms this UTF-8 string into HTML entities.

String#to_uri_fragment()

Transforms this string into a valid URI fragment. See www.nmt.edu/tcc/help/pubs/xhtml/id-type.html

String#to_file_name()

Transforms this string into a vaild file name that can be safely used in a URL. See en.wikipedia.org/wiki/URI_scheme#Generic_syntax

String#to_html_entities()

Transforms this UTF-8 string into HTML entities.

String#to_uri_fragment()

Transforms this string into a valid URI fragment. See www.nmt.edu/tcc/help/pubs/xhtml/id-type.html

String#thru_erb(aBinding = Kernel.binding)

Passes this string through ERB and returns the result.

String#shell_escape()

Transforms this string into an escaped POSIX shell argument whilst preserving Unicode characters.

String#table_of_contents()

Builds a table of contents from XHTML headings (<h1>, <h2>, etc.) found in this string and returns an array containing [toc, text] where:

toc:the generated table of contents
text:a modified version of this string which contains anchors for the hyperlinks in the table of contents (so that the TOC can link to the content in this string)
SequenceMixin#next()

Returns the next section in the chapter.

SequenceMixin#prev()

Returns the previous section in the chapter.

SequenceMixin#sibling(aOffset)
TemplateMixin#template_name()

Basename of the template file, which resides in the config/ directory, used to render objects of this class.

TemplateMixin#template()

Returns the template used to render objects of this class.

TemplateMixin#template_ivar()

Returns the name of the instance variable for objects of this class. This variable is used in the template of this class.

TemplateMixin#url()

Path (relative to the output/ directory) to the HTML output file of this object.

TemplateMixin#to_html(aOpts = {})

Transforms this object into HTML.

TemplateMixin#render(aOpts = {})

Renders a complete HTML page for this object.

TemplateMixin#to_link(aName = nil, aAnchor = nil)

Returns a relative hyperlink to this object.

aName:sets the name of the hyperlink, if given
aAnchor:adds a URI fragment to the hyperlink‘s URL, if given