cuca 0.01
Sign up to get free protection for your applications and to get access to all the features.
- data/application_skeleton/README +21 -0
- data/application_skeleton/app/_controllers/application.rb +7 -0
- data/application_skeleton/app/_layouts/simple.rb +19 -0
- data/application_skeleton/app/_widgets/sourcecode.rb +21 -0
- data/application_skeleton/app/_widgets/test.rb +23 -0
- data/application_skeleton/app/demo.rb +64 -0
- data/application_skeleton/app/index.rb +39 -0
- data/application_skeleton/app/user/__default_username/index.rb +7 -0
- data/application_skeleton/conf/environment.rb +16 -0
- data/application_skeleton/log/access.log +1 -0
- data/application_skeleton/log/error.log +1 -0
- data/application_skeleton/log/messages +1 -0
- data/application_skeleton/public/css/style.css +27 -0
- data/application_skeleton/public/dispatch.cgi +31 -0
- data/application_skeleton/public/dispatch.fcgi +36 -0
- data/application_skeleton/public/img/cuca-seagull.png +0 -0
- data/application_skeleton/scripts/console +5 -0
- data/application_skeleton/scripts/console.rb +5 -0
- data/application_skeleton/scripts/server-lighttpd-fcgi.rb +116 -0
- data/application_skeleton/scripts/server-lighttpd.rb +109 -0
- data/application_skeleton/scripts/server-webrick.rb +26 -0
- data/application_skeleton/scripts/test.rb +8 -0
- data/application_skeleton/tests/widgets/link.rb +22 -0
- data/bin/cuca +43 -0
- data/lib/cuca/app.rb +317 -0
- data/lib/cuca/cgi_emu.rb +67 -0
- data/lib/cuca/cgi_fix.rb +58 -0
- data/lib/cuca/const.rb +3 -0
- data/lib/cuca/controller.rb +240 -0
- data/lib/cuca/generator/markaby.rb +80 -0
- data/lib/cuca/generator/view.rb +121 -0
- data/lib/cuca/layout.rb +62 -0
- data/lib/cuca/mimetypes.rb +89 -0
- data/lib/cuca/session.rb +143 -0
- data/lib/cuca/sessionflash.rb +56 -0
- data/lib/cuca/sessionpage.rb +41 -0
- data/lib/cuca/stdlib/arform.rb +208 -0
- data/lib/cuca/stdlib/arview.rb +16 -0
- data/lib/cuca/stdlib/form.rb +137 -0
- data/lib/cuca/stdlib/formerrors.rb +20 -0
- data/lib/cuca/stdlib/link.rb +37 -0
- data/lib/cuca/stdlib/list.rb +3 -0
- data/lib/cuca/stdlib/listwidget/dblist.rb +122 -0
- data/lib/cuca/stdlib/listwidget/list.rb +189 -0
- data/lib/cuca/stdlib/listwidget/querydef.rb +167 -0
- data/lib/cuca/stdlib/listwidget/staticdatalist.rb +79 -0
- data/lib/cuca/stdlib/slink.rb +30 -0
- data/lib/cuca/test/helpers.rb +42 -0
- data/lib/cuca/urlmap.rb +267 -0
- data/lib/cuca/widget.rb +212 -0
- data/lib/cuca.rb +68 -0
- metadata +141 -0
data/lib/cuca/urlmap.rb
ADDED
@@ -0,0 +1,267 @@
|
|
1
|
+
|
2
|
+
if __FILE__ == $0 then
|
3
|
+
require 'rubygems'
|
4
|
+
require 'cuca'
|
5
|
+
end
|
6
|
+
|
7
|
+
module Cuca
|
8
|
+
|
9
|
+
# URLMap will throw this in case we can't find a controller
|
10
|
+
# file for a URL.
|
11
|
+
class RoutingError < StandardError # :nodoc:
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
# == URLMap
|
16
|
+
#
|
17
|
+
# URLMap is used internally to match a URL to a controller file.
|
18
|
+
# Call with ds = URLMap.new('/path/to/app', 'path/from/url')
|
19
|
+
#
|
20
|
+
# You can then fetch the following values:
|
21
|
+
#
|
22
|
+
# * script - path to the controller file
|
23
|
+
# * assigns - hash with variable assigns from the url (magick prefixes)
|
24
|
+
# * subcall - name of subcall or nil if a normal call was made
|
25
|
+
# * action - Action name (Note: action.capitalize+"Controller" is your controller class name)
|
26
|
+
# * action_path - Path to the action
|
27
|
+
# * action_path_full - Full path to application
|
28
|
+
# * action_module - The module the action should be loaded into (to avoid name conflicts, depends on action_path)
|
29
|
+
#
|
30
|
+
#
|
31
|
+
# == Match on other URL
|
32
|
+
#
|
33
|
+
# A widget/controller can make use of the URLMap object to scan on other directories (example to find out if a
|
34
|
+
# link url will be withing the same controller).
|
35
|
+
#
|
36
|
+
# See match? / submatch? and usubmatch?
|
37
|
+
#
|
38
|
+
#
|
39
|
+
# == Notes
|
40
|
+
#
|
41
|
+
# URL's ending with '/' will be scanned for default index files.
|
42
|
+
#
|
43
|
+
# URL's where last part (action) starts with '-' will be scanned for
|
44
|
+
# subcalls
|
45
|
+
#
|
46
|
+
# If no script is found or any other error it will raise a RoutingError exception
|
47
|
+
#
|
48
|
+
#
|
49
|
+
# == Example
|
50
|
+
#
|
51
|
+
# u = URLMap.new('/home/bones/src/cuca_app/app', 'customer/southwind_lda/show'
|
52
|
+
#
|
53
|
+
# u.script => '/home/bones/src/cuca_app/app/customer/__customer/show.rb'
|
54
|
+
# u.action => 'show'
|
55
|
+
# u.assigns => { 'customer' => 'southwind_lda' }
|
56
|
+
# u.action_path => 'customer/southwind_lda/'
|
57
|
+
#
|
58
|
+
class URLMap
|
59
|
+
attr_reader :assigns
|
60
|
+
attr_reader :script
|
61
|
+
attr_reader :subcall
|
62
|
+
attr_reader :action
|
63
|
+
attr_reader :action_path
|
64
|
+
attr_reader :action_path_full
|
65
|
+
attr_reader :action_module
|
66
|
+
|
67
|
+
DEF_ACT = Cuca::App::config['magic_action_prefix'] || '__'
|
68
|
+
DEF_IDX = [ 'index', 'default' ]
|
69
|
+
|
70
|
+
private
|
71
|
+
def scan_file(base, file)
|
72
|
+
|
73
|
+
if (file == '') then # check for default index file
|
74
|
+
DEF_IDX.each do |idxfile|
|
75
|
+
if File.exist?("#{base}/#{idxfile}.rb")
|
76
|
+
@action = idxfile
|
77
|
+
return "#{idxfile}.rb"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
raise RoutingError.new("No default index file found in #{base}")
|
81
|
+
end
|
82
|
+
|
83
|
+
@action = file
|
84
|
+
|
85
|
+
# check if a regular file exists:
|
86
|
+
# puts "Checking file on #{check}"
|
87
|
+
return (file+".rb") if File.exist?("#{base}/#{file}.rb")
|
88
|
+
|
89
|
+
# check if the subcall file exists:
|
90
|
+
if (file[0].chr == '-') then
|
91
|
+
(action,subcall) = file.scan(/^\-(.*)\-(.*)$/).flatten
|
92
|
+
if action.nil? || subcall.nil? || action.strip.empty? then
|
93
|
+
raise RoutingError.new("Bad format on subcall: #{file}")
|
94
|
+
end
|
95
|
+
raise RoutingError.new("Script not found for subcall: #{file}: #{action}.rb") if !File.exist?("#{base}/#{action}.rb")
|
96
|
+
@subcall = subcall
|
97
|
+
@action = action
|
98
|
+
return "#{action}.rb"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
def scan_dir(base, file)
|
104
|
+
return file if File.directory?("#{base}/#{file}")
|
105
|
+
|
106
|
+
d = Dir["#{base}/#{DEF_ACT}*"].collect { |f| f.split('/').last }
|
107
|
+
|
108
|
+
# puts "Directory not found, checking for default in #{base} - #{file}"
|
109
|
+
|
110
|
+
# puts d.inspect
|
111
|
+
#
|
112
|
+
raise RoutingError.new("Multiple default actions defined in #{base}") if d.size > 1
|
113
|
+
raise RoutingError.new("Routing Error in #{base}") if d.empty?
|
114
|
+
|
115
|
+
|
116
|
+
@assigns[d[0][DEF_ACT.size..-1]] = file
|
117
|
+
d[0]
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
private
|
122
|
+
def make_module(path)
|
123
|
+
const_name = "Appmod_#{path.gsub(/[\/\\]/, '_')}"
|
124
|
+
|
125
|
+
if Cuca::const_defined?(const_name.intern) then
|
126
|
+
return Cuca::const_get(const_name.intern)
|
127
|
+
end
|
128
|
+
|
129
|
+
m = Module.new
|
130
|
+
Cuca::const_set(const_name.intern, m)
|
131
|
+
return m
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
# scan will match an URI to a script and set assigns. (called from initialize)
|
136
|
+
private
|
137
|
+
def scan
|
138
|
+
files = @path_info.split('/')
|
139
|
+
|
140
|
+
files << '' if @path_info[@path_info.size-1].chr == '/' # add empty element if we point to a directory
|
141
|
+
|
142
|
+
# puts files.inspect
|
143
|
+
real_path = @base_path
|
144
|
+
|
145
|
+
# scan directory
|
146
|
+
files.each_index do |idx|
|
147
|
+
next if idx >= (files.size-1) # skip last element
|
148
|
+
r = scan_dir(real_path, files[idx])
|
149
|
+
raise RoutingError.new("Routing Error at #{real_path} - #{files[idx]}") if !r
|
150
|
+
real_path = "#{real_path}/#{r}"
|
151
|
+
end
|
152
|
+
|
153
|
+
@action_path = real_path[@base_path.length..-1]
|
154
|
+
@action_path_full = real_path
|
155
|
+
@action_module = make_module(@action_path)
|
156
|
+
|
157
|
+
# scan file (last element)
|
158
|
+
r = scan_file(real_path, files.last)
|
159
|
+
|
160
|
+
raise RoutingError.new("Routing Error - script not found at #{real_path} - #{files.last}") if !r
|
161
|
+
|
162
|
+
real_path = "#{real_path}/#{r}"
|
163
|
+
|
164
|
+
@script = File.expand_path(real_path)
|
165
|
+
self
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
# match will check if the supplied url maches with a script
|
170
|
+
# returns boolean
|
171
|
+
#
|
172
|
+
# Example:
|
173
|
+
# URLMap('/path/to/app', '/customer/southwind_lda/').match?('/path/to/app/customer/__custid/index.rb') => true
|
174
|
+
public
|
175
|
+
def match?(script)
|
176
|
+
m_script = @script
|
177
|
+
p_script = File.expand_path(script)
|
178
|
+
|
179
|
+
# $stderr.puts "URLMap::match - #{m_script} - #{p_script}"
|
180
|
+
return (m_script == p_script)
|
181
|
+
rescue RoutingError
|
182
|
+
false
|
183
|
+
end
|
184
|
+
|
185
|
+
|
186
|
+
# this will match if the current script can be found within a path
|
187
|
+
# from the parameters.
|
188
|
+
#
|
189
|
+
# Example:
|
190
|
+
# URLMap('/path/to/app', '/customer/southwind_lda/').submatch?('/customer/__custid/') => true
|
191
|
+
public
|
192
|
+
def submatch?(some_path)
|
193
|
+
# $stderr.puts "Submatch: #{some_path} with #{@script} - #{(@script.length < some_path.length).inspect} #{@script.include?(some_path)}"
|
194
|
+
return false if @script.length < some_path.length
|
195
|
+
return @script.include?(some_path)
|
196
|
+
end
|
197
|
+
|
198
|
+
# this will match the current script to a part of a url (link):
|
199
|
+
#
|
200
|
+
# Example:
|
201
|
+
# URLMap('/path/to/app', '/customer/southwind_lda/').submatch?('/customer/other_customer/') => true
|
202
|
+
public
|
203
|
+
def usubmatch?(some_path)
|
204
|
+
@path_info.include?(some_path)
|
205
|
+
end
|
206
|
+
|
207
|
+
# FIXME: needed?
|
208
|
+
public
|
209
|
+
def has_script?(script)
|
210
|
+
return !(@script == '')
|
211
|
+
end
|
212
|
+
|
213
|
+
|
214
|
+
def initialize(base_path, path_info, default_actions = ['index'])
|
215
|
+
@path_info = path_info
|
216
|
+
@base_path = base_path
|
217
|
+
@script = ''
|
218
|
+
@subcall = nil
|
219
|
+
@default_actions = default_actions
|
220
|
+
@assigns = {}
|
221
|
+
@action = ''
|
222
|
+
@action_path = ''
|
223
|
+
scan
|
224
|
+
self
|
225
|
+
end
|
226
|
+
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
230
|
+
|
231
|
+
|
232
|
+
#
|
233
|
+
# Testings:
|
234
|
+
#
|
235
|
+
|
236
|
+
if __FILE__ == $0 then
|
237
|
+
require 'app'
|
238
|
+
|
239
|
+
BASE = '/home/bones/src/cuca/app'
|
240
|
+
URL = 'user/martin/'
|
241
|
+
|
242
|
+
puts "Testing on '#{BASE}' - '#{URL}'"
|
243
|
+
|
244
|
+
module Cuca
|
245
|
+
ds = URLMap.new(BASE, URL)
|
246
|
+
begin
|
247
|
+
rescue RoutingError => e
|
248
|
+
puts "E: Invalid request #{$!}"
|
249
|
+
end
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
puts "Match with: #{ds.match?('/home/bones/src/cuca/app/user/__default_username/index.rb')}"
|
254
|
+
puts "Submatch with /user/__username/ #{ds.submatch?('/user/__username/')}"
|
255
|
+
puts "Submatch with '/user/' #{ds.submatch?('/user/')}"
|
256
|
+
puts "USubmatch with '/user/' #{ds.usubmatch?('/user/martin')}"
|
257
|
+
puts
|
258
|
+
puts "Script is: #{ds.script}"
|
259
|
+
puts "Assigns are: #{ds.assigns.inspect}"
|
260
|
+
puts "Subcall: #{ds.subcall.inspect}"
|
261
|
+
puts "Action: #{ds.action}"
|
262
|
+
puts "Action Path: #{ds.action_path}"
|
263
|
+
puts "Action Path Full: #{ds.action_path_full}"
|
264
|
+
puts "Action Module: #{ds.action_module.inspect}"
|
265
|
+
end
|
266
|
+
|
267
|
+
end
|
data/lib/cuca/widget.rb
ADDED
@@ -0,0 +1,212 @@
|
|
1
|
+
module Cuca
|
2
|
+
# === Widget
|
3
|
+
#
|
4
|
+
# All elements that generate content (e.g. html) are widgets. To implement a widget create
|
5
|
+
# a class derrived from Cuca::Widget and overwrite the +output+ method. The output method
|
6
|
+
# can take any argument or blocks - whatever you need to build your content. At the end you
|
7
|
+
# should write your result to @_content. For this it is advisable to use the content accessor
|
8
|
+
# or any of the Cuca::Generator 's.
|
9
|
+
#
|
10
|
+
# == Variables
|
11
|
+
#
|
12
|
+
# Instance variables shall be used by sub-widgets and generators. You can fetch them
|
13
|
+
# with get_assigns.
|
14
|
+
#
|
15
|
+
# == Naming
|
16
|
+
#
|
17
|
+
# Name all widgets like YournameWidget - when using them in a generator simply call them
|
18
|
+
# without the 'Widget' and directly with the paramenters of the output.
|
19
|
+
#
|
20
|
+
# == Examples
|
21
|
+
# An example widget without a generator:
|
22
|
+
#
|
23
|
+
# class BigfontWidget < Cuca::Widget
|
24
|
+
# def output(text_to_print)
|
25
|
+
# content << "<b><i>#{text_to_print}</i></b>"
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
#
|
30
|
+
# Example with the Markaby Generator - makes use of the BigfontWidget example above
|
31
|
+
#
|
32
|
+
# require 'cuca/generators/markaby'
|
33
|
+
#
|
34
|
+
# class HeadlineWidget < Cuca::Widget
|
35
|
+
# include Cuca::Generator::Markaby
|
36
|
+
#
|
37
|
+
# def output(text_to_print)
|
38
|
+
# @t = text_to_print # only instance variables are visisble to generators
|
39
|
+
# mab { div.headline { Bigfont(@t) }}
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
class Widget
|
44
|
+
|
45
|
+
# An accessor to @_content
|
46
|
+
# All 'generators' (like the mab -function) should append their
|
47
|
+
# generated clear text to @_content, latest with the before_to_s method
|
48
|
+
def content
|
49
|
+
@_content
|
50
|
+
end
|
51
|
+
|
52
|
+
# overwrite the content
|
53
|
+
def content=(newval)
|
54
|
+
@_content = newval
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
# an accessor to the current controller object - if available, otherwise nil
|
59
|
+
def controller
|
60
|
+
$controller_object || nil
|
61
|
+
end
|
62
|
+
|
63
|
+
# Hints is shared a shared container for all widgets. If you want to pass an information
|
64
|
+
# from one widget to another this can be useful.
|
65
|
+
# The last widget renered is the controller, then the Layout.
|
66
|
+
def hints
|
67
|
+
@@_hints
|
68
|
+
end
|
69
|
+
|
70
|
+
# clear all hints
|
71
|
+
def self.clear_hints
|
72
|
+
@@_hints = {}
|
73
|
+
end
|
74
|
+
|
75
|
+
# An accessor to the global cgi variables
|
76
|
+
def cgi
|
77
|
+
$cgi
|
78
|
+
end
|
79
|
+
|
80
|
+
# An accessor to the global logger variables
|
81
|
+
def log
|
82
|
+
$logger
|
83
|
+
end
|
84
|
+
|
85
|
+
# An accessor to the Cuca::app object
|
86
|
+
def app
|
87
|
+
$app
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
# an accessor to cgi.parameters variables. This is NOT params from the CGI class
|
92
|
+
# (see cgi_fix)
|
93
|
+
def params
|
94
|
+
$cgi.parameters
|
95
|
+
end
|
96
|
+
|
97
|
+
# accessor to cgi query parameters (http GET)
|
98
|
+
def query_parameters
|
99
|
+
$cgi.query_parameters
|
100
|
+
end
|
101
|
+
|
102
|
+
# accessor to the cgi request parameters (http POST)
|
103
|
+
def request_parameters
|
104
|
+
$cgi.request_parameters
|
105
|
+
end
|
106
|
+
|
107
|
+
# an accessor to request_method
|
108
|
+
def request_method
|
109
|
+
return $cgi.request_method
|
110
|
+
end
|
111
|
+
|
112
|
+
# Escape a string to use with URL etc..
|
113
|
+
def escape(text)
|
114
|
+
CGI::escape(text)
|
115
|
+
end
|
116
|
+
|
117
|
+
# Unescape an escaped string
|
118
|
+
def unescape(text)
|
119
|
+
CGI::unescape(text)
|
120
|
+
end
|
121
|
+
|
122
|
+
# escape a string on HTML codes
|
123
|
+
def escapeHTML(text)
|
124
|
+
CGI::escapeHTML(text)
|
125
|
+
end
|
126
|
+
|
127
|
+
# unescape an html escaped string
|
128
|
+
def unescapeHTML(text)
|
129
|
+
CGI::unescapeHTML(text)
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
# initialize - don't use widgets directly with .new.
|
134
|
+
#
|
135
|
+
# params[:assigns] variables in form of hash(var=>val) to make available to
|
136
|
+
# the generator blocks if they require/need
|
137
|
+
# params[:args] will be passed to the output method
|
138
|
+
# block will also be passed to the output method
|
139
|
+
def initialize(params = {}, &block)
|
140
|
+
@_assigns = params[:assigns] || {}
|
141
|
+
@_args = params[:args] || {}
|
142
|
+
@_profiler = params[:profiler] || nil
|
143
|
+
@_block = block
|
144
|
+
@_content = ""
|
145
|
+
|
146
|
+
@@_hints ||= {}
|
147
|
+
end
|
148
|
+
|
149
|
+
# will fetch a list of assigns to be passed to a code generator block
|
150
|
+
# this includes the :assigns from the constructor plus all instance
|
151
|
+
# variables from the widget
|
152
|
+
def get_assigns
|
153
|
+
a = @_assigns.clone
|
154
|
+
|
155
|
+
self.instance_variables.each do |v|
|
156
|
+
next if v.match(/^\@\_/)
|
157
|
+
next if v.include?('cancel_execution') # this is some internal key
|
158
|
+
a[v.gsub(/\@/,'')] = self.instance_variable_get(v)
|
159
|
+
end
|
160
|
+
return a
|
161
|
+
end
|
162
|
+
|
163
|
+
# clear widgets generated content
|
164
|
+
def clear
|
165
|
+
@_content = ""
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
# Overwrite this method with a function that takes the arguments and optionally
|
170
|
+
# a block as you like.
|
171
|
+
def output(*args, &block)
|
172
|
+
@_content = "This widget doesnt have any content"
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
# this method can be implemented by the generator
|
177
|
+
# to do finishing touches to @_content. Will be called before
|
178
|
+
# @content.to_s is returned to the controller/App
|
179
|
+
# def before_to_s
|
180
|
+
# end
|
181
|
+
|
182
|
+
# get cleartext for the widget
|
183
|
+
def to_s
|
184
|
+
if @_profiler then
|
185
|
+
require 'profiler'
|
186
|
+
Profiler__::start_profile
|
187
|
+
end
|
188
|
+
|
189
|
+
output(*@_args, &@_block)
|
190
|
+
before_to_s if self.methods.include?('before_to_s')
|
191
|
+
content = @_content.to_s
|
192
|
+
|
193
|
+
if @_profiler then
|
194
|
+
Profiler__::stop_profile
|
195
|
+
@_profiler.puts "____________________PROFILER #{self.class.inspect} ______________________"
|
196
|
+
Profiler__::print_profile(@_profiler)
|
197
|
+
end
|
198
|
+
|
199
|
+
return content
|
200
|
+
end
|
201
|
+
|
202
|
+
|
203
|
+
# this can be used by derrived classes
|
204
|
+
def self.define_attr_method(name, value=nil)
|
205
|
+
sing = class << self; self; end
|
206
|
+
sing.class_eval "def #{name}; #{value.inspect}; end"
|
207
|
+
# $stderr.puts "def #{name}; #{value.to_s.inspect}; end"
|
208
|
+
end
|
209
|
+
|
210
|
+
end
|
211
|
+
|
212
|
+
end # Module
|
data/lib/cuca.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# == Cuca - a widget-based web framework
|
2
|
+
#
|
3
|
+
# Cuca is a small web development framework mainly designed to build
|
4
|
+
# applications - there is little focus on design but more on coding
|
5
|
+
# efficiency.
|
6
|
+
#
|
7
|
+
# It implements the following concepts:
|
8
|
+
# * A Widget is a screen element. Can be a full page or part of it.
|
9
|
+
# The Controller and the Layout are Widgets, too.
|
10
|
+
# * A Controller deals with one request URI (get, post or both) and can set variables
|
11
|
+
# other widgets can make use of. It can also define a Layout and filters.
|
12
|
+
# * A Layout wraps the output of a controller and finally return the
|
13
|
+
# built web page.
|
14
|
+
# * A Generator (NOT "code generator") can be used within any Widget to help building the web content.
|
15
|
+
# Cuca comes with a Markaby and eruby Generator.
|
16
|
+
# * A Session can used optionally to keep stateful data.
|
17
|
+
#
|
18
|
+
#
|
19
|
+
# When you 'require' cuca you must set the global varibale $cuca_path to the root of your
|
20
|
+
# application structure. This is normally done by your dispatch.cgi or dispatch.fcgi
|
21
|
+
# script that comes with the cuca application skeleton.
|
22
|
+
#
|
23
|
+
# === See also
|
24
|
+
#
|
25
|
+
# * Cuca::Widget
|
26
|
+
# * Cuca::Controller
|
27
|
+
# * Cuca::Layout
|
28
|
+
# * Cuca::Session
|
29
|
+
# * Cuca::App
|
30
|
+
|
31
|
+
require 'cgi'
|
32
|
+
require 'cuca/cgi_fix'
|
33
|
+
require 'rubygems'
|
34
|
+
|
35
|
+
# All Classes are defined under this namespace
|
36
|
+
module Cuca
|
37
|
+
|
38
|
+
class CucaException < Exception # :nodoc:
|
39
|
+
end
|
40
|
+
|
41
|
+
# Any error on the application
|
42
|
+
class ApplicationException < Exception
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
if $cuca_path.nil? then
|
49
|
+
$stderr.puts "WARN: $cuca_path not found, assuming #{Dir.pwd}"
|
50
|
+
$cuca_path = Dir.pwd
|
51
|
+
end
|
52
|
+
|
53
|
+
require 'cuca/const'
|
54
|
+
|
55
|
+
$cuca_path = File.expand_path($cuca_path) + '/'
|
56
|
+
|
57
|
+
require 'cuca/app'
|
58
|
+
|
59
|
+
$LOAD_PATH << $cuca_path+'/lib'
|
60
|
+
begin
|
61
|
+
require $cuca_path+'/conf/environment'
|
62
|
+
rescue LoadError => e
|
63
|
+
$stderr.puts "WARN: Error loading conf/environment: #{e}"
|
64
|
+
end
|
65
|
+
|
66
|
+
require 'cuca/widget'
|
67
|
+
require 'cuca/controller'
|
68
|
+
require 'cuca/layout'
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cuca
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.01"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Martin Boese
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-05-08 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: markaby
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0.5"
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: fcgi
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 0.8.7
|
32
|
+
version:
|
33
|
+
description: Cuca is a light web development framework that supports CGI and FastCGI. It has a widget-bases approach to reuse functionality and does not implement an MVC architecture. Content can be generated directly by the controller with the help of external widgets that can generate code using markaby, eruby or any other user implemented 'generator'. It supports pretty URL's, layouts, sessions and the rendering of 'partials'.
|
34
|
+
email: boesemar@gmx.de
|
35
|
+
executables:
|
36
|
+
- cuca
|
37
|
+
extensions: []
|
38
|
+
|
39
|
+
extra_rdoc_files: []
|
40
|
+
|
41
|
+
files:
|
42
|
+
- bin/cuca
|
43
|
+
- lib/cuca.rb
|
44
|
+
- lib/cuca
|
45
|
+
- lib/cuca/cgi_fix.rb
|
46
|
+
- lib/cuca/controller.rb
|
47
|
+
- lib/cuca/stdlib
|
48
|
+
- lib/cuca/stdlib/arview.rb
|
49
|
+
- lib/cuca/stdlib/form.rb
|
50
|
+
- lib/cuca/stdlib/link.rb
|
51
|
+
- lib/cuca/stdlib/slink.rb
|
52
|
+
- lib/cuca/stdlib/arform.rb
|
53
|
+
- lib/cuca/stdlib/listwidget
|
54
|
+
- lib/cuca/stdlib/listwidget/querydef.rb
|
55
|
+
- lib/cuca/stdlib/listwidget/dblist.rb
|
56
|
+
- lib/cuca/stdlib/listwidget/staticdatalist.rb
|
57
|
+
- lib/cuca/stdlib/listwidget/list.rb
|
58
|
+
- lib/cuca/stdlib/list.rb
|
59
|
+
- lib/cuca/stdlib/formerrors.rb
|
60
|
+
- lib/cuca/generator
|
61
|
+
- lib/cuca/generator/markaby.rb
|
62
|
+
- lib/cuca/generator/view.rb
|
63
|
+
- lib/cuca/sessionflash.rb
|
64
|
+
- lib/cuca/widget.rb
|
65
|
+
- lib/cuca/mimetypes.rb
|
66
|
+
- lib/cuca/test
|
67
|
+
- lib/cuca/test/helpers.rb
|
68
|
+
- lib/cuca/sessionpage.rb
|
69
|
+
- lib/cuca/session.rb
|
70
|
+
- lib/cuca/cgi_emu.rb
|
71
|
+
- lib/cuca/app.rb
|
72
|
+
- lib/cuca/urlmap.rb
|
73
|
+
- lib/cuca/layout.rb
|
74
|
+
- lib/cuca/const.rb
|
75
|
+
- application_skeleton/log
|
76
|
+
- application_skeleton/log/messages
|
77
|
+
- application_skeleton/log/error.log
|
78
|
+
- application_skeleton/log/access.log
|
79
|
+
- application_skeleton/README
|
80
|
+
- application_skeleton/tests
|
81
|
+
- application_skeleton/tests/widgets
|
82
|
+
- application_skeleton/tests/widgets/link.rb
|
83
|
+
- application_skeleton/app
|
84
|
+
- application_skeleton/app/index.rb
|
85
|
+
- application_skeleton/app/demo.rb
|
86
|
+
- application_skeleton/app/_controllers
|
87
|
+
- application_skeleton/app/_controllers/application.rb
|
88
|
+
- application_skeleton/app/_layouts
|
89
|
+
- application_skeleton/app/_layouts/simple.rb
|
90
|
+
- application_skeleton/app/_widgets
|
91
|
+
- application_skeleton/app/_widgets/test.rb
|
92
|
+
- application_skeleton/app/_widgets/sourcecode.rb
|
93
|
+
- application_skeleton/app/user
|
94
|
+
- application_skeleton/app/user/__default_username
|
95
|
+
- application_skeleton/app/user/__default_username/index.rb
|
96
|
+
- application_skeleton/app/_views
|
97
|
+
- application_skeleton/scripts
|
98
|
+
- application_skeleton/scripts/server-lighttpd-fcgi.rb
|
99
|
+
- application_skeleton/scripts/console.rb
|
100
|
+
- application_skeleton/scripts/test.rb
|
101
|
+
- application_skeleton/scripts/server-lighttpd.rb
|
102
|
+
- application_skeleton/scripts/server-webrick.rb
|
103
|
+
- application_skeleton/scripts/console
|
104
|
+
- application_skeleton/lib
|
105
|
+
- application_skeleton/public
|
106
|
+
- application_skeleton/public/dispatch.fcgi
|
107
|
+
- application_skeleton/public/dispatch.cgi
|
108
|
+
- application_skeleton/public/css
|
109
|
+
- application_skeleton/public/css/style.css
|
110
|
+
- application_skeleton/public/img
|
111
|
+
- application_skeleton/public/img/cuca-seagull.png
|
112
|
+
- application_skeleton/conf
|
113
|
+
- application_skeleton/conf/environment.rb
|
114
|
+
has_rdoc: true
|
115
|
+
homepage: http://cuca.rubyforge.org/
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: "0"
|
126
|
+
version:
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: "0"
|
132
|
+
version:
|
133
|
+
requirements: []
|
134
|
+
|
135
|
+
rubyforge_project: cuca
|
136
|
+
rubygems_version: 1.1.1
|
137
|
+
signing_key:
|
138
|
+
specification_version: 2
|
139
|
+
summary: A widget-based web framework
|
140
|
+
test_files: []
|
141
|
+
|