mentawai 0.5.0 → 0.6.0
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.
- data/History.txt +9 -6
- data/Manifest.txt +50 -43
- data/bin/menta +244 -122
- data/config/hoe.rb +21 -18
- data/config/requirements.rb +0 -2
- data/lib/mentawai/application.rb +64 -0
- data/lib/mentawai/core/action.rb +27 -0
- data/lib/mentawai/core/app_context.rb +1 -0
- data/lib/mentawai/core/app_manager.rb +45 -6
- data/lib/mentawai/core/controller.rb +55 -19
- data/lib/mentawai/core/forward.rb +31 -13
- data/lib/mentawai/core/input.rb +9 -9
- data/lib/mentawai/handler/menta_handler.rb +178 -0
- data/lib/mentawai/i18n/loc_manager.rb +61 -0
- data/lib/mentawai/loader.rb +6 -0
- data/lib/mentawai/page/methods/content_type.rb +19 -0
- data/lib/mentawai/page/methods/messages.rb +78 -0
- data/lib/mentawai/page/page_method.rb +16 -3
- data/lib/mentawai/server.rb +41 -49
- data/lib/mentawai/util/array.rb +12 -0
- data/lib/mentawai/util/properties.rb +51 -0
- data/lib/mentawai/version.rb +2 -2
- data/lib/mentawai.rb +1 -0
- data/script/console +10 -0
- data/script/console.cmd +1 -0
- data/script/destroy.cmd +1 -0
- data/script/generate.cmd +1 -0
- data/script/txt2html +14 -6
- data/script/txt2html.cmd +1 -0
- data/tasks/deployment.rake +10 -3
- data/tasks/website.rake +2 -2
- metadata +21 -14
- data/website/index.html +0 -93
- data/website/index.txt +0 -39
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -138
- data/website/template.rhtml +0 -48
- /data/{log/debug.log → PostInstall.txt} +0 -0
data/History.txt
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
-
== 0.
|
2
|
-
|
3
|
-
* 3 major enhancement:
|
4
|
-
* Using Rake instead of Merb
|
5
|
-
* menta script to create blank app
|
6
|
-
* Available as ruby gem 'mentawai'
|
1
|
+
== 0.6.0 2008-04-30
|
7
2
|
|
3
|
+
* MentaOnRuby is now a web container as well as a web server
|
4
|
+
* Now supports directory listing, default page, and static file serving like a web server
|
5
|
+
* No more /views or /actions directory. Now we have /WEB-INF/src and /WEB-INF/lib
|
6
|
+
* ERB pages can be anywere now
|
7
|
+
* Everything inside /WEB-INF directory is protected from external access
|
8
|
+
* You can run different applications in the same instance of MentaOnRuby ('/' = /ROOT directory like Java servlets)
|
9
|
+
* You can use the new page method content_type to set the content-type of a erb template (ex: text/xml)
|
10
|
+
* Many other improvements and bug fixes
|
data/Manifest.txt
CHANGED
@@ -1,43 +1,50 @@
|
|
1
|
-
History.txt
|
2
|
-
License.txt
|
3
|
-
Manifest.txt
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
config/
|
9
|
-
|
10
|
-
lib/mentawai
|
11
|
-
lib/mentawai/
|
12
|
-
lib/mentawai/core/
|
13
|
-
lib/mentawai/core/
|
14
|
-
lib/mentawai/core/
|
15
|
-
lib/mentawai/core/
|
16
|
-
lib/mentawai/core/
|
17
|
-
lib/mentawai/core/
|
18
|
-
lib/mentawai/core/
|
19
|
-
lib/mentawai/core/
|
20
|
-
lib/mentawai/core/
|
21
|
-
lib/mentawai/
|
22
|
-
lib/mentawai/
|
23
|
-
lib/mentawai/
|
24
|
-
lib/mentawai/
|
25
|
-
lib/mentawai/
|
26
|
-
lib/mentawai/
|
27
|
-
lib/mentawai/
|
28
|
-
lib/mentawai/
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
1
|
+
History.txt
|
2
|
+
License.txt
|
3
|
+
Manifest.txt
|
4
|
+
PostInstall.txt
|
5
|
+
README.txt
|
6
|
+
Rakefile
|
7
|
+
bin/menta
|
8
|
+
config/hoe.rb
|
9
|
+
config/requirements.rb
|
10
|
+
lib/mentawai.rb
|
11
|
+
lib/mentawai/application.rb
|
12
|
+
lib/mentawai/core/action.rb
|
13
|
+
lib/mentawai/core/action_config.rb
|
14
|
+
lib/mentawai/core/app_context.rb
|
15
|
+
lib/mentawai/core/app_manager.rb
|
16
|
+
lib/mentawai/core/controller.rb
|
17
|
+
lib/mentawai/core/cookies.rb
|
18
|
+
lib/mentawai/core/forward.rb
|
19
|
+
lib/mentawai/core/input.rb
|
20
|
+
lib/mentawai/core/invocation_chain.rb
|
21
|
+
lib/mentawai/core/output.rb
|
22
|
+
lib/mentawai/core/session.rb
|
23
|
+
lib/mentawai/handler/menta_handler.rb
|
24
|
+
lib/mentawai/i18n/loc_manager.rb
|
25
|
+
lib/mentawai/loader.rb
|
26
|
+
lib/mentawai/page/methods/content_type.rb
|
27
|
+
lib/mentawai/page/methods/messages.rb
|
28
|
+
lib/mentawai/page/methods/out.rb
|
29
|
+
lib/mentawai/page/page_method.rb
|
30
|
+
lib/mentawai/server.rb
|
31
|
+
lib/mentawai/session/menta_session.rb
|
32
|
+
lib/mentawai/session/rack_session.rb
|
33
|
+
lib/mentawai/util/array.rb
|
34
|
+
lib/mentawai/util/properties.rb
|
35
|
+
lib/mentawai/util/string.rb
|
36
|
+
lib/mentawai/version.rb
|
37
|
+
script/console
|
38
|
+
script/console.cmd
|
39
|
+
script/destroy
|
40
|
+
script/destroy.cmd
|
41
|
+
script/generate
|
42
|
+
script/generate.cmd
|
43
|
+
script/txt2html
|
44
|
+
script/txt2html.cmd
|
45
|
+
setup.rb
|
46
|
+
tasks/deployment.rake
|
47
|
+
tasks/environment.rake
|
48
|
+
tasks/website.rake
|
49
|
+
test/test_helper.rb
|
50
|
+
test/test_mentawai.rb
|
data/bin/menta
CHANGED
@@ -1,122 +1,244 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
def version
|
4
|
-
require 'mentawai/version'
|
5
|
-
puts "mentawai #{Mentawai::VERSION::STRING}" +
|
6
|
-
" -
|
7
|
-
puts "More information on http://www.mentaframework.org"
|
8
|
-
end
|
9
|
-
|
10
|
-
def help
|
11
|
-
version
|
12
|
-
puts
|
13
|
-
puts "-v,--version\t\tShow version"
|
14
|
-
puts "-h,--help\t\tShow this help"
|
15
|
-
puts "<
|
16
|
-
end
|
17
|
-
|
18
|
-
START_FILE = <<EOF
|
19
|
-
require 'rubygems'
|
20
|
-
require 'mentawai'
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
server
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
def
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
def version
|
4
|
+
require 'mentawai/version'
|
5
|
+
puts "mentawai #{Mentawai::VERSION::STRING}" +
|
6
|
+
" - Mentawai Web Container, Server and Framework in Ruby"
|
7
|
+
puts "More information on http://www.mentaframework.org"
|
8
|
+
end
|
9
|
+
|
10
|
+
def help
|
11
|
+
version
|
12
|
+
puts
|
13
|
+
puts "-v,--version\t\tShow version"
|
14
|
+
puts "-h,--help\t\tShow this help"
|
15
|
+
puts "-c,--create <dirname>\tCreate web container (default dirname = 'mentawai')"
|
16
|
+
end
|
17
|
+
|
18
|
+
START_FILE = <<EOF
|
19
|
+
require 'rubygems'
|
20
|
+
require 'mentawai'
|
21
|
+
|
22
|
+
include Mentawai
|
23
|
+
|
24
|
+
server = Server.new
|
25
|
+
server.host = '127.0.0.1'
|
26
|
+
server.port = 8081
|
27
|
+
|
28
|
+
# Configure the parameters of your web application... (ROOT context)
|
29
|
+
|
30
|
+
root_app_options = {
|
31
|
+
:app_context => '/', # default = '/'
|
32
|
+
:app_manager_file => 'app_manager.rb', # default = 'app_manager.rb'
|
33
|
+
:app_manager_class => 'AppManager', # default = 'AppManager'
|
34
|
+
:action_extension => 'mtw', # default = 'mtw'
|
35
|
+
:listing_allowed => false, # default = false
|
36
|
+
:default_page => 'index.erb', # default = 'index.erb'
|
37
|
+
:dirs_allowed_for_listing => [] # default = []
|
38
|
+
}
|
39
|
+
|
40
|
+
server.add(root_app_options)
|
41
|
+
|
42
|
+
# Configure the parameters of a second web application... (/myapp context)
|
43
|
+
|
44
|
+
myapp_app_options = {
|
45
|
+
:app_context => '/myapp',
|
46
|
+
:action_extension => 'menta',
|
47
|
+
:listing_allowed => true,
|
48
|
+
:dirs_allowed_for_listing => ['img']
|
49
|
+
}
|
50
|
+
|
51
|
+
server.add(myapp_app_options)
|
52
|
+
|
53
|
+
# Start mongrel server to serve your Mentawai applications...
|
54
|
+
|
55
|
+
server.start
|
56
|
+
|
57
|
+
|
58
|
+
EOF
|
59
|
+
|
60
|
+
APP_MANAGER_FILE_1 = <<EOF
|
61
|
+
include Mentawai::Core
|
62
|
+
|
63
|
+
class AppManager < ApplicationManager
|
64
|
+
|
65
|
+
def init(appContext)
|
66
|
+
|
67
|
+
# Define an action...
|
68
|
+
action(:action_name => "/Hello", :class_name => "MyApp1::Hello").on(:success => fwd("hello.erb"))
|
69
|
+
|
70
|
+
# Add a custom page method (like a tag, but this is for your ERB pages)
|
71
|
+
addPageMethod(:m_my_method, 'Mentawai::Page::Method::Out', 'print')
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
EOF
|
76
|
+
|
77
|
+
APP_MANAGER_FILE_2 = <<EOF
|
78
|
+
include Mentawai::Core
|
79
|
+
|
80
|
+
class AppManager < ApplicationManager
|
81
|
+
|
82
|
+
def init(appContext)
|
83
|
+
|
84
|
+
# Define an action...
|
85
|
+
action(:action_name => "/Hello", :class_name => "MyApp2::Hello").on(:success => fwd("hello.erb"))
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
EOF
|
91
|
+
|
92
|
+
|
93
|
+
ACTION_FILE_1 = <<EOF
|
94
|
+
|
95
|
+
module MyApp1
|
96
|
+
|
97
|
+
class Hello < Mentawai::Core::Action
|
98
|
+
|
99
|
+
def execute
|
100
|
+
|
101
|
+
username = input['username']
|
102
|
+
|
103
|
+
username = "NO USER" if username.nil?
|
104
|
+
|
105
|
+
output['username'] = username.upcase
|
106
|
+
|
107
|
+
:success
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
def sayHi
|
112
|
+
|
113
|
+
output['username'] = "Roger"
|
114
|
+
|
115
|
+
:success
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
def sayHello
|
120
|
+
|
121
|
+
output['username'] = "Rick"
|
122
|
+
|
123
|
+
:success
|
124
|
+
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
EOF
|
130
|
+
|
131
|
+
ACTION_FILE_2 = <<EOF
|
132
|
+
|
133
|
+
module MyApp2
|
134
|
+
|
135
|
+
class Hello < Mentawai::Core::Action
|
136
|
+
|
137
|
+
def sayHi
|
138
|
+
|
139
|
+
output['username'] = "Sergio"
|
140
|
+
|
141
|
+
:success
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
def sayHello
|
146
|
+
|
147
|
+
output['username'] = "Rubem"
|
148
|
+
|
149
|
+
:success
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
end
|
155
|
+
EOF
|
156
|
+
|
157
|
+
VIEW_FILE_1 = <<EOF
|
158
|
+
<html>
|
159
|
+
<body>
|
160
|
+
<title>ROOT ('/') Mentawai Application</title>
|
161
|
+
<!-- using menta method m_out -->
|
162
|
+
<h3>Hello1: <%= m_out('username') %></h3>
|
163
|
+
<!-- using custom page method -->
|
164
|
+
<h3>Hello2: <%= m_my_method('username') %></h3>
|
165
|
+
</body>
|
166
|
+
</html>
|
167
|
+
EOF
|
168
|
+
|
169
|
+
VIEW_FILE_2 = <<EOF
|
170
|
+
<html>
|
171
|
+
<body>
|
172
|
+
<title>myapp ('/myapp') Mentawai Application</title>
|
173
|
+
<!-- using menta method m_out -->
|
174
|
+
<h3>Hi1: <%= m_out('username') %></h3>
|
175
|
+
</body>
|
176
|
+
</html>
|
177
|
+
EOF
|
178
|
+
|
179
|
+
|
180
|
+
def create_app(app)
|
181
|
+
Dir.mkdir(app)
|
182
|
+
|
183
|
+
Dir.mkdir(app + '/ROOT')
|
184
|
+
Dir.mkdir(app + '/ROOT/WEB-INF')
|
185
|
+
Dir.mkdir(app + '/ROOT/WEB-INF/src')
|
186
|
+
Dir.mkdir(app + '/ROOT/WEB-INF/lib')
|
187
|
+
|
188
|
+
Dir.mkdir(app + '/myapp')
|
189
|
+
Dir.mkdir(app + '/myapp/WEB-INF')
|
190
|
+
Dir.mkdir(app + '/myapp/WEB-INF/src')
|
191
|
+
Dir.mkdir(app + '/myapp/WEB-INF/lib')
|
192
|
+
|
193
|
+
f = File.open(app + '/start.rb', 'w')
|
194
|
+
f.print START_FILE
|
195
|
+
f.close
|
196
|
+
|
197
|
+
f = File.open(app + '/ROOT/WEB-INF/app_manager.rb', 'w')
|
198
|
+
f.print APP_MANAGER_FILE_1
|
199
|
+
f.close
|
200
|
+
|
201
|
+
f = File.open(app + '/ROOT/WEB-INF/src/hello.rb', 'w')
|
202
|
+
f.print ACTION_FILE_1
|
203
|
+
f.close
|
204
|
+
|
205
|
+
f = File.open(app + '/ROOT/hello.erb', 'w')
|
206
|
+
f.print VIEW_FILE_1
|
207
|
+
f.close
|
208
|
+
|
209
|
+
f = File.open(app + '/myapp/WEB-INF/app_manager.rb', 'w')
|
210
|
+
f.print APP_MANAGER_FILE_2
|
211
|
+
f.close
|
212
|
+
|
213
|
+
f = File.open(app + '/myapp/WEB-INF/src/hello.rb', 'w')
|
214
|
+
f.print ACTION_FILE_2
|
215
|
+
f.close
|
216
|
+
|
217
|
+
f = File.open(app + '/myapp/hello.erb', 'w')
|
218
|
+
f.print VIEW_FILE_2
|
219
|
+
f.close
|
220
|
+
|
221
|
+
puts "Mentawai web container created: #{app}"
|
222
|
+
puts "To run: ruby start.rb inside \"#{app}\""
|
223
|
+
puts
|
224
|
+
puts "Successfuly created a mentawai server!"
|
225
|
+
end
|
226
|
+
|
227
|
+
if %w(-v --version).include? ARGV.first
|
228
|
+
version
|
229
|
+
exit(0)
|
230
|
+
end
|
231
|
+
|
232
|
+
if %w(-h --help).include?(ARGV.first) || ARGV.length == 0 then
|
233
|
+
help
|
234
|
+
exit(0)
|
235
|
+
end
|
236
|
+
|
237
|
+
if %w(-c --create).include?(ARGV.first)
|
238
|
+
arg = ARGV[1] || 'mentawai'
|
239
|
+
create_app(arg)
|
240
|
+
exit(0)
|
241
|
+
end
|
242
|
+
|
243
|
+
puts "Invalid argument!"
|
244
|
+
|
data/config/hoe.rb
CHANGED
@@ -2,11 +2,14 @@ require 'mentawai/version'
|
|
2
2
|
|
3
3
|
AUTHOR = 'Sergio Oliveira Jr.' # can also be an array of Authors
|
4
4
|
EMAIL = "sergio.oliveira.jr@gmail.com"
|
5
|
-
DESCRIPTION = "
|
5
|
+
DESCRIPTION = "Mentawai Web Container, Server and Framework in Ruby"
|
6
6
|
GEM_NAME = 'mentawai' # what ppl will type to install your gem
|
7
7
|
RUBYFORGE_PROJECT = 'mentawai' # The unix name for your project
|
8
8
|
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
9
|
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
|
+
EXTRA_DEPENDENCIES = [
|
11
|
+
# ['activesupport', '>= 1.3.1']
|
12
|
+
] # An array of rubygem dependencies [name, version]
|
10
13
|
|
11
14
|
@config_file = "~/.rubyforge/user-config.yml"
|
12
15
|
@config = nil
|
@@ -28,26 +31,26 @@ Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
|
28
31
|
end
|
29
32
|
|
30
33
|
|
31
|
-
REV = nil
|
32
|
-
# UNCOMMENT IF REQUIRED:
|
33
|
-
# REV = `svn info
|
34
|
+
REV = nil
|
35
|
+
# UNCOMMENT IF REQUIRED:
|
36
|
+
# REV = YAML.load(`svn info`)['Revision']
|
34
37
|
VERS = Mentawai::VERSION::STRING + (REV ? ".#{REV}" : "")
|
35
38
|
RDOC_OPTS = ['--quiet', '--title', 'mentawai documentation',
|
36
39
|
"--opname", "index.html",
|
37
|
-
"--line-numbers",
|
40
|
+
"--line-numbers",
|
38
41
|
"--main", "README",
|
39
42
|
"--inline-source"]
|
40
43
|
|
41
44
|
class Hoe
|
42
|
-
def extra_deps
|
43
|
-
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
45
|
+
def extra_deps
|
46
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
44
47
|
@extra_deps
|
45
|
-
end
|
48
|
+
end
|
46
49
|
end
|
47
50
|
|
48
51
|
# Generate all the Rake tasks
|
49
52
|
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
50
|
-
hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
53
|
+
$hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
51
54
|
p.developer(AUTHOR, EMAIL)
|
52
55
|
p.description = DESCRIPTION
|
53
56
|
p.summary = DESCRIPTION
|
@@ -55,16 +58,16 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
55
58
|
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
56
59
|
p.test_globs = ["test/**/test_*.rb"]
|
57
60
|
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
58
|
-
|
61
|
+
|
59
62
|
# == Optional
|
60
63
|
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
61
|
-
#p.extra_deps =
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
64
|
+
#p.extra_deps = EXTRA_DEPENDENCIES
|
65
|
+
|
66
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
67
|
+
end
|
66
68
|
|
67
|
-
CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
69
|
+
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
68
70
|
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
69
|
-
hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
70
|
-
hoe.rsync_args = '-av --delete --ignore-errors'
|
71
|
+
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
72
|
+
$hoe.rsync_args = '-av --delete --ignore-errors'
|
73
|
+
$hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
|
data/config/requirements.rb
CHANGED
@@ -0,0 +1,64 @@
|
|
1
|
+
|
2
|
+
module Mentawai
|
3
|
+
|
4
|
+
class Application
|
5
|
+
|
6
|
+
attr_reader :appContext, :contextPath, :appManagerFilename, :appManagerClass, :appManagerFile, :appManager, :extension, :default_page, :listing_allowed, :dirs_allowed_for_listing
|
7
|
+
|
8
|
+
def initialize(params)
|
9
|
+
|
10
|
+
@appContext = Hash.new
|
11
|
+
|
12
|
+
@contextPath = params[:app_context] || '/'
|
13
|
+
|
14
|
+
@appManagerFilename = params[:app_manager_file] || 'app_manager.rb'
|
15
|
+
@appManagerFilename = ".#{contextPathDir}/WEB-INF/#{@appManagerFilename.sub(/^\//, "")}"
|
16
|
+
raise "Application manager does not exist: " + @appManagerFilename if not File.exists?(@appManagerFilename)
|
17
|
+
|
18
|
+
@appManagerClass = params[:app_manager_class] || 'AppManager'
|
19
|
+
|
20
|
+
@appManagerFile = File.new(@appManagerFilename)
|
21
|
+
|
22
|
+
@appManager = nil
|
23
|
+
|
24
|
+
@extension = params[:action_extension] || 'mtw'
|
25
|
+
|
26
|
+
@default_page = params[:default_page] || 'index.erb'
|
27
|
+
|
28
|
+
@listing_allowed = params[:listing_allowed] || false
|
29
|
+
|
30
|
+
@dirs_allowed_for_listing = params[:dirs_allowed_for_listing] || []
|
31
|
+
|
32
|
+
@appManagerFileLastModified = 0
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def contextPathDir
|
37
|
+
if contextPath == '/'
|
38
|
+
"/ROOT"
|
39
|
+
else
|
40
|
+
contextPath
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_s
|
45
|
+
"#{contextPath} (#{appManagerFilename}/#{appManagerClass})"
|
46
|
+
end
|
47
|
+
|
48
|
+
def reloadAppManager(force = false)
|
49
|
+
if force || @appManagerFile.mtime != @appManagerFileLastModified then
|
50
|
+
if @appManagerFileLastModified == 0 then
|
51
|
+
puts "Loading app manager: " + @appManagerFilename
|
52
|
+
else
|
53
|
+
puts "Reloading app manager: " + @appManagerFilename
|
54
|
+
end
|
55
|
+
load @appManagerFilename
|
56
|
+
@appManager = eval(appManagerClass + ".new(self)")
|
57
|
+
@appManager.init(@appContext)
|
58
|
+
@appManagerFileLastModified = @appManagerFile.mtime
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
data/lib/mentawai/core/action.rb
CHANGED
@@ -5,6 +5,33 @@ module Mentawai
|
|
5
5
|
|
6
6
|
attr_accessor :input, :output, :session, :application, :locale, :cookies, :page
|
7
7
|
|
8
|
+
def messages
|
9
|
+
return nil if output.nil?
|
10
|
+
msgs = output['messages']
|
11
|
+
if not msgs
|
12
|
+
output['messages'] = msgs = Array.new
|
13
|
+
end
|
14
|
+
msgs
|
15
|
+
end
|
16
|
+
|
17
|
+
def errors
|
18
|
+
return nil if output.nil?
|
19
|
+
errs = output['errors']
|
20
|
+
if not errs
|
21
|
+
output['errors'] = errs = Array.new
|
22
|
+
end
|
23
|
+
errs
|
24
|
+
end
|
25
|
+
|
26
|
+
def fieldErrors
|
27
|
+
return nil if output.nil?
|
28
|
+
fieldErrs = output['fieldErrors']
|
29
|
+
if not fieldErrs
|
30
|
+
output['fieldErrors'] = fieldErrs = Hash.new
|
31
|
+
end
|
32
|
+
fieldErrs
|
33
|
+
end
|
34
|
+
|
8
35
|
end
|
9
36
|
|
10
37
|
end
|