aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2009-12-14 14:14:29 +0100
committerBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2009-12-14 14:14:29 +0100
commit69eea2c4ff347a623a582d4099511db766faba42 (patch)
tree20968e7b580b8234a4575070558649c081583ca4
parentf2748fba35edfb42a03068afcc3dc1305109fcc3 (diff)
provide complete wizzard style
-rwxr-xr-xaccess_control.rb5
-rwxr-xr-xcustomize.rb2
-rw-r--r--default.css5
-rwxr-xr-xdelete_poll.rb4
-rw-r--r--dudle.rb80
-rwxr-xr-xedit_columns.rb25
-rwxr-xr-xhistory.rb2
-rwxr-xr-xindex.cgi4
-rwxr-xr-xinvite_participants.rb4
-rwxr-xr-xoverview.rb (renamed from help.rb)8
-rwxr-xr-xparticipate.rb2
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
diff --git a/dudle.rb b/dudle.rb
index 7fb3609..5aec81c 100644
--- a/dudle.rb
+++ b/dudle.rb
@@ -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
diff --git a/history.rb b/history.rb
index bbded14..9537191 100755
--- a/history.rb
+++ b/history.rb
@@ -43,5 +43,5 @@ $d << <<HTML
</div>
HTML
-$d.out($cgi)
+$d.out
end
diff --git a/index.cgi b/index.cgi
index 590e864..57f3728 100755
--- a/index.cgi
+++ b/index.cgi
@@ -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
diff --git a/help.rb b/overview.rb
index f553dbb..3355ae3 100755
--- a/help.rb
+++ b/overview.rb
@@ -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"))}&amp;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