diff options
-rwxr-xr-x | access_control.rb | 5 | ||||
-rwxr-xr-x | customize.rb | 2 | ||||
-rw-r--r-- | default.css | 5 | ||||
-rwxr-xr-x | delete_poll.rb | 4 | ||||
-rw-r--r-- | dudle.rb | 80 | ||||
-rwxr-xr-x | edit_columns.rb | 25 | ||||
-rwxr-xr-x | history.rb | 2 | ||||
-rwxr-xr-x | index.cgi | 4 | ||||
-rwxr-xr-x | invite_participants.rb | 4 | ||||
-rwxr-xr-x | overview.rb (renamed from help.rb) | 8 | ||||
-rwxr-xr-x | participate.rb | 2 |
11 files changed, 91 insertions, 50 deletions
diff --git a/access_control.rb b/access_control.rb index a40ad43..dfe3381 100755 --- a/access_control.rb +++ b/access_control.rb @@ -162,8 +162,9 @@ if $cgi.include?("ac_user") end end -unless $d.html.header["status"] == "REDIRECT" +$d.wizzard_redirect +if $d.html.header["status"] != "REDIRECT" $d.html << "<h2>Change Access Control Settings</h2>" @@ -221,5 +222,5 @@ AC end -$d.out($cgi) +$d.out end diff --git a/customize.rb b/customize.rb index d49d10e..3f9bb6e 100755 --- a/customize.rb +++ b/customize.rb @@ -134,7 +134,7 @@ $d << <<CHARSET </div> CHARSET -$d.out($cgi) +$d.out end diff --git a/default.css b/default.css index 2da40c7..98d4a38 100644 --- a/default.css +++ b/default.css @@ -186,6 +186,11 @@ html { top: 0px; margin-top: 0px; } +#wizzard_navigation{ + margin-left: 0; + padding-left: 0; + margin-top: 2ex; +} .textcolumn, .shorttextcolumn{ text-align: justify; diff --git a/delete_poll.rb b/delete_poll.rb index fc8f6b2..75f63db 100755 --- a/delete_poll.rb +++ b/delete_poll.rb @@ -51,7 +51,7 @@ if $cgi.include?("confirmnumber") </ul> </div> SUCCESS - $d.out($cgi) + $d.out exit else hint = <<HINT @@ -93,6 +93,6 @@ $d.html << <<TABLE </form> TABLE -$d.out($cgi) +$d.out end @@ -36,13 +36,9 @@ class Dudle tabs << ["Home",@basedir] if @is_poll tabs << ["",""] - tabs << ["Poll","."] - tabs << ["History","history.cgi"] - tabs << ["Help","help.cgi"] + tabs += @usertabs tabs << ["",""] - tabs << ["Edit Columns","edit_columns.cgi"] - tabs << ["Invite Participants","invite_participants.cgi"] - tabs << ["Access Control","access_control.cgi"] + tabs += @configtabs tabs << ["Delete Poll","delete_poll.cgi"] tabs << ["",""] end @@ -61,19 +57,32 @@ class Dudle ret end - def initialize(htmltitle, revision=nil) + def initialize(tabtitle, revision=nil) + @cgi = $cgi + @tabtitle = tabtitle if File.exists?("data.yaml") && !File.stat("data.yaml").directory? @is_poll = true @basedir = ".." - if revision - @table = YAML::load(VCS.cat(revision, "data.yaml")) - else - @table = YAML::load_file("data.yaml") - end + @revision = revision || VCS.revno + @table = YAML::load(VCS.cat(@revision, "data.yaml")) @urlsuffix = File.basename(File.expand_path(".")) @title = @table.name - @html = HTML.new("dudle - #{@title} - #{htmltitle}") + @html = HTML.new("dudle - #{@title} - #{@tabtitle}") @html.header["Cache-Control"] = "no-cache" + # set-up tabs + @usertabs = [ + ["Poll","."], + ["History","history.cgi"] + ] + @configtabs = [ + ["Edit Columns","edit_columns.cgi"], + ["Invite Participants","invite_participants.cgi"], + ["Access Control","access_control.cgi"], + ["Overview","overview.cgi"] + ] + confignames = @configtabs.collect{|name,file| name} + @is_config = confignames.include?(@tabtitle) + @wizzardindex = confignames.index(@tabtitle) if @is_config else @is_poll = false @basedir = "." @@ -81,6 +90,7 @@ class Dudle @html = HTML.new(@title) end + @css = ["default", "classic", "print"].collect{|f| f + ".css"} Dir.open("#{@basedir}/css/").each{|f| @@ -100,15 +110,51 @@ class Dudle <div id='header2'></div> <div id='header3'></div> <div id='main'> -#{tabs(htmltitle)} +#{tabs(@tabtitle)} <div id='content'> <h1>#{@title}</h1> HEAD end - def out(cgi) - @html << "</div></div></body>" - @html.out(cgi) + def wizzard_nav + ret = "<div id='wizzard_navigation'><table><tr>" + [["Previous",@wizzardindex == 0], + ["Next",@wizzardindex >= @configtabs.size()-2], + ["Finish",@wizzardindex == @configtabs.size()-1]].each{|button,disabled| + ret += <<READY + <td> + <form method='post' action=''> + <div> + <input type='hidden' name='undo_revision' value='#{@revision}' /> + <input type='submit' #{disabled ? "disabled='disabled'" : ""} name='#{button}' value='#{button}' /> + </div> + </form> + </td> +READY + } + ret += "</tr></table></div>" + end + + def wizzard_redirect + [["Previous",@wizzardindex-1], + ["Next",@wizzardindex+1], + ["Finish",@configtabs.size()-1]].each{|action,linkindex| + if $cgi.include?(action) + @html.header["status"] = "REDIRECT" + @html.header["Cache-Control"] = "no-cache" + @html.header["Location"] = @configtabs[linkindex][1] + @html << "All changes were saved sucessfully. <a href=\"#{@configtabs[linkindex][1]}\">Proceed!</a>" + out + exit + end + } + end + + def out + @html << wizzard_nav if @is_config && @wizzardindex != @configtabs.size() -1 + @html << "</div>" + @html << "</div></body>" + @html.out(@cgi) end def <<(htmlbodytext) diff --git a/edit_columns.rb b/edit_columns.rb index c966983..cc41046 100755 --- a/edit_columns.rb +++ b/edit_columns.rb @@ -28,8 +28,7 @@ revbeforeedit = VCS.revno if $cgi.include?("undo_revision") && $cgi["undo_revision"].to_i < revbeforeedit undorevision = $cgi["undo_revision"].to_i $d = Dudle.new("Edit Columns",undorevision) - comment = "Reverted Poll" - comment = "Redo changes" if $cgi.include?("redo") + comment = $cgi.include?("redo") ? "Redo changes" : "Reverted Poll" $d.table.store("#{comment} to version #{undorevision}") else $d = Dudle.new("Edit Columns") @@ -38,12 +37,7 @@ end $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") -if $cgi.include?("done") - $d.html.header["status"] = "REDIRECT" - $d.html.header["Cache-Control"] = "no-cache" - $d.html.header["Location"] = "help.cgi" - $d << "All changes were saved sucessfully. <a href=\"help.cgi\">Proceed!</a>" -else +$d.wizzard_redirect revno = VCS.revno @@ -115,23 +109,14 @@ UNDOREDOREADY </td> TD } - $d << <<READY - <td> - <form method='post' action=''> - <div> - <input type='hidden' name='undo_revision' value='#{revno}' /> - <input type='submit' name='done' value='Done' /> - </div> - </form> - </td> + $d << <<END </tr> </table> </div> -READY +END #$d << (urevs + rrevs).to_html(curundorev,"") -end -$d.out($cgi) +$d.out end @@ -43,5 +43,5 @@ $d << <<HTML </div> HTML -$d.out($cgi) +$d.out end @@ -53,7 +53,7 @@ if $cgi.include?("create_poll") && $cgi.include?("poll_url") VCS.init File.symlink("../participate.rb","index.cgi") VCS.add("index.cgi") - ["atom","customize", "history", "help", "edit_columns","access_control", "delete_poll", "invite_participants"].each{|f| + ["atom","customize", "history", "overview", "edit_columns","access_control", "delete_poll", "invite_participants"].each{|f| File.symlink("../#{f}.rb","#{f}.cgi") VCS.add("#{f}.cgi") } @@ -120,6 +120,6 @@ CREATE $d << NOTICE end -$d.out($cgi) +$d.out end diff --git a/invite_participants.rb b/invite_participants.rb index abb1ddc..3ce6d74 100755 --- a/invite_participants.rb +++ b/invite_participants.rb @@ -29,6 +29,8 @@ if $cgi.include?("add_participant") $d.table.add_participant("",$cgi["add_participant"],{}) end +$d.wizzard_redirect + $d << <<TABLE <h2>Invite Participants</h2> <form method='post' action=''> @@ -36,6 +38,6 @@ $d << <<TABLE </form> TABLE -$d.out($cgi) +$d.out end @@ -23,20 +23,22 @@ if __FILE__ == $0 load "../dudle.rb" -$d = Dudle.new("Help") +$d = Dudle.new("Overview") + +$d.wizzard_redirect $d << <<END The link to your poll is: <pre>#{SITEURL}</pre> <a href='mailto:?subject=link%20to%20dudle%20poll%20about%20#{CGI.escapeHTML(CGI.escape($d.title).gsub("+","%20"))}&body=#{SITEURL}'>Send this link via email...</a> <form method='get' action='.'> - <div> + <div style='margin-top:1ex'> <input type='submit' value='To the Vote interface' /> </div> </form> END -$d.out($cgi) +$d.out end diff --git a/participate.rb b/participate.rb index 0493011..df10d30 100755 --- a/participate.rb +++ b/participate.rb @@ -56,5 +56,5 @@ $d << <<HTML #{$d.table.comment_to_html} HTML -$d.out($cgi) +$d.out end |