From 54386017ceacacb2a6990a29bffc7f93982572e4 Mon Sep 17 00:00:00 2001 From: Benjamin Kellermann Date: Thu, 26 Nov 2009 00:15:10 +0100 Subject: heavy code restructuring, moved common code to dudle.rb --- dudle.rb | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 dudle.rb (limited to 'dudle.rb') diff --git a/dudle.rb b/dudle.rb new file mode 100644 index 0000000..a94dfcf --- /dev/null +++ b/dudle.rb @@ -0,0 +1,91 @@ +############################################################################ +# Copyright 2009 Benjamin Kellermann # +# # +# This file is part of dudle. # +# # +# Dudle is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Affero General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# Dudle is distributed in the hope that it will be useful, but WITHOUT ANY # +# WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public # +# License for more details. # +# # +# You should have received a copy of the GNU Affero General Public License # +# along with dudle. If not, see . # +############################################################################ + +require "yaml" +require "cgi" + +$cgi = CGI.new + +olddir = File.expand_path(".") +Dir.chdir("..") +require "html" +require "poll" +require "config" +require "charset" +Dir.chdir(olddir) + +class Dudle + attr_reader :html, :table, :urlsuffix + def Dudle.tabs(active_tab) + ret = "
    " + [["Home",".."], + ["",""], + ["Poll","."], + ["History","history.cgi"], + ["Help","help.cgi"], + ["",""], + ["Edit Columns","edit_columns.cgi"], + ["Invite Participants","invite_participants.cgi"], + ["Access Control","access_control.cgi"], + ["Delete Poll","delete_poll.cgi"], + ["",""], + ["Customize","customize.cgi"] + ].each{|tab,file| + case tab + when active_tab + ret += "
  •  #{tab} 
  • " + when "" + ret += "
  • " + else + ret += "
  •  #{tab} 
  • " + end + } + ret += "
" + ret + end + def initialize(htmltitle, revision=nil) + if revision + @table = YAML::load(VCS.cat(revision, "data.yaml")) + else + @table = YAML::load_file("data.yaml") + end + @urlsuffix = File.basename(File.expand_path(".")) + + @html = HTML.new("dudle - #{@table.name} - #{htmltitle}") + @html.header["Cache-Control"] = "no-cache" + @html.add_css("../dudle.css") + + @html << < +