Hi all,

New to typo, new to rails, new to ruby. Looking for a bit of assistance in 
modifying the del.icio.us <http://del.icio.us> sidebar in Typo. What I 
basically want to do is add a text, non-link description to each of the 
del.icio.us <http://del.icio.us> links that are fed into my site. I've tried 
editing various bits of the ruby code in the controllers, and adding item 
collections into the sidebar code, but I keep coming up with errors.

I'm basically trying to replicate what's been done on this site:

http://www.7nights.com/asterisk/

On my own site:

http://www.yesterdaywasdramatic.com


Thanks in advance for any bit help you offer.

Kyle
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://rubyforge.org/pipermail/typo-list/attachments/20050804/b4cc49dd/attachment.htm
From justus at ryoohki.net  Thu Aug  4 16:12:30 2005
From: justus at ryoohki.net (Justus Pendleton)
Date: Thu Aug  4 16:06:38 2005
Subject: [typo] blosxom entry importer
Message-ID: <[EMAIL PROTECTED]>

Attached is the importer I wrote to get my blosxom entries into Typo.
It is my first ruby script and largely based on the other files in
db/converters.  Blosxom has a ton of plugins and this script only
understands the few I use: meta-markup, meta-author, entries cache
(meta-creation_date), seemore.  You're on your own for comments and
flavours :)
-------------- next part --------------
#!/usr/bin/env ruby
# vim: ts=2 sw=2

require File.dirname(__FILE__) + '/../../config/environment'
require 'optparse'
require 'etc'
require 'article'
require 'category'
require 'html_engine'

class BlosxomMigrate
  attr_accessor :options

  def initialize
    self.options = {}
    self.parse_options
    self.convert_entries
  end

  def convert_entries
                blosxom_entry_extension = "txt"
                Dir.chdir(self.options[:dir])
                Find.find(".") { |filename|
                        if filename =~ /(.*)\.#{blosxom_entry_extension}$/
                                category = File.dirname($1[2..-1])
                                entryname = File.basename($1[2..-1])

                                puts("Parsing #{filename}")

                                if category == '.'
                                        categories = nil
                                else
                                        categories = category.split('/')
                                end

                                if categories
                                        categories.each do |cat|
                                                # there was a category 
associated with this post so add it to the DB
                                                Category.create('name' => cat) 
unless Category.find_by_name(cat)
                                        end
                                end

                                a = Article.new

                                # use the blosxom filename for the permalink
                                a.permalink = entryname

                                uid = File.stat(filename).uid
                                user = Etc.getpwuid(uid).name

                                # these can be overridden by meta keywords
                                # but we use these for defaults
                                a.author = user
                                a.created_at = File.stat(filename).mtime
                                a.text_filter = 'none'

                                fp = File.open(filename, "r")
                                title = fp.readline
                                title.chomp!
                                a.title = title

                                meta = true
                                do_extended = false
                                body = ''
                                extended = ''

                                fp.readlines.each { |line|
                                        if meta == true and line =~ /^\s*$/
                                                meta = false
                                                next
                                        end

                                        if meta == true
                                                case line
                                                        when /meta\-markup: 
(.*)$/
                                                                case $1
                                                                        when 
/textile/: a.text_filter = 'textile'
                                                                        when 
/markdown/: a.text_filter = 'markdown smartypants'
                                                                end
                                                        when 
/meta\-creation_date: (.*)$/
                                                                # 23/3/2005 
02:31:50
                                                                $1 =~ 
/(\d+)\/(\d+)\/(\d+) (\d+):(\d+):(\d+)/
                                                                time = 
Time.mktime($3, $2, $1, $4, $5, $6)
                                                                a.created_at = 
time
                                                        when /meta\-author: 
(.*)$/
                                                                a.author = $1
                                                        else
                                                                puts("Unknown 
meta: #{line}")
                                                end
                                        else
                                                if line =~ /\<\!\-\- more 
\-\-\>/
                                                        do_extended = true
                                                        next
                                                end

                                                if do_extended == true
                                                        extended << line        
                                                else
                                                        body << line
                                                end
                                        end
                                }

                                a.body = body

                                if extended != ''
                                        a.extended = extended
                                end

                                a.save

                                # make sure we add with categories
                                if categories
                                        categories.each do |cat|
                                                
a.categories.push_with_attributes(Category.find_by_name(cat), :is_primary => 1)
                                        end
                                end

                                # a.comments.create 
(author,email,url,body,created_at,updated_at)
                                # a.trackbacks.create 
(title,excerpt,url,ip,blog_name,created_at,updated_at)

                        end

                }
        end

  def parse_options
    OptionParser.new do |opt|
      opt.banner = 'Usage: blosxom.rb [options]'

      opt.on('-d', '--dir DIR', 'blosxom datadir to import') do |d|
        self.options[:dir] = d
      end

      opt.on_tail('-h', '--help', 'Show this message.') do
        puts opt
        exit
      end

      opt.parse!(ARGV)
    end

    unless self.options.include?(:dir)
      puts 'See blosxom.rb --help for help.'
      exit
    end
  end
end

BlosxomMigrate.new
From ben at incomumdesign.com  Thu Aug  4 17:13:55 2005
From: ben at incomumdesign.com (Benjamin Jackson)
Date: Thu Aug  4 17:08:02 2005
Subject: [typo] Delicious Sidebar - Timeout::Error
Message-ID: <[EMAIL PROTECTED]>

I'm getting a Timeout error in my production log after adding the 
del.icio.us component to my sidebar:

Timeout::Error (execution expired):
     /usr/local/lib/ruby/1.8/timeout.rb:42:in `new'
     /usr/local/lib/ruby/1.8/net/protocol.rb:83:in `connect'
     /usr/local/lib/ruby/1.8/net/protocol.rb:82:in `timeout'
     /usr/local/lib/ruby/1.8/timeout.rb:55:in `timeout'
     /usr/local/lib/ruby/1.8/net/protocol.rb:82:in `connect'
     /usr/local/lib/ruby/1.8/net/protocol.rb:64:in `initialize'
     /usr/local/lib/ruby/1.8/net/protocols.rb:37:in `initialize'
     /usr/local/lib/ruby/1.8/net/http.rb:430:in `open'
     /usr/local/lib/ruby/1.8/net/http.rb:430:in `do_start'
     /usr/local/lib/ruby/1.8/net/http.rb:419:in `start'
     /usr/local/lib/ruby/1.8/net/http.rb:324:in `start'
     /usr/local/lib/ruby/1.8/open-uri.rb:544:in `proxy_open'
     /usr/local/lib/ruby/1.8/open-uri.rb:525:in `direct_open'
     /usr/local/lib/ruby/1.8/open-uri.rb:169:in `open_loop'
     /usr/local/lib/ruby/1.8/open-uri.rb:164:in `catch'
     /usr/local/lib/ruby/1.8/open-uri.rb:164:in `open_loop'
     /usr/local/lib/ruby/1.8/open-uri.rb:134:in `open_uri'
     /usr/local/lib/ruby/1.8/open-uri.rb:424:in `open'
     /usr/local/lib/ruby/1.8/open-uri.rb:85:in `open'
     /app/models/aggregations/delicious.rb:27:in `refresh'
     /app/models/aggregations/delicious.rb:21:in `initialize'
     /app/helpers/application_helper.rb:115:in `new'
etc ...

The installation works fine on my OS X machine running lighttpd 1.4 and 
the latest mysql, but chokes on TxD's shared server. Running 492 from 
the trunk.
___________________
Ben Jackson
Diretor de Desenvolvimento

[EMAIL PROTECTED]
http://www.incomumdesign.com

Reply via email to