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 --- edit_columns.rb | 60 ++++++++++++++------------------------------------------- 1 file changed, 14 insertions(+), 46 deletions(-) (limited to 'edit_columns.rb') diff --git a/edit_columns.rb b/edit_columns.rb index 9841bc2..474281c 100755 --- a/edit_columns.rb +++ b/edit_columns.rb @@ -19,62 +19,31 @@ # along with dudle. If not, see . # ############################################################################ -require "yaml" -require "cgi" - - if __FILE__ == $0 - -$cgi = CGI.new - -olddir = File.expand_path(".") -Dir.chdir("..") -require "html" -load "config.rb" -require "poll" -Dir.chdir(olddir) -# BUGFIX for Time.parse, which handles the zone indeterministically -class << Time - alias_method :old_parse, :parse - def Time.parse(date, now=self.now) - Time.old_parse("2009-10-25 00:30") - Time.old_parse(date) - end -end + +load "../dudle.rb" revbeforeedit = VCS.revno if $cgi.include?("undo_revision") && $cgi["undo_revision"].to_i < revbeforeedit undorevision = $cgi["undo_revision"].to_i - table = YAML::load(VCS.cat(undorevision, "data.yaml")) + $d = Dudle.new("Edit Columns",undorevision) comment = "Reverted Poll" comment = "Redo changes" if $cgi.include?("redo") - table.store("#{comment} to version #{undorevision}") + $d.table.store("#{comment} to version #{undorevision}") else - table = YAML::load_file("data.yaml") + $d = Dudle.new("Edit Columns") end -table.edit_column($cgi["columnid"],$cgi["new_columnname"],$cgi) if $cgi.include?("new_columnname") -table.delete_column($cgi["deletecolumn"]) if $cgi.include?("deletecolumn") +$d.table.edit_column($cgi["columnid"],$cgi["new_columnname"],$cgi) if $cgi.include?("new_columnname") +$d.table.delete_column($cgi["deletecolumn"]) if $cgi.include?("deletecolumn") revno = VCS.revno -$html = HTML.new("dudle - #{table.name} - Edit Columns") -$html.header["Cache-Control"] = "no-cache" -load "../charset.rb" -$html.add_css("../dudle.css") - -$html << "" -$html << Dudle::tabs("Edit Columns") - -$html << < -

#{table.name}

-

Add and Remove Columns

-TABLE +$d << "

Add and Remove Columns

" # ADD/REMOVE COLUMN -$html << table.edit_column_htmlform($cgi["editcolumn"],revno) +$d << $d.table.edit_column_htmlform($cgi["editcolumn"],revno) h = VCS.history urevs = h.undorevisions @@ -120,13 +89,13 @@ if rrevs.min hidden["Redo"] = "" end - $html << <
UNDOREDOREADY ["Undo","Redo"].each{|button| - $html << < TD } - $html << <
@@ -152,10 +121,9 @@ TD
READY -#$html << (urevs + rrevs).to_html(curundorev,"") +#$d << (urevs + rrevs).to_html(curundorev,"") -$html << "" -$html.out($cgi) +$d.out($cgi) end -- cgit v1.2.3
@@ -139,7 +108,7 @@ UNDOREDOREADY