[url=http://gdgdlog.net/log/show/130]http://gdgdlog.net/log/show/130[/url]
Builder::XmlMarkup?
def rss_test
require 'rss/maker'
rss = RSS::Maker.make("2.0") do |maker|
# channelの設定
maker.channel.about = url_for(:controller=>"rss", :action=>"new")
maker.channel.title = "ぐだろぐ"
maker.channel.description = "日記やメモなど、ぐだぐだ書いていくソーシャルネットワークに疲れた人向けのサービスです。"
maker.channel.link = url_for(:controller=>"top")
maker.channel.language = "ja"
# RSSのitemを更新日が新しい順番にソート
maker.items.do_sort = true
maker.items.max_size = 15
# itemの設定
Site.find(:all, : order=>"created_at DESC", :limit=>15).each do |log|
item = maker.items.new_item
item.title = log.site_name
item.link = url_for(:controller=>"log", :action=>"show", :id=>log.id)
item.dc_subject = url_for(:controller=>"log", :action=>"show", :id=>log.id)
# item.description = short_text(log.text, 200)
item.date = Time.parse(log.created_at.to_s)
end
end
@headers["Content-Type"] = 'application/xml; charset=UTF-8'
render :text => rss.to_s, :layout => false
end
Builder::XmlMarkup?
def rss_test1
xml = Builder::XmlMarkup.new
xmlobj = xml.rss("version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/") do
xml.channel do
xml.title("ぐだろぐ")
xml.link(url_for(:controller=>"top"))
xml.description "日記やメモなど、ぐだぐだ書いていくソーシャルネットワークに疲れた人向けのサービスです。"
xml.language "ja"
xml.ttl "60"
Site.find(:all, :order=>"created_at DESC", :limit=>15).each do |log|
xml.item do
xml.title(log.site_name)
# xml.description(short_text(log.text, 200))
xml.pubDate(log.created_at)
xml.link(url_for(:controller=>"log", :action=>"show", :id=>log.id))
xml.tag!("dc:creator", "ぐだろぐ")
end
end
end
end
render :xml => xmlobj
end