mentawai 0.5.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 +7 -0
- data/License.txt +20 -0
- data/Manifest.txt +43 -0
- data/README.txt +48 -0
- data/Rakefile +4 -0
- data/bin/menta +122 -0
- data/config/hoe.rb +70 -0
- data/config/requirements.rb +17 -0
- data/lib/mentawai/core/action.rb +11 -0
- data/lib/mentawai/core/action_config.rb +79 -0
- data/lib/mentawai/core/app_context.rb +48 -0
- data/lib/mentawai/core/app_manager.rb +111 -0
- data/lib/mentawai/core/controller.rb +233 -0
- data/lib/mentawai/core/cookies.rb +57 -0
- data/lib/mentawai/core/forward.rb +57 -0
- data/lib/mentawai/core/input.rb +99 -0
- data/lib/mentawai/core/invocation_chain.rb +58 -0
- data/lib/mentawai/core/output.rb +51 -0
- data/lib/mentawai/core/session.rb +75 -0
- data/lib/mentawai/loader.rb +54 -0
- data/lib/mentawai/page/methods/out.rb +17 -0
- data/lib/mentawai/page/page_method.rb +137 -0
- data/lib/mentawai/server.rb +106 -0
- data/lib/mentawai/session/menta_session.rb +84 -0
- data/lib/mentawai/session/rack_session.rb +91 -0
- data/lib/mentawai/util/string.rb +34 -0
- data/lib/mentawai/version.rb +9 -0
- data/lib/mentawai.rb +16 -0
- data/log/debug.log +0 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/test_helper.rb +2 -0
- data/test/test_mentawai.rb +11 -0
- data/website/index.html +93 -0
- data/website/index.txt +39 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.rhtml +48 -0
- metadata +102 -0
data/History.txt
ADDED
data/License.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 FIXME full name
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
History.txt
|
2
|
+
License.txt
|
3
|
+
Manifest.txt
|
4
|
+
README.txt
|
5
|
+
Rakefile
|
6
|
+
bin/menta
|
7
|
+
config/hoe.rb
|
8
|
+
config/requirements.rb
|
9
|
+
lib/mentawai.rb
|
10
|
+
lib/mentawai/core/action.rb
|
11
|
+
lib/mentawai/core/action_config.rb
|
12
|
+
lib/mentawai/core/app_context.rb
|
13
|
+
lib/mentawai/core/app_manager.rb
|
14
|
+
lib/mentawai/core/controller.rb
|
15
|
+
lib/mentawai/core/cookies.rb
|
16
|
+
lib/mentawai/core/forward.rb
|
17
|
+
lib/mentawai/core/input.rb
|
18
|
+
lib/mentawai/core/invocation_chain.rb
|
19
|
+
lib/mentawai/core/output.rb
|
20
|
+
lib/mentawai/core/session.rb
|
21
|
+
lib/mentawai/loader.rb
|
22
|
+
lib/mentawai/page/methods/out.rb
|
23
|
+
lib/mentawai/page/page_method.rb
|
24
|
+
lib/mentawai/server.rb
|
25
|
+
lib/mentawai/session/menta_session.rb
|
26
|
+
lib/mentawai/session/rack_session.rb
|
27
|
+
lib/mentawai/util/string.rb
|
28
|
+
lib/mentawai/version.rb
|
29
|
+
log/debug.log
|
30
|
+
script/destroy
|
31
|
+
script/generate
|
32
|
+
script/txt2html
|
33
|
+
setup.rb
|
34
|
+
tasks/deployment.rake
|
35
|
+
tasks/environment.rake
|
36
|
+
tasks/website.rake
|
37
|
+
test/test_helper.rb
|
38
|
+
test/test_mentawai.rb
|
39
|
+
website/index.html
|
40
|
+
website/index.txt
|
41
|
+
website/javascripts/rounded_corners_lite.inc.js
|
42
|
+
website/stylesheets/screen.css
|
43
|
+
website/template.rhtml
|
data/README.txt
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
= mentawai
|
2
|
+
|
3
|
+
* FIX (url)
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
FIX (describe your package)
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* FIX (list of features or problems)
|
12
|
+
|
13
|
+
== SYNOPSIS:
|
14
|
+
|
15
|
+
FIX (code sample of usage)
|
16
|
+
|
17
|
+
== REQUIREMENTS:
|
18
|
+
|
19
|
+
* FIX (list of requirements)
|
20
|
+
|
21
|
+
== INSTALL:
|
22
|
+
|
23
|
+
* FIX (sudo gem install, anything else)
|
24
|
+
|
25
|
+
== LICENSE:
|
26
|
+
|
27
|
+
(The MIT License)
|
28
|
+
|
29
|
+
Copyright (c) 2008 FIX
|
30
|
+
|
31
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
32
|
+
a copy of this software and associated documentation files (the
|
33
|
+
'Software'), to deal in the Software without restriction, including
|
34
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
35
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
36
|
+
permit persons to whom the Software is furnished to do so, subject to
|
37
|
+
the following conditions:
|
38
|
+
|
39
|
+
The above copyright notice and this permission notice shall be
|
40
|
+
included in all copies or substantial portions of the Software.
|
41
|
+
|
42
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
43
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
44
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
45
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
46
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
47
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
48
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/bin/menta
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
def version
|
4
|
+
require 'mentawai/version'
|
5
|
+
puts "mentawai #{Mentawai::VERSION::STRING}" +
|
6
|
+
" - The Mentawai Web Framework implemented 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 "<appname>\t\tCreate blank menta app"
|
16
|
+
end
|
17
|
+
|
18
|
+
START_FILE = <<EOF
|
19
|
+
require 'rubygems'
|
20
|
+
require 'mentawai'
|
21
|
+
|
22
|
+
server = Mentawai::Server.new
|
23
|
+
server.host = '0.0.0.0'
|
24
|
+
server.port = 8080
|
25
|
+
|
26
|
+
# Setup the ROOT context (ROOT web application)
|
27
|
+
server.application('/', 'app_manager.rb', 'AppManager')
|
28
|
+
|
29
|
+
# You can setup as many applications as you want
|
30
|
+
# Ex:
|
31
|
+
# server.application('/myapp1', 'myapp1.rb', 'AppManager')
|
32
|
+
# server.application('/myapp2', 'myapp2.rb', 'AppManager')
|
33
|
+
|
34
|
+
# Start mongrel web server to server you mentawai app
|
35
|
+
server.start
|
36
|
+
EOF
|
37
|
+
|
38
|
+
APP_MANAGER_FILE = <<EOF
|
39
|
+
include Mentawai::Core
|
40
|
+
|
41
|
+
class AppManager < ApplicationManager
|
42
|
+
|
43
|
+
def init(appContext)
|
44
|
+
action("Hello").on(:success => Forward.new("hello.erb"))
|
45
|
+
addPageMethod(:m_my_method, 'Mentawai::Page::Method::Out', 'print')
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
EOF
|
50
|
+
|
51
|
+
ACTION_FILE = <<EOF
|
52
|
+
|
53
|
+
class Hello < Mentawai::Core::Action
|
54
|
+
|
55
|
+
def execute
|
56
|
+
|
57
|
+
puts "Inside action Hello!"
|
58
|
+
|
59
|
+
username = input['username']
|
60
|
+
|
61
|
+
username = "NO USER" if username.nil?
|
62
|
+
|
63
|
+
output['username'] = username.upcase
|
64
|
+
|
65
|
+
:success
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
EOF
|
70
|
+
|
71
|
+
VIEW_FILE = <<EOF
|
72
|
+
<html>
|
73
|
+
<body>
|
74
|
+
<!-- using menta method m_out -->
|
75
|
+
<h3>Hello1: <%= m_out('username') %></h3>
|
76
|
+
<!-- using custom page method -->
|
77
|
+
<h3>Hello2: <%= m_my_method('username') %></h3>
|
78
|
+
</body>
|
79
|
+
</html>
|
80
|
+
EOF
|
81
|
+
|
82
|
+
def create_app(app)
|
83
|
+
Dir.mkdir(app)
|
84
|
+
Dir.mkdir(app + '/actions')
|
85
|
+
Dir.mkdir(app + '/views')
|
86
|
+
f = File.open(app + '/start.rb', 'w')
|
87
|
+
f.print START_FILE
|
88
|
+
f.close
|
89
|
+
f = File.open(app + '/app_manager.rb', 'w')
|
90
|
+
f.print APP_MANAGER_FILE
|
91
|
+
f.close
|
92
|
+
f = File.open(app + '/actions/hello.rb', 'w')
|
93
|
+
f.print ACTION_FILE
|
94
|
+
f.close
|
95
|
+
f = File.open(app + '/views/hello.erb', 'w')
|
96
|
+
f.print VIEW_FILE
|
97
|
+
f.close
|
98
|
+
puts "Create menta app \"#{app}\""
|
99
|
+
puts "To run: ruby start.rb inside \"#{app}\""
|
100
|
+
end
|
101
|
+
|
102
|
+
if %w(-v --version).include? ARGV.first
|
103
|
+
version
|
104
|
+
exit(0)
|
105
|
+
end
|
106
|
+
|
107
|
+
if %w(-h --help).include?(ARGV.first) || ARGV.length == 0 then
|
108
|
+
help
|
109
|
+
exit(0)
|
110
|
+
end
|
111
|
+
|
112
|
+
if ARGV.length == 1
|
113
|
+
arg = ARGV[0]
|
114
|
+
if arg =~ /^\-\-?/
|
115
|
+
puts "Unrecognized argument: #{arg}"
|
116
|
+
exit(0)
|
117
|
+
end
|
118
|
+
create_app(arg)
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
|
data/config/hoe.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'mentawai/version'
|
2
|
+
|
3
|
+
AUTHOR = 'Sergio Oliveira Jr.' # can also be an array of Authors
|
4
|
+
EMAIL = "sergio.oliveira.jr@gmail.com"
|
5
|
+
DESCRIPTION = "A port of the Mentawai framework to Ruby + Mongrel + Rack"
|
6
|
+
GEM_NAME = 'mentawai' # what ppl will type to install your gem
|
7
|
+
RUBYFORGE_PROJECT = 'mentawai' # The unix name for your project
|
8
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
|
+
|
11
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
12
|
+
@config = nil
|
13
|
+
RUBYFORGE_USERNAME = "unknown"
|
14
|
+
def rubyforge_username
|
15
|
+
unless @config
|
16
|
+
begin
|
17
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
18
|
+
rescue
|
19
|
+
puts <<-EOS
|
20
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
21
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
22
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
23
|
+
EOS
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
end
|
27
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
REV = nil
|
32
|
+
# UNCOMMENT IF REQUIRED:
|
33
|
+
# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
|
34
|
+
VERS = Mentawai::VERSION::STRING + (REV ? ".#{REV}" : "")
|
35
|
+
RDOC_OPTS = ['--quiet', '--title', 'mentawai documentation',
|
36
|
+
"--opname", "index.html",
|
37
|
+
"--line-numbers",
|
38
|
+
"--main", "README",
|
39
|
+
"--inline-source"]
|
40
|
+
|
41
|
+
class Hoe
|
42
|
+
def extra_deps
|
43
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
44
|
+
@extra_deps
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Generate all the Rake tasks
|
49
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
50
|
+
hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
51
|
+
p.developer(AUTHOR, EMAIL)
|
52
|
+
p.description = DESCRIPTION
|
53
|
+
p.summary = DESCRIPTION
|
54
|
+
p.url = HOMEPATH
|
55
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
56
|
+
p.test_globs = ["test/**/test_*.rb"]
|
57
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
58
|
+
|
59
|
+
# == Optional
|
60
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
61
|
+
#p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
|
62
|
+
|
63
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
68
|
+
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'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
include FileUtils
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
%w[rake hoe newgem rubigen].each do |req_gem|
|
6
|
+
begin
|
7
|
+
require req_gem
|
8
|
+
rescue LoadError
|
9
|
+
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
|
+
puts "Installation: gem install #{req_gem} -y"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
16
|
+
|
17
|
+
require 'mentawai'
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Mentawai
|
2
|
+
module Core
|
3
|
+
|
4
|
+
class ActionConfig
|
5
|
+
|
6
|
+
def initialize(className, name = nil, inner = nil)
|
7
|
+
@className = className
|
8
|
+
if name == nil then
|
9
|
+
@actionName = className
|
10
|
+
else
|
11
|
+
@actionName = name
|
12
|
+
end
|
13
|
+
@innerAction = inner
|
14
|
+
@filters = Array.new
|
15
|
+
@consequences = Hash.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_s
|
19
|
+
s = "ActionConfig: " + @className
|
20
|
+
s += " / " + @actionName
|
21
|
+
if @innerAction != nil then
|
22
|
+
s += " / " + @innerAction
|
23
|
+
else
|
24
|
+
s += " / nil"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def on(result, conseq = nil)
|
29
|
+
|
30
|
+
if conseq == nil then
|
31
|
+
|
32
|
+
raise "Expecting a hash!" if !result.is_a?(Hash)
|
33
|
+
|
34
|
+
result.each do |k,v|
|
35
|
+
@consequences[k] = v
|
36
|
+
end
|
37
|
+
|
38
|
+
else
|
39
|
+
@consequences[result] = conseq
|
40
|
+
end
|
41
|
+
|
42
|
+
self
|
43
|
+
end
|
44
|
+
|
45
|
+
def filter(filter)
|
46
|
+
if filter.is_a?(Array) then
|
47
|
+
filter.each { |f| @filters.push(f) }
|
48
|
+
else
|
49
|
+
@filters.push(filter)
|
50
|
+
end
|
51
|
+
self
|
52
|
+
end
|
53
|
+
|
54
|
+
def className
|
55
|
+
@className
|
56
|
+
end
|
57
|
+
|
58
|
+
def actionName
|
59
|
+
@actionName
|
60
|
+
end
|
61
|
+
|
62
|
+
def innerAction
|
63
|
+
@innerAction
|
64
|
+
end
|
65
|
+
|
66
|
+
def filters
|
67
|
+
@filters.each do |f|
|
68
|
+
yield f
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def getConsequence(result)
|
73
|
+
@consequences[result]
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Mentawai
|
2
|
+
module Core
|
3
|
+
|
4
|
+
class AppContext
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@values = Hash.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def put(key, value)
|
11
|
+
@values[key] = value
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(key)
|
15
|
+
@values[key]
|
16
|
+
end
|
17
|
+
|
18
|
+
def remove(key)
|
19
|
+
@values.delete(key)
|
20
|
+
end
|
21
|
+
|
22
|
+
def hasKey?(key)
|
23
|
+
@values.has_key?(key)
|
24
|
+
end
|
25
|
+
|
26
|
+
alias has_key? hasKey?
|
27
|
+
alias key? hasKey?
|
28
|
+
|
29
|
+
def keys
|
30
|
+
@values.each do |k|
|
31
|
+
yield k
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def values
|
36
|
+
@values.each do |k,v|
|
37
|
+
yield k,v
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
alias [] get
|
42
|
+
alias []= put
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'mentawai/core/action_config'
|
2
|
+
|
3
|
+
module Mentawai
|
4
|
+
module Core
|
5
|
+
|
6
|
+
class ApplicationManager
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
|
10
|
+
puts "Initializing application manager..."
|
11
|
+
|
12
|
+
@actions = Hash.new
|
13
|
+
@innerActions = Hash.new
|
14
|
+
|
15
|
+
@globalFilters = Array.new
|
16
|
+
@globalConsequences = Hash.new
|
17
|
+
|
18
|
+
@loader = Loader.new('./actions')
|
19
|
+
@loader.reloadFiles
|
20
|
+
|
21
|
+
@pageMethods = initPageMethods
|
22
|
+
@customPageMethods = Hash.new
|
23
|
+
end
|
24
|
+
|
25
|
+
def init(application)
|
26
|
+
# should be overriden...
|
27
|
+
end
|
28
|
+
|
29
|
+
def pageMethods
|
30
|
+
@pageMethods
|
31
|
+
end
|
32
|
+
|
33
|
+
def reloadActions
|
34
|
+
@loader.reloadFiles
|
35
|
+
end
|
36
|
+
|
37
|
+
def addPageMethod(name, *params)
|
38
|
+
raise "Invalid parameters!" if params.length == 0 || params.length > 2
|
39
|
+
params[1] = 'exec' if params[1].nil?
|
40
|
+
@customPageMethods[name] = params
|
41
|
+
end
|
42
|
+
|
43
|
+
def customPageMethods
|
44
|
+
@customPageMethods
|
45
|
+
end
|
46
|
+
|
47
|
+
def action(className, actionName = nil, innerAction = nil)
|
48
|
+
ac = ActionConfig.new(className, actionName, innerAction)
|
49
|
+
addActionConfig(ac)
|
50
|
+
end
|
51
|
+
|
52
|
+
def addActionConfig(ac)
|
53
|
+
actionName = ac.actionName
|
54
|
+
innerAction = ac.innerAction
|
55
|
+
if innerAction == nil then
|
56
|
+
@actions[actionName] = ac
|
57
|
+
else
|
58
|
+
map = @innerActions[actionName]
|
59
|
+
if map == nil then
|
60
|
+
map = Hash.new
|
61
|
+
@innerActions[actionName] = map
|
62
|
+
end
|
63
|
+
map[innerAction] = ac
|
64
|
+
end
|
65
|
+
ac
|
66
|
+
end
|
67
|
+
|
68
|
+
def filter(filter)
|
69
|
+
@globalFilters.push(filter)
|
70
|
+
end
|
71
|
+
|
72
|
+
def filters
|
73
|
+
@globalFilters.each do |f|
|
74
|
+
yield f
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def on(result, conseq)
|
79
|
+
@globalConsequences[result] = conseq
|
80
|
+
end
|
81
|
+
|
82
|
+
def getConsequence(result)
|
83
|
+
@globalConsequences[result]
|
84
|
+
end
|
85
|
+
|
86
|
+
def getActionConfig(actionName, innerAction = nil)
|
87
|
+
|
88
|
+
if innerAction == nil then
|
89
|
+
@actions[actionName]
|
90
|
+
else
|
91
|
+
map = @innerActions[actionName]
|
92
|
+
if map == nil
|
93
|
+
nil
|
94
|
+
else
|
95
|
+
map[innerAction]
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
|
103
|
+
def initPageMethods
|
104
|
+
h = Hash.new
|
105
|
+
h[:m_out] = [ 'Mentawai::Page::Method::Out', 'print' ]
|
106
|
+
h
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|