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 --- participate.rb | 52 ++++++++++++---------------------------------------- 1 file changed, 12 insertions(+), 40 deletions(-) (limited to 'participate.rb') diff --git a/participate.rb b/participate.rb index 6efca03..f085e8f 100755 --- a/participate.rb +++ b/participate.rb @@ -19,26 +19,14 @@ # along with dudle. If not, see . # ############################################################################ -require "yaml" if __FILE__ == $0 - -require "cgi" - -$cgi = CGI.new - -olddir = File.expand_path(".") -Dir.chdir("..") -require "html" -require "poll" -load "config.rb" -Dir.chdir(olddir) - -table = YAML::load_file("data.yaml") +load "../dudle.rb" +$d = Dudle.new("Poll") if $cgi.include?("add_participant") if $cgi.include?("delete_participant") - table.delete($cgi["olduser"]) + $d.table.delete($cgi["olduser"]) else agreed = {} $cgi.params.each{|k,v| @@ -47,43 +35,27 @@ if $cgi.include?("add_participant") end } - table.add_participant($cgi["olduser"],$cgi["add_participant"],agreed) + $d.table.add_participant($cgi["olduser"],$cgi["add_participant"],agreed) end end -table.add_comment($cgi["commentname"],$cgi["comment"]) if $cgi["comment"] != "" -table.delete_comment($cgi["delete_comment"].to_i) if $cgi.include?("delete_comment") - -$html = HTML.new("dudle - #{table.name}") -$html.header["Cache-Control"] = "no-cache" -load "../charset.rb" -$html.add_css("../dudle.css") -$html.add_css("../print.css","print") +$d.table.add_comment($cgi["commentname"],$cgi["comment"]) if $cgi["comment"] != "" +$d.table.delete_comment($cgi["delete_comment"].to_i) if $cgi.include?("delete_comment") -$html.add_atom("atom.cgi") if File.exists?("../atom.rb") +$d.html.add_css("../print.css","print") - -$html << "" - -$html << Dudle::tabs("Poll") - -$html << < -HEAD +$d.html.add_atom("atom.cgi") if File.exists?("../atom.rb") # TABLE -$html << <#{table.name} +$d << <
- #{table.to_html($cgi['edituser'])} + #{$d.table.to_html($cgi['edituser'])} TABLE -$html << table.comment_to_html - -$html << "" +$d << $d.table.comment_to_html -$html.out($cgi) +$d.out($cgi) end -- cgit v1.2.3