#!/usr/bin/ruby # -*- encoding: utf-8 -*- require 'erb' require 'rss' require '../bin/rss_cdata.rb' require '../bin/newsparser.rb' # Layout class class Layout extend ERB::DefMethod def_erb_method('layout', '../template/layout-news.html.erb') end # urlhead="http://vinelinux.org/" newsdir="./" topdir=".." tmpdir = topdir+'/template/' targetname="vlmagazine" rssname=targetname+'.rdf' header=File.open(topdir+"/template/header.tmpl") footer=File.open(topdir+"/template/footer.tmpl") # Create rss object rss = RSS::Maker.make("1.0") do |maker| maker.channel.about = "http://vinelinux.org/#{targetname}/rss" maker.channel.title = "Vine Linux Magazine" maker.channel.description = "Vine Linux Magazine です" maker.channel.link = "http://vinelinux.org/#{targetname}/" maker.items.do_sort = true # create news indexhtml contents newsindex = <Vine Linux Magazine

Vine Linux Magazine では Vine Linux を活用するのに便利な情報を記事として提供していきます。

掲載予定
- 定期的な VineSeed/VinePlus パッケージ紹介 (ほぼ月刊)
- Vine Linux 活用記事 (月1本程度で不定期)

記事一覧

EOF # create all news page Dir.open(newsdir) { |dir| for filename in dir.grep(/.dat$/).sort.reverse news = NewsParser.new IO.read(newsdir+filename) titletext = news.item['title'].gsub("\n","").gsub(/<[^>]+>/,"").strip $header_title = 'Vine Linux Magazine - '+titletext if (news.item['date'].gsub(/\,/,"") <= Time.now.strftime('%Y%m%d')) # index content newsindex += <<-EOF EOF # rss rssitem = maker.items.new_item rssitem.link = urlhead+"#{targetname}/#{filename.gsub(/.dat/,".html")}" rssitem.title = news.item['title'] rssitem.date = Time.parse(news.item['date'].gsub(/\,/,"/")) rssitem.dc_date = Time.parse(news.item['date'].gsub(/\,/,"/")) rssitem.content_encoded = news.item['description'] end # news page content newshtml = <<-EOF

Vine Linux Magazine
#{news.item['title']}

EOF if (news.item['author']) newshtml += <<-EOF
筆者: #{news.item['author']}
EOF end newshtml += <<-EOF
発行日: #{news.item['date']}

#{news.item['description']}

EOF # wrtite news page template = ERB.new(newshtml) newfile = open(filename.gsub(/.dat/,".html"), "w") newfile.puts Layout.new.layout { template.result } newfile.close end } newsindex += < EOF # write news indexhtml $header_title = 'Vine Linux Magazine' template = ERB.new(newsindex) newsindexhtml = open("index.html", "w") newsindexhtml.puts Layout.new.layout { template.result } newsindexhtml.close end # write news rss File.open(rssname, "w") do |file| file.puts rss.to_s end
[#{news.item['date']}] #{titletext}