diff options
Diffstat (limited to '')
-rwxr-xr-x | config.cgi | 116 | ||||
-rw-r--r-- | datepoll.rb | 6 | ||||
-rw-r--r-- | dudle.css | 7 | ||||
-rw-r--r-- | overview.rb | 1 | ||||
-rw-r--r-- | participate.rb | 87 | ||||
-rw-r--r-- | poll.rb | 65 |
6 files changed, 191 insertions, 91 deletions
diff --git a/config.cgi b/config.cgi new file mode 100755 index 0000000..e468f43 --- /dev/null +++ b/config.cgi @@ -0,0 +1,116 @@ +#!/usr/bin/env ruby + +################################ +# Author: Benjamin Kellermann # +# Licence: CC-by-sa 3.0 # +# see Licence # +################################ + +require "yaml" +require "cgi" + + +if __FILE__ == $0 + +$cgi = CGI.new + +TYPE = "text/html" +#TYPE = "application/xhtml+xml" +CHARSET = "utf-8" + +$htmlout = <<HEAD +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" + "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> +HEAD + +if File.exist?("data.yaml") +olddir = File.expand_path(".") +Dir.chdir("..") +load "charset.rb" +load "config.rb" +require "poll" +require "datepoll" +Dir.chdir(olddir) + +if $cgi.include?("revision") + REVISION=$cgi["revision"].to_i + table = YAML::load(VCS.cat(REVISION, "data.yaml")) +else + table = YAML::load_file("data.yaml") +end + +$htmlout = <<HTMLHEAD +<head> + <meta http-equiv="Content-Type" content="#{TYPE}; charset=#{CHARSET}" /> + <meta http-equiv="Content-Style-Type" content="text/css" /> + <title>dudle - config - #{table.name}</title> + <link rel="stylesheet" type="text/css" href="../dudle.css" title="default"/> +</head> +<body> + <div id='backlink'> + <a href='.' style='text-decoration:none'>#{BACK}</a> + </div> + <h1>#{table.name}</h1> +HTMLHEAD + +table.invite_delete($cgi["invite_delete"]) if $cgi.include?("invite_delete") + +if $cgi.include?("add_remove_column") + $htmlout += "Could not add/remove column #{$cgi["add_remove_column"]}" unless table.add_remove_column($cgi["add_remove_column"],$cgi["columndescription"]) +end +table.toggle_hidden if $cgi.include?("toggle_hidden") + +$htmlout += table.to_html(config = true) + +$htmlout += <<INVITEDELETE +<div id='invite_delete'> + <fieldset> + <legend>invite/delete participant</legend> + <form method='post' action='config.cgi'> + <div> + <input size='16' value='#{$cgi["invite_delete"]}' type='text' name='invite_delete' /> + <input type='submit' value='invite/delete' /> + </div> + </form> + </fieldset> +</div> +INVITEDELETE + +# ADD/REMOVE COLUMN +$htmlout +=<<ADD_REMOVE +<div id='add_remove_column'> +<fieldset><legend>add/remove column</legend> +<form method='post' action='config.cgi'> +#{table.add_remove_column_htmlform} +</form> +</fieldset> +</div> +ADD_REMOVE + +$htmlout +=<<HIDDEN +<div id='toggle_hidden'> + <fieldset> + <legend>Toggle Hidden flag</legend> + <form method='post' action='config.cgi'> + <div> + <input type='hidden' name='toggle_hidden' value='toggle' /> + <input type='submit' value='#{table.hidden ? "unhide" : "hide"}' /> + </div> + </form> + </fieldset> +</div> +HIDDEN + +$htmlout += "</body>" +else + load "charset.rb" + load "config.rb" + load "overview.rb" +end + +$htmlout += "</html>" + +$cgi.out("type" => TYPE ,"charset" => CHARSET,"cookie" => $utfcookie, "Cache-Control" => "no-cache"){$htmlout} +end + diff --git a/datepoll.rb b/datepoll.rb index 7cee069..3486aa0 100644 --- a/datepoll.rb +++ b/datepoll.rb @@ -56,9 +56,6 @@ class DatePoll < Poll startdate = Date.parse("#{Date.today.year}-#{Date.today.month}-1") end ret = <<END -<div id='add_remove_column'> -<fieldset><legend>add/remove column</legend> -<form method='post' action='.'> <div> <table><tr> END @@ -92,9 +89,6 @@ END </tr></table> <input type='hidden' name='add_remove_column_month' value='#{startdate.strftime("%Y-%m")}' /> </div> -</form> -</fieldset> -</div> END ret end @@ -80,3 +80,10 @@ body { h1 { text-align: center; } + +div#history{ + min-height: 24ex; +} +div#add_comment{ + float: left; +} diff --git a/overview.rb b/overview.rb index 061c804..ce829e1 100644 --- a/overview.rb +++ b/overview.rb @@ -23,6 +23,7 @@ if $cgi.include?("create_poll") VCS.init File.symlink("../index.cgi","index.cgi") File.symlink("../atom.cgi","atom.cgi") + File.symlink("../config.cgi","config.cgi") File.open("data.yaml","w").close VCS.add("data.yaml") case $cgi["poll_type"] diff --git a/participate.rb b/participate.rb index 759e0c5..279d1dc 100644 --- a/participate.rb +++ b/participate.rb @@ -45,18 +45,41 @@ if $cgi.include?("add_participant") table.add_participant($cgi["add_participant"],agreed) end -table.invite_delete($cgi["invite_delete"]) if $cgi.include?("invite_delete") - -if $cgi.include?("add_remove_column") - $htmlout += "Could not add/remove column #{$cgi["add_remove_column"]}" unless table.add_remove_column($cgi["add_remove_column"],$cgi["columndescription"]) -end - table.add_comment($cgi["commentname"],$cgi["comment"]) if $cgi.include?("comment") table.delete_comment($cgi["delete_comment"].to_i) if $cgi.include?("delete_comment") -table.toggle_hidden if $cgi.include?("toggle_hidden") -$htmlout += table.to_html +# POLL +$htmlout += <<POLLTABLE +<div id='polltable'> +<form method='post' action='.'> +#{table.to_html} +</form> +</div> +POLLTABLE + +$htmlout += table.comment_to_html + + +# ADD COMMENT +$htmlout += <<ADDCOMMENT +<div id='add_comment'> + <fieldset> + <legend>Comment</legend> + <form method='post' action='.'> + <div> + <label for='Commentname'>Name: </label> + <input id='Commentname' value='anonymous' type='text' name='commentname' /> + <br /> + <textarea cols='50' rows='6' name='comment' ></textarea> + <br /> + <input type='submit' value='Submit' /> + </div> + </form> + </fieldset> +</div> +ADDCOMMENT +# HISTORY MAXREV=VCS.revno REVISION=MAXREV unless defined?(REVISION) log = VCS.history @@ -92,53 +115,15 @@ $htmlout += "</table>" $htmlout += "</fieldset>" $htmlout += "</div>" -$htmlout += <<INVITEDELETE -<div id='invite_delete'> - <fieldset> - <legend>invite/delete participant</legend> - <form method='post' action='.'> - <div> - <input size='16' value='#{$cgi["invite_delete"]}' type='text' name='invite_delete' /> - <input type='submit' value='invite/delete' /> - </div> - </form> - </fieldset> -</div> -INVITEDELETE - -$htmlout += table.add_remove_column_htmlform - -$htmlout += <<ADDCOMMENT -<div id='add_comment'> - <fieldset> - <legend>Comment</legend> - <form method='post' action='.'> - <div> - <label for='Commentname'>Name: </label> - <input id='Commentname' value='anonymous' type='text' name='commentname' /> - <br /> - <textarea cols='50' rows='10' name='comment' ></textarea> - <br /> - <input type='submit' value='Submit' /> - </div> - </form> - </fieldset> -</div> -ADDCOMMENT -$htmlout +=<<HIDDEN -<div id='toggle_hidden'> +$htmlout +=<<CONFIG +<div id='configlink'> <fieldset> - <legend>Toggle Hidden flag</legend> - <form method='post' action='.'> - <div> - <input type='hidden' name='toggle_hidden' value='toggle' /> - <input type='submit' value='#{table.hidden ? "unhide" : "hide"}' /> - </div> - </form> + <legend>Configure the Poll</legend> + <a href='config.cgi' style='text-decoration:none'>config</a> </fieldset> </div> -HIDDEN +CONFIG $htmlout += "</body>" @@ -38,10 +38,8 @@ class Poll ret += "</tr>\n" ret end - def to_html - ret = "<div id='polltable'>\n" - ret += "<form method='post' action='.'>\n" - ret += "<table border='1'>\n" + def to_html(config = false) + ret = "<table border='1'>\n" ret += head_to_html sort_data($cgi.include?("sort") ? $cgi.params["sort"] : ["timestamp"]).each{|participant,poll| @@ -65,27 +63,9 @@ class Poll ret += "<td class='date'>#{poll['timestamp'].strftime('%d.%m, %H:%M')}</td>" ret += "</tr>\n" } - - # PARTICIPATE - ret += "<tr id='add_participant'>\n" - ret += "<td class='name'><input size='16' type='text' name='add_participant' title='To change a line, add a new person with the same name!' /></td>\n" - @head.sort.each{|columntitle,columndescription| - ret += "<td class='checkboxes'> - <table><tr> - <td class='input-yes'><label for='add_participant_checked_#{columntitle}_yes'>#{YES}</label></td> - <td><input type='radio' value='0 yes' id='add_participant_checked_#{columntitle}_yes' name='add_participant_checked_#{columntitle}' title='#{columntitle}' /></td> - </tr><tr> - <td class='input-no'><label for='add_participant_checked_#{columntitle}_no'>#{NO}</label></td> - <td><input type='radio' value='2 no' id='add_participant_checked_#{columntitle}_no' name='add_participant_checked_#{columntitle}' title='#{columntitle}' checked='checked' /></td> - </tr><tr> - <td class='input-maybe'><label for='add_participant_checked_#{columntitle}_maybe'>#{MAYBE}</label></td> - <td><input type='radio' value='1 maybe' id='add_participant_checked_#{columntitle}_maybe' name='add_participant_checked_#{columntitle}' title='#{columntitle}' /></td> - </tr></table> - </td>\n" - } - ret += "<td class='checkboxes'><input type='submit' value='add/edit' /></td>\n" - ret += "</tr>\n" + # PARTICIPATE + ret += participate_to_html unless config # SUMMARY ret += "<tr><td class='name'>total</td>\n" @@ -125,10 +105,33 @@ class Poll ret += "</tr>" ret += "</table>\n" - ret += "</form>\n" - ret += "</div>" - - ret += "<div id='comments'>" + ret + end + def participate_to_html + ret = "<tr id='add_participant'>\n" + ret += "<td class='name'><input size='16' type='text' name='add_participant' title='To change a line, add a new person with the same name!' /></td>\n" + @head.sort.each{|columntitle,columndescription| + ret += "<td class='checkboxes'> + <table><tr> + <td class='input-yes'><label for='add_participant_checked_#{columntitle}_yes'>#{YES}</label></td> + <td><input type='radio' value='0 yes' id='add_participant_checked_#{columntitle}_yes' name='add_participant_checked_#{columntitle}' title='#{columntitle}' /></td> + </tr><tr> + <td class='input-no'><label for='add_participant_checked_#{columntitle}_no'>#{NO}</label></td> + <td><input type='radio' value='2 no' id='add_participant_checked_#{columntitle}_no' name='add_participant_checked_#{columntitle}' title='#{columntitle}' checked='checked' /></td> + </tr><tr> + <td class='input-maybe'><label for='add_participant_checked_#{columntitle}_maybe'>#{MAYBE}</label></td> + <td><input type='radio' value='1 maybe' id='add_participant_checked_#{columntitle}_maybe' name='add_participant_checked_#{columntitle}' title='#{columntitle}' /></td> + </tr></table> + </td>\n" + } + ret += "<td class='checkboxes'><input type='submit' value='add/edit' /></td>\n" + + ret += "</tr>\n" + + ret + end + def comment_to_html + ret = "<div id='comments'>" unless @comment.empty? ret += "<fieldset><legend>Comments</legend>" @comment.each_with_index{|c,i| @@ -156,9 +159,6 @@ COMMENT end def add_remove_column_htmlform return <<END -<div id='add_remove_column'> -<fieldset><legend>add/remove column</legend> -<form method='post' action='.'> <div> <label for='columntitle'>Columntitle: </label> <input id='columntitle' size='16' type='text' value='#{$cgi["add_remove_column"]}' name='add_remove_column' /> @@ -166,9 +166,6 @@ COMMENT <input id='columndescription' size='30' type='text' value='#{$cgi["columndescription"]}' name='columndescription' /> <input type='submit' value='add/remove column' /> </div> -</form> -</fieldset> -</div> END end def add_participant(name, agreed) |