Thoth 0.1.4 released

Tuesday April 15, 2008 @ 10:22 PM (PDT)

Thoth 0.1.4 has been released. The only change is a fix for a silly memory leak and caching bug introduced in 0.1.3.

Comments

I didn’t know you could introduce memory leaks in Ruby. How did you manage to do that?

Bah, just because a language is garbage-collected doesn’t mean it can’t have memory leaks:

#!/usr/bin/env ruby
foo = 'bar'

loop do
  foo << 'bar'  
end

In this case, I was using the return value of the to_s method of an object as part of the cache key for the main index page when I should have been using the value of the inspect method. For this particular object, to_s returned a String that included a unique object id which changed for every request, which meant that every request added a new instance of the index page to the cache in memory.

It wasn’t a permanent leak, since the cache entries automatically expired after 60 seconds, but on a high-traffic blog, the excessive per-request memory usage could have resulted in memory exhaustion.

Good to know.

Thanks for the explanation!

Would like to know more: does the thoth blog support some sort of categorization? Can it be extended with other Ramaze controllers, etc.

Thanks!

Thoth supports freeform tagging, but doesn’t have support for fixed, predefined categories.

You can extend Thoth easily by writing plugins in Ruby. Plugins can override existing functionality (including controllers) or add new functionality. There’s a very basic example here.

Thanks for responding to the categorization question, now a few more . . .

1. Routing/urls: let’s say I create an “About” page within Thoth. Is there any way I can specify a unique url that doesn’t contain “page”? So I am looking to achieve “http://myblog.org/about” as opposed to “http://myblog.org/page/about” Is there a way to do this?

2. How do I specify using MySQL upon blog creation (with the thoth command)? My system defaults to SQLLite3. Presumably I need to create the database first in MySQL?

3. Search doesn’t appear to be working.

4. Finally, is there a preferred contact area for asking questions (other than the wiki area for reporting issues)?

5. Um, where do the actual ramaze files reside for thoth? I thought about poking around for the routing, but I can’t

Great software, btw.

Thanks again,

Matt

1. Thoth doesn’t allow you to configure routes, but this is a great idea. In the meantime, you could write a simple plugin that loads on startup and adds a Ramaze route like so: Ramaze::Route['/about'] = '/page/about'

2. You need to edit thoth.conf and change the database connection string. Once you’ve done that, create your MySQL database manually, then start Thoth and it will automatically create the necessary tables.

3. Thoth’s search currently uses the Yahoo! Search API rather than doing an internal search. Once your blog is public and has been indexed by the Yahoo! crawler, this should yield excellent results, but until then you won’t see anything. I’m currently working on internal search functionality for a future version of Thoth, but this is a very difficult thing to implement in a database-agnostic way.

4. Feel free to email me directly.

5. Thoth’s core libs are installed as a gem, so they’ll be in your gem include directory. This differs from system to system, but if you run thoth -h, it’ll display the paths for the default public and view directories. The core libs are in the /lib directory under the same root dir as the public and view directories. I wouldn’t recommend modifying anything there though, since you’ll lose your changes when you upgrade or reinstall Thoth. It’s best to use plugins for custom modifications.

I’ve been searching for a lightweight blogging engine and found thoth, which is waaaaaaaay more speedy than mephisto which I have installed for several of my clients. So far I’m impressed and absolutely love the simplicity. Thank you! That being said, I’m very tempted to give ramaze a whirl, given that I’m busy researching various MVC frameworks and am reluctant to use rails given the poor performance I have noticed with rails apps. Anyway, that’s another issue.

I would love to see a category/section feature, as Matt mentioned. I’m also looking forward to the resolution of the issue I posted via the thoth site ;-)

Hi Ryan

I’m trying to get set up so that as well as using my local view files, thoth uses my local versions of the models and controllers as well. But i can’t figure out how to set this up – can you give me any pointers?

many thanks!
max

If you want to make extensive changes, you should probably just fork the GitHub repo and make your changes directly to the source. Otherwise, you can create a load-time plugin that modifies or overrides Thoth’s existing classes.

There’s a guide here that describes how to create a runtime Thoth plugin; the only difference between that and a load-time plugin is that a load-time plugin is specified in the configuration file and is loaded as soon as Thoth starts. See the comments in the config file for more info. There are also some examples of load-time plugins here, courtesy of Jay Caines-Gooby.

i loaded thoth irb like this:
thoth —irb

It doesn’t seem to have loaded the classes – is it meant to? I guess i was expecting it to be like the rails console, where i can interface with the db through the model classes. Is that meant to be the case? Do i just need to require them in order to use them?

thanks!
max

thoth --irb drops you in at the state just before Thoth is initialized. Once you’re in the irb console, type Thoth.init_thoth to open the database connection and load Thoth’s models and controllers. Then you should be able to interact with the DB through the models.

Hi Ryan, me again. I’m struggling with the thoth_tags plugin, would you be able to help me out?

I thought that the purpose of the plugin was to add class and instance methods to Tag. But, i have to jump through a few hoops in order to use them. Here’s the plugin code (with some code edited out for clarity): the plugin adds a class method ‘top_tags’ (or does it??), and i’ve also added an instance method ‘children’.


  module Thoth; module Plugin
  
    module Tags
      Configuration.for("thoth_#{Thoth.trait[:mode]}") do
        ...
      end
      
      def children
        Tag.filter(:parent_id => self.id).all
      end
  
      class << self
        def top_tags(limit = 10)
          ..
        end
      end
    end
  
  end; end

And here’s me playing in irb:


  >> Thoth.init_thoth
  ...config stuff...
  [2009-06-28 12:34:47] INFO   Loaded plugin: thoth_redirect
  [2009-06-28 12:34:47] INFO   Loaded plugin: thoth_tags
  => ["delicious", "redirect", "tags"]
  #ok, we've loaded the plugin
  
  >> irb Thoth
  >> Tag
  => Thoth::Tag
  #so far so good
  
  #to access the method from the plugin i have to explicitly namespace it
  >> Tag.top_tags
  NoMethodError: undefined method `top_tags' for Thoth::Tag:Class
  	from (irb#1):3
  
  >> Thoth::Plugin::Tags.top_tags
  => [[#<Thoth::Tag @values={:name=>"academic", :parent_id=>nil, :id=>2}, 2], [#<Thoth::Tag @values={:name=>"phd&quot;, :parent_id=>2, :id=>3}, 1], [#<Thoth::Tag @values={:name=>"published", :parent_id=>2, :id=>5}, 1]]
  
  #if i include the plugin into the class...
  >> class Tag;include Thoth::Plugin::Tags;end
  => Thoth::Tag
  
  #...i can access my instance method...
  >> Tag.first.children
  => [#<Thoth::Tag @values={:name=>"phd&quot;, :parent_id=>2, :id=>3}, #<Thoth::Tag @values={:name=>"published", :parent_id=>2, :id=>5}]
  
  #...but the class method still doesn't work
  >> Tag.top_tags
  NoMethodError: undefined method `top_tags' for Thoth::Tag:Class
  	from (irb#1):6

Is top_tags meant to be a class method of Tag? And, should these methods automatically be available to the Tag class and instances without having to explicitly include them?

many thanks, max

No, the thoth_tags plugin isn’t meant to modify the Thoth::Tag model class. It only provides a Thoth::Plugin::Tags.top_tags method that can be called from a view to get a list of top tags.

Hi again Ryan. My thoth site has been live for a few days now but searching returns no results. Do i have to do anything to enable the yahoo search gubbins to start working?

thanks
max

btw we’re announcing the site on monday, it’s still under wraps for now. It should hopefully get a lot of hits though as it’s connected to an upcoming tv series about the internet. I can’t say more than that for now, but once it’s all out there i’ll give you the url to add to your “sites using Thoth” list. I do of course have a ‘Powered by Thoth’ link at the bottom :)

If there are few (or no) inbound links to your new website, it’s unlikely that the Yahoo! crawlers will have found it yet. Once your site starts getting links, the crawlers should find it and index it pretty quickly.

Thanks Ryan

The search is bringing back one result so far, which i guess means that it was indexed shortly after it went live (so four or five days ago). Will it be indexed more frequently as it’s web presence grows, do you know?

Talking of growing its presence, you can add “http://alekskrotoski.com” to your list of ‘sites using Thoth’. Thanks again for all your help. I have to say as well that after my initial problems, modifying thoth to suit my site’s needs has been easy and actually a joy. Cheers! max

Yeah, as the site increases in popularity and gains more inlinks, you should see more results in the index and quicker crawling overall.

To speed things up a little, you can also submit your sitemap (autogenerated by Thoth at http://alekskrotoski.com/sitemap) to Yahoo! Site Explorer. That will tell the crawler about every page and blog post on the site, and it’ll refresh the sitemap and recrawl more frequently.

Nice work on the site, by the way.

Thanks ryan. I’ll need to tweak the sitemap because most of the navigation is done using tags (the navbar is mainly just links to tags) and the sitemap seems to only have the posts in it.

re the site – thanks! I just (!) did the coding, the design was by someone else. :) Our mutual friend Jay Gooby helped me with the apache/slicehost setup as well.

Copyright © 2002-2012 Ryan Grove. All rights reserved.
Powered by Thoth.