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
@@ -58,12 +58,12 @@ class Exception # :nodoc: all
|
|
58
58
|
number = start
|
59
59
|
extract = source[start..finish].collect do |line|
|
60
60
|
number += 1
|
61
|
-
line = line.gsub(/; @out
|
61
|
+
line = line.gsub(/; @out #{Nitro::TemplateMixin::START_DELIM}/, ' ?>').gsub(/#{Nitro::TemplateMixin::END_DELIM}/, '<?r ')
|
62
62
|
"#{' ' * indent}#{number}: #{line}"
|
63
63
|
end
|
64
64
|
|
65
65
|
return extract.join("\n")
|
66
|
-
rescue => ex
|
66
|
+
rescue Object => ex
|
67
67
|
''
|
68
68
|
end
|
69
69
|
end
|
@@ -110,6 +110,3 @@ class Exception # :nodoc: all
|
|
110
110
|
end
|
111
111
|
|
112
112
|
end
|
113
|
-
|
114
|
-
# * George Moschovitis <gm@navel.gr>
|
115
|
-
# * Rob Pitt <rob@motionpath.co.uk>
|
@@ -19,8 +19,10 @@ class StaticInclude
|
|
19
19
|
# <?include href="root/myfile.sx" ?>
|
20
20
|
|
21
21
|
def self.transform(text, compiler)
|
22
|
-
|
23
|
-
|
22
|
+
resolve_include(text, compiler.controller)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.resolve_include(text, controller)
|
24
26
|
return text.gsub(/<\?include href=["|'](.*?)["|'](.*)\?>/) do |match|
|
25
27
|
found = false
|
26
28
|
|
@@ -29,7 +31,7 @@ class StaticInclude
|
|
29
31
|
# root.
|
30
32
|
|
31
33
|
href = $1[1, 999999] # hack!!
|
32
|
-
template_stack = [
|
34
|
+
template_stack = [ Nitro::Template.root ]
|
33
35
|
else
|
34
36
|
# Relative path, traverse the template_root stack.
|
35
37
|
|
@@ -60,13 +62,13 @@ class StaticInclude
|
|
60
62
|
|
61
63
|
itext = File.read(filename)
|
62
64
|
itext.gsub!(/<\?xml.*\?>/, '')
|
63
|
-
itext.gsub!(/<\/?root(.*?)>/m, ' ')
|
64
|
-
|
65
|
+
itext.gsub!(/<\/?root(.*?)>/m, ' ')
|
66
|
+
|
67
|
+
# Recursively resolve to handle sub-includes.
|
68
|
+
|
69
|
+
resolve_include(itext, controller)
|
65
70
|
end
|
66
71
|
end
|
67
|
-
|
68
72
|
end
|
69
73
|
|
70
74
|
end
|
71
|
-
|
72
|
-
# * George Moschovitis <gm@navel.gr>
|
@@ -1,23 +1,31 @@
|
|
1
|
-
require '
|
1
|
+
require 'nitro/markup'
|
2
2
|
|
3
3
|
module Nitro
|
4
4
|
|
5
|
-
module
|
6
|
-
|
7
|
-
include Glue::Markup
|
5
|
+
module MarkupCompiler
|
6
|
+
include Markup
|
8
7
|
|
9
8
|
# Transform the markup macros.
|
10
9
|
# Maps #(..) to :sanitize.
|
11
10
|
# Maps #|..| to :markup.
|
11
|
+
#
|
12
|
+
# Additional markup macros:
|
13
|
+
#
|
14
|
+
# Maps ''..'' to #{...to_link}
|
15
|
+
# Maps {{..}} to #{R ..}
|
16
|
+
# Maps #<..> to #{R ..}
|
12
17
|
|
13
18
|
def self.transform(text, compiler = nil)
|
14
19
|
text.gsub!(/\#\((.*?)\)/, '#{sanitize(\1)}')
|
15
20
|
text.gsub!(/\#\|(.*?)\|/, '#{markup(\1)}')
|
21
|
+
|
22
|
+
text.gsub!(/\'\'(.*?)\'\'/, '#{\1.to_link}')
|
23
|
+
text.gsub!(/\{\{(.*?)\}\}/, '#{R \1}')
|
24
|
+
text.gsub!(/\#\<(.*?)\>/, '#{R \1}')
|
25
|
+
|
16
26
|
return text
|
17
27
|
end
|
18
28
|
|
19
29
|
end
|
20
30
|
|
21
31
|
end
|
22
|
-
|
23
|
-
# * George Moschovitis <gm@navel.gr>
|
@@ -203,7 +203,7 @@ class Morphing
|
|
203
203
|
end
|
204
204
|
|
205
205
|
def comment(c)
|
206
|
-
unless
|
206
|
+
unless Nitro::Template.strip_xml_comments
|
207
207
|
@buffer << "<!--#{c}-->"
|
208
208
|
end
|
209
209
|
end
|
@@ -270,7 +270,3 @@ class Morphing
|
|
270
270
|
end
|
271
271
|
|
272
272
|
end
|
273
|
-
|
274
|
-
# * George Moschovitis <gm@navel.gr>
|
275
|
-
# * Guillaume Pierronnet <guillaume.pierronnet@gmail.com>
|
276
|
-
# * Chris Farmiloe <chris.farmiloe@farmiloe.com>
|
@@ -12,7 +12,7 @@ module ScriptCompiler
|
|
12
12
|
def self.transform(text, compiler)
|
13
13
|
begin
|
14
14
|
client = constant("#{compiler.controller}::Client")
|
15
|
-
rescue
|
15
|
+
rescue NameError => ex
|
16
16
|
client = nil
|
17
17
|
end
|
18
18
|
|
@@ -50,7 +50,7 @@ module ScriptCompiler
|
|
50
50
|
#{function_code}
|
51
51
|
}
|
52
52
|
}
|
53
|
-
rescue => ex
|
53
|
+
rescue Object => ex
|
54
54
|
Logger.debug ex.inspect if $DBG
|
55
55
|
end
|
56
56
|
end
|
@@ -113,5 +113,3 @@ module ScriptCompiler
|
|
113
113
|
end
|
114
114
|
|
115
115
|
end
|
116
|
-
|
117
|
-
# * George Moschovitis <gm@navel.gr>
|
data/lib/nitro/compiler/xslt.rb
CHANGED
data/lib/nitro/context.rb
CHANGED
@@ -3,6 +3,7 @@ require 'forwardable'
|
|
3
3
|
require 'facet/kernel/assign_with'
|
4
4
|
|
5
5
|
require 'glue/cache/memory'
|
6
|
+
require 'glue/attributeutils'
|
6
7
|
|
7
8
|
require 'nitro/cgi'
|
8
9
|
require 'nitro/cgi/request'
|
@@ -112,6 +113,12 @@ class Context
|
|
112
113
|
@out
|
113
114
|
end
|
114
115
|
|
116
|
+
# Access the server
|
117
|
+
|
118
|
+
def server
|
119
|
+
@dispatcher.server
|
120
|
+
end
|
121
|
+
|
115
122
|
# Lazy lookup of the session to avoid costly cookie
|
116
123
|
# lookup when not needed.
|
117
124
|
|
@@ -126,7 +133,7 @@ class Context
|
|
126
133
|
return Global
|
127
134
|
end
|
128
135
|
alias_method :application, :global
|
129
|
-
|
136
|
+
=begin
|
130
137
|
# Lookup the controller for this request.
|
131
138
|
#--
|
132
139
|
# FIXME: improve this! BUGGY
|
@@ -135,7 +142,7 @@ class Context
|
|
135
142
|
def controller
|
136
143
|
@dispatcher.controllers[@base || '/']
|
137
144
|
end
|
138
|
-
|
145
|
+
=end
|
139
146
|
# Automagically populate an object from request parameters.
|
140
147
|
# This is a truly dangerous method.
|
141
148
|
#
|
@@ -153,7 +160,7 @@ class Context
|
|
153
160
|
# User.new.assign_with(request)
|
154
161
|
|
155
162
|
def fill(obj, options = {})
|
156
|
-
|
163
|
+
AttributeUtils.populate_object(obj, @params, options)
|
157
164
|
end
|
158
165
|
alias_method :populate, :fill
|
159
166
|
alias_method :assign, :fill
|
@@ -181,5 +188,3 @@ class Context
|
|
181
188
|
end
|
182
189
|
|
183
190
|
end
|
184
|
-
|
185
|
-
# * George Moschovitis <gm@navel.gr>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'nitro/element'
|
2
|
+
require 'nitro/helper/xhtml'
|
3
|
+
|
4
|
+
module Nitro
|
5
|
+
|
6
|
+
# A specialized kind of element used for implementing UI
|
7
|
+
# controls.
|
8
|
+
#--
|
9
|
+
# TODO: add support for the singleton pattern to avoid excessive
|
10
|
+
# memory usage.
|
11
|
+
#++
|
12
|
+
|
13
|
+
class Control < Element
|
14
|
+
# THINK: maybe include this in element too?
|
15
|
+
include Nitro::XhtmlHelper
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'nitro/control'
|
2
|
+
|
3
|
+
module Nitro
|
4
|
+
|
5
|
+
# The base class for controls used to inspect object
|
6
|
+
# attributes.
|
7
|
+
#--
|
8
|
+
# TODO: find a better name.
|
9
|
+
#++
|
10
|
+
|
11
|
+
class AttributeControl < Control
|
12
|
+
|
13
|
+
# The attribute that this control renders.
|
14
|
+
|
15
|
+
attr_accessor :attribute
|
16
|
+
|
17
|
+
# The annotations used for rendering
|
18
|
+
|
19
|
+
attr_accessor :anno
|
20
|
+
|
21
|
+
# The value
|
22
|
+
|
23
|
+
attr_accessor :value
|
24
|
+
alias values value
|
25
|
+
|
26
|
+
# === Input
|
27
|
+
#
|
28
|
+
# * object = the object to inspect
|
29
|
+
# * a = the attribute to inspect
|
30
|
+
# * options = additional options
|
31
|
+
|
32
|
+
def initialize(object, a, options)
|
33
|
+
@object = object
|
34
|
+
@attribute = a
|
35
|
+
@anno = @object.class.ann(@attribute)
|
36
|
+
@objann = @object.annotation[@attribute] || @object.annotation
|
37
|
+
@value = @object.send(@attribute)
|
38
|
+
@options = options
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
# Emit the label for this control.
|
44
|
+
# The label is skipped if the control is created with the
|
45
|
+
# option :no_label set to true.
|
46
|
+
|
47
|
+
def emit_label
|
48
|
+
return '' if @options[:no_label]
|
49
|
+
title = @anno[:title] || @options[:label] || @attribute.to_s.humanize
|
50
|
+
%{<label for="#{@attribute}">#{title}</label>}
|
51
|
+
end
|
52
|
+
|
53
|
+
# Emit the css style for this control.
|
54
|
+
# This mehtod takes into account the passed options (first)
|
55
|
+
# and then the attribute annotations.
|
56
|
+
|
57
|
+
def emit_style
|
58
|
+
unless style = (@options[:style] || @anno[:control_style])
|
59
|
+
# unless style = (@objann[:control_style] || @options[:style] || @anno[:control_style])
|
60
|
+
if self.class.respond_to? :style
|
61
|
+
style = self.class.style
|
62
|
+
else
|
63
|
+
style = nil
|
64
|
+
end
|
65
|
+
end
|
66
|
+
style ? %{ style="#{style}"} : ''
|
67
|
+
end
|
68
|
+
|
69
|
+
# Add support to your controls for being disabled
|
70
|
+
# by including an emit_disabled on form items
|
71
|
+
# or testing for is_disabled? on more complex controls.
|
72
|
+
|
73
|
+
def emit_disabled
|
74
|
+
is_disabled? ? %{ disabled="disabled"} : ''
|
75
|
+
end
|
76
|
+
|
77
|
+
#--
|
78
|
+
# FIXME
|
79
|
+
#++
|
80
|
+
|
81
|
+
def is_disabled?
|
82
|
+
return false if @options[:all]
|
83
|
+
@options[:disable_controls] || @anno[:disable_control]
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'nitro/control/attribute'
|
2
|
+
|
3
|
+
module Nitro
|
4
|
+
|
5
|
+
# A Control used to edit boolean attributes.
|
6
|
+
|
7
|
+
class CheckboxControl < AttributeControl
|
8
|
+
setting :style, :default => '', :doc => 'The default style'
|
9
|
+
|
10
|
+
def render
|
11
|
+
checked = @value == true ? ' checked="checked"' : ''
|
12
|
+
%{
|
13
|
+
<input type="checkbox" id="#{@attribute}_ctl" name="#{@attribute}" #{emit_style}#{checked}#{emit_disabled} /> #{emit_label}
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'nitro/control/attribute'
|
2
|
+
|
3
|
+
module Nitro
|
4
|
+
|
5
|
+
# A Control used to edit datetime attributes.
|
6
|
+
#--
|
7
|
+
# TODO: implement me!
|
8
|
+
#++
|
9
|
+
|
10
|
+
class DatetimeControl < AttributeControl
|
11
|
+
setting :style, :default => '', :doc => 'The default style'
|
12
|
+
|
13
|
+
def render
|
14
|
+
%{
|
15
|
+
NOT IMPLEMENTED
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'nitro/control/attribute'
|
2
|
+
|
3
|
+
module Nitro
|
4
|
+
|
5
|
+
# Usage note:
|
6
|
+
# don't forget to set form :method to :multipart
|
7
|
+
# or :method to :post and :enctype to 'multipart/form-data'
|
8
|
+
|
9
|
+
class FileControl < AttributeControl
|
10
|
+
setting :style, :default => 'width: 250px', :doc => 'The default style'
|
11
|
+
|
12
|
+
def render
|
13
|
+
%{
|
14
|
+
#{emit_label}
|
15
|
+
<input type="file" id="#{@attribute}_ctl" name="#{@attribute}" value="#{@object.send(@attribute)}"#{emit_style}#{emit_disabled} />
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'nitro/control/attribute'
|
2
|
+
|
3
|
+
module Nitro
|
4
|
+
|
5
|
+
# Controls a Fixnum attribute.
|
6
|
+
|
7
|
+
class FixnumControl < AttributeControl
|
8
|
+
setting :style, :default => 'width: 100px', :doc => 'The default style'
|
9
|
+
|
10
|
+
def render
|
11
|
+
style = @anno.control_style || self.class.style
|
12
|
+
%{
|
13
|
+
#{emit_label}
|
14
|
+
<input type="text" id="#{@attribute}_ctl" name="#{@attribute}" value="#{value}"#{emit_style}#{emit_disabled} />
|
15
|
+
<a href="#" onclick="el=document.getElementById('#{@attribute}_ctl'); el.value=(parseInt(el.value) || 0)+#{step}; return false;">+</a>
|
16
|
+
<a href="#" onclick="el=document.getElementById('#{@attribute}_ctl'); el.value=(parseInt(el.value) || 0)-#{step}; return false;">-</a>
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def step
|
21
|
+
1
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'nitro/control/attribute'
|
2
|
+
|
3
|
+
module Nitro
|
4
|
+
|
5
|
+
# Controls a Float attribute.
|
6
|
+
|
7
|
+
class FloatControl < AttributeControl
|
8
|
+
setting :style, :default => 'width: 100px', :doc => 'The default style'
|
9
|
+
|
10
|
+
def render
|
11
|
+
style = @anno.control_style || self.class.style
|
12
|
+
%{
|
13
|
+
#{emit_label}
|
14
|
+
<input type="text" id="#{@attribute}_ctl" name="#{@attribute}" value="#{value}"#{emit_style}#{emit_disabled} />
|
15
|
+
<a href="#" onclick="el=document.getElementById('#{@attribute}_ctl'); el.value=(parseInt(el.value) || 0)+#{step}; return false;">+</a>
|
16
|
+
<a href="#" onclick="el=document.getElementById('#{@attribute}_ctl'); el.value=(parseInt(el.value) || 0)-#{step}; return false;">-</a>
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def step
|
21
|
+
0.5
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|