Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Thanks, sure I'll try to provide more information.

wc -l tells me that the whole framework is 1095 lines of code. It is composed of this different modules:

the main module handles the page generation in a functional way, I pass a method implementing a given page of the site and this method will get a parameter that is an object that holds the whole state of the page, so I've methods like isloggedin?, username, isadmin? and so on.

The same module will handle HTML generation. We rewrote it from scratch using method_missing so there are no preset tags. We write things like

  H.div('id'=>'foobar') { ... content ... }
And there are virtual tags we can define that are tags with specific pre-set properties. Also there are DSL-ish ways to write SELECTs, HTML lists, and other elements that written as H.tag(..) { } are not very easy to write/read.

Then there is the DB module that is somewhat similar but much more light than Active State, but the idea is to encapsulate a query and the single rows in objects with methods like .each, .save, .delete and so on. Example:

    users = fetchall("SELECT * FROM user")
    users.each{|user|
        user['username'] += "x"
        user.save
    }
Will append 'x' to every username in the DB. We restricted all the functionalities in order to don't have any kind of "rebuild" stage, just the information passed in every query from the DB are enough. There is not one class per table and so on it is pretty basic.

Another module is KFS: this is a class that will create a database in the filesystem in a very simple to manage way. Every time we have data we don't want to store in the DB we store it in KFS: the KFS root is inside the webroot so for example storing an image there will have the effect to be directly accessible by the web server. KFS is designed to don't have race conditions and is atomic. So it acts as a base for a caching system.

Other things implemented in this 1095 line so fo code is a DSL able to generate forms for us with the ability to automatically check for missed fields, to auto-fill parts of the form with defaults coming from a DB query or from a Ruby hash object and so on.

The framework is also able to do automatic pagination of everything we like to paginate just passing an anonymous function for data access and a block for item->html rendering. Send emails, generate Google Charts with little code, and... that's it.

Our configuration is Apache + mod_ruby + ruby 1.8 + MySQL

All the code was written in less than 30 days including 50% of the framework (the other 50% was already written by me in a week of the last summer).

Thanks for your comment.



Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: