# Custom code for 'pinned' widget class ::RuneBlog::Widget class Pinned Type, Title = "pinned", "Pinned posts" def initialize(repo) @blog = repo @datafile = "list.data" @lines = File.exist?(@datafile) ? File.readlines(@datafile) : [] end def _html_body(file, css = nil) # FIXME file.puts "" if css file.puts "
" file.puts " " file.puts " " end file.puts " " yield file.puts " \n" end def build posts = nil Dir.chdir(@blog.root/:posts) { posts = Dir["*"] } hash = {} @links = [] @lines.each do |x| num, title = x.chomp.split(" ", 2) hash[num] = title pre = '%04d' % num nslug = posts.grep(/#{pre}-/).first name = nslug[5..-1] link = name+".html" @links << [title, link] end write_main write_card end def write_main tag = Type card_title = Title css = "body { font-family: verdana }" mainfile = "#{tag}-main" File.open("#{mainfile}.html", "w") do |f| _html_body(f, css) do f.puts "" f.puts "