cuca 0.01

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. data/application_skeleton/README +21 -0
  2. data/application_skeleton/app/_controllers/application.rb +7 -0
  3. data/application_skeleton/app/_layouts/simple.rb +19 -0
  4. data/application_skeleton/app/_widgets/sourcecode.rb +21 -0
  5. data/application_skeleton/app/_widgets/test.rb +23 -0
  6. data/application_skeleton/app/demo.rb +64 -0
  7. data/application_skeleton/app/index.rb +39 -0
  8. data/application_skeleton/app/user/__default_username/index.rb +7 -0
  9. data/application_skeleton/conf/environment.rb +16 -0
  10. data/application_skeleton/log/access.log +1 -0
  11. data/application_skeleton/log/error.log +1 -0
  12. data/application_skeleton/log/messages +1 -0
  13. data/application_skeleton/public/css/style.css +27 -0
  14. data/application_skeleton/public/dispatch.cgi +31 -0
  15. data/application_skeleton/public/dispatch.fcgi +36 -0
  16. data/application_skeleton/public/img/cuca-seagull.png +0 -0
  17. data/application_skeleton/scripts/console +5 -0
  18. data/application_skeleton/scripts/console.rb +5 -0
  19. data/application_skeleton/scripts/server-lighttpd-fcgi.rb +116 -0
  20. data/application_skeleton/scripts/server-lighttpd.rb +109 -0
  21. data/application_skeleton/scripts/server-webrick.rb +26 -0
  22. data/application_skeleton/scripts/test.rb +8 -0
  23. data/application_skeleton/tests/widgets/link.rb +22 -0
  24. data/bin/cuca +43 -0
  25. data/lib/cuca/app.rb +317 -0
  26. data/lib/cuca/cgi_emu.rb +67 -0
  27. data/lib/cuca/cgi_fix.rb +58 -0
  28. data/lib/cuca/const.rb +3 -0
  29. data/lib/cuca/controller.rb +240 -0
  30. data/lib/cuca/generator/markaby.rb +80 -0
  31. data/lib/cuca/generator/view.rb +121 -0
  32. data/lib/cuca/layout.rb +62 -0
  33. data/lib/cuca/mimetypes.rb +89 -0
  34. data/lib/cuca/session.rb +143 -0
  35. data/lib/cuca/sessionflash.rb +56 -0
  36. data/lib/cuca/sessionpage.rb +41 -0
  37. data/lib/cuca/stdlib/arform.rb +208 -0
  38. data/lib/cuca/stdlib/arview.rb +16 -0
  39. data/lib/cuca/stdlib/form.rb +137 -0
  40. data/lib/cuca/stdlib/formerrors.rb +20 -0
  41. data/lib/cuca/stdlib/link.rb +37 -0
  42. data/lib/cuca/stdlib/list.rb +3 -0
  43. data/lib/cuca/stdlib/listwidget/dblist.rb +122 -0
  44. data/lib/cuca/stdlib/listwidget/list.rb +189 -0
  45. data/lib/cuca/stdlib/listwidget/querydef.rb +167 -0
  46. data/lib/cuca/stdlib/listwidget/staticdatalist.rb +79 -0
  47. data/lib/cuca/stdlib/slink.rb +30 -0
  48. data/lib/cuca/test/helpers.rb +42 -0
  49. data/lib/cuca/urlmap.rb +267 -0
  50. data/lib/cuca/widget.rb +212 -0
  51. data/lib/cuca.rb +68 -0
  52. metadata +141 -0
@@ -0,0 +1,21 @@
1
+ Welcome to the Cuca Framework
2
+
3
+ Directory Layout:
4
+
5
+ app - Place your application here
6
+ conf - Your script configs and environment.rb file
7
+ lib - Is in your load path
8
+ public - Point your webserver to this directory
9
+ log - Cuca framework log directory (should be writable by the webserver)
10
+ scripts - Tools to run/debug/test cuca
11
+ tests - application tests
12
+
13
+
14
+ To get started:
15
+
16
+ 1. Run ./script/server-webrick.rb and open http://localhost:2000/
17
+ 2. See http://cuca.rubyforge.org/ for more information
18
+
19
+
20
+ Questions/Comments/Suggestions are welcome: Email boesemar@rubyforge.org or
21
+ use the rubyforge cuca project forum.
@@ -0,0 +1,7 @@
1
+ # Use this class to define system wide controller class (if you decide to derive
2
+ # your controllers from ApplicationController)
3
+
4
+ require 'cuca/generator/markaby'
5
+ class ApplicationController < Cuca::Controller
6
+ include Cuca::Generator::Markaby
7
+ end
@@ -0,0 +1,19 @@
1
+ #
2
+ # A simple Layout
3
+ #
4
+ class SimpleLayout < Cuca::Layout
5
+ def output
6
+ content << <<-EOF
7
+ <HTML>
8
+ <HEAD><TITLE>Cuca Default Page - #{@page_title}</TITLE></HEAD>
9
+ <LINK href="/css/style.css" type="text/css" rel="stylesheet"></LINK>
10
+
11
+ <BODY>
12
+ #{@content_for_layout}
13
+ <HR/>
14
+ <SMALL>Generated by Cuca Framework #{Time.now} (using 'simple' demo layout on Cuca Version #{Cuca::VERSION})</SMALL>
15
+ </BODY>
16
+ </HTML>
17
+ EOF
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ # this demo widget will display the sourcecode of the current
2
+ # action (the file that contains the controller)
3
+ #
4
+ # This is a demo widget - part of the cuca application skeleton
5
+ # You can delete it unless you have any use for it in your applicaiton
6
+
7
+
8
+ require 'cuca/generator/markaby'
9
+ class SourceCodeWidget < Cuca::Widget
10
+ include Cuca::Generator::Markaby
11
+
12
+ def output
13
+ @script = app.urlmap.script
14
+ mab do
15
+ div(:style=>'background-color:#FAFAFF; border: 1px dashed blue;') do
16
+ b { "Sourcecode of: " }; text "#{@script}"
17
+ pre { escapeHTML(File.open(@script).read) } # escapeHTML is defined in Cuca::Widget
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ # this demo widget will simply display all parameters and blocks
2
+ # it got called with.
3
+ #
4
+ # This is a demo widget - part of the cuca application skeleton
5
+ # You can delete it unless you have any use for it in your applica
6
+ require 'cuca/generator/markaby'
7
+
8
+ class TestWidget < Cuca::Widget
9
+
10
+ include Cuca::Generator::Markaby
11
+
12
+ def output(*args, &block)
13
+ @a = @_assigns
14
+ mab { text "Debug-Widget: "; br ;
15
+ text "ARGS: " + args.inspect ; br ;
16
+ text "ASSIGNS:" + @a.inspect; br;
17
+ text "PARAMS: " + @params.inspect ; br;
18
+ text "BLOCK: " + (block_given? ? "YES" : "NO") ; br }
19
+ mab { text "Block returns:" ;br }
20
+ mab(&block)
21
+ end
22
+
23
+ end
@@ -0,0 +1,64 @@
1
+ # this action will show some widgets
2
+
3
+
4
+ require 'cuca/stdlib/list' # this will include the StaticDataListWidget
5
+ require 'cuca/stdlib/link' # to use the LinkWidget
6
+
7
+
8
+ class DemoController < ApplicationController
9
+
10
+ layout 'simple'
11
+
12
+ def run
13
+ @page_title = "Example use of a Widget"
14
+ @script = app.urlmap.script
15
+ mab do
16
+ h1 { "A few widgets" }
17
+ br
18
+ i { "Please have a look at the page sourcecode below so these mixed examples make sense" }
19
+ br
20
+ br
21
+
22
+ # LinkWidget 1
23
+ h2 { "This is a simple Link" }
24
+ Link('index') { "This is a Link back to Index" }
25
+ br
26
+
27
+ # LinkWidget 2
28
+ h2 { "Also the following block is one link, but with markaby code as content that displays the bird and the script filename" }
29
+ Link('index', {}) { img(:src=>'/img/cuca-seagull.png'); br; text "Rendered with #{@script}" }
30
+ br
31
+
32
+ # Static Data List
33
+ h2 { "This is a demo of the List widget using Static Data" }
34
+ small { "Note: You can sort, browse and filter this list" }
35
+ StaticDataList('random_names',
36
+ :columns => [ { :id => 'id', :display=>'ID #' },
37
+ { :id => 'name', :display=>'Name' } ],
38
+ :data => [[ 1, 'Jack'],
39
+ [ 2, 'Elvis'],
40
+ [ 3, 'Alice'],
41
+ [ 4, 'John'],
42
+ [ 5, 'Elwood'],
43
+ [ 6, 'Jake'],
44
+ [ 7, 'Purple'],
45
+ [ 8, 'Nicci'],
46
+ [ 9, 'Feti'],
47
+ [ 10, 'Fella'],
48
+ [ 11, 'Scott'],
49
+ [ 12, 'Leo']])
50
+ br
51
+
52
+ # TestWidget
53
+ h2 {"The 'TestWidget' will take any parameter and any block and will display how we called it: " }
54
+ Test("one", 2, 'tree') { b { "a bold block with a string" }}
55
+ br
56
+
57
+ # SourceCode
58
+ h2 { "Finally this is the sourcecode of the script" }
59
+ SourceCode();
60
+ br
61
+ end
62
+ end
63
+
64
+ end
@@ -0,0 +1,39 @@
1
+ # This index demo will just output some text using Markaby
2
+
3
+ require 'cuca/stdlib/slink'
4
+
5
+ class IndexController < ApplicationController
6
+ layout 'simple'
7
+
8
+ def run
9
+ @page_title = "Welcome"
10
+ mab do
11
+ img(:src=>'/img/cuca-seagull.png', :alt=>"Cuca Bird");
12
+ br
13
+ h1 { "Welcome to Cuca" }
14
+ br
15
+ text "Thank you for installing the cuca framework.";br;
16
+ br
17
+ h2 { "If you want to lean cuca" }
18
+ ul do
19
+ li { text "Have a look at the Demo Widgets: "; SLink('demo', 'Here') }
20
+ li { text "Checkout the cuca website: "; SLink("http://cuca.rubyforge.net") }
21
+ li { text "Read the source code of these examples" }
22
+ end
23
+
24
+ h2 { "If you want to start a new application" }
25
+ text "This skeleton comes with a few examples you might want to cleanup. Mainly:"
26
+ ul do
27
+ li { "Delete app/_widgets/*" }
28
+ li { "Delete app/demo.rb and app/index.rb" }
29
+ li { "Delete app/_layout/*" }
30
+ li { "Look at public/css/style.css" }
31
+ li { "Look at app/_controllers/application.rb" }
32
+ end
33
+ br
34
+ h2 { "Good Luck..." }
35
+ text "If you like cuca use the rubyforge to give any type of feedback."
36
+ end
37
+ end
38
+ end
39
+
@@ -0,0 +1,7 @@
1
+ class IndexController < ApplicationController
2
+
3
+ def run
4
+ content << "User is #{@username}"
5
+ end
6
+
7
+ end
@@ -0,0 +1,16 @@
1
+
2
+ # Use this file to setup your application environment
3
+
4
+ Cuca::App.configure do |config|
5
+ # config.db_database = 'm3'
6
+ # config.db_username = 'postgres'
7
+ # config.db_password = ''
8
+ # config.db_host = 'localhost'
9
+ # config.db_adapter = 'postgresql'
10
+ # config.db_database_testing = 'm3_test'
11
+
12
+ config.log_level = 3
13
+ config.include_directories = %w{_controllers _layouts _models _widgets}
14
+ config.magic_action_prefix = '__default_'
15
+
16
+ end
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,27 @@
1
+ .list table {
2
+ font-size: 10pt;
3
+ }
4
+
5
+ .list .hl a {
6
+ display: block;
7
+ background-color: gray;
8
+ text-decoration: none;
9
+ font-weight: bold;
10
+ color:white;
11
+ }
12
+
13
+
14
+ h1 {
15
+ border-bottom: 1px solid gray;
16
+ font-size: 15pt;
17
+ }
18
+
19
+ h2 {
20
+ border-bottom: 1px solid gray;
21
+ font-size: 12pt;
22
+ }
23
+
24
+ small {
25
+ color: gray;
26
+ }
27
+
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # Set this Environment variable to load the cuca framework from a specific
4
+ # Path. If not set it will try via rubygems.
5
+
6
+ FRAMEWORK_PATH = ENV['CUCA_FRAMEWORK_PATH']
7
+
8
+ $cuca_path = File.dirname(__FILE__)+"/../"
9
+
10
+ if (FRAMEWORK_PATH) then
11
+ $: << FRAMEWORK_PATH
12
+ require 'cuca'
13
+ require 'rubygems'
14
+ else
15
+ require 'rubygems'
16
+ require 'cuca'
17
+ end
18
+
19
+ Signal.trap("INT") do
20
+ $stderr.puts "INT caught"
21
+ exit
22
+ end
23
+
24
+
25
+ start = (Time.now.to_f * 1000).to_i
26
+ application = Cuca::App.new
27
+ application.cgicall
28
+ stop = (Time.now.to_f * 1000).to_i
29
+ dur_msec = stop - start
30
+ application.logger.info("App::cgicall: #{dur_msec} msec [= #{(1000 / dur_msec).to_i} pages / second]")
31
+
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/ruby
2
+
3
+
4
+ FRAMEWORK_PATH = ENV['CUCA_FRAMEWORK_PATH']
5
+
6
+ $cuca_path = File.dirname(__FILE__)+"/../"
7
+
8
+ if (FRAMEWORK_PATH) then
9
+ $: << FRAMEWORK_PATH
10
+ require 'cuca'
11
+ require 'rubygems'
12
+ else
13
+ require 'rubygems'
14
+ require 'cuca'
15
+ end
16
+
17
+ require "fcgi"
18
+
19
+ Signal.trap("INT") do
20
+ $stderr.puts "INT caught"
21
+ exit
22
+ end
23
+
24
+ $cuca_path = File.dirname(__FILE__)+"/../"
25
+
26
+
27
+ FCGI.each_cgi do |cgi|
28
+ CGI::fix_env(cgi.env_table)
29
+ start = (Time.now.to_f * 1000).to_i
30
+ application = Cuca::App.new(cgi)
31
+ application.cgicall
32
+ stop = (Time.now.to_f * 1000).to_i
33
+ dur_msec = stop - start
34
+ application.logger.info("App::cgicall (#{cgi.path_info}: #{dur_msec} msec [= #{(1000 / dur_msec).to_i} pages / second]")
35
+ end
36
+
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/ruby
2
+
3
+ libs = " -r irb/completion -r rubygems -r cuca"
4
+
5
+ exec "irb #{libs} --simple-prompt"
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/ruby
2
+ # A simple irb session that loads the cuca framework
3
+
4
+ libs = " -r irb/completion -r rubygems -r cuca"
5
+ exec "irb #{libs} --simple-prompt"
@@ -0,0 +1,116 @@
1
+ #!/usr/bin/ruby
2
+
3
+ cuca_path = File.expand_path(File.dirname(__FILE__)+"/../")
4
+ document_root = "#{cuca_path}/public/"
5
+ error_log = "#{cuca_path}/log/error.log"
6
+ access_log = "#{cuca_path}/log/access.log"
7
+ pid_file = '/tmp/lighttpd.pid'
8
+ dispatcher = "dispatch.fcgi"
9
+ server_port = 2000
10
+ server_program = "/usr/sbin/lighttpd"
11
+
12
+ config = <<-EOF
13
+
14
+ server.modules = (
15
+ "mod_access",
16
+ "mod_alias",
17
+ "mod_accesslog",
18
+ "mod_fastcgi"
19
+ )
20
+
21
+ # cgi.assign = ( "" => "/usr/bin/ruby" )
22
+
23
+ fastcgi.server = ( "/" => (( "bin-path" => "#{cuca_path}/public/#{dispatcher}",
24
+ "socket" => "/tmp/ruby.socket",
25
+ "min-procs" => 1,
26
+ "max-procs" => 1 )) )
27
+
28
+ server.document-root = "#{document_root}"
29
+
30
+ server.port = #{server_port}
31
+
32
+ server.errorlog = "#{error_log}"
33
+
34
+ server.error-handler-404 = "/#{dispatcher}"
35
+
36
+ index-file.names = ( "index.html" )
37
+
38
+ accesslog.filename = "#{access_log}"
39
+
40
+ # debug.log-request-handling = "enable"
41
+
42
+ server.pid-file = "#{pid_file}"
43
+
44
+ dir-listing.encoding = "utf-8"
45
+ server.dir-listing = "disable"
46
+
47
+ server.username = "www-data"
48
+ server.groupname = "www-data"
49
+
50
+
51
+
52
+ mimetype.assign = (
53
+ ".rpm" => "application/x-rpm",
54
+ ".pdf" => "application/pdf",
55
+ ".sig" => "application/pgp-signature",
56
+ ".spl" => "application/futuresplash",
57
+ ".class" => "application/octet-stream",
58
+ ".ps" => "application/postscript",
59
+ ".torrent" => "application/x-bittorrent",
60
+ ".dvi" => "application/x-dvi",
61
+ ".gz" => "application/x-gzip",
62
+ ".pac" => "application/x-ns-proxy-autoconfig",
63
+ ".swf" => "application/x-shockwave-flash",
64
+ ".tar.gz" => "application/x-tgz",
65
+ ".tgz" => "application/x-tgz",
66
+ ".tar" => "application/x-tar",
67
+ ".zip" => "application/zip",
68
+ ".mp3" => "audio/mpeg",
69
+ ".m3u" => "audio/x-mpegurl",
70
+ ".wma" => "audio/x-ms-wma",
71
+ ".wax" => "audio/x-ms-wax",
72
+ ".ogg" => "audio/x-wav",
73
+ ".wav" => "audio/x-wav",
74
+ ".gif" => "image/gif",
75
+ ".jpg" => "image/jpeg",
76
+ ".jpeg" => "image/jpeg",
77
+ ".png" => "image/png",
78
+ ".xbm" => "image/x-xbitmap",
79
+ ".xpm" => "image/x-xpixmap",
80
+ ".xwd" => "image/x-xwindowdump",
81
+ ".css" => "text/css",
82
+ ".html" => "text/html",
83
+ ".htm" => "text/html",
84
+ ".js" => "text/javascript",
85
+ ".asc" => "text/plain",
86
+ ".c" => "text/plain",
87
+ ".conf" => "text/plain",
88
+ ".text" => "text/plain",
89
+ ".txt" => "text/plain",
90
+ ".dtd" => "text/xml",
91
+ ".xml" => "text/xml",
92
+ ".mpeg" => "video/mpeg",
93
+ ".mpg" => "video/mpeg",
94
+ ".mov" => "video/quicktime",
95
+ ".qt" => "video/quicktime",
96
+ ".avi" => "video/x-msvideo",
97
+ ".asf" => "video/x-ms-asf",
98
+ ".asx" => "video/x-ms-asf",
99
+ ".wmv" => "video/x-ms-wmv",
100
+ ".bz2" => "application/x-bzip",
101
+ ".tbz" => "application/x-bzip-compressed-tar",
102
+ ".tar.bz2" => "application/x-bzip-compressed-tar"
103
+ )
104
+
105
+
106
+ EOF
107
+
108
+
109
+ fn = '/tmp/lighttpd-cuca.conf'
110
+
111
+ f = File.new(fn, 'w')
112
+ f << config
113
+ f.close
114
+
115
+ puts "Starting lighttpd on port #{server_port}"
116
+ system("#{server_program} -D -f #{fn}")
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/ruby
2
+
3
+ cuca_path = File.expand_path(File.dirname(__FILE__))+"/../"
4
+ document_root = "#{cuca_path}/public/"
5
+ error_log = "#{cuca_path}/log/error.log"
6
+ access_log = "#{cuca_path}/log/access.log"
7
+ pid_file = '/tmp/lighttpd.pid'
8
+ server_program = "/usr/sbin/lighttpd"
9
+ server_port = 2000
10
+
11
+ config = <<-EOF
12
+
13
+ server.modules = (
14
+ "mod_access",
15
+ "mod_alias",
16
+ "mod_accesslog",
17
+ "mod_cgi"
18
+ )
19
+
20
+ cgi.assign = ( ".cgi" => "/usr/bin/ruby" )
21
+
22
+ server.document-root = "#{document_root}"
23
+
24
+ server.port = #{server_port}
25
+
26
+ server.errorlog = "#{error_log}"
27
+
28
+ server.error-handler-404 = "/dispatch.cgi"
29
+ # server.error-handler-404 = "/error-404.html"
30
+
31
+ index-file.names = ( "index.html" )
32
+
33
+ accesslog.filename = "#{access_log}"
34
+
35
+ server.pid-file = "#{pid_file}"
36
+
37
+ dir-listing.encoding = "utf-8"
38
+ server.dir-listing = "disable"
39
+
40
+ # server.username = "www-data"
41
+ # server.groupname = "www-data"
42
+
43
+
44
+
45
+ mimetype.assign = (
46
+ ".rpm" => "application/x-rpm",
47
+ ".pdf" => "application/pdf",
48
+ ".sig" => "application/pgp-signature",
49
+ ".spl" => "application/futuresplash",
50
+ ".class" => "application/octet-stream",
51
+ ".ps" => "application/postscript",
52
+ ".torrent" => "application/x-bittorrent",
53
+ ".dvi" => "application/x-dvi",
54
+ ".gz" => "application/x-gzip",
55
+ ".pac" => "application/x-ns-proxy-autoconfig",
56
+ ".swf" => "application/x-shockwave-flash",
57
+ ".tar.gz" => "application/x-tgz",
58
+ ".tgz" => "application/x-tgz",
59
+ ".tar" => "application/x-tar",
60
+ ".zip" => "application/zip",
61
+ ".mp3" => "audio/mpeg",
62
+ ".m3u" => "audio/x-mpegurl",
63
+ ".wma" => "audio/x-ms-wma",
64
+ ".wax" => "audio/x-ms-wax",
65
+ ".ogg" => "audio/x-wav",
66
+ ".wav" => "audio/x-wav",
67
+ ".gif" => "image/gif",
68
+ ".jpg" => "image/jpeg",
69
+ ".jpeg" => "image/jpeg",
70
+ ".png" => "image/png",
71
+ ".xbm" => "image/x-xbitmap",
72
+ ".xpm" => "image/x-xpixmap",
73
+ ".xwd" => "image/x-xwindowdump",
74
+ ".css" => "text/css",
75
+ ".html" => "text/html",
76
+ ".htm" => "text/html",
77
+ ".js" => "text/javascript",
78
+ ".asc" => "text/plain",
79
+ ".c" => "text/plain",
80
+ ".conf" => "text/plain",
81
+ ".text" => "text/plain",
82
+ ".txt" => "text/plain",
83
+ ".dtd" => "text/xml",
84
+ ".xml" => "text/xml",
85
+ ".mpeg" => "video/mpeg",
86
+ ".mpg" => "video/mpeg",
87
+ ".mov" => "video/quicktime",
88
+ ".qt" => "video/quicktime",
89
+ ".avi" => "video/x-msvideo",
90
+ ".asf" => "video/x-ms-asf",
91
+ ".asx" => "video/x-ms-asf",
92
+ ".wmv" => "video/x-ms-wmv",
93
+ ".bz2" => "application/x-bzip",
94
+ ".tbz" => "application/x-bzip-compressed-tar",
95
+ ".tar.bz2" => "application/x-bzip-compressed-tar"
96
+ )
97
+
98
+
99
+ EOF
100
+
101
+
102
+ fn = '/tmp/lighttpd-cuca.conf'
103
+
104
+ f = File.new(fn, 'w')
105
+ f << config
106
+ f.close
107
+
108
+ puts "Starting lighttpd on port #{server_port}"
109
+ system("#{server_program} -D -f #{fn}")
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'webrick'
4
+ require 'cgi'
5
+
6
+
7
+ # this is for http debugging
8
+ class CucaHandler < WEBrick::HTTPServlet::CGIHandler
9
+ alias :old_do_GET :do_GET
10
+
11
+ def do_GET(req, res)
12
+ # puts "------------ Request ----------\n #{req.to_s}"
13
+ start = (Time.now.to_f * 100).to_i
14
+ r = old_do_GET(req, res)
15
+ stop = (Time.now.to_f * 100).to_i
16
+ # $stderr.puts "WEBRICK: Time: #{stop - start} ms"
17
+ # puts "------------ RESPONSE ----------\n #{res.to_s}"
18
+ end
19
+
20
+ end
21
+
22
+ server = WEBrick::HTTPServer.new(:Port => 2000)
23
+ server.mount("/", CucaHandler, File.expand_path(File.dirname(__FILE__))+"/../public/dispatch.cgi")
24
+
25
+ trap("INT"){ server.shutdown }
26
+ server.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'webrick'
4
+
5
+ server = WEBrick::HTTPServer.new(:Port => 2000)
6
+ server.mount("/", WEBrick::HTTPServlet::CGIHandler, File.expand_path(File.dirname(__FILE__))+"/../public/test.cgi")
7
+ trap("INT"){ server.shutdown }
8
+ server.start
@@ -0,0 +1,22 @@
1
+ require 'rubygems'
2
+
3
+ $cuca_path = File.dirname(__FILE__)+"/../../"
4
+
5
+ require 'cuca'
6
+ require 'cuca/test/helpers'
7
+
8
+ class TC_TestWidget < Test::Unit::TestCase
9
+
10
+ include Cuca::Test::Helpers
11
+
12
+ def setup
13
+ init()
14
+ end
15
+
16
+ def test_linkwidget
17
+ link = widget(LinkWidget, '/link/to') { "Something" }
18
+ assert link.to_s.include?('<a') && link.to_s.include?('Something')
19
+ end
20
+
21
+
22
+ end
data/bin/cuca ADDED
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # This is a simple script to install the cuca application skeleton
4
+ # provided by the cuca gems.
5
+ #
6
+ require 'ftools'
7
+ require 'fileutils'
8
+
9
+ if ARGV.size == 0 then
10
+ $stderr.puts "Usage #{__FILE__} [directory of application]"
11
+ exit
12
+ end
13
+
14
+ framework_path = File.dirname(__FILE__)+"/../application_skeleton/"
15
+
16
+ appname = ARGV[0]
17
+
18
+ puts "Createing application skeleton in #{appname}"
19
+
20
+
21
+ Dir.glob("#{framework_path}/**/*").each do |file|
22
+ fname = file[framework_path.length..-1]
23
+ dname = "#{appname}/#{fname}"
24
+
25
+ if File.exists?(dname) then
26
+ puts "(exists) #{fname}"
27
+ next
28
+ end
29
+
30
+ if File.directory?(file) then
31
+ puts "(mkdir) #{fname}"
32
+ File.makedirs(dname)
33
+ next
34
+ end
35
+
36
+ puts "(install) #{fname}"
37
+ File.install(file, dname)
38
+
39
+ if fname.include?('/scripts/server') || fname.include?('/public/dispatch') || fname.include?('/scripts/console') then
40
+ puts "(chmod) #{fname} (755)"
41
+ FileUtils.chmod(33261, dname)
42
+ end
43
+ end