# Custom code for 'links' widget require 'liveblog' class ::RuneBlog::Widget class Links Type, Title = "links", "External links" def initialize(repo) @blog = repo @datafile = input = "list.data" @lines = _get_data(@datafile) 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 @data = @lines.map! {|x| x.chomp.split(/, */, 3) } css = "body { font-family: verdana }" card_title = Title File.open("#{Type}-main.html", "w") do |f| _html_body(f, css) do f.puts "

#{card_title}



" url_ref = nil @data.each do |url, frameable, title| url_ref = "href = '#{url}'" url_ref << " target=blank" if frameable == "yes" css = "color: #8888FF; text-decoration: none; font-size: 21px" f.puts %[#{title}
] end end end end def write_card tag = "links" url = :widgets/tag/tag+"-main.html" card_title = "External links" # FIXME cardfile = "#{Type}-card" File.open("#{cardfile}.html", "w") do |f| f.puts <<-EOS
#{card_title}
EOS @data.each do |url2, frameable, title| f.puts "" main_ref = %[href="javascript: void(0)" onclick="javascript:open_main('#{url2}')"] tab_ref = %[href="#{url2}"] url_ref = (frameable == "yes") ? main_ref : tab_ref anchor = %[#{title}] wrapper = %[
  • #{anchor}
  • ] f.puts wrapper end f.puts <<-EOS
    EOS end end def edit_menu end def refresh end end end