Path: femto.rb
Last Update: Wed Feb 25 13:55:59 +0100 2009

Femto - A very small Bulletin Board

Copyright 2009 Stefan Kamphausen <www.skamphausen.de>

Written and (currently) maintained by Stefan Kamphausen

This program is free software. You can re-distribute and/or modify this program under the same terms as Ruby itself, Ruby Distribute License or GNU General Public License.


Femto is a very small (hence the name) bulletin board software suited to be used in a CGI environment.

One specific design purpose is, that, if you want to use Femto, you just drop it in a CGI directory and you‘re done. No database, no libraries, no installation, no nothing.

See rdoc or —longhelp for more documentation.


  • Click on "New" to add a post.
    • A post needs a section (drop down).
    • A post needs a header (max 40 chars, settable in the file).
    • A post needs a description (max 200 chars, settable in the file).
  • Click on the header of an item to fetch the description.
  • Deletion is either available for every visitor as a link labled "delete" in the footer of an item or as a separate page which is shown after a post and contains a "secret" link to the deletion page. No questions, no undo.


The Easy Way

Put it into any CGI directory and adjust the $URL at the top of this file to reflect the installation. (Unfortunately Rubys cgi.rb does not (yet?) generate the access URL automatically as Perls CGI does.) Then adjust the sections way down in the file

The Sophisticated Way

You, know: Use the source!

This file includes the Javascipt and the CSS down below, following the spcial END token. Adjust this to your needs.

And if that isn‘t enough: change the source! You‘re not familiar with Ruby? Well, either this is the software you start using as your entry point into the Ruby world, or you don‘t use it at all.


Femto want‘s to be a cooperative simple bulletin board:

  • Easy installation (see above)
  • No requirements (no database, or non-standard libraries)
  • No usermanagement (no sessions, no cookies, no identification)
  • No errorhandling. If you use Femto in a wrong way, it will fail, break or damage your system.
  • Cooperative collaboration. You know, back in the university, there was the black board, made of zettles (little pieces of paper). Everyone could anonymously post notes, and remove others. Every one was fair, well almost. It worked!


  • Remove items not only based on age, but on item count (per section?).


  • Encoding-handling in Post, PStore and display.
  • Security testing, we want to be absolutely sure that those parameter can‘t be misused.
  • Maxpost-size based upon Content-Length?

What‘s happening (Internals)

  • All items are stored in a simple PStore file, don‘t expect too much performance.
  • When you post an item only the first 40 chars from the header and the first 200 chars of the description are stored (settable via MAX_DESC_SIZE and MAX_HEADER_SIZE in the script).
  • Whenever you post an item, the item store is searched for old items (see MAX_AGE). As long as you‘re only viewing items the older ones remain active.

Required files

cgi   digest/md5   pstore   getoptlong   rdoc/usage  



FEMTO_VERSION = "1.3"   Version
ITEM_STORE = "../femto_items.db"   Where to store the items
MAX_AGE = 60 * 60 * 24 * 30   When will old items be removed.
ASSET_EXPIRE_AGE = 60 * 60 * 24   When will assets (JS, CSS) expire?
MAX_HEADER_SIZE = 40   The maximum size of the header of an item
MAX_DESC_SIZE = 200   The maximum size of the description
PUBLIC_DELETE_LINK = true   Set this to true to see a deletion link on each post or to false to get the secret deletion link upon posting a message

Public Instance methods

The main CGI function

This function will be called when the option —debug was given. Obviously for debugging only.