diff options
author | Benjamin Kellermann <Benjamin.Kellermann@gmx.de> | 2010-10-25 14:41:23 +0200 |
---|---|---|
committer | Benjamin Kellermann <Benjamin.Kellermann@gmx.de> | 2010-10-25 14:41:23 +0200 |
commit | bf302820595fad3ab235a6caed617ab669d2849f (patch) | |
tree | 79f3589b8039da92cb3a0638b64e1211a912e6fe | |
parent | 3cdd4c38782236482074322168adfa1e98870960 (diff) |
more clean main page, new example tab
-rw-r--r-- | config_sample.rb | 54 | ||||
-rw-r--r-- | dudle.rb | 1 | ||||
-rwxr-xr-x | example.cgi | 73 | ||||
-rwxr-xr-x | index.cgi | 11 |
4 files changed, 81 insertions, 58 deletions
diff --git a/config_sample.rb b/config_sample.rb index 69263c8..a5ea129 100644 --- a/config_sample.rb +++ b/config_sample.rb @@ -52,7 +52,29 @@ BUGREPORTMAIL = "Benjamin.Kellermann@tu-dresden.de" # Send bug reports automatically with the programm “mail” AUTO_SEND_REPORT = false -# Add some Example Polls to the start page +# add the htmlcode in the Variable INDEXNOTICE to the startpage +# Example: displays all available Polls +indexnotice = <<INDEXNOTICE +<h2>Available Polls</h2> +<table> + <tr> + <th>Poll</th><th>Last change</th> + </tr> +INDEXNOTICE +Dir.glob("*/data.yaml").sort_by{|f| + File.new(f).mtime +}.reverse.collect{|f| f.gsub(/\/data\.yaml$/,'') }.each{|site| + indexnotice += <<INDEXNOTICE +<tr class='participantrow'> + <td class='polls'><a href='./#{CGI.escapeHTML(site).gsub("'","%27")}/'>#{CGI.escapeHTML(site)}</a></td> + <td class='mtime'>#{File.new(site + "/data.yaml").mtime.strftime('%d.%m, %H:%M')}</td> +</tr> +INDEXNOTICE +} +indexnotice += "</table>" +INDEXNOTICE = indexnotice + +# Add some Example Polls to the example page # you may create those using the normal interface # and make them password protected afterwards # .htaccess and .htdigest are deleted after @@ -74,27 +96,17 @@ EXAMPLES = [ } ] -# add the htmlcode in the Variable NOTICE to the startpage +# add the htmlcode in the Variable EXAMPLENOTICE to the startpage # Example: displays all available Polls -notice = <<NOTICE -<h2>Available Polls</h2> -<table> - <tr> - <th>Poll</th><th>Last change</th> - </tr> -NOTICE -Dir.glob("*/data.yaml").sort_by{|f| - File.new(f).mtime -}.reverse.collect{|f| f.gsub(/\/data\.yaml$/,'') }.each{|site| - notice += <<NOTICE -<tr class='participantrow'> - <td class='polls'><a href='./#{CGI.escapeHTML(site).gsub("'","%27")}/'>#{CGI.escapeHTML(site)}</a></td> - <td class='mtime'>#{File.new(site + "/data.yaml").mtime.strftime('%d.%m, %H:%M')}</td> -</tr> -NOTICE -} -notice += "</table>" -NOTICE = notice +examplenotice = <<EXAMPLENOTICE + <h2>Screencasts</h2> + <ol> + <li><a href="0-register.ogv">Register a new user</a></li> + <li><a href="1-setup.ogv">Setup a new poll</a></li> + <li><a href="2-participate.ogv">Participate in a poll</a></li> + </ol> +EXAMPLENOTICE +EXAMPLENOTICE = examplenotice # choose a default stylesheet # e.g., "classic.css", "css/foobar.css", ... @@ -63,6 +63,7 @@ class Dudle tabs << @deletetab tabs << ["",""] else + tabs << [_("Examples"),"example.cgi"] tabs << [_("About"),"about.cgi"] end tabs << @customizetab diff --git a/example.cgi b/example.cgi index 6ba9b02..d2bf9cd 100755 --- a/example.cgi +++ b/example.cgi @@ -19,39 +19,58 @@ # along with dudle. If not, see <http://www.gnu.org/licenses/>. # ############################################################################ -require "cgi" -$cgi = CGI.new -def _(string) - string -end -require "config" +if __FILE__ == $0 + +require "dudle" + +$d = Dudle.new + +if $cgi.include?("poll") -poll = nil -EXAMPLES.each{|p| - poll = p if $cgi["poll"] == p[:url] -} + poll = nil + EXAMPLES.each{|p| + poll = p if $cgi["poll"] == p[:url] + } -raise "Example not found: '#{$cgi["poll"]}'" unless poll + raise "Example not found: '#{$cgi["poll"]}'" unless poll -targeturl = poll[:url] + targeturl = poll[:url] -if poll[:new_environment] - targeturl += "_#{Time.now.to_i}" + if poll[:new_environment] + targeturl += "_#{Time.now.to_i}" - while (File.exists?(targeturl)) - targeturl += "I" + while (File.exists?(targeturl)) + targeturl += "I" + end + VCS.branch(poll[:url],targeturl) + end + + if poll[:revno] + Dir.chdir(targeturl) + VCS.revert(poll[:revno]) + Dir.chdir("..") end - VCS.branch(poll[:url],targeturl) -end -if poll[:revno] - Dir.chdir(targeturl) - VCS.revert(poll[:revno]) - Dir.chdir("..") + $d.html.header["status"] = "REDIRECT" + $d.html.header["Cache-Control"] = "no-cache" + $d.html.header["Location"] = SITEURL + targeturl + +else + if defined?(EXAMPLES) + $d << "<div class='textcolumn'><h2>" + _("Examples") + "</h2>" + $d << _("If you want to play with the application, you may want to take a look at these example polls:") + $d << "<ul>" + EXAMPLES.each{|poll| + $d << "<li><a href='example.cgi?poll=#{poll[:url]}'>#{poll[:description]}</a></li>" unless poll[:hidden] + } + $d << "</ul></div>" + end + + $d << EXAMPLENOTICE end -$cgi.out({ - "status" => "REDIRECT", - "Cache-Control" => "no-cache", - "Location" => SITEURL + targeturl -}){""} + +$d.out + + +end @@ -132,17 +132,8 @@ NOTICE </form> CREATE - if defined?(EXAMPLES) - $d << "<div class='textcolumn'><h2>" + _("Examples") + "</h2>" - $d << _("If you want to play with the application, you may want to take a look at these example polls:") - $d << "<ul>" - EXAMPLES.each{|poll| - $d << "<li><a href='example.cgi?poll=#{poll[:url]}'>#{poll[:description]}</a></li>" unless poll[:hidden] - } - $d << "</ul></div>" - end - $d << NOTICE + $d << INDEXNOTICE end $d.out |