lolita 3.1.16 → 3.1.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/Gemfile +2 -1
  2. data/History.rdoc +10 -0
  3. data/VERSION +1 -1
  4. data/app/views/components/lolita/configuration/field/_display.html.erb +1 -1
  5. data/app/views/components/lolita/configuration/field/_label.html.erb +1 -1
  6. data/app/views/components/lolita/configuration/field/array/habtm/_display.html.haml +1 -1
  7. data/app/views/components/lolita/configuration/field/array/select/_display.html.erb +1 -1
  8. data/app/views/components/lolita/configuration/list/_paginator.html.erb +1 -1
  9. data/app/views/components/lolita/configuration/nested_form/_display.html.erb +3 -3
  10. data/app/views/components/lolita/configuration/nested_form/_fields.html.erb +1 -1
  11. data/app/views/components/lolita/configuration/tab/_display.html.erb +4 -13
  12. data/app/views/components/lolita/configuration/tab/_error_msg.html.erb +14 -0
  13. data/app/views/components/lolita/configuration/tab/_form.html.erb +1 -1
  14. data/app/views/components/lolita/shared/_header.html.erb +1 -1
  15. data/app/views/kaminari/lolita/_first_page.html.erb +11 -0
  16. data/app/views/kaminari/lolita/_gap.html.erb +8 -0
  17. data/app/views/kaminari/lolita/_last_page.html.erb +11 -0
  18. data/app/views/kaminari/lolita/_next_page.html.erb +11 -0
  19. data/app/views/kaminari/lolita/_page.html.erb +12 -0
  20. data/app/views/kaminari/lolita/_paginator.html.erb +23 -0
  21. data/app/views/kaminari/lolita/_prev_page.html.erb +11 -0
  22. data/app/views/layouts/lolita/application.html.erb +5 -3
  23. data/config/locales/en.yml +2 -0
  24. data/config/locales/lv.yml +10 -1
  25. data/lib/lolita/configuration/field/array.rb +10 -0
  26. data/lib/lolita/configuration/helper.rb +1 -1
  27. data/lib/lolita/configuration/nested_form.rb +33 -0
  28. data/lib/lolita/rails.rb +5 -1
  29. data/lib/lolita/system_configuration/application.rb +21 -0
  30. data/lib/lolita/system_configuration/base.rb +161 -0
  31. data/lib/lolita.rb +6 -2
  32. data/lolita.gemspec +15 -3
  33. data/public/javascripts/lolita/tab.js +9 -14
  34. data/public/stylesheets/lolita/style.css +114 -19
  35. data/spec/lolita_spec.rb +1 -1
  36. metadata +52 -32
  37. data/lib/lolita/base_configuration.rb +0 -166
@@ -1,166 +0,0 @@
1
- module Lolita
2
- # Base::Configuration methods are accessable through Lolita module.
3
- # Like Lolita.modules and Lolita.routes and so on.
4
- class BaseConfiguration
5
-
6
- attr_reader :scope, :modules, :routes, :controllers,:resources
7
- attr_accessor :mappings,:default_route,:user_classes,:authentication
8
- attr_writer :default_locale
9
-
10
- def initialize(scope)
11
- @scope=scope
12
- @mappings={}
13
- @resources={}
14
- @default_module=nil
15
- @user_classes=[]
16
- @modules=[]
17
- @routes={}
18
- @controllers={}
19
- end
20
-
21
- def navigation
22
- @navigation||=Lolita::Navigation::Base.new()
23
- @navigation
24
- end
25
-
26
- def locales=(value)
27
- unless value.is_a?(Array)
28
- @locales=[value]
29
- else
30
- @locales=value
31
- end
32
- end
33
-
34
- def locales
35
- @locales || []
36
- end
37
-
38
- def locale()
39
- @locale || default_locale
40
- end
41
-
42
- def locale=given_locale
43
- @locale=if locales.include?(given_locale.to_s.to_sym)
44
- given_locale.to_s.to_sym
45
- else
46
- Lolita.default_locale
47
- end
48
- end
49
- # Return default locale. First looks for defined default locale for Lolita, when not found than
50
- # take first of defined #locales for Lolita, if there no defined locales for Lolita, than
51
- # look for I18n and take default locale from there or if there is no I18n than take :en
52
- def default_locale
53
- @default_locale || self.locales.first || (defined?(::I18n) ? ::I18n.default_locale : :en)
54
- end
55
- # Call (with #call) to route klass
56
- # And return all names of routes that are needed for resource.
57
- # When with #add_module routes are defined like
58
- # Lolita.add_module MyModule, :route=>:my_module
59
- # then this will be passed to the method that creates routes, but
60
- # when Proc is passed to <i>:route</i> then this Proc should return
61
- # name of route or nil.
62
- # These names then are used for methods like <em>lolita_[route_name]_route</em>
63
- # that should be required somewhere in you module.
64
- def conditional_routes(klass=nil)
65
- @routes.map{|name,route|
66
- if route.first
67
- if route.last.respond_to?(:call)
68
- route.last.call(klass)
69
- else
70
- route.last
71
- end
72
- end
73
- }.compact
74
- end
75
-
76
- # Find all routes that is needed for defined classes
77
- # And return only one for each different route.
78
- def common_routes(klasses)
79
- @routes.map{|name,route|
80
- unless route.first
81
- klasses.map{|klass| route.last.respond_to?(:call) ? route.last.call(klass) : route.last}
82
- end
83
- }.flatten.compact.uniq
84
- end
85
-
86
- # Include module in Lolita, don't know why i need this
87
- def use(module_name)
88
- Lolita.send(:include,module_name)
89
- end
90
-
91
- def add_mapping(resource,options={})
92
- mapping = Lolita::Mapping.new(resource, options)
93
- self.mappings[mapping.name] = mapping
94
- mapping
95
- end
96
-
97
- # Add new module to Lolita
98
- # Accpted options
99
- # * <tt>controller</tt> - not in use
100
- # * <tt>nested</tt> - is route stands itsefl or is used in combination with resource
101
- # * <tt>route</tt> - Symbol of route name or lambad, that return route name based on resource.
102
- # Route name is used to call method lolita_[route_name] in Mapper class, and that should draw route.
103
- # * <tt>:name</tt> - name of module, underscored symbol. Used to draw default route, by default always
104
- # lolita_rest is called, but if route with resource name is found, than by default this route will be drawn.
105
- # Like lolita_for :posts, can go to different controller than rest and do other things.
106
- # * <tt>:path</tt> - some file that will be included. Deprecated will be removed
107
- # ====Example
108
- # Lolita.add_module Lolita::Posts, :route=>:post, :name=>:post
109
- # lolita_for :posts #=> create url whatever is defined in lolita_post method, and goes to :controller=>"lolita/posts"
110
- # Lolita.add_module Lolita::FileUpload, :route=>lambda{|resource| resource.lolita.tabs.by_type(:file) ? :file_upload : nil}
111
- # lolita_for :users #=> creat default rest urls and also call method lolita_file_upload if user lolita define :file tab.
112
- # To add route for public interface that goes to added module, than use
113
- # Lolita.add_module Post, :name=>:posts
114
- # And then when in routes.rb will be defined lolita_for(:posts) it will call method <i>lolita_posts_route</i>
115
- # and that method should define resource.
116
- # ====Example
117
- # # require this in your gem or lib
118
- # module ActionDispatch::Routing
119
- # class Mapper
120
- # protected
121
- # def lolita_posts_route mapping, controllers
122
- # resources mapping.plural,:only=>[:index,:new,:create],
123
- # :controller=>controllers[:posts],:module=>mapping.module
124
- # end
125
- # end
126
- # end
127
- # You open Mapper class and add your method that call #resources or #match or other method that define route
128
- # For common route for all lolita resources your method should look like this
129
- # ====Example
130
- # def lolita_files_route
131
- # mapping=Lolita.add_mapping(:files,:class_name=>"Lolita::Multimedia::File",:module=>"file_upload")
132
- # scope :module=>mapping.module do
133
- # resources mapping.name
134
- # end
135
- # end
136
- def add_module module_container, options={}
137
- raise ArgumentError, "Can't add module without module container!" unless module_container
138
- options.assert_valid_keys(:controller,:route,:model,:path,:name,:nested)
139
- name=options[:name]||module_container.to_s.to_sym
140
- self.modules<<module_container
141
-
142
- if options.has_key?(:route)
143
- self.routes[name]=[options.has_key?(:nested) ? options[:nested] : true,options[:route]]
144
- end
145
- self.controllers[name]=options[:controller] if options.has_key?(:controller)
146
-
147
- if options[:path]
148
- require File.join(options[:path],name.to_s)
149
- end
150
-
151
- end
152
-
153
- # Lolita.extend_route_for(:any,:posts,:file_upload) do |resource|
154
- # if resource.tabs.by_type(:metadata)
155
- # with do
156
- # resources :metadata
157
- # end
158
- # end
159
- #end
160
- # :any for any
161
- # lolita/posts/metadata
162
- # lolita/posts/files/metadata
163
- def lolita_extend_route_for()
164
- end
165
- end
166
- end