nitro 0.31.0 → 0.40.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/nitro +135 -37
- data/doc/CHANGELOG.1 +108 -108
- data/doc/CHANGELOG.2 +89 -89
- data/doc/CHANGELOG.3 +105 -105
- data/{CHANGELOG → doc/CHANGELOG.4} +509 -509
- data/doc/{AUTHORS → CONTRIBUTORS} +49 -37
- data/doc/LIBRARIES +13 -0
- data/doc/LICENSE +2 -3
- data/doc/MIGRATION +45 -0
- data/doc/RELEASES +131 -11
- data/doc/TODO +67 -0
- data/lib/glue/magick.rb +0 -3
- data/lib/glue/sweeper.rb +30 -15
- data/lib/glue/thumbnails.rb +0 -2
- data/lib/glue/webfile.rb +23 -11
- data/lib/nitro.rb +37 -44
- data/lib/nitro/adapter/cgi.rb +0 -3
- data/lib/nitro/adapter/console.rb +0 -2
- data/lib/nitro/adapter/fastcgi.rb +6 -3
- data/lib/nitro/adapter/mongrel.rb +97 -58
- data/lib/nitro/adapter/script.rb +4 -6
- data/lib/nitro/adapter/webrick.rb +33 -87
- data/lib/nitro/adapter/webrick/vcr.rb +85 -0
- data/lib/nitro/caching.rb +0 -2
- data/lib/nitro/caching/actions.rb +0 -2
- data/lib/nitro/caching/fragments.rb +0 -2
- data/lib/nitro/caching/output.rb +45 -16
- data/lib/nitro/caching/proxy.rb +49 -0
- data/lib/nitro/cgi.rb +3 -6
- data/lib/nitro/cgi/cookie.rb +0 -3
- data/lib/nitro/cgi/request.rb +67 -24
- data/lib/nitro/cgi/response.rb +0 -2
- data/lib/nitro/cgi/{sendfile.rb → send_file.rb} +7 -6
- data/lib/nitro/compiler.rb +62 -55
- data/lib/nitro/compiler/cleanup.rb +0 -3
- data/lib/nitro/compiler/elements.rb +31 -28
- data/lib/nitro/compiler/errors.rb +2 -5
- data/lib/nitro/compiler/include.rb +10 -8
- data/lib/nitro/compiler/layout.rb +0 -2
- data/lib/nitro/compiler/localization.rb +0 -2
- data/lib/nitro/compiler/markup.rb +14 -6
- data/lib/nitro/compiler/morphing.rb +1 -5
- data/lib/nitro/compiler/script.rb +2 -4
- data/lib/nitro/compiler/squeeze.rb +0 -2
- data/lib/nitro/compiler/xslt.rb +0 -2
- data/lib/nitro/context.rb +10 -5
- data/lib/nitro/control.rb +18 -0
- data/lib/nitro/control/attribute.rb +88 -0
- data/lib/nitro/control/attribute/checkbox.rb +19 -0
- data/lib/nitro/control/attribute/datetime.rb +21 -0
- data/lib/nitro/control/attribute/file.rb +20 -0
- data/lib/nitro/control/attribute/fixnum.rb +26 -0
- data/lib/nitro/control/attribute/float.rb +26 -0
- data/lib/nitro/control/attribute/options.rb +38 -0
- data/lib/nitro/control/attribute/password.rb +16 -0
- data/lib/nitro/control/attribute/text.rb +16 -0
- data/lib/nitro/control/attribute/textarea.rb +16 -0
- data/lib/nitro/control/none.rb +16 -0
- data/lib/nitro/control/relation.rb +53 -0
- data/lib/nitro/control/relation/belongs_to.rb +0 -0
- data/lib/nitro/control/relation/has_many.rb +97 -0
- data/lib/nitro/control/relation/joins_many.rb +0 -0
- data/lib/nitro/control/relation/many_to_many.rb +0 -0
- data/lib/nitro/control/relation/refers_to.rb +29 -0
- data/lib/nitro/controller.rb +7 -296
- data/lib/nitro/dispatcher.rb +72 -34
- data/lib/nitro/element.rb +36 -10
- data/lib/nitro/element/javascript.rb +0 -2
- data/lib/nitro/flash.rb +23 -10
- data/lib/nitro/global.rb +36 -11
- data/lib/nitro/helper.rb +22 -8
- data/lib/nitro/helper/benchmark.rb +0 -2
- data/lib/nitro/helper/buffer.rb +0 -3
- data/lib/nitro/helper/css.rb +12 -0
- data/lib/nitro/helper/debug.rb +1 -3
- data/lib/nitro/helper/default.rb +1 -0
- data/lib/nitro/helper/feed.rb +400 -386
- data/lib/nitro/helper/form.rb +246 -116
- data/lib/nitro/helper/javascript.rb +28 -2
- data/lib/nitro/helper/javascript/morphing.rb +0 -2
- data/lib/nitro/helper/javascript/prototype.rb +0 -2
- data/lib/nitro/helper/javascript/scriptaculous.rb +0 -1
- data/lib/nitro/helper/layout.rb +0 -2
- data/lib/nitro/helper/navigation.rb +87 -0
- data/lib/nitro/helper/pager.rb +11 -22
- data/lib/nitro/helper/table.rb +9 -32
- data/lib/nitro/helper/url.rb +104 -0
- data/lib/nitro/helper/xhtml.rb +20 -4
- data/lib/nitro/helper/xml.rb +0 -2
- data/lib/nitro/markup.rb +131 -0
- data/lib/nitro/part.rb +52 -7
- data/lib/nitro/publishable.rb +328 -0
- data/lib/nitro/render.rb +30 -61
- data/lib/nitro/router.rb +12 -4
- data/lib/nitro/sanitize.rb +48 -0
- data/lib/nitro/scaffold.rb +9 -11
- data/lib/nitro/scaffold/controller.rb +25 -0
- data/lib/nitro/scaffold/model.rb +150 -0
- data/lib/nitro/scaffolding.rb +1 -3
- data/lib/nitro/server.rb +57 -32
- data/lib/nitro/server/drb.rb +16 -2
- data/lib/nitro/server/runner.rb +80 -102
- data/lib/nitro/service.rb +0 -1
- data/lib/nitro/service/xmlrpc.rb +0 -2
- data/lib/nitro/session.rb +26 -18
- data/lib/nitro/session/drb.rb +2 -16
- data/lib/nitro/session/memory.rb +0 -2
- data/lib/nitro/template.rb +219 -0
- data/lib/nitro/test/assertions.rb +1 -3
- data/lib/nitro/test/context.rb +0 -1
- data/lib/nitro/test/testcase.rb +0 -1
- data/lib/nitro/version.rb +6 -0
- data/lib/part/admin.rb +16 -0
- data/lib/part/admin/controller.rb +19 -0
- data/lib/part/admin/helper.rb +30 -0
- data/lib/part/admin/og/controller.rb +114 -0
- data/lib/part/admin/og/customize.rb +4 -0
- data/lib/part/admin/og/template/index.xhtml +27 -0
- data/lib/part/admin/og/template/list.xhtml +38 -0
- data/lib/part/admin/og/template/search.xhtml +20 -0
- data/lib/part/admin/og/template/update.xhtml +25 -0
- data/lib/part/admin/skin.rb +207 -0
- data/lib/part/admin/template/denied.xhtml +13 -0
- data/lib/part/admin/template/index.xhtml +12 -0
- data/lib/part/admin/todo.txt +2 -0
- data/proto/public/error.xhtml +4 -2
- data/proto/run.rb +0 -2
- data/test/glue/tc_webfile.rb +1 -0
- data/test/nitro/cgi/tc_request.rb +23 -0
- data/test/nitro/helper/tc_feed.rb +0 -3
- data/test/nitro/helper/tc_navbar.rb +74 -0
- data/test/nitro/helper/tc_table.rb +2 -0
- data/test/nitro/tc_cgi.rb +72 -19
- data/test/nitro/tc_controller.rb +35 -26
- data/test/nitro/tc_controller_aspect.rb +1 -0
- data/test/nitro/tc_controller_params.rb +864 -0
- data/test/nitro/tc_dispatcher.rb +2 -2
- data/test/nitro/tc_element.rb +16 -16
- data/test/nitro/tc_flash.rb +3 -3
- data/test/nitro/tc_markup.rb +31 -0
- data/test/nitro/tc_render.rb +12 -14
- data/test/nitro/tc_session.rb +9 -7
- data/test/nitro/tc_template.rb +34 -0
- metadata +217 -198
- data/INSTALL +0 -121
- data/ProjectInfo +0 -74
- data/README +0 -555
- data/doc/apache.txt +0 -9
- data/doc/config.txt +0 -28
- data/doc/faq.txt +0 -7
- data/doc/lhttpd.txt +0 -7
- data/lib/nitro/adapter/scgi.rb +0 -239
- data/lib/nitro/helper/form/builder.rb +0 -144
- data/lib/nitro/helper/form/controls.rb +0 -389
- data/lib/nitro/helper/rss.rb +0 -72
- data/proto/conf/apache.conf +0 -51
- data/proto/public/scaffold/advanced_search.xhtml +0 -30
- data/proto/public/scaffold/edit.xhtml +0 -11
- data/proto/public/scaffold/form.xhtml +0 -1
- data/proto/public/scaffold/index.xhtml +0 -20
- data/proto/public/scaffold/list.xhtml +0 -32
- data/proto/public/scaffold/new.xhtml +0 -11
- data/proto/public/scaffold/search.xhtml +0 -29
- data/proto/public/scaffold/view.xhtml +0 -8
- data/proto/script/scgi_ctl +0 -221
- data/proto/script/scgi_service +0 -128
- data/setup.rb +0 -1585
- data/src/part/admin.rb +0 -16
- data/src/part/admin/controller.rb +0 -81
- data/src/part/admin/skin.rb +0 -21
- data/src/part/admin/system.css +0 -135
- data/src/part/admin/template/denied.xhtml +0 -1
- data/src/part/admin/template/index.xhtml +0 -43
- data/test/nitro/helper/tc_rss.rb +0 -24
data/lib/nitro/session/drb.rb
CHANGED
@@ -3,22 +3,8 @@ require 'nitro/session'
|
|
3
3
|
|
4
4
|
module Nitro
|
5
5
|
|
6
|
-
Logger.info "Using DRb sessions at #{
|
6
|
+
Logger.info "Using DRb sessions at #{Session.cache_address}:#{Session.cache_port}." if defined?(Logger) && $DBG
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
# The address of the Drb store.
|
11
|
-
|
12
|
-
setting :cache_address, :default => '127.0.0.1', :doc => 'The address of the Drb store'
|
13
|
-
|
14
|
-
# The port of the Drb store.
|
15
|
-
|
16
|
-
setting :cache_port, :default => 9069, :doc => 'The port of the Drb store'
|
8
|
+
Session.cache = Glue::DrbCache.new(Session.cache_address, Session.cache_port)
|
17
9
|
|
18
10
|
end
|
19
|
-
|
20
|
-
Session.cache = Glue::DrbCache.new
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
# * George Moschovitis <gm@navel.gr>
|
data/lib/nitro/session/memory.rb
CHANGED
@@ -0,0 +1,219 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
require 'facets/more/openobject'
|
3
|
+
require 'glue/configuration'
|
4
|
+
|
5
|
+
module Nitro
|
6
|
+
|
7
|
+
# A template is a text file with embeded Ruby code. The template
|
8
|
+
# processor converts the original text file to ruby code and
|
9
|
+
# then evaluates this code to produce the result of the
|
10
|
+
# template transformation.
|
11
|
+
|
12
|
+
module TemplateMixin
|
13
|
+
|
14
|
+
# Set some pretty safe delimiters for templates.
|
15
|
+
|
16
|
+
START_DELIM = "<<NITRO_TEMPLATE_DELIMETER\n"
|
17
|
+
END_DELIM = "\nNITRO_TEMPLATE_DELIMETER\n"
|
18
|
+
|
19
|
+
# Convert a template to actual Ruby code, ready to be
|
20
|
+
# evaluated.
|
21
|
+
#
|
22
|
+
# [+template+]
|
23
|
+
# The template as a String.
|
24
|
+
#
|
25
|
+
# [+buffer+]
|
26
|
+
# The variable to act as a buffer where the ruby code
|
27
|
+
# for this template will be generated. Passed as a
|
28
|
+
# String.
|
29
|
+
#
|
30
|
+
# [+base_dir+]
|
31
|
+
# The base directory where the templates reside.
|
32
|
+
|
33
|
+
def compile_template(template, buffer = '@out', base_dir = File.expand_path(Template.root))
|
34
|
+
text = template.dup
|
35
|
+
|
36
|
+
# gmosx, THINK: what is this ?!?
|
37
|
+
|
38
|
+
buffer = '@out' unless buffer.is_a?(String) or buffer.is_a?(Symbol)
|
39
|
+
|
40
|
+
# Strip the xml header! (interracts with the following gsub!)
|
41
|
+
|
42
|
+
text.gsub!(/<\?xml.*\?>/, "")
|
43
|
+
|
44
|
+
# Transform include instructions <include href="xxx" />
|
45
|
+
# must be transformed before the processinc instructions.
|
46
|
+
# Useful to include fragments cached on disk
|
47
|
+
#--
|
48
|
+
# gmosx, FIXME: NOT TESTED! test and add caching.
|
49
|
+
# add load_statically_included fixes.
|
50
|
+
#++
|
51
|
+
|
52
|
+
text.gsub!(/<include href=["'](.*?)["'](.*)(.?)\/>/) do |match|
|
53
|
+
"<?r File.read( '\#{@dispatcher.root}/#$1' ?>"
|
54
|
+
end
|
55
|
+
|
56
|
+
# xform render/inject instructions <render href="xxx" />
|
57
|
+
# must be transformed before the processinc instructions.
|
58
|
+
|
59
|
+
text.gsub!(/<(render|inject) href=["'](.*?)["'](.*)(.?)\/>/) do |match|
|
60
|
+
"<?r render '#$2' ?>"
|
61
|
+
end
|
62
|
+
|
63
|
+
# Remove <root> elements. typically removed by xslt but lets
|
64
|
+
# play it safe. The <root> element is typically added to
|
65
|
+
# template files to make them XHTML valid.
|
66
|
+
|
67
|
+
text.gsub!(/<(\/)?root>/, '')
|
68
|
+
|
69
|
+
# Transform the processing instructions, use <?r as
|
70
|
+
# a marker.
|
71
|
+
|
72
|
+
text.gsub!(/\?>/, "; #{buffer} << #{START_DELIM}")
|
73
|
+
text.gsub!(/<\?r(\s?)/, "#{END_DELIM}; ")
|
74
|
+
|
75
|
+
# Transform alternative code tags.
|
76
|
+
# (very useful in xsl stylesheets)
|
77
|
+
|
78
|
+
text.gsub!(/<\/ruby>/, "; #{buffer} << #{START_DELIM}")
|
79
|
+
text.gsub!(/<ruby>/, "#{END_DELIM}; ")
|
80
|
+
|
81
|
+
# Also handle erb/asp/jsp style tags. Those tags
|
82
|
+
# *cannot* be used with an xslt stylesheet.
|
83
|
+
|
84
|
+
text.gsub!(/%>/, "; #{buffer} << #{START_DELIM}")
|
85
|
+
text.gsub!(/<%/, "#{END_DELIM}; ")
|
86
|
+
|
87
|
+
# Alterative versions of interpolation.
|
88
|
+
# (very useful in xsl stylesheets)
|
89
|
+
# Example: #\my_val\
|
90
|
+
|
91
|
+
text.gsub!(/\#\\(.*?)\\/, '#{\1}')
|
92
|
+
|
93
|
+
# Alternative for entities.
|
94
|
+
# (useful in xsl stylesheets)
|
95
|
+
# Examples: %nbsp;, %rquo;
|
96
|
+
|
97
|
+
text.gsub!(/%(#\d+|\w+);/, '&\1;')
|
98
|
+
|
99
|
+
# Compile time ruby code. This code is evaluated when
|
100
|
+
# compiling the template and the result injected directly
|
101
|
+
# into the result. Usefull for example to prevaluate
|
102
|
+
# localization. Just use the #[] marker instead of #{}.
|
103
|
+
|
104
|
+
text.gsub!(/\#\[(.*?)\]/) do |match|
|
105
|
+
eval($1)
|
106
|
+
end
|
107
|
+
|
108
|
+
text = "#{buffer} << #{START_DELIM}#{text}#{END_DELIM}"
|
109
|
+
|
110
|
+
return text
|
111
|
+
end
|
112
|
+
|
113
|
+
# Evaluate the template.
|
114
|
+
#
|
115
|
+
# [+ruby+]
|
116
|
+
# A String containing the compiled template
|
117
|
+
# code.
|
118
|
+
#
|
119
|
+
# [+binding+]
|
120
|
+
# The evaluation binding for the rendering.
|
121
|
+
|
122
|
+
def evaluate_template(ruby, the_binding = nil)
|
123
|
+
eval(ruby, the_binding)
|
124
|
+
end
|
125
|
+
|
126
|
+
# Compile and render the template.
|
127
|
+
|
128
|
+
def process_template(template, buffer = 'out', the_binding = nil)
|
129
|
+
evaluate_template(compile_template(template, buffer), the_binding)
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
# A helper class that provides access to the Template methods
|
135
|
+
# as singleton methods.
|
136
|
+
|
137
|
+
class Template
|
138
|
+
|
139
|
+
# The default root directory where template files reside.
|
140
|
+
|
141
|
+
if File.exist?('template')
|
142
|
+
default_root = 'template'
|
143
|
+
elsif File.exist?('src/template')
|
144
|
+
default_root = 'src/template'
|
145
|
+
else
|
146
|
+
default_root = 'public'
|
147
|
+
end
|
148
|
+
|
149
|
+
setting :root, :default => default_root, :doc => 'The default root directory where template files reside'
|
150
|
+
|
151
|
+
# The default template name.
|
152
|
+
|
153
|
+
setting :default, :default => 'index', :doc => 'The default template name'
|
154
|
+
|
155
|
+
# The default template file extension.
|
156
|
+
|
157
|
+
setting :extension, :default => 'xhtml', :doc => 'The default template file extension'
|
158
|
+
|
159
|
+
# Strip xml comments from templates?
|
160
|
+
|
161
|
+
setting :strip_xml_comments, :default => false, :doc => 'Strip xml comments from templates?'
|
162
|
+
|
163
|
+
class << self
|
164
|
+
include TemplateMixin
|
165
|
+
alias_method :compile, :compile_template
|
166
|
+
alias_method :transform, :compile_template
|
167
|
+
alias_method :evaluate, :evaluate_template
|
168
|
+
alias_method :process, :process_template
|
169
|
+
end
|
170
|
+
|
171
|
+
include TemplateMixin
|
172
|
+
|
173
|
+
# Helper.
|
174
|
+
|
175
|
+
def render(template)
|
176
|
+
str = ''
|
177
|
+
process_template(template, 'str', binding)
|
178
|
+
return str
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# A Template that reads from files and also
|
183
|
+
# provides a simple but effective caching scheme.
|
184
|
+
# An intuitive binding mechanism provides the
|
185
|
+
# expansion environment.
|
186
|
+
#--
|
187
|
+
# gmosx: there is a problem with using OpenObject here!!!
|
188
|
+
# the eval no longer works!
|
189
|
+
#++
|
190
|
+
|
191
|
+
class FileTemplate < OpenStruct
|
192
|
+
include TemplateMixin
|
193
|
+
|
194
|
+
@@compiled_template_cache = {}
|
195
|
+
|
196
|
+
attr_accessor :template_filename
|
197
|
+
|
198
|
+
def initialize(filename = nil)
|
199
|
+
super
|
200
|
+
@template_filename = filename
|
201
|
+
end
|
202
|
+
|
203
|
+
def process
|
204
|
+
__out__ = ''
|
205
|
+
|
206
|
+
unless compiled = @@compiled_template_cache[@template_filename]
|
207
|
+
template = File.read(@template_filename)
|
208
|
+
compiled = compile_template(template, '__out__')
|
209
|
+
@@compiled_template_cache[@template_filename] = compiled
|
210
|
+
end
|
211
|
+
|
212
|
+
evaluate_template(compiled, binding)
|
213
|
+
|
214
|
+
return __out__
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
end
|
219
|
+
|
@@ -137,7 +137,7 @@ module Test::Unit::Assertions
|
|
137
137
|
assert_block(msg) { cookie.value == value }
|
138
138
|
end
|
139
139
|
|
140
|
-
# :section:
|
140
|
+
# :section: Nitro::Template related assertions.
|
141
141
|
|
142
142
|
# :section: Redirection assertions.
|
143
143
|
|
@@ -167,5 +167,3 @@ module Test::Unit::Assertions
|
|
167
167
|
end
|
168
168
|
|
169
169
|
end
|
170
|
-
|
171
|
-
# * George Moschovitis <gm@navel.gr>
|
data/lib/nitro/test/context.rb
CHANGED
data/lib/nitro/test/testcase.rb
CHANGED
data/lib/part/admin.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
require 'part/admin/skin'
|
3
|
+
require 'part/admin/controller'
|
4
|
+
require 'part/admin/og/controller'
|
5
|
+
|
6
|
+
Nitro::Server.map(
|
7
|
+
'/admin' => AdminController,
|
8
|
+
'/admin/og' => OgAdminController
|
9
|
+
)
|
10
|
+
|
11
|
+
# A admin management part.
|
12
|
+
|
13
|
+
class AdminPart < Nitro::Part
|
14
|
+
def initialiaze
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'part/admin/skin'
|
2
|
+
require 'part/admin/helper'
|
3
|
+
|
4
|
+
# The main Controller for the Admin part.
|
5
|
+
|
6
|
+
class AdminController < Nitro::Controller
|
7
|
+
helper :table, :sitemap
|
8
|
+
helper AdminHelper
|
9
|
+
ann :self, :element_namespace => AdminSkin
|
10
|
+
|
11
|
+
def self.setup_template_root(path)
|
12
|
+
super
|
13
|
+
@template_root << File.join(File.dirname(__FILE__), 'template')
|
14
|
+
end
|
15
|
+
|
16
|
+
def index
|
17
|
+
end
|
18
|
+
ann :index, :title => 'Admin', :parent_controller => '/'
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# This helper should be included to all Admin plugins. Provides
|
2
|
+
# security and other utilities.
|
3
|
+
|
4
|
+
module AdminHelper
|
5
|
+
def self.included(base)
|
6
|
+
super
|
7
|
+
base.before :authorize
|
8
|
+
end
|
9
|
+
|
10
|
+
#--
|
11
|
+
# Generally you do not override this method.
|
12
|
+
#++
|
13
|
+
|
14
|
+
def authorize
|
15
|
+
unless authorized_user?
|
16
|
+
print 'Access denied'
|
17
|
+
exit
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Is the user authorizes to browse Admin pages?
|
22
|
+
#
|
23
|
+
#--
|
24
|
+
# Override this method in your application
|
25
|
+
#++
|
26
|
+
|
27
|
+
def authorized_user?
|
28
|
+
return true
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
require 'part/admin/skin'
|
4
|
+
require 'part/admin/helper'
|
5
|
+
|
6
|
+
#--
|
7
|
+
# Some helper methods. Also used by the extended enchanting
|
8
|
+
# code.
|
9
|
+
#++
|
10
|
+
|
11
|
+
module OgAdminHelper
|
12
|
+
|
13
|
+
def class_to_name(klass)
|
14
|
+
klass.to_s.gsub(/::/, '-')
|
15
|
+
end
|
16
|
+
|
17
|
+
def name_to_class(name)
|
18
|
+
constant(CGI.unescape(name.gsub(/-/, '::')))
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
# The Controller for the OgBrowser Admin module.
|
24
|
+
|
25
|
+
class OgAdminController < Nitro::Controller
|
26
|
+
|
27
|
+
helper :table, :sitemap
|
28
|
+
helper AdminHelper, OgAdminHelper
|
29
|
+
|
30
|
+
ann :self, :element_namespace => AdminSkin
|
31
|
+
|
32
|
+
def self.setup_template_root(path)
|
33
|
+
super
|
34
|
+
@template_root << File.join(File.dirname(__FILE__), 'template')
|
35
|
+
end
|
36
|
+
|
37
|
+
def index
|
38
|
+
@classes = Og.manager.managed_classes.sort { |x, y| x.name <=> y.name }
|
39
|
+
end
|
40
|
+
ann :index, :title => 'Og', :parent_controller => AdminController
|
41
|
+
|
42
|
+
def list(name)
|
43
|
+
@klass = name_to_class(name)
|
44
|
+
@objects, @pager = paginate(@klass, :per_page => Scaffolding.per_page)
|
45
|
+
end
|
46
|
+
ann :list, :title => 'List', :parent => :index
|
47
|
+
|
48
|
+
def search(name)
|
49
|
+
@klass = name_to_class(name)
|
50
|
+
@obj = @klass.allocate
|
51
|
+
end
|
52
|
+
ann :search, :title => 'Search', :parent => :list
|
53
|
+
|
54
|
+
def search_results
|
55
|
+
@klass = name_to_class(request.params.delete('object_class_name').to_s)
|
56
|
+
@objects, @pager = paginate(@klass.query_by_example(request.params), :per_page => Scaffolding.per_page)
|
57
|
+
end
|
58
|
+
ann :search_results, :template => :list
|
59
|
+
ann :search_results, :title => 'Results', :parent => :search
|
60
|
+
|
61
|
+
def delete_class(name)
|
62
|
+
name_to_class(name).delete_all
|
63
|
+
redirect_to_referer
|
64
|
+
end
|
65
|
+
|
66
|
+
def destroy_class(name)
|
67
|
+
name_to_class(name).destroy
|
68
|
+
redirect_to_referer
|
69
|
+
end
|
70
|
+
|
71
|
+
def create(name)
|
72
|
+
klass = name_to_class(name)
|
73
|
+
@obj = klass.allocate
|
74
|
+
end
|
75
|
+
ann :create, :template => :update
|
76
|
+
ann :create, :title => 'Create', :parent => :index
|
77
|
+
|
78
|
+
def read(name, oid)
|
79
|
+
end
|
80
|
+
|
81
|
+
def update(name, oid)
|
82
|
+
klass = name_to_class(name)
|
83
|
+
@obj = klass[oid]
|
84
|
+
end
|
85
|
+
ann :update, :title => 'Update', :parent => :index
|
86
|
+
|
87
|
+
def save
|
88
|
+
klass = name_to_class(request['object_class_name'].to_s)
|
89
|
+
|
90
|
+
if oid = request['oid']
|
91
|
+
obj = klass[oid.to_s]
|
92
|
+
obj.assign(request, :assign_relations => true, :force_boolean => true)
|
93
|
+
else
|
94
|
+
obj = klass.create
|
95
|
+
obj.assign(request, :assign_relations => true)
|
96
|
+
end
|
97
|
+
|
98
|
+
unless obj.valid?
|
99
|
+
flash.concat :ERRORS, obj.errors
|
100
|
+
redirect_to_referer
|
101
|
+
end
|
102
|
+
|
103
|
+
obj.save
|
104
|
+
|
105
|
+
redirect :list, :name, obj.class
|
106
|
+
end
|
107
|
+
|
108
|
+
def delete(name, oid)
|
109
|
+
klass = name_to_class(name)
|
110
|
+
klass.delete(oid)
|
111
|
+
redirect_to_referer
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|