# Custom code for 'news' widget class ::RuneBlog::Widget class News Type, Title = "news", "News" def initialize(repo) @blog = repo @datafile = "list.data" lines = File.readlines(@datafile) @data = lines.map {|line| line.chomp.split(/, */) } end def build write_main write_card end def _html_body(file, css = nil) file.puts "" if css file.puts " " file.puts " " file.puts " " end file.puts " " yield file.puts " \n" end def write_main mainfile = "#{Type}-main" css = "body { font-family: verdana }" File.open("#{mainfile}.html", "w") do |f| _html_body(f, css) do f.puts "

#{Title}



" @data.each do |file, frameable, title| title = title.gsub(/\\/, "") # kludge case frameable when "yes"; url_ref = "href = '#{file}'" when "no"; url_ref = %[href='#{file}' target='blank'] end css = "color: #8888FF; text-decoration: none; font-size: 21px" f.puts %[#{title}
] end end end end def write_card cardfile = "#{Type}-card" url = "widgets/#{Type}/#{Type}-main.html" File.open("#{cardfile}.html", "w") do |f| f.puts <<-EOS
#{Title}
EOS @data.each do |file, frameable, title| case frameable when "yes"; url_ref = _main(file) # remote, frameable when "no"; url_ref = _blank(file) # remote, not frameable end anchor = %[#{title}] wrapper = %[
  • #{anchor}
  • ] f.puts wrapper end f.puts <<-EOS
    EOS end end def edit_menu end def refresh end end end