Answers below.

On Tue, 30 Aug 2005, why the lucky stiff wrote:

So, let me see if I understand.  You're using Hobix where others
might use ActiveRecord?  I'm guessing that you're just using Hobix
API calls inside your controllers?  I'd really like to hear more
about how this really works. Maybe you could explain a specific
example which stuffs data in Hobix.

I actually do use ActiveRecord, I just don't have any database tables.
I just use AR because it gets me some handy Rails fu. The object in AR
contains an entry index and the weblog object, and methods in the
model act on those, doing saves, regens, and upgens as necessary.  The
controller preps data for views and packages it for the model,
handling any exceptions that come back.  Hobix's filesystem storage
plugin goes substantially unused, as the site sits on a network-based
distributed user data store.

Here's an example.  Note that I was new to Ruby, to Rails, and to
Hobix when I started on this, so it isn't as fluent as it will be in
the future.

# controller: (@b is the model object, a Podcast)
def personalize
  case @request.method
  when :get
    @b=Podcast.find(@session['user']['login']) unless @b
  when :post
    @b=Podcast.find(@session['user']['login']) unless @b
    linklist=nil
    unless @params['link_name'].empty?
      [EMAIL PROTECTED]'link_name'].values.zip(@params['link_place'].values)
    end
    vars=Hash.new
    vars['podcast_title'[EMAIL PROTECTED]'podcast']['title']
    vars['podcast_tagline'[EMAIL PROTECTED]'podcast']['tagline']
    vars['podcast_author'[EMAIL PROTECTED]'user']['login']
    vars['linklist']=linklist
    @b.save(vars)
    flash['notice']="Changes saved."
    redirect_to :action => "show"
  end
end

# model:
def save(vars=nil)
  @podcast=Hobix::Weblog.load(@hobix_yaml)
  if vars
    @podcast.title=vars["podcast_title"] if vars['podcast_title']
    @podcast.tagline=vars["podcast_tagline"] if vars['podcast_tagline']
    if vars['linklist']
      @podcast.linklist = Hobix::LinkList.new
      @podcast.linklist.links=YAML::Omap.new
      vars['linklist'].each do |k,v|
        next if k.nil? or v.nil? or k.empty? or v.empty?
        @podcast.linklist.links[k]=v
      end
    end
  end

  @podcast.save
  @podcast=Hobix::Weblog::load(@hobix_yaml)
  # full regen is necessary if hobix.yaml changes
  @podcast.regenerate
end


How did you do enclosures?  Are they entry attachments or something?

I have an additional object on the Entry, a Hash that I just call
'cast'.  It has the three required fields (length, URL, MIME type),
and the URL is just a call back to a method in another controller that
sends the media file from its designated place in the user data store.

Since the site lets you do all kinds of different things to media
files, I couldn't attach them to any particular Entry object.

--
Justin
_______________________________________________
Hobix-is-the-way mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/hobix-is-the-way

Reply via email to