Comments

why the lucky stiff why at hobix.com
Wed Sep 22 12:05:21 EDT 2004


Radley wrote:

> Do you plan on adding built-in functionality for comments on posts? If 
> not, would it be tough to add it yourself?

Comments will be out soon and, yes, they're very easy to add yourself.
Each comment is stored in your `entries' directory.  If you have an
entry at `entries/blog/iTiedMyShoe.yaml', then comments will be stored
at `entries/blog/iTiedMyShoe.comments'.  The file contains an Array of
Hobix::Entry objects.

The comment is considered an 'attachment' to the post.  Anything can act
as an attachment, so this opens the way for trackback files, ad-hoc hit
counters, any arbitrary stuff you want to attach to a post.

So, adding a comment basically goes like this:

  weblog = Hobix::Weblog.load( "/path/to/hobix.yaml" )
  comment = Hobix::Entry.new do |e|
     e.author = "commentor's name"
     e.content = "comment message"
     e.created = Time.now
  end
  comments = weblog.storage.load_attached( entry_id, "comments" ) rescue []
  comments << comment
  weblog.storage.save_attached( entry_id, "comments", comments )
  weblog.regenerate :update

_why






More information about the Hobix-is-the-way mailing list