raw 0.49.0
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/CONTRIBUTORS +106 -0
- data/doc/LICENSE +32 -0
- data/doc/coding_conventions.txt +11 -0
- data/lib/raw.rb +42 -0
- data/lib/raw/adapter.rb +113 -0
- data/lib/raw/adapter/cgi.rb +41 -0
- data/lib/raw/adapter/fastcgi.rb +48 -0
- data/lib/raw/adapter/mongrel.rb +146 -0
- data/lib/raw/adapter/script.rb +94 -0
- data/lib/raw/adapter/webrick.rb +144 -0
- data/lib/raw/adapter/webrick/vcr.rb +91 -0
- data/lib/raw/cgi.rb +323 -0
- data/lib/raw/cgi/cookie.rb +47 -0
- data/lib/raw/cgi/http.rb +62 -0
- data/lib/raw/compiler.rb +138 -0
- data/lib/raw/compiler/filter/cleanup.rb +21 -0
- data/lib/raw/compiler/filter/elements.rb +166 -0
- data/lib/raw/compiler/filter/elements/element.rb +210 -0
- data/lib/raw/compiler/filter/localization.rb +23 -0
- data/lib/raw/compiler/filter/markup.rb +32 -0
- data/lib/raw/compiler/filter/morph.rb +123 -0
- data/lib/raw/compiler/filter/morph/each.rb +34 -0
- data/lib/raw/compiler/filter/morph/for.rb +11 -0
- data/lib/raw/compiler/filter/morph/if.rb +26 -0
- data/lib/raw/compiler/filter/morph/selected_if.rb +43 -0
- data/lib/raw/compiler/filter/morph/standard.rb +55 -0
- data/lib/raw/compiler/filter/morph/times.rb +27 -0
- data/lib/raw/compiler/filter/script.rb +116 -0
- data/lib/raw/compiler/filter/squeeze.rb +16 -0
- data/lib/raw/compiler/filter/static_include.rb +74 -0
- data/lib/raw/compiler/filter/template.rb +121 -0
- data/lib/raw/compiler/reloader.rb +96 -0
- data/lib/raw/context.rb +154 -0
- data/lib/raw/context/flash.rb +157 -0
- data/lib/raw/context/global.rb +88 -0
- data/lib/raw/context/request.rb +338 -0
- data/lib/raw/context/response.rb +57 -0
- data/lib/raw/context/session.rb +198 -0
- data/lib/raw/context/session/drb.rb +11 -0
- data/lib/raw/context/session/file.rb +15 -0
- data/lib/raw/context/session/memcached.rb +13 -0
- data/lib/raw/context/session/memory.rb +12 -0
- data/lib/raw/context/session/og.rb +15 -0
- data/lib/raw/context/session/pstore.rb +13 -0
- data/lib/raw/control.rb +18 -0
- data/lib/raw/control/attribute.rb +91 -0
- data/lib/raw/control/attribute/checkbox.rb +25 -0
- data/lib/raw/control/attribute/datetime.rb +21 -0
- data/lib/raw/control/attribute/file.rb +20 -0
- data/lib/raw/control/attribute/fixnum.rb +26 -0
- data/lib/raw/control/attribute/float.rb +26 -0
- data/lib/raw/control/attribute/options.rb +38 -0
- data/lib/raw/control/attribute/password.rb +16 -0
- data/lib/raw/control/attribute/text.rb +16 -0
- data/lib/raw/control/attribute/textarea.rb +16 -0
- data/lib/raw/control/none.rb +16 -0
- data/lib/raw/control/relation.rb +59 -0
- data/lib/raw/control/relation/belongs_to.rb +0 -0
- data/lib/raw/control/relation/has_many.rb +97 -0
- data/lib/raw/control/relation/joins_many.rb +0 -0
- data/lib/raw/control/relation/many_to_many.rb +0 -0
- data/lib/raw/control/relation/refers_to.rb +29 -0
- data/lib/raw/controller.rb +37 -0
- data/lib/raw/controller/publishable.rb +160 -0
- data/lib/raw/dispatcher.rb +209 -0
- data/lib/raw/dispatcher/format.rb +108 -0
- data/lib/raw/dispatcher/format/atom.rb +31 -0
- data/lib/raw/dispatcher/format/css.rb +0 -0
- data/lib/raw/dispatcher/format/html.rb +42 -0
- data/lib/raw/dispatcher/format/json.rb +31 -0
- data/lib/raw/dispatcher/format/rss.rb +33 -0
- data/lib/raw/dispatcher/format/xoxo.rb +31 -0
- data/lib/raw/dispatcher/mounter.rb +60 -0
- data/lib/raw/dispatcher/router.rb +111 -0
- data/lib/raw/errors.rb +19 -0
- data/lib/raw/helper.rb +86 -0
- data/lib/raw/helper/benchmark.rb +23 -0
- data/lib/raw/helper/buffer.rb +60 -0
- data/lib/raw/helper/cookie.rb +32 -0
- data/lib/raw/helper/debug.rb +28 -0
- data/lib/raw/helper/default.rb +16 -0
- data/lib/raw/helper/feed.rb +451 -0
- data/lib/raw/helper/form.rb +284 -0
- data/lib/raw/helper/javascript.rb +59 -0
- data/lib/raw/helper/layout.rb +40 -0
- data/lib/raw/helper/navigation.rb +87 -0
- data/lib/raw/helper/pager.rb +305 -0
- data/lib/raw/helper/table.rb +247 -0
- data/lib/raw/helper/xhtml.rb +218 -0
- data/lib/raw/helper/xml.rb +125 -0
- data/lib/raw/mixin/magick.rb +35 -0
- data/lib/raw/mixin/sweeper.rb +71 -0
- data/lib/raw/mixin/thumbnails.rb +1 -0
- data/lib/raw/mixin/webfile.rb +165 -0
- data/lib/raw/render.rb +271 -0
- data/lib/raw/render/builder.rb +26 -0
- data/lib/raw/render/caching.rb +81 -0
- data/lib/raw/render/call.rb +43 -0
- data/lib/raw/render/send_file.rb +46 -0
- data/lib/raw/render/stream.rb +39 -0
- data/lib/raw/scaffold.rb +13 -0
- data/lib/raw/scaffold/controller.rb +25 -0
- data/lib/raw/scaffold/model.rb +157 -0
- data/lib/raw/test.rb +5 -0
- data/lib/raw/test/assertions.rb +169 -0
- data/lib/raw/test/context.rb +55 -0
- data/lib/raw/test/testcase.rb +79 -0
- data/lib/raw/util/attr.rb +128 -0
- data/lib/raw/util/encode_uri.rb +149 -0
- data/lib/raw/util/html_filter.rb +538 -0
- data/lib/raw/util/markup.rb +130 -0
- data/test/glue/tc_webfile.rb +1 -0
- data/test/nitro/CONFIG.rb +3 -0
- data/test/nitro/adapter/raw_post1.bin +9 -0
- data/test/nitro/adapter/tc_webrick.rb +16 -0
- data/test/nitro/cgi/tc_cookie.rb +14 -0
- data/test/nitro/cgi/tc_request.rb +61 -0
- data/test/nitro/compiler/tc_client_morpher.rb +47 -0
- data/test/nitro/compiler/tc_compiler.rb +25 -0
- data/test/nitro/dispatcher/tc_mounter.rb +47 -0
- data/test/nitro/helper/tc_feed.rb +135 -0
- data/test/nitro/helper/tc_navbar.rb +74 -0
- data/test/nitro/helper/tc_pager.rb +35 -0
- data/test/nitro/helper/tc_table.rb +68 -0
- data/test/nitro/helper/tc_xhtml.rb +19 -0
- data/test/nitro/tc_caching.rb +19 -0
- data/test/nitro/tc_cgi.rb +222 -0
- data/test/nitro/tc_context.rb +17 -0
- data/test/nitro/tc_controller.rb +103 -0
- data/test/nitro/tc_controller_aspect.rb +32 -0
- data/test/nitro/tc_controller_params.rb +885 -0
- data/test/nitro/tc_dispatcher.rb +109 -0
- data/test/nitro/tc_element.rb +85 -0
- data/test/nitro/tc_flash.rb +59 -0
- data/test/nitro/tc_helper.rb +47 -0
- data/test/nitro/tc_render.rb +119 -0
- data/test/nitro/tc_router.rb +61 -0
- data/test/nitro/tc_server.rb +35 -0
- data/test/nitro/tc_session.rb +66 -0
- data/test/nitro/tc_template.rb +71 -0
- data/test/nitro/util/tc_encode_url.rb +87 -0
- data/test/nitro/util/tc_markup.rb +31 -0
- data/test/public/blog/another/very_litle/index.xhtml +1 -0
- data/test/public/blog/inc1.xhtml +2 -0
- data/test/public/blog/inc2.xhtml +1 -0
- data/test/public/blog/list.xhtml +9 -0
- data/test/public/dummy_mailer/registration.xhtml +5 -0
- metadata +244 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
require "raw/control/attribute"
|
2
|
+
|
3
|
+
module Raw
|
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="#{control_id}" name="#{@attribute}" #{emit_style}#{checked}#{emit_disabled} /> #{emit_label}
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def emit_label
|
18
|
+
return '' if @options[:no_label]
|
19
|
+
title = @anno[:title] || @options[:label] || @attribute.to_s.humanize
|
20
|
+
%{<label for="#{@attribute}" style="display: inline">#{title}</label>}
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "raw/control/attribute"
|
2
|
+
|
3
|
+
module Raw
|
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 "raw/control/attribute"
|
2
|
+
|
3
|
+
module Raw
|
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="#{control_id}" name="#{@attribute}" value="#{@object.send(@attribute)}"#{emit_style}#{emit_disabled} />
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "raw/control/attribute"
|
2
|
+
|
3
|
+
module Raw
|
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="#{control_id}" name="#{@attribute}" value="#{value}"#{emit_style}#{emit_disabled} />
|
15
|
+
<a href="#" onclick="el=document.getElementById('#{control_id}'); el.value=(parseInt(el.value) || 0)+#{step}; return false;">+</a>
|
16
|
+
<a href="#" onclick="el=document.getElementById('#{control_id}'); 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 "raw/control/attribute"
|
2
|
+
|
3
|
+
module Raw
|
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="#{control_id}" name="#{@attribute}" value="#{value}"#{emit_style}#{emit_disabled} />
|
15
|
+
<a href="#" onclick="el=document.getElementById('#{control_id}'); el.value=(parseInt(el.value) || 0)+#{step}; return false;">+</a>
|
16
|
+
<a href="#" onclick="el=document.getElementById('#{control_id}'); 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
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "raw/control/attribute"
|
2
|
+
|
3
|
+
module Raw
|
4
|
+
|
5
|
+
# Controls a Fixnum attribute that can contain discreet values
|
6
|
+
# (options).
|
7
|
+
#
|
8
|
+
# === Example
|
9
|
+
#
|
10
|
+
# Pass a 'reverse' dictionary. Reverse to reuse the has for
|
11
|
+
# easy rendering of labels. Dictionary to allow for ordered
|
12
|
+
# keys.
|
13
|
+
#
|
14
|
+
# PRIORITY_VALUES = Dictionary[
|
15
|
+
# 0, :trivial,
|
16
|
+
# 1, :minor,
|
17
|
+
# 2, :major,
|
18
|
+
# 3, :blocker
|
19
|
+
# ]
|
20
|
+
#
|
21
|
+
# attr_accessor :priority, Fixnum, :control => :options, :options_data => PRIORITY_VALUES
|
22
|
+
|
23
|
+
class OptionsControl < AttributeControl
|
24
|
+
setting :style, :default => 'width: 100px', :doc => 'The default style'
|
25
|
+
|
26
|
+
def render
|
27
|
+
style = @anno[:control_style] || self.class.style
|
28
|
+
data = @anno[:options_data]
|
29
|
+
%{
|
30
|
+
#{emit_label}
|
31
|
+
<select id="#{control_id}" name="#{@attribute}">
|
32
|
+
#{options :labels => data.values, :values => data.keys, :selected => value}
|
33
|
+
</select>
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "raw/control/attribute"
|
2
|
+
|
3
|
+
module Raw
|
4
|
+
|
5
|
+
class PasswordControl < AttributeControl
|
6
|
+
setting :style, :default => 'width: 250px', :doc => 'The default style'
|
7
|
+
|
8
|
+
def render
|
9
|
+
%{
|
10
|
+
#{emit_label}
|
11
|
+
<input type="password" id="#{control_id}" name="#{@attribute}" value="#{@object.send(@attribute)}"#{emit_style}#{emit_disabled} />
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "raw/control/attribute"
|
2
|
+
|
3
|
+
module Raw
|
4
|
+
|
5
|
+
class TextControl < AttributeControl
|
6
|
+
setting :style, :default => 'width: 250px', :doc => 'The default style'
|
7
|
+
|
8
|
+
def render
|
9
|
+
%{
|
10
|
+
#{emit_label}
|
11
|
+
<input type="text" id="#{control_id}" name="#{@attribute}" value="#{@object.send(@attribute)}"#{emit_style}#{emit_disabled} />
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "raw/control/attribute"
|
2
|
+
|
3
|
+
module Raw
|
4
|
+
|
5
|
+
class TextareaControl < AttributeControl
|
6
|
+
setting :style, :default => 'width: 500px; height: 100px', :doc => 'The default style'
|
7
|
+
|
8
|
+
def render
|
9
|
+
%{
|
10
|
+
#{emit_label}
|
11
|
+
<textarea id="#{control_id}" name="#{@attribute}"#{emit_style}#{emit_disabled}>#{@object.send(@attribute)}</textarea>
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require "raw/control/attribute"
|
2
|
+
|
3
|
+
module Raw
|
4
|
+
|
5
|
+
# The base class for controls used to inspect object
|
6
|
+
# relations.
|
7
|
+
#--
|
8
|
+
# FIXME: this is a temp hack.
|
9
|
+
# TODO: Fix mismatches with attributes.
|
10
|
+
#++
|
11
|
+
|
12
|
+
class RelationControl < AttributeControl
|
13
|
+
|
14
|
+
# === Input
|
15
|
+
#
|
16
|
+
# * object = the object to inspect
|
17
|
+
# * symbol = the relation symbol
|
18
|
+
# * anno = the relation annotations
|
19
|
+
# * options = additional options
|
20
|
+
|
21
|
+
def initialize object, rel, options
|
22
|
+
@object = object
|
23
|
+
@anno = rel
|
24
|
+
@value = options[:value] || object.send(rel.name.to_sym)
|
25
|
+
@options = options
|
26
|
+
end
|
27
|
+
|
28
|
+
def symbol
|
29
|
+
@anno[:symbol]
|
30
|
+
end
|
31
|
+
|
32
|
+
def rel
|
33
|
+
@anno
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
# Used as id attribute in HTML markup.
|
39
|
+
def control_id
|
40
|
+
"#{rel.name}_ctl"
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
# Emit the label for this control.
|
45
|
+
# The label is skipped if the control is created with the
|
46
|
+
# option :no_label set to true.
|
47
|
+
#--
|
48
|
+
# TODO: reuse attribute control version.
|
49
|
+
#++
|
50
|
+
|
51
|
+
def emit_label
|
52
|
+
return '' if @options[:no_label]
|
53
|
+
title = @anno[:title] || @options[:label] || @anno[:name].to_s.humanize
|
54
|
+
%{<label for="#{control_id}">#{title}</label>}
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
File without changes
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require "raw/control/relation"
|
2
|
+
|
3
|
+
module Raw
|
4
|
+
|
5
|
+
# HasMany, ManyToMany and JoinsMany
|
6
|
+
|
7
|
+
class HasManyControl < RelationControl
|
8
|
+
|
9
|
+
#pre :do_this, :on => :populate_object
|
10
|
+
|
11
|
+
def render
|
12
|
+
str = "#{emit_label}"
|
13
|
+
str << emit_container_start
|
14
|
+
str << emit_js
|
15
|
+
if selected_items.empty?
|
16
|
+
str << emit_selector(:removable => false)
|
17
|
+
else
|
18
|
+
removable = selected_items.size != 1 ? true : false
|
19
|
+
selected_items.each do |item|
|
20
|
+
str << emit_selector(:selected => item.pk)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
str << emit_container_end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
# these parts are seperated from render to make it easier
|
29
|
+
# to extend and customise the HasManyControl
|
30
|
+
|
31
|
+
def all_items
|
32
|
+
return @all_items unless @all_items.nil?
|
33
|
+
@all_items = rel.target_class.all
|
34
|
+
end
|
35
|
+
|
36
|
+
def selected_items
|
37
|
+
if @object.saved?
|
38
|
+
values
|
39
|
+
else
|
40
|
+
[] # gmosx, THINK: this is a hack fix!
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def emit_container_start
|
45
|
+
%{<div class="many_to_many_container">}
|
46
|
+
end
|
47
|
+
|
48
|
+
def emit_container_end
|
49
|
+
'</div>'
|
50
|
+
end
|
51
|
+
|
52
|
+
# :removable controls wether the minus button is active
|
53
|
+
# :selected denotes the oid to flag as selected in the list
|
54
|
+
|
55
|
+
def emit_selector(options={})
|
56
|
+
removable = options.fetch(:removable, true)
|
57
|
+
selected = options.fetch(:selected, nil)
|
58
|
+
%{
|
59
|
+
<div>
|
60
|
+
<select class="has_many_ctl" name="#{rel.name}[]" id="#{control_id}" #{emit_style}#{emit_disabled}>
|
61
|
+
<option value="">None</option>
|
62
|
+
#{options(:labels => all_items.map{|o| o.to_s}, :values => all_items.map{|o| o.pk}, :selected => selected)}
|
63
|
+
</select>
|
64
|
+
<input type="button" class="#{rel.name}_remove_btn" value=" - " onclick="rm_#{rel.name}_rel(this);" #{'disabled="disabled"' unless removable} />
|
65
|
+
<input type="button" class="#{rel.name}_add_btn" value=" + " onclick="add_#{rel.name}_rel(this);"#{emit_disabled} />
|
66
|
+
</div>
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
# Inline script: override this to change behavior
|
71
|
+
|
72
|
+
def emit_js
|
73
|
+
%{
|
74
|
+
<script type="text/javascript">
|
75
|
+
rm_#{rel.name}_rel = function(el){
|
76
|
+
ctl=el.parentNode;
|
77
|
+
container=ctl.parentNode;
|
78
|
+
container.removeChild(ctl);
|
79
|
+
inputTags = container.getElementsByTagName('input');
|
80
|
+
if(inputTags.length==2)
|
81
|
+
inputTags[0].disabled='disabled';
|
82
|
+
}
|
83
|
+
add_#{rel.name}_rel = function(el){
|
84
|
+
ctl=el.parentNode;
|
85
|
+
container=ctl.parentNode;
|
86
|
+
node=ctl.cloneNode(true);
|
87
|
+
node.getElementsByTagName('input')[0].removeAttribute('disabled');
|
88
|
+
if(container.lastChild==ctl) container.appendChild(node);
|
89
|
+
else container.insertBefore(node, ctl.nextSibling);
|
90
|
+
if(container.childNodes.length>1) container.getElementsByTagName('input')[0].disabled='';
|
91
|
+
}
|
92
|
+
</script>
|
93
|
+
}
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "raw/control/relation"
|
2
|
+
|
3
|
+
module Raw
|
4
|
+
|
5
|
+
# RefersTo. Also used for BelongsTo.
|
6
|
+
|
7
|
+
class RefersToControl < RelationControl
|
8
|
+
|
9
|
+
def render
|
10
|
+
%{
|
11
|
+
#{emit_label}
|
12
|
+
<select id="#{control_id}" name="#{rel.name}"#{emit_disabled}>
|
13
|
+
#{emit_options}
|
14
|
+
</select>
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def emit_options
|
19
|
+
objs = rel.target_class.all
|
20
|
+
selected = selected.pk if selected = value
|
21
|
+
%{
|
22
|
+
<option value="">--</option>
|
23
|
+
#{options(:labels => objs.map{|o| o.to_s}, :values => objs.map{|o| o.pk}, :selected => selected)}
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "raw/controller/publishable"
|
2
|
+
|
3
|
+
module Raw
|
4
|
+
|
5
|
+
# The Controller part in the MVC paradigm. The controller's
|
6
|
+
# published methods are called actrions. The controller class
|
7
|
+
# contains the Publishable mixin and additional helper mixins.
|
8
|
+
|
9
|
+
class Controller
|
10
|
+
include Publishable
|
11
|
+
|
12
|
+
# This callback is called after the Controller is mounted.
|
13
|
+
|
14
|
+
def self.mounted(path)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns the current controller from the context thread local
|
18
|
+
# variable.
|
19
|
+
|
20
|
+
def self.current
|
21
|
+
Thread.current[:CURRENT_CONTROLLER]
|
22
|
+
end
|
23
|
+
|
24
|
+
#--
|
25
|
+
# Replaces the current controller (helper for render).
|
26
|
+
# This is an internal method.
|
27
|
+
#++
|
28
|
+
|
29
|
+
def self.replace_current(controller) # :nodoc:
|
30
|
+
old = Thread.current[:CURRENT_CONTROLLER]
|
31
|
+
Thread.current[:CURRENT_CONTROLLER] = controller
|
32
|
+
return old
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|