lolita 3.0.7 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/GUIDELINE +4 -0
- data/README.rdoc +50 -0
- data/VERSION +1 -1
- data/app/controllers/lolita/rest_controller.rb +27 -11
- data/app/helpers/components/lolita/configuration/list_component.rb +11 -0
- data/app/helpers/lolita_helper.rb +1 -1
- data/app/views/components/lolita/configuration/field/_display.html.erb +9 -0
- data/app/views/components/lolita/configuration/field/_label.html.erb +1 -0
- data/app/views/components/lolita/{field → configuration/field}/_object.html.erb +0 -0
- data/app/views/components/lolita/configuration/field/array/_display.html.erb +5 -0
- data/app/views/components/lolita/configuration/field/array/habtm/_display.html.erb +26 -0
- data/app/views/components/lolita/configuration/field/array/select/_display.html.erb +5 -0
- data/app/views/components/lolita/configuration/field/big_decimal/_display.html.erb +1 -0
- data/app/views/components/lolita/{field/_boolean.html.erb → configuration/field/boolean/_display.html.erb} +0 -0
- data/app/views/components/lolita/configuration/field/date/_display.html.erb +1 -0
- data/app/views/components/lolita/{field/_string.html.erb → configuration/field/float/_display.html.erb} +0 -0
- data/app/views/components/lolita/configuration/field/integer/_display.html.erb +1 -0
- data/app/views/components/lolita/configuration/field/string/_display.html.erb +5 -0
- data/app/views/components/lolita/{field/_disabled.html.erb → configuration/field/string/disabled/_display.html.erb} +0 -0
- data/app/views/components/lolita/{field/_password.html.erb → configuration/field/string/password/_display.html.erb} +0 -0
- data/app/views/components/lolita/configuration/field/string/text/_display.html.erb +34 -0
- data/app/views/components/lolita/configuration/field/time/_display.html.erb +1 -0
- data/app/views/components/lolita/{field_set → configuration/field_set}/_display.html.erb +1 -1
- data/app/views/components/lolita/configuration/list/_body.html.erb +5 -0
- data/app/views/components/lolita/{list → configuration/list}/_body_cell.html.erb +0 -0
- data/app/views/components/lolita/{list → configuration/list}/_checkbox_cell.html.erb +0 -0
- data/app/views/components/lolita/{list → configuration/list}/_checkbox_header.html.erb +0 -0
- data/app/views/components/lolita/configuration/list/_display.html.erb +12 -0
- data/app/views/components/lolita/configuration/list/_filter.html.erb +8 -0
- data/app/views/components/lolita/configuration/list/_header.html.erb +9 -0
- data/app/views/components/lolita/{list → configuration/list}/_header_cell.html.erb +0 -0
- data/app/views/components/lolita/{list → configuration/list}/_new_resource.html.erb +0 -0
- data/app/views/components/lolita/configuration/list/_paginator.html.erb +3 -0
- data/app/views/components/lolita/configuration/list/_row.html.erb +7 -0
- data/app/views/components/lolita/{list → configuration/list}/_title.html.erb +0 -0
- data/app/views/components/lolita/{list → configuration/list}/_tool_cell.html.erb +0 -0
- data/app/views/components/lolita/{list → configuration/list}/_tool_header.html.erb +0 -0
- data/app/views/components/lolita/configuration/tab/_display.html.erb +17 -0
- data/app/views/components/lolita/configuration/tab/_fields.html.erb +7 -0
- data/app/views/components/lolita/configuration/tab/content/_display.html.erb +1 -0
- data/app/views/components/lolita/configuration/tab/default/_display.html.erb +9 -0
- data/app/views/components/lolita/{tabs → configuration/tabs}/_display.html.erb +4 -3
- data/app/views/{lolita/layouts → layouts/lolita}/application.html.erb +0 -0
- data/app/views/{lolita/layouts → layouts/lolita}/application.html.erb_spec.rb +0 -0
- data/author +1 -1
- data/lib/lolita.rb +31 -12
- data/lib/lolita/adapter/active_record.rb +16 -5
- data/lib/lolita/adapter/mongoid.rb +2 -2
- data/lib/lolita/base_configuration.rb +44 -2
- data/lib/lolita/builder.rb +31 -14
- data/lib/lolita/configuration/column.rb +92 -86
- data/lib/lolita/configuration/columns.rb +65 -65
- data/lib/lolita/configuration/factory.rb +8 -8
- data/lib/lolita/configuration/field.rb +156 -100
- data/lib/lolita/configuration/field/array.rb +74 -0
- data/lib/lolita/configuration/field/big_decimal.rb +12 -0
- data/lib/lolita/configuration/field/boolean.rb +7 -5
- data/lib/lolita/configuration/field/date.rb +13 -0
- data/lib/lolita/configuration/field/integer.rb +7 -5
- data/lib/lolita/configuration/field/string.rb +8 -6
- data/lib/lolita/configuration/field/time.rb +13 -0
- data/lib/lolita/configuration/fields.rb +36 -0
- data/lib/lolita/configuration/filter.rb +63 -0
- data/lib/lolita/configuration/list.rb +101 -91
- data/lib/lolita/configuration/page.rb +1 -0
- data/lib/lolita/configuration/tab.rb +137 -131
- data/lib/lolita/configuration/tab/content.rb +14 -12
- data/lib/lolita/configuration/tab/default.rb +15 -13
- data/lib/lolita/configuration/tabs.rb +2 -2
- data/lib/lolita/controllers/component_helpers.rb +26 -14
- data/lib/lolita/controllers/internal_helpers.rb +14 -0
- data/lib/lolita/controllers/url_helpers.rb +47 -10
- data/lib/lolita/dbi/base.rb +50 -50
- data/lib/lolita/errors.rb +2 -2
- data/lib/lolita/hooks.rb +298 -0
- data/lib/lolita/hooks/named_hook.rb +122 -0
- data/lib/lolita/lazy_loader.rb +46 -46
- data/lib/lolita/mapping.rb +3 -2
- data/lib/lolita/navigation.rb +48 -0
- data/lib/lolita/observed_array.rb +7 -0
- data/lib/lolita/rails/routes.rb +29 -3
- data/lolita.gemspec +65 -48
- data/public/javascripts/lolita/tab.js +5 -0
- data/public/javascripts/rails.js +137 -137
- data/public/stylesheets/lolita/style.css +3 -1
- data/spec/builder_spec.rb +42 -0
- data/spec/configuration/field_spec.rb +29 -18
- data/spec/configuration/filter_spec.rb +60 -0
- data/spec/configuration/tab_spec.rb +28 -20
- data/spec/configuration/tabs_spec.rb +8 -4
- data/spec/controllers/lolita_rest_spec.rb +15 -0
- data/spec/hooks_spec.rb +191 -0
- data/spec/lolita_spec.rb +6 -4
- data/spec/navigation/tree_spec.rb +59 -0
- data/spec/rails_app/app/mongoid/post.rb +2 -0
- data/spec/rails_app/app/views/components/lolita/{list → configuration/list}/_body_cell.html.erb +0 -0
- data/spec/rails_app/config/application.rb +1 -0
- data/spec/rails_app/lib/lolita/configuration/field/my_custom_collection.rb +14 -0
- data/spec/simple_spec_helper.rb +1 -0
- data/spec/spec_helper.rb +1 -2
- metadata +66 -49
- data/README.md +0 -5
- data/app/helpers/components/lolita/list_component.rb +0 -9
- data/app/views/components/lolita/field/_collection.html.erb +0 -5
- data/app/views/components/lolita/field/_date.html.erb +0 -1
- data/app/views/components/lolita/field/_datetime.html.erb +0 -1
- data/app/views/components/lolita/field/_display.html.erb +0 -6
- data/app/views/components/lolita/field/_integer.html.erb +0 -1
- data/app/views/components/lolita/field/_label.html.erb +0 -1
- data/app/views/components/lolita/field/_select.html.erb +0 -1
- data/app/views/components/lolita/field/_text.html.erb +0 -27
- data/app/views/components/lolita/list/_body.html.erb +0 -5
- data/app/views/components/lolita/list/_display.html.erb +0 -11
- data/app/views/components/lolita/list/_header.html.erb +0 -9
- data/app/views/components/lolita/list/_paginator.html.erb +0 -4
- data/app/views/components/lolita/list/_row.html.erb +0 -7
- data/app/views/components/lolita/tab/_content.html.erb +0 -1
- data/app/views/components/lolita/tab/_default.html.erb +0 -11
- data/app/views/components/lolita/tab/_display.html.erb +0 -7
- data/app/views/components/lolita/tab/_fields.html.erb +0 -7
- data/lib/lolita/configuration/field/collection.rb +0 -71
- data/lib/lolita/configuration/field/datetime.rb +0 -10
- data/lib/lolita/configuration/field/disabled.rb +0 -10
- data/lib/lolita/configuration/field/password.rb +0 -10
- data/lib/lolita/configuration/field/text.rb +0 -10
- data/lib/lolita/hooks/base.rb +0 -58
- data/lib/lolita/hooks/component.rb +0 -15
- data/lib/lolita/hooks/hooks.rb +0 -15
@@ -0,0 +1,122 @@
|
|
1
|
+
module Lolita
|
2
|
+
module Hooks
|
3
|
+
|
4
|
+
# Named hooks is special hook class that uses Lolita::Hooks, but also add some other useful methods and behaviour.
|
5
|
+
# Main reason for named hooks is to provide filter like hooks. First thing is to define it for futher use.
|
6
|
+
# Lolita::Hooks::NamedHook.add(:people)
|
7
|
+
# Next step is to add hook for it. Like this
|
8
|
+
# Lolita::Hooks.people.add_hook(:get_married)
|
9
|
+
# And then add callback for named hook.
|
10
|
+
# Lolita::Hooks.person.get_merried do
|
11
|
+
# go_to_honeymoon
|
12
|
+
# end
|
13
|
+
# john=Person.new("John")
|
14
|
+
# john.fire(:get_merried) # and now john will go to honeymoon
|
15
|
+
# Hooks are added for pluralized hook name, even if you pass like #add(:person), it will create named hook
|
16
|
+
# with <i>people</i> name. This will be class, and when you call #person it will create instance for that class.
|
17
|
+
class NamedHook
|
18
|
+
|
19
|
+
class << self
|
20
|
+
# Add named hook name with NamedHook class. Each hook is Hash and keys is filters.
|
21
|
+
# Also it have <em>:_class</em> key that is class for named hook.
|
22
|
+
def add(name)
|
23
|
+
name=name.to_s.pluralize
|
24
|
+
named_hooks[name.to_sym]={:_class=>get_named_hook_class(name)}
|
25
|
+
add_filter_method(name)
|
26
|
+
end
|
27
|
+
|
28
|
+
# All defined named hook names
|
29
|
+
def names
|
30
|
+
named_hooks.keys
|
31
|
+
end
|
32
|
+
|
33
|
+
def exist?(name)
|
34
|
+
self.names.include?(name)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Find or create named hook instance.
|
38
|
+
def find_or_create(hook_name,filter_name)
|
39
|
+
unless filtered_hook=self.find(hook_name,filter_name)
|
40
|
+
named_hook=self.by_name(hook_name)
|
41
|
+
named_hook[:_class].new(hook_name,filter_name)
|
42
|
+
else
|
43
|
+
filtered_hook
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def find(hook_name,filter_name)
|
48
|
+
if named_hook=self.by_name(hook_name)
|
49
|
+
named_hook[filter_name.to_sym]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Return named hook by given name.
|
54
|
+
def by_name(name)
|
55
|
+
name=name.to_s.pluralize
|
56
|
+
named_hooks[name.to_sym]
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def named_hooks
|
62
|
+
@@named_hooks||={}
|
63
|
+
@@named_hooks
|
64
|
+
end
|
65
|
+
|
66
|
+
def add_filter_method(name)
|
67
|
+
self.class_eval <<-FILTER,__FILE__,__LINE__+1
|
68
|
+
class << Lolita::Hooks
|
69
|
+
def #{name.singularize}(name)
|
70
|
+
Lolita::Hooks::NamedHook.find_or_create("#{name.pluralize}",name)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
FILTER
|
74
|
+
end
|
75
|
+
|
76
|
+
def get_named_hook_class(name)
|
77
|
+
klass=Class.new(Lolita::Hooks::NamedHook)
|
78
|
+
klass.instance_variable_set(:"@hook_name",name.to_sym)
|
79
|
+
klass.send(:include,Lolita::Hooks)
|
80
|
+
define_named_hook_class_methods(klass)
|
81
|
+
klass
|
82
|
+
end
|
83
|
+
|
84
|
+
def define_named_hook_class_methods(klass)
|
85
|
+
klass.class_eval do
|
86
|
+
attr_accessor :name,:hook_name
|
87
|
+
def initialize hook_name,name
|
88
|
+
named_hook=self.class.by_name(hook_name)
|
89
|
+
@name=name
|
90
|
+
@hook_name=hook_name
|
91
|
+
unless named_hook[name.to_sym]
|
92
|
+
named_hook[name.to_sym]=self
|
93
|
+
else
|
94
|
+
raise ArgumentError, "Named hook #{name} for #{hook_name} already exist!"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.hook_name
|
99
|
+
@hook_name
|
100
|
+
end
|
101
|
+
|
102
|
+
# def self.fire(*hook_names,&block)
|
103
|
+
# hook_names||=[]
|
104
|
+
# hook_names.extract_options!
|
105
|
+
# super(*hook_names,&block)
|
106
|
+
# if named_hook=self.by_name(self.hook_name)
|
107
|
+
# named_hook.each{|filter_name, filter|
|
108
|
+
# unless filter_name.to_sym==:"_class"
|
109
|
+
# self.fire(*(hook_names + [{:scope=>filter}]),&block)
|
110
|
+
# end
|
111
|
+
# }
|
112
|
+
# end
|
113
|
+
# end
|
114
|
+
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
data/lib/lolita/lazy_loader.rb
CHANGED
@@ -1,47 +1,47 @@
|
|
1
|
-
module Lolita
|
2
|
-
class LazyLoader
|
3
|
-
|
4
|
-
#attr_reader :lazy_class,:eval_block,:class_instance
|
5
|
-
|
6
|
-
def self.lazy_load(instance_name,var_name,lazy_class,*args,&block)
|
7
|
-
temp_var=instance_name.instance_variable_get(var_name)
|
8
|
-
unless temp_var
|
9
|
-
temp_var=instance_name.instance_variable_set(var_name,self.new(lazy_class,*args,&block))
|
10
|
-
end
|
11
|
-
if temp_var.to_s=~/Lolita::LazyLoader/ && temp_var.class_instance
|
12
|
-
instance_name.instance_variable_set(var_name,temp_var.class_instance)
|
13
|
-
else
|
14
|
-
temp_var
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def initialize(lazy_class,*args,&block)
|
19
|
-
@args=args
|
20
|
-
@lazy_class=lazy_class
|
21
|
-
@eval_block=block
|
22
|
-
end
|
23
|
-
|
24
|
-
def class_instance
|
25
|
-
@class_instance || self
|
26
|
-
end
|
27
|
-
|
28
|
-
def method_missing(method_name,*args,&block)
|
29
|
-
unless @class_instance
|
30
|
-
arity=@lazy_class.instance_method(:initialize).arity
|
31
|
-
if arity==-1 # when expectign *args
|
32
|
-
@class_instance=@lazy_class.new(*@args,&@eval_block)
|
33
|
-
elsif arity.abs>0 # when expecting specific number of arguments without any *args
|
34
|
-
@class_instance=@lazy_class.new(*@args.slice(0..arity.abs-1),&@eval_block)
|
35
|
-
else
|
36
|
-
@class_instance=@lazy_class.new(&@eval_block)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
@class_instance.__send__(method_name,*args,&block)
|
40
|
-
end
|
41
|
-
|
42
|
-
instance_methods.each { |method|
|
43
|
-
next if ["hash","respond_to?","__id__","__send__","to_s","object_id","method_missing","class_instance","initialize"].include?(method.to_s)
|
44
|
-
eval("undef :#{method}")
|
45
|
-
}
|
46
|
-
end
|
1
|
+
module Lolita
|
2
|
+
class LazyLoader
|
3
|
+
|
4
|
+
#attr_reader :lazy_class,:eval_block,:class_instance
|
5
|
+
|
6
|
+
def self.lazy_load(instance_name,var_name,lazy_class,*args,&block)
|
7
|
+
temp_var=instance_name.instance_variable_get(var_name)
|
8
|
+
unless temp_var
|
9
|
+
temp_var=instance_name.instance_variable_set(var_name,self.new(lazy_class,*args,&block))
|
10
|
+
end
|
11
|
+
if temp_var.to_s=~/Lolita::LazyLoader/ && temp_var.class_instance
|
12
|
+
instance_name.instance_variable_set(var_name,temp_var.class_instance)
|
13
|
+
else
|
14
|
+
temp_var
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(lazy_class,*args,&block)
|
19
|
+
@args=args
|
20
|
+
@lazy_class=lazy_class
|
21
|
+
@eval_block=block
|
22
|
+
end
|
23
|
+
|
24
|
+
def class_instance
|
25
|
+
@class_instance || self
|
26
|
+
end
|
27
|
+
|
28
|
+
def method_missing(method_name,*args,&block)
|
29
|
+
unless @class_instance
|
30
|
+
arity=@lazy_class.instance_method(:initialize).arity
|
31
|
+
if arity==-1 # when expectign *args
|
32
|
+
@class_instance=@lazy_class.new(*@args,&@eval_block)
|
33
|
+
elsif arity.abs>0 # when expecting specific number of arguments without any *args
|
34
|
+
@class_instance=@lazy_class.new(*@args.slice(0..arity.abs-1),&@eval_block)
|
35
|
+
else
|
36
|
+
@class_instance=@lazy_class.new(&@eval_block)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
@class_instance.__send__(method_name,*args,&block)
|
40
|
+
end
|
41
|
+
|
42
|
+
instance_methods.each { |method|
|
43
|
+
next if ["hash","respond_to?","__id__","__send__","to_s","object_id","method_missing","class_instance","initialize"].include?(method.to_s)
|
44
|
+
eval("undef :#{method}")
|
45
|
+
}
|
46
|
+
end
|
47
47
|
end
|
data/lib/lolita/mapping.rb
CHANGED
@@ -19,7 +19,8 @@ module Lolita
|
|
19
19
|
|
20
20
|
# TODO how it is when lolita plugin extend default path and there is module is this not break the logic?
|
21
21
|
def initialize(name,options={})
|
22
|
-
@
|
22
|
+
@as=options[:as]
|
23
|
+
@plural=(options[:as] ? options[:as] : name).to_sym
|
23
24
|
@singular=(options[:singular] || @plural.to_s.singularize).to_sym
|
24
25
|
@class_name=(options[:class_name] || name.to_s.classify).to_s
|
25
26
|
@ref = ActiveSupport::Dependencies.ref(@class_name)
|
@@ -28,7 +29,7 @@ module Lolita
|
|
28
29
|
@module=options[:module]
|
29
30
|
mod=@module ? nil : "lolita/"
|
30
31
|
@controllers=Hash.new{|h,k|
|
31
|
-
h[k]="#{mod}#{k}"
|
32
|
+
h[k]=options[:controller] || "#{mod}#{k}"
|
32
33
|
}
|
33
34
|
end
|
34
35
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Lolita
|
2
|
+
module Navigation
|
3
|
+
|
4
|
+
class Tree
|
5
|
+
include Lolita::ObservedArray
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@branches=[]
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def collection_variable
|
14
|
+
@branches
|
15
|
+
end
|
16
|
+
|
17
|
+
def build_element element,*args
|
18
|
+
if element.is_a?(Lolita::Navigation::Branch)
|
19
|
+
element
|
20
|
+
else
|
21
|
+
Lolita::Navigation::Branch.new(*args)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end #base class end
|
25
|
+
|
26
|
+
#
|
27
|
+
# c_branch=Branch.new(:category)
|
28
|
+
# c_branch.mapping == Lolita.mappings[:category] #=>true
|
29
|
+
# c.branch.resource == Lolita.mappings[:category].to #=>true
|
30
|
+
# Branch.new(:page, :path=>{:action=>:new},:after=>Navigation.by_name(:category,:level=>1))
|
31
|
+
# Branch.new(:user,:prepend=>Navigation.root || {:level=>0} || 0)
|
32
|
+
# Branch.new(
|
33
|
+
# Proc.new{|resource| resource.lolita.reports.by_name("statistic")},
|
34
|
+
# :append=>Navigation.by_name(:category,:level=>1),
|
35
|
+
# :path=>{:action=>:report,:plural=>true}
|
36
|
+
# )
|
37
|
+
class Branch
|
38
|
+
attr_reader :name
|
39
|
+
|
40
|
+
def initialize(*args)
|
41
|
+
options=args.extract_options!
|
42
|
+
@name=args.first
|
43
|
+
|
44
|
+
end
|
45
|
+
end #branch class end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -55,6 +55,13 @@ module Lolita
|
|
55
55
|
value=build_element(value)
|
56
56
|
collection_variable[index]=value
|
57
57
|
end
|
58
|
+
|
59
|
+
#To support enumerable functions as each, collect etc.
|
60
|
+
def each
|
61
|
+
collection_variable.each{|collection_element| yield collection_element}
|
62
|
+
end
|
63
|
+
|
64
|
+
|
58
65
|
private
|
59
66
|
|
60
67
|
def collection_variable
|
data/lib/lolita/rails/routes.rb
CHANGED
@@ -1,11 +1,27 @@
|
|
1
1
|
module ActionDispatch::Routing
|
2
2
|
|
3
|
+
class RouteSet
|
4
|
+
# alias_method_chain :draw, :lolita
|
5
|
+
|
6
|
+
# def draw_with_lolita
|
7
|
+
# Lolita::Hooks.run("")
|
8
|
+
# draw_without_lolita
|
9
|
+
# end
|
10
|
+
end
|
3
11
|
class Mapper
|
4
12
|
|
5
13
|
# Every module, that is used with lolita and has routes, need to have
|
6
14
|
# <code>resource method</code>, for example, lolita_rest, that should be added
|
7
15
|
# to ActionDispatch::Routing::Mapper class, as a *protected* method.
|
8
16
|
# Module can automaticliy add resource route or allow user to do it.
|
17
|
+
# It accepts some useful options
|
18
|
+
# * <tt>:module</tt>
|
19
|
+
# * <tt>:path</tt>
|
20
|
+
# * <tt>:as</tt>
|
21
|
+
# * <tt>:path_prefix</tt>
|
22
|
+
# * <tt>:controller</tt>
|
23
|
+
# * <tt>:class_name</tt>
|
24
|
+
# * <tt>:singular</tt>
|
9
25
|
# ====Example
|
10
26
|
# Lolita.add_module Lolita::Gallery,:route=>:gallery
|
11
27
|
# # in route.rb
|
@@ -13,6 +29,7 @@ module ActionDispatch::Routing
|
|
13
29
|
# # lolita_for try to call :lolita_gallery in Mapper class
|
14
30
|
def lolita_for *resources
|
15
31
|
#TODO refactor
|
32
|
+
return if migrating?
|
16
33
|
options = resources.extract_options!
|
17
34
|
|
18
35
|
# if as = options.delete(:as)
|
@@ -33,7 +50,6 @@ module ActionDispatch::Routing
|
|
33
50
|
resources.each{|resource|
|
34
51
|
mapping=Lolita.add_mapping(resource,options)
|
35
52
|
Lolita.resources[mapping.name]=mapping
|
36
|
-
|
37
53
|
target_class=mapping.to
|
38
54
|
all_resource_classes<<target_class
|
39
55
|
|
@@ -43,9 +59,13 @@ module ActionDispatch::Routing
|
|
43
59
|
with_lolita_exclusive_scope mapping.fullpath,mapping.path do
|
44
60
|
# if not defined lolita default configuration in model, than can't use :rest
|
45
61
|
if !target_class.respond_to?(:lolita) && !Lolita::routes[mapping.name]
|
46
|
-
|
62
|
+
warn("Lolita not found in #{target_class}. Including Lolita::Configuration")
|
63
|
+
target_class.send(:include, Lolita::Configuration)
|
64
|
+
#raise Lolita::NotFound, "Lolita not found in #{target_class}. Include Lolita::Configuration"
|
47
65
|
elsif target_class.respond_to?(:lolita) && target_class.instance_variable_get(:@lolita).nil?
|
48
|
-
|
66
|
+
warn "Calling #lolita on #{target_class}, because lolita not initialized yet."
|
67
|
+
target_class.lolita
|
68
|
+
#raise Lolita::NotInitialized, "Call lolita method in #{target_class}."
|
49
69
|
else
|
50
70
|
route=Lolita.routes[mapping.name] || Lolita.default_route
|
51
71
|
end
|
@@ -86,5 +106,11 @@ module ActionDispatch::Routing
|
|
86
106
|
ensure
|
87
107
|
@scope[:as], @scope[:path], @scope[:module] = old_as, old_path, old_module
|
88
108
|
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def migrating?
|
113
|
+
File.basename($0)=="rake" && $ARGV.include?("db:migrate")
|
114
|
+
end
|
89
115
|
end
|
90
116
|
end
|
data/lolita.gemspec
CHANGED
@@ -5,16 +5,16 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{lolita}
|
8
|
-
s.version = "3.0
|
8
|
+
s.version = "3.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["ITHouse", "Arturs Meisters"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-04-12}
|
13
13
|
s.description = %q{Great Rails CMS that allow you to start working with models right when you add this to your project.}
|
14
14
|
s.email = %q{support@ithouse.lv}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE.txt",
|
17
|
-
"README.
|
17
|
+
"README.rdoc"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
@@ -24,50 +24,54 @@ Gem::Specification.new do |s|
|
|
24
24
|
"Gemfile",
|
25
25
|
"IDEA",
|
26
26
|
"LICENSE.txt",
|
27
|
-
"README.
|
27
|
+
"README.rdoc",
|
28
28
|
"Rakefile",
|
29
29
|
"VERSION",
|
30
30
|
"app/controllers/lolita/rest_controller.rb",
|
31
|
-
"app/helpers/components/lolita/list_component.rb",
|
31
|
+
"app/helpers/components/lolita/configuration/list_component.rb",
|
32
32
|
"app/helpers/lolita_helper.rb",
|
33
|
-
"app/views/components/lolita/field/
|
34
|
-
"app/views/components/lolita/field/
|
35
|
-
"app/views/components/lolita/field/
|
36
|
-
"app/views/components/lolita/field/
|
37
|
-
"app/views/components/lolita/field/
|
38
|
-
"app/views/components/lolita/field/_display.html.erb",
|
39
|
-
"app/views/components/lolita/field/
|
40
|
-
"app/views/components/lolita/field/
|
41
|
-
"app/views/components/lolita/field/
|
42
|
-
"app/views/components/lolita/field/
|
43
|
-
"app/views/components/lolita/field/
|
44
|
-
"app/views/components/lolita/field/
|
45
|
-
"app/views/components/lolita/field/
|
46
|
-
"app/views/components/lolita/
|
47
|
-
"app/views/components/lolita/
|
48
|
-
"app/views/components/lolita/
|
49
|
-
"app/views/components/lolita/
|
50
|
-
"app/views/components/lolita/list/
|
51
|
-
"app/views/components/lolita/list/
|
52
|
-
"app/views/components/lolita/list/
|
53
|
-
"app/views/components/lolita/list/
|
54
|
-
"app/views/components/lolita/list/
|
55
|
-
"app/views/components/lolita/list/
|
56
|
-
"app/views/components/lolita/list/
|
57
|
-
"app/views/components/lolita/list/
|
58
|
-
"app/views/components/lolita/list/
|
59
|
-
"app/views/components/lolita/list/
|
33
|
+
"app/views/components/lolita/configuration/field/_display.html.erb",
|
34
|
+
"app/views/components/lolita/configuration/field/_label.html.erb",
|
35
|
+
"app/views/components/lolita/configuration/field/_object.html.erb",
|
36
|
+
"app/views/components/lolita/configuration/field/array/_display.html.erb",
|
37
|
+
"app/views/components/lolita/configuration/field/array/habtm/_display.html.erb",
|
38
|
+
"app/views/components/lolita/configuration/field/array/select/_display.html.erb",
|
39
|
+
"app/views/components/lolita/configuration/field/big_decimal/_display.html.erb",
|
40
|
+
"app/views/components/lolita/configuration/field/boolean/_display.html.erb",
|
41
|
+
"app/views/components/lolita/configuration/field/date/_display.html.erb",
|
42
|
+
"app/views/components/lolita/configuration/field/float/_display.html.erb",
|
43
|
+
"app/views/components/lolita/configuration/field/integer/_display.html.erb",
|
44
|
+
"app/views/components/lolita/configuration/field/string/_display.html.erb",
|
45
|
+
"app/views/components/lolita/configuration/field/string/disabled/_display.html.erb",
|
46
|
+
"app/views/components/lolita/configuration/field/string/password/_display.html.erb",
|
47
|
+
"app/views/components/lolita/configuration/field/string/text/_display.html.erb",
|
48
|
+
"app/views/components/lolita/configuration/field/time/_display.html.erb",
|
49
|
+
"app/views/components/lolita/configuration/field_set/_display.html.erb",
|
50
|
+
"app/views/components/lolita/configuration/list/_body.html.erb",
|
51
|
+
"app/views/components/lolita/configuration/list/_body_cell.html.erb",
|
52
|
+
"app/views/components/lolita/configuration/list/_checkbox_cell.html.erb",
|
53
|
+
"app/views/components/lolita/configuration/list/_checkbox_header.html.erb",
|
54
|
+
"app/views/components/lolita/configuration/list/_display.html.erb",
|
55
|
+
"app/views/components/lolita/configuration/list/_filter.html.erb",
|
56
|
+
"app/views/components/lolita/configuration/list/_header.html.erb",
|
57
|
+
"app/views/components/lolita/configuration/list/_header_cell.html.erb",
|
58
|
+
"app/views/components/lolita/configuration/list/_new_resource.html.erb",
|
59
|
+
"app/views/components/lolita/configuration/list/_paginator.html.erb",
|
60
|
+
"app/views/components/lolita/configuration/list/_row.html.erb",
|
61
|
+
"app/views/components/lolita/configuration/list/_title.html.erb",
|
62
|
+
"app/views/components/lolita/configuration/list/_tool_cell.html.erb",
|
63
|
+
"app/views/components/lolita/configuration/list/_tool_header.html.erb",
|
64
|
+
"app/views/components/lolita/configuration/tab/_display.html.erb",
|
65
|
+
"app/views/components/lolita/configuration/tab/_fields.html.erb",
|
66
|
+
"app/views/components/lolita/configuration/tab/content/_display.html.erb",
|
67
|
+
"app/views/components/lolita/configuration/tab/default/_display.html.erb",
|
68
|
+
"app/views/components/lolita/configuration/tabs/_display.html.erb",
|
60
69
|
"app/views/components/lolita/navigation/_display.html.erb",
|
61
70
|
"app/views/components/lolita/shared/_flash.html.erb",
|
62
71
|
"app/views/components/lolita/shared/_header.html.erb",
|
63
72
|
"app/views/components/lolita/shared/_right_sidebar.html.erb",
|
64
|
-
"app/views/
|
65
|
-
"app/views/
|
66
|
-
"app/views/components/lolita/tab/_display.html.erb",
|
67
|
-
"app/views/components/lolita/tab/_fields.html.erb",
|
68
|
-
"app/views/components/lolita/tabs/_display.html.erb",
|
69
|
-
"app/views/lolita/layouts/application.html.erb",
|
70
|
-
"app/views/lolita/layouts/application.html.erb_spec.rb",
|
73
|
+
"app/views/layouts/lolita/application.html.erb",
|
74
|
+
"app/views/layouts/lolita/application.html.erb_spec.rb",
|
71
75
|
"app/views/lolita/rest/form.html.erb",
|
72
76
|
"app/views/lolita/rest/index.html.erb",
|
73
77
|
"author",
|
@@ -93,15 +97,16 @@ Gem::Specification.new do |s|
|
|
93
97
|
"lib/lolita/configuration/columns.rb",
|
94
98
|
"lib/lolita/configuration/factory.rb",
|
95
99
|
"lib/lolita/configuration/field.rb",
|
100
|
+
"lib/lolita/configuration/field/array.rb",
|
101
|
+
"lib/lolita/configuration/field/big_decimal.rb",
|
96
102
|
"lib/lolita/configuration/field/boolean.rb",
|
97
|
-
"lib/lolita/configuration/field/
|
98
|
-
"lib/lolita/configuration/field/datetime.rb",
|
99
|
-
"lib/lolita/configuration/field/disabled.rb",
|
103
|
+
"lib/lolita/configuration/field/date.rb",
|
100
104
|
"lib/lolita/configuration/field/integer.rb",
|
101
|
-
"lib/lolita/configuration/field/password.rb",
|
102
105
|
"lib/lolita/configuration/field/string.rb",
|
103
|
-
"lib/lolita/configuration/field/
|
106
|
+
"lib/lolita/configuration/field/time.rb",
|
104
107
|
"lib/lolita/configuration/field_set.rb",
|
108
|
+
"lib/lolita/configuration/fields.rb",
|
109
|
+
"lib/lolita/configuration/filter.rb",
|
105
110
|
"lib/lolita/configuration/list.rb",
|
106
111
|
"lib/lolita/configuration/page.rb",
|
107
112
|
"lib/lolita/configuration/tab.rb",
|
@@ -115,13 +120,13 @@ Gem::Specification.new do |s|
|
|
115
120
|
"lib/lolita/controllers/view_user_helpers.rb",
|
116
121
|
"lib/lolita/dbi/base.rb",
|
117
122
|
"lib/lolita/errors.rb",
|
118
|
-
"lib/lolita/hooks
|
119
|
-
"lib/lolita/hooks/
|
120
|
-
"lib/lolita/hooks/hooks.rb",
|
123
|
+
"lib/lolita/hooks.rb",
|
124
|
+
"lib/lolita/hooks/named_hook.rb",
|
121
125
|
"lib/lolita/lazy_loader.rb",
|
122
126
|
"lib/lolita/mapping.rb",
|
123
127
|
"lib/lolita/modules.rb",
|
124
128
|
"lib/lolita/modules/rest.rb",
|
129
|
+
"lib/lolita/navigation.rb",
|
125
130
|
"lib/lolita/observed_array.rb",
|
126
131
|
"lib/lolita/rails.rb",
|
127
132
|
"lib/lolita/rails/all.rb",
|
@@ -189,11 +194,13 @@ Gem::Specification.new do |s|
|
|
189
194
|
"public/stylesheets/lolita/default.css",
|
190
195
|
"public/stylesheets/lolita/style.css",
|
191
196
|
"spec/adapter_helper.rb",
|
197
|
+
"spec/builder_spec.rb",
|
192
198
|
"spec/configuration/base_spec.rb",
|
193
199
|
"spec/configuration/column_spec.rb",
|
194
200
|
"spec/configuration/columns_spec.rb",
|
195
201
|
"spec/configuration/field_set_spec.rb",
|
196
202
|
"spec/configuration/field_spec.rb",
|
203
|
+
"spec/configuration/filter_spec.rb",
|
197
204
|
"spec/configuration/list_spec.rb",
|
198
205
|
"spec/configuration/page_spec.rb",
|
199
206
|
"spec/configuration/tab_spec.rb",
|
@@ -201,8 +208,10 @@ Gem::Specification.new do |s|
|
|
201
208
|
"spec/controllers/internal_helpers_spec.rb",
|
202
209
|
"spec/controllers/lolita_rest_spec.rb",
|
203
210
|
"spec/dbi/base_spec.rb",
|
211
|
+
"spec/hooks_spec.rb",
|
204
212
|
"spec/lolita_spec.rb",
|
205
213
|
"spec/mapping_spec.rb",
|
214
|
+
"spec/navigation/tree_spec.rb",
|
206
215
|
"spec/orm/mongoid.rb",
|
207
216
|
"spec/rails_app/app/controllers/application_controller.rb",
|
208
217
|
"spec/rails_app/app/helpers/application_helper.rb",
|
@@ -211,7 +220,7 @@ Gem::Specification.new do |s|
|
|
211
220
|
"spec/rails_app/app/mongoid/post.rb",
|
212
221
|
"spec/rails_app/app/mongoid/preference.rb",
|
213
222
|
"spec/rails_app/app/mongoid/profile.rb",
|
214
|
-
"spec/rails_app/app/views/components/lolita/list/_body_cell.html.erb",
|
223
|
+
"spec/rails_app/app/views/components/lolita/configuration/list/_body_cell.html.erb",
|
215
224
|
"spec/rails_app/config/application.rb",
|
216
225
|
"spec/rails_app/config/boot.rb",
|
217
226
|
"spec/rails_app/config/environment.rb",
|
@@ -224,6 +233,7 @@ Gem::Specification.new do |s|
|
|
224
233
|
"spec/rails_app/config/initializers/secret_token.rb",
|
225
234
|
"spec/rails_app/config/routes.rb",
|
226
235
|
"spec/rails_app/db/schema.rb",
|
236
|
+
"spec/rails_app/lib/lolita/configuration/field/my_custom_collection.rb",
|
227
237
|
"spec/rails_app/public/images/lolita/plus.png",
|
228
238
|
"spec/rails_app/public/javascripts/jquery-1.5.1.min.js",
|
229
239
|
"spec/rails_app/public/javascripts/lolita/main.js",
|
@@ -283,6 +293,7 @@ Gem::Specification.new do |s|
|
|
283
293
|
"spec/rails_app/public/stylesheets/lolita/default.css",
|
284
294
|
"spec/rails_app/public/stylesheets/lolita/style.css",
|
285
295
|
"spec/routing/routes_spec.rb",
|
296
|
+
"spec/simple_spec_helper.rb",
|
286
297
|
"spec/spec_helper.rb",
|
287
298
|
"spec/support/factories/post.rb",
|
288
299
|
"test/cells/form_cell_test.rb",
|
@@ -295,11 +306,13 @@ Gem::Specification.new do |s|
|
|
295
306
|
s.summary = %q{Great Rails CMS.}
|
296
307
|
s.test_files = [
|
297
308
|
"spec/adapter_helper.rb",
|
309
|
+
"spec/builder_spec.rb",
|
298
310
|
"spec/configuration/base_spec.rb",
|
299
311
|
"spec/configuration/column_spec.rb",
|
300
312
|
"spec/configuration/columns_spec.rb",
|
301
313
|
"spec/configuration/field_set_spec.rb",
|
302
314
|
"spec/configuration/field_spec.rb",
|
315
|
+
"spec/configuration/filter_spec.rb",
|
303
316
|
"spec/configuration/list_spec.rb",
|
304
317
|
"spec/configuration/page_spec.rb",
|
305
318
|
"spec/configuration/tab_spec.rb",
|
@@ -307,8 +320,10 @@ Gem::Specification.new do |s|
|
|
307
320
|
"spec/controllers/internal_helpers_spec.rb",
|
308
321
|
"spec/controllers/lolita_rest_spec.rb",
|
309
322
|
"spec/dbi/base_spec.rb",
|
323
|
+
"spec/hooks_spec.rb",
|
310
324
|
"spec/lolita_spec.rb",
|
311
325
|
"spec/mapping_spec.rb",
|
326
|
+
"spec/navigation/tree_spec.rb",
|
312
327
|
"spec/orm/mongoid.rb",
|
313
328
|
"spec/rails_app/app/controllers/application_controller.rb",
|
314
329
|
"spec/rails_app/app/helpers/application_helper.rb",
|
@@ -329,7 +344,9 @@ Gem::Specification.new do |s|
|
|
329
344
|
"spec/rails_app/config/initializers/secret_token.rb",
|
330
345
|
"spec/rails_app/config/routes.rb",
|
331
346
|
"spec/rails_app/db/schema.rb",
|
347
|
+
"spec/rails_app/lib/lolita/configuration/field/my_custom_collection.rb",
|
332
348
|
"spec/routing/routes_spec.rb",
|
349
|
+
"spec/simple_spec_helper.rb",
|
333
350
|
"spec/spec_helper.rb",
|
334
351
|
"spec/support/factories/post.rb",
|
335
352
|
"test/cells/form_cell_test.rb",
|