<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: typo code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 15:55:45 GMT</pubDate>
    <description>DZone Snippets: typo code</description>
    <item>
      <title>Typo export to Wordpress WXR (script version)</title>
      <link>http://snippets.dzone.com/posts/show/4326</link>
      <description>I tried to use this method here: http://snippets.dzone.com/posts/show/3264 however my typo blog was too slow and it kept timing out (which is why we're switching to wordpress anyway...).  So I stole the code and hacked it up a bit so it could be run as a script.&lt;br /&gt;&lt;br /&gt;Put this in $RAILS_ROOT/script/wp_export.rb, and run it like:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;RAILS_ENV=production ./script/wp_export.rb &gt; out.wxr&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Import it with the "Import Wordpress" tool in your wordpress blog's admin interface.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/env ruby&lt;br /&gt;require File.dirname(__FILE__) + '/../config/boot'&lt;br /&gt;require 'environment'&lt;br /&gt;&lt;br /&gt;require 'application'&lt;br /&gt;&lt;br /&gt;# we need a controller to generate html output&lt;br /&gt;class FakeController &lt; ApplicationController&lt;br /&gt;  include ActionView::Helpers::TextHelper&lt;br /&gt;  include ActionView::Helpers::TagHelper&lt;br /&gt;end&lt;br /&gt;fake_controller = FakeController.new&lt;br /&gt;&lt;br /&gt;articles = Article.find(:all)&lt;br /&gt;&lt;br /&gt;xml = Builder::XmlMarkup.new(:target =&gt; STDOUT, :indent =&gt; 2)&lt;br /&gt;&lt;br /&gt;xml.instruct! :xml, :version=&gt;"1.0", :encoding=&gt;"UTF-8"&lt;br /&gt;xml.rss 'version' =&gt; "2.0",&lt;br /&gt;        'xmlns:content' =&gt; "http://purl.org/rss/1.0/modules/content/",&lt;br /&gt;        'xmlns:wfw' =&gt; "http://wellformedweb.org/CommentAPI/",&lt;br /&gt;        'xmlns:dc' =&gt; "http://purl.org/dc/elements/1.1/",&lt;br /&gt;        'xmlns:wp' =&gt; "http://wordpress.org/export/1.0/" do&lt;br /&gt;  xml.channel do&lt;br /&gt;    xml.title "The Robot Co-op"&lt;br /&gt;    xml.link "http://www.robotcoop.com"&lt;br /&gt;    xml.language "en-us"&lt;br /&gt;    xml.ttl "40"&lt;br /&gt;    xml.description "Robot coop blog"&lt;br /&gt;&lt;br /&gt;    articles.each do |a|&lt;br /&gt;        xml.item do&lt;br /&gt;          xml.title a.title&lt;br /&gt;          xml.content(:encoded) { |x| x &lt;&lt; a.html(fake_controller, :all) }&lt;br /&gt;          xml.pubDate a.published_at.rfc2822&lt;br /&gt;          xml.guid "urn:uuid:{a.guid}", "isPermaLink" =&gt; "false"&lt;br /&gt;          author = a.user.name rescue a.author&lt;br /&gt;          xml.author author&lt;br /&gt;          xml.dc :creator, author&lt;br /&gt;          for category in a.categories&lt;br /&gt;            xml.category category.name&lt;br /&gt;          end&lt;br /&gt;          for tag in a.tags&lt;br /&gt;            xml.category tag.display_name&lt;br /&gt;          end&lt;br /&gt;          xml.wp :post_id, a.id&lt;br /&gt;          xml.wp :post_date, a.published_at.strftime("%Y-%m-%d %H:%M:%S")&lt;br /&gt;          xml.wp :comment_status, 'closed'&lt;br /&gt;          xml.wp :ping_status, 'closed'&lt;br /&gt;          xml.wp :post_name, a.permalink&lt;br /&gt;          xml.wp :status, 'publish'&lt;br /&gt;          xml.wp :post_parent, '0'&lt;br /&gt;          xml.wp :post_type, 'post'&lt;br /&gt;          for comment in a.comments&lt;br /&gt;            xml.wp(:comment) do&lt;br /&gt;              xml.wp :comment_id, comment.id&lt;br /&gt;              xml.wp :comment_author, comment.author&lt;br /&gt;              xml.wp :comment_author_email, comment.email&lt;br /&gt;              xml.wp :comment_author_url, comment.url&lt;br /&gt;              xml.wp :comment_author_IP, comment.ip&lt;br /&gt;              xml.wp :comment_date, comment.published_at.strftime("%Y-%m-%d %H:%M:%S")&lt;br /&gt;              xml.wp(:comment_content) { |x| x &lt;&lt; comment.body }&lt;br /&gt;              xml.wp :comment_approved, '1'&lt;br /&gt;              xml.wp :comment_parent, '0'&lt;br /&gt;            end&lt;br /&gt;          end&lt;br /&gt;       end&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 18 Jul 2007 23:41:54 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4326</guid>
      <author>laurelfan (Laurel Fan)</author>
    </item>
    <item>
      <title>Typo export to WordPress WXR</title>
      <link>http://snippets.dzone.com/posts/show/3264</link>
      <description>If you want to move from Typo to Wordpress, you can use this to export the strange Wordpress RSS file format (comments and all).&lt;br /&gt;&lt;br /&gt;Just add this to the XmlController :&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  def wp&lt;br /&gt;    @articles = Article.find( :all, :include =&gt; [:categories, :tags, :user, :blog])&lt;br /&gt;  end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;And then add this file (app/views/xml/wp.rxml):&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;// insert code here..&lt;br /&gt;xml.instruct! :xml, :version=&gt;"1.0", :encoding=&gt;"UTF-8"&lt;br /&gt;&lt;br /&gt;xml.rss 'version' =&gt; "2.0", 'xmlns:content' =&gt; "http://purl.org/rss/1.0/modules/content/", 'xmlns:wfw' =&gt; "http://wellformedweb.org/CommentAPI/", 'xmlns:dc' =&gt; "http://purl.org/dc/elements/1.1/", 'xmlns:wp' =&gt; "http://wordpress.org/export/1.0/" do&lt;br /&gt;  xml.channel do&lt;br /&gt;    xml.title @feed_title&lt;br /&gt;    xml.link @link&lt;br /&gt;    xml.language "en-us"&lt;br /&gt;    xml.ttl "40"&lt;br /&gt;    xml.description this_blog.blog_subtitle&lt;br /&gt;&lt;br /&gt;    @articles.each do |a|&lt;br /&gt;        xml.item do&lt;br /&gt;          xml.title post_title(a)&lt;br /&gt;          xml.content(:encoded) { |x| x &lt;&lt; '&lt;![CDATA[' + a.full_html + ']]&gt;' }&lt;br /&gt;          xml.pubDate a.published_at.rfc2822&lt;br /&gt;          xml.guid "urn:uuid:#{a.guid}", "isPermaLink" =&gt; "false"&lt;br /&gt;          author = a.user.name rescue a.author&lt;br /&gt;          xml.author author&lt;br /&gt;          xml.dc :creator, author&lt;br /&gt;          for category in a.categories&lt;br /&gt;            xml.category category.name&lt;br /&gt;          end&lt;br /&gt;          for tag in a.tags&lt;br /&gt;            xml.category tag.display_name&lt;br /&gt;          end&lt;br /&gt;          xml.wp :post_id, a.id&lt;br /&gt;          xml.wp :post_date, a.published_at.strftime("%Y-%m-%d %H:%M:%S")&lt;br /&gt;          xml.wp :comment_status, 'closed'&lt;br /&gt;          xml.wp :ping_status, 'closed'&lt;br /&gt;          xml.wp :post_name, a.permalink&lt;br /&gt;          xml.wp :status, 'publish'&lt;br /&gt;          xml.wp :post_parent, '0'&lt;br /&gt;          xml.wp :post_type, 'post'&lt;br /&gt;          for comment in a.comments&lt;br /&gt;            xml.wp(:comment) do&lt;br /&gt;              xml.wp :comment_id, comment.id&lt;br /&gt;              xml.wp :comment_author, comment.author&lt;br /&gt;              xml.wp :comment_author_email, comment.email&lt;br /&gt;              xml.wp :comment_author_url, comment.url&lt;br /&gt;              xml.wp :comment_author_IP, comment.ip&lt;br /&gt;              xml.wp :comment_author_date, comment.published_at.strftime("%Y-%m-%d %H:%M:%S")&lt;br /&gt;              xml.wp(:comment_content) { |x| x &lt;&lt; comment.full_html }&lt;br /&gt;              xml.wp :comment_approved, '1'&lt;br /&gt;              xml.wp :comment_parent, '0'&lt;br /&gt;            end&lt;br /&gt;          end&lt;br /&gt;        end&lt;br /&gt;    end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Then hit your typo blog at http://myblog/xml/wp and save the file to import through the WordPress interface.</description>
      <pubDate>Tue, 09 Jan 2007 23:52:47 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3264</guid>
      <author>schacon (Scott Chacon)</author>
    </item>
    <item>
      <title>measure map tags for typo</title>
      <link>http://snippets.dzone.com/posts/show/874</link>
      <description>See my associated &lt;a href="http://weblog.digett.com/articles/2005/11/07/measure-map"&gt;blog post&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# /app/views/articles/_article.rhtml&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;!--&lt;br /&gt;if(!mmposts){var mmposts=[];}mmposts[mmposts.length]="&lt;%= article.id %&gt;";&lt;br /&gt;//--&gt;&lt;/script&gt;&lt;br /&gt;&lt;!-- mmp mmid:&lt;%= article.id %&gt; mmdate:&lt;%= article.created_at.to_s(:db) %&gt; mmurl:&lt;%=h article_url(article, true) %&gt; mmtitle:&lt;%=h article.title %&gt; --&gt;&lt;br /&gt;&lt;br /&gt;# /app/views/articles/_comment.rhtml&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;!--&lt;br /&gt;if(!mmcomments){var mmcomments=[];}mmcomments[mmcomments.length]="&lt;%= comment.id %&gt;";&lt;br /&gt;//--&gt;&lt;/script&gt;&lt;br /&gt;&lt;!-- mmc mmid:&lt;%= comment.id %&gt; mmdate:&lt;%= comment.created_at.to_s(:db) %&gt; mmauthor:&lt;%=h comment.author %&gt; --&gt;&lt;br /&gt;&lt;br /&gt;# /app/views/articles/read.rhtml&lt;br /&gt;# This is the same as the _article.rhtml snippet, but using the @article instance var instead of the article local var&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;!--&lt;br /&gt;if(!mmposts){var mmposts=[];}mmposts[mmposts.length]="&lt;%= @article.id %&gt;";&lt;br /&gt;//--&gt;&lt;/script&gt;&lt;br /&gt;&lt;!-- mmp mmid:&lt;%= @article.id %&gt; mmdate:&lt;%= @article.created_at.to_s(:db) %&gt; mmurl:&lt;%=h article_url(@article, true) %&gt; mmtitle:&lt;%=h @article.title %&gt; --&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;There's also a javascript include to add to the bottom of your typo theme, but there's no customization required...</description>
      <pubDate>Tue, 08 Nov 2005 03:18:51 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/874</guid>
      <author>technoweenie (Rick Olson)</author>
    </item>
    <item>
      <title>redirecting wordpress xml links to typo in lighttpd</title>
      <link>http://snippets.dzone.com/posts/show/696</link>
      <description>Update: go for the simplest regex possible...&lt;br /&gt;&lt;br /&gt;&lt;code&gt;$HTTP["host"] =~ "awesomerailsapp.com" {&lt;br /&gt;  server.error-handler-404 = "/dispatch.fcgi"&lt;br /&gt;  server.document-root = "/awesomerailsapp/public/"&lt;br /&gt;  url.redirect = (&lt;br /&gt;    "^/feed/atom" =&gt; "http://awesomerailsapp.com/xml/atom/feed.xml",&lt;br /&gt;    "^/feed" =&gt; "http://awesomerailsapp.com/xml/rss/feed.xml",&lt;br /&gt;    "^/wp-rss2\.php" =&gt; "http://awesomerailsapp.com/xml/rss/feed.xml",&lt;br /&gt;    "^/wp-atom\.php" =&gt; "http://awesomerailsapp.com/xml/atom/feed.xml",&lt;br /&gt;    # my wp article format to typo's&lt;br /&gt;    "^/(\d{4})/(\d{2})/(\d{2})/([\w-_]+)" =&gt; "/articles/$1/$2/$3/$4"&lt;br /&gt;  )&lt;br /&gt;&lt;br /&gt;  # bring on the rest of the config&lt;br /&gt;}&lt;/code&gt;</description>
      <pubDate>Sat, 10 Sep 2005 04:41:12 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/696</guid>
      <author>technoweenie (Rick Olson)</author>
    </item>
    <item>
      <title>Typo under lighttpd</title>
      <link>http://snippets.dzone.com/posts/show/323</link>
      <description>Example vhost of a typo install under lighttpd&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$HTTP["host"] =~ "typo.jasonhoffman.org" {&lt;br /&gt;server.document-root = "/home/jah/apps/typo/trunk/public/"&lt;br /&gt;server.error-handler-404   = "/dispatch.fcgi"&lt;br /&gt;server.indexfiles           = ( "dispatch.fcgi")&lt;br /&gt;server.errorlog = "/home/jah/logs/error.typo.log"&lt;br /&gt;  fastcgi.server = ( ".fcgi" =&gt;&lt;br /&gt;     ( "localhost" =&gt;&lt;br /&gt;       ( "socket" =&gt; "/home/jah/tmp/typo-jah.socket",&lt;br /&gt;                            "min-procs" =&gt; 1,&lt;br /&gt;                            "max-procs" =&gt; 5,&lt;br /&gt;         "bin-path" =&gt; "/home/jah/apps/typo/trunk/public/dispatch.fcgi",&lt;br /&gt;         "bin-environment" =&gt; ( "RAILS_ENV" =&gt; "production" )&lt;br /&gt;  )))&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 25 May 2005 18:36:35 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/323</guid>
      <author>jason (Jason Hoffman)</author>
    </item>
    <item>
      <title>Pretty archive URLs in Typo with Routes</title>
      <link>http://snippets.dzone.com/posts/show/31</link>
      <description>Tobi posted this as a new URL scheme for Typo.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;# allow neat perma urls&lt;br /&gt;map.connect 'articles/:year/:month/:day', :controller  =&gt; 'articles', &lt;br /&gt;     :action =&gt; 'find_by_date', &lt;br /&gt;     :year =&gt; /\d{4}/, :day =&gt; nil, :month =&gt; nil&lt;br /&gt;map.connect 'articles/:year/:month/:day/:title', :controller  =&gt; 'articles', &lt;br /&gt;     :action =&gt; 'permalink', :year =&gt; /\d{4}/&lt;/code&gt;</description>
      <pubDate>Sun, 03 Apr 2005 16:41:16 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/31</guid>
      <author>peter (Peter Cooperx)</author>
    </item>
  </channel>
</rss>
