lolita 3.1.6 → 3.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/Gemfile +1 -1
  2. data/History.rdoc +8 -1
  3. data/README.rdoc +1 -1
  4. data/VERSION +1 -1
  5. data/app/controllers/lolita/info_controller.rb +38 -0
  6. data/app/controllers/lolita/rest_controller.rb +4 -4
  7. data/app/views/components/lolita/configuration/column/_display.html.erb +1 -1
  8. data/app/views/components/lolita/configuration/column/_header.html.erb +1 -1
  9. data/app/views/components/lolita/configuration/column/_sort.html.erb +1 -1
  10. data/app/views/components/lolita/configuration/columns/_last.html.erb +2 -2
  11. data/app/views/components/lolita/configuration/field/_display.html.erb +1 -1
  12. data/app/views/components/lolita/configuration/field/_label.html.erb +1 -1
  13. data/app/views/components/lolita/configuration/list/_filter.html.erb +1 -1
  14. data/app/views/components/lolita/configuration/list/_new_resource.html.erb +1 -1
  15. data/app/views/components/lolita/configuration/list/_title.html.erb +1 -1
  16. data/app/views/components/lolita/shared/_header.html.erb +1 -1
  17. data/app/views/components/lolita/shared/_right_sidebar.html.erb +1 -1
  18. data/app/views/layouts/lolita/application.html.erb +2 -2
  19. data/app/views/lolita/info/index.html.erb +232 -0
  20. data/lib/lolita.rb +3 -0
  21. data/lib/lolita/builder.rb +218 -55
  22. data/lib/lolita/configuration/filter.rb +1 -1
  23. data/lib/lolita/configuration/tab.rb +2 -2
  24. data/lib/lolita/controllers/component_helpers.rb +4 -5
  25. data/lib/lolita/controllers/internal_helpers.rb +3 -4
  26. data/lib/lolita/rails/routes.rb +12 -4
  27. data/lolita.gemspec +9 -6
  28. data/public/javascripts/lolita/application.js +1 -0
  29. data/public/javascripts/lolita/main.js +5 -0
  30. data/spec/builder_spec.rb +97 -18
  31. data/spec/controllers/lolita_rest_spec.rb +1 -1
  32. data/spec/navigation/branch_spec.rb +0 -1
  33. metadata +117 -118
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source "http://rubygems.org"
2
2
 
3
3
  # Thing how to seperate gems for Rails Engine from those that are only for lolita
4
4
  gem "rails", "~>3.0"
5
- gem "kaminari", "~>0.11.0"
5
+ gem "kaminari", "~>0.12.4"
6
6
  gem "abstract"
7
7
  gem "builder", "~> 2.1.2" #cucumber asks for builder 3 but rails supports 2.1
8
8
 
data/History.rdoc CHANGED
@@ -1,5 +1,12 @@
1
- === Version 3.1.7 / 2011-
1
+ === Version 3.1.8 / 2011
2
+
3
+ === Version 3.1.7 / 2011-06-10
2
4
  * Enhancements
5
+ * Builder refactored. Now support conditions. (Arturs Meisters)
6
+
7
+ * Bug fixes
8
+ * Updated Kaminari to 0.12.4 - previous version has serious BUG (Arturs Meisters, Gatis Tomsons)
9
+ * Lolita messaging not used in RestController (Arturs Meisters)
3
10
 
4
11
  === Version 3.1.6 / 2011-05-19
5
12
  * Enhancements
data/README.rdoc CHANGED
@@ -36,7 +36,7 @@ For more detailed usage read Usage[https://github.com/ithouse/lolita/wiki/Usage]
36
36
 
37
37
  ===Add authorization to Lolita
38
38
 
39
- Easiest way to add authentication is with Devise. First install Devise as gem, than add to it your project.
39
+ Easiest way to add authentication is with Devise. First install Devise as gem, than add it to your project.
40
40
  Make Devise model, lets say, User. After that add these lines in <i>/config/initializers/lolita.rb</i>
41
41
  config.user_classes << User
42
42
  config.authentication = :authenticate_user!
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.6
1
+ 3.1.7
@@ -0,0 +1,38 @@
1
+ class Lolita::InfoController < ApplicationController
2
+ @@properties = []
3
+ def index
4
+ end
5
+ def properties
6
+ if request.local?
7
+ render :inline => to_html
8
+ else
9
+ render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => :forbidden
10
+ end
11
+ end
12
+
13
+ private
14
+
15
+ def self.property(name, value = nil)
16
+ value ||= yield
17
+ @@properties << [name, value] if value
18
+ rescue Exception
19
+ end
20
+
21
+ def to_html
22
+ (table = '<table>').tap do
23
+ @@properties.each do |(name, value)|
24
+ table << %(<tr><td class="name">#{CGI.escapeHTML(name.to_s)}</td>)
25
+ formatted_value = if value.kind_of?(Array)
26
+ "<ul>" + value.map { |v| "<li>#{CGI.escapeHTML(v.to_s)}</li>" }.join + "</ul>"
27
+ else
28
+ CGI.escapeHTML(value.to_s)
29
+ end
30
+ table << %(<td class="value">#{formatted_value}</td></tr>)
31
+ end
32
+ table << '</table>'
33
+ end
34
+ end
35
+
36
+ property 'Lolita version', "#{LOLITA_VERSION}"
37
+
38
+ end
@@ -42,9 +42,9 @@ class Lolita::RestController < ApplicationController
42
42
  self.run(:before_destroy)
43
43
  get_resource
44
44
  if self.resource && self.resource.destroy
45
- flash[:notice] = I18n.t "lolita.shared.destroy_notice"
45
+ flash[:notice] = ::I18n.t "lolita.shared.destroy_notice"
46
46
  else
47
- flash[:alert] = I18n.t "lolita.shared.destroy_alert"
47
+ flash[:alert] = ::I18n.t "lolita.shared.destroy_alert"
48
48
  end
49
49
  self.run(:after_destroy)
50
50
  redirect_to lolita_resources_path
@@ -95,13 +95,13 @@ class Lolita::RestController < ApplicationController
95
95
 
96
96
  def respond_html_200
97
97
  response.headers["Validation"] = 'true'
98
- flash.now[:notice] = I18n.t "lolita.shared.save_notice"
98
+ response.headers["Lolita-Notice"] = ::I18n.t "lolita.shared.save_notice"
99
99
  show_form
100
100
  end
101
101
 
102
102
  def respond_html_400
103
103
  response.headers["Validation"] = 'false'
104
- flash.now[:alert] = I18n.t "lolita.shared.save_alert"
104
+ response.headers["Lolita-Alert"] = ::I18n.t "lolita.shared.save_alert"
105
105
  show_form
106
106
  end
107
107
 
@@ -1,4 +1,4 @@
1
1
  <td>
2
- <% value=column.formatter.with(record.send(column.name.to_sym),record) %>
2
+ <% value=column.formatter.with(record.send(column.name.to_sym),record,self) %>
3
3
  <%= value.to_s %>
4
4
  </td>
@@ -2,6 +2,6 @@
2
2
  <% if column.sortable? %>
3
3
  <%= render_component column, :sort %>
4
4
  <% else %>
5
- <%= column.title %>
5
+ <%= column.title.to_s.capitalize %>
6
6
  <% end %>
7
7
  </th>
@@ -1,4 +1,4 @@
1
1
  <% param_options=params.reject{|k,v| [:controller,:action].include?(k)} %>
2
2
  <% options=param_options.merge(column.sort_options(params)) %>
3
3
  <% direction_indicator=column.currently_sorting?(params) && options[:sd].to_s=="desc" ? raw('&uArr;') : raw('&dArr;') %>
4
- <%= link_to raw("#{column.title } #{direction_indicator}"), lolita_resources_path(options) %>
4
+ <%= link_to raw("#{column.title.to_s.capitalize } #{direction_indicator}"), lolita_resources_path(options) %>
@@ -1,4 +1,4 @@
1
1
  <td class="tool-cell">
2
- <%= link_to I18n.t("lolita.shared.edit"),edit_lolita_resource_path(:id=>record.id) %>
3
- <%= link_to I18n.t("lolita.shared.delete"), lolita_resource_path(:id=>record.id),:method=>:delete,:confirm=>I18n.t("lolita.list.confirm") %>
2
+ <%= link_to ::I18n.t("lolita.shared.edit"),edit_lolita_resource_path(:id=>record.id) %>
3
+ <%= link_to ::I18n.t("lolita.shared.delete"), lolita_resource_path(:id=>record.id),:method=>:delete,:confirm=>I18n.t("lolita.list.confirm") %>
4
4
  </td>
@@ -1,5 +1,5 @@
1
1
  <div class="field" id="field_<%=field.__id__%>">
2
- <%= render_component :"lolita/configuration/field", :label, :field=>field %>
2
+ <%= render_component *field.build(:name=>"/lolita/configuration/field", :state => :"label") %>
3
3
  <div class="field-value" id="field_<%=field.__id__%>_value">
4
4
  <%= render_component *field.build %>
5
5
  </div>
@@ -1 +1 @@
1
- <%= label resource_name, field.name, raw(field.title), :id=>"field_#{field.__id__}_label" %>
1
+ <%= label resource_name, field.name, raw(field.title.to_s.capitalize), :id=>"field_#{field.__id__}_label" %>
@@ -3,6 +3,6 @@
3
3
  <% list.filter.fields.each do |field| %>
4
4
  <%= render_component *field.build(:filter, :filter=>list.filter) %>
5
5
  <% end %>
6
- <button type="submit"><%= I18n.t "lolita.filter.apply_button" %></button>
6
+ <button type="submit"><%= ::I18n.t "lolita.filter.apply_button" %></button>
7
7
  </form>
8
8
  <% end -%>
@@ -1,4 +1,4 @@
1
1
  <a href="<%= new_lolita_resource_path%>" class="create">
2
- <%= I18n.t("lolita.list.add_new",:name=>resource_class.human_name.downcase) %>
2
+ <%= ::I18n.t("lolita.list.add_new",:name=>resource_class.model_name.human.downcase) %>
3
3
  <%= image_tag "lolita/plus.png", :alt=>"+" %>
4
4
  </a>
@@ -1,5 +1,5 @@
1
1
  <div class="boxtitle">
2
- <h1 class="black"><%= resource_class.human_name(:count=>2) %></h1>
2
+ <h1 class="black"><%= resource_class.model_name.human(:count=>2) %></h1>
3
3
  <div class="arrow">
4
4
  </div>
5
5
  </div>
@@ -3,7 +3,7 @@
3
3
  <% if lolita_current_user %>
4
4
  <nav>
5
5
  <a href="<%=send(:"edit_#{lolita_current_user.class.to_s.downcase}_password_path")%>" class="username"><%=lolita_current_user.email%></a>
6
- <a href="<%=send(:"destroy_#{lolita_current_user.class.to_s.downcase}_session_path")%>" class="button grey"><%=I18n.t("lolita.shared.log_out")%></a>
6
+ <a href="<%=send(:"destroy_#{lolita_current_user.class.to_s.downcase}_session_path")%>" class="button grey"><%=::I18n.t("lolita.shared.log_out")%></a>
7
7
  </nav>
8
8
  <% end %>
9
9
  </header>
@@ -8,7 +8,7 @@
8
8
  <div class="last-save">
9
9
  <%= resource.updated_at.strftime("#{t("lolita.tabs.last_save")}: %m/%d/%Y %H:%M ") if resource.respond_to?(:updated_at) && resource.updated_at %>
10
10
  </div>
11
- <button class="save-all"><%=I18n.t("lolita.tabs.save")%></button>
11
+ <button class="save-all"><%=::I18n.t("lolita.tabs.save")%></button>
12
12
  </div>
13
13
  </div>
14
14
  </div>
@@ -20,11 +20,11 @@
20
20
  <script>
21
21
  if(!window.jQuery){
22
22
  document.write('<script src="/javascripts/jquery-1.6.min.js">\x3C/script>');
23
- document.write('<script src="/javascripts/jquery-ui.1.8.13.min.js">\x3C/script>');
23
+ document.write('<script src="/javascripts/jquery-ui-1.8.13.min.js">\x3C/script>');
24
24
  }
25
25
  </script>
26
26
  <%= javascript_include_tag "modernizr-1.7.min" %>
27
- <%= javascript_include_tag "rails","lolita/tab","lolita/main" %>
27
+ <%= javascript_include_tag "rails","lolita/tab","lolita/main","lolita/application" %>
28
28
  <%= yield :script %>
29
29
  <%= raw csrf_meta_tag %>
30
30
  </head>
@@ -0,0 +1,232 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Lolita: Welcome aboard</title>
5
+ <style type="text/css" media="screen">
6
+ body {
7
+ margin: 0;
8
+ margin-bottom: 25px;
9
+ padding: 0;
10
+ background-color: #f0f0f0;
11
+ font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
12
+ font-size: 13px;
13
+ color: #333;
14
+ }
15
+
16
+ h1 {
17
+ font-size: 28px;
18
+ color: #000;
19
+ }
20
+
21
+ a {color: #03c}
22
+ a:hover {
23
+ background-color: #03c;
24
+ color: white;
25
+ text-decoration: none;
26
+ }
27
+
28
+
29
+ #page {
30
+ background-color: #f0f0f0;
31
+ width: 750px;
32
+ margin: 0;
33
+ margin-left: auto;
34
+ margin-right: auto;
35
+ }
36
+
37
+ #content {
38
+ float: left;
39
+ background-color: white;
40
+ border: 3px solid #aaa;
41
+ border-top: none;
42
+ padding: 25px;
43
+ width: 500px;
44
+ }
45
+
46
+ #sidebar {
47
+ float: right;
48
+ width: 175px;
49
+ }
50
+
51
+ #footer {
52
+ clear: both;
53
+ }
54
+
55
+
56
+ #header, #about, #getting-started {
57
+ padding-left: 75px;
58
+ padding-right: 30px;
59
+ }
60
+
61
+
62
+ #header {
63
+ background-image: url("images/lolita/plus.png");
64
+ background-repeat: no-repeat;
65
+ background-position: top left;
66
+ height: 64px;
67
+ }
68
+ #header h1, #header h2 {margin: 0}
69
+ #header h2 {
70
+ color: #888;
71
+ font-weight: normal;
72
+ font-size: 16px;
73
+ }
74
+
75
+
76
+ #about h3 {
77
+ margin: 0;
78
+ margin-bottom: 10px;
79
+ font-size: 14px;
80
+ }
81
+
82
+ #about-content {
83
+ background-color: #ffd;
84
+ border: 1px solid #fc0;
85
+ margin-left: -55px;
86
+ margin-right: -10px;
87
+ }
88
+ #about-content table {
89
+ margin-top: 10px;
90
+ margin-bottom: 10px;
91
+ font-size: 11px;
92
+ border-collapse: collapse;
93
+ }
94
+ #about-content td {
95
+ padding: 10px;
96
+ padding-top: 3px;
97
+ padding-bottom: 3px;
98
+ }
99
+ #about-content td.name {color: #555}
100
+ #about-content td.value {color: #000}
101
+
102
+ #about-content ul {
103
+ padding: 0;
104
+ list-style-type: none;
105
+ }
106
+
107
+ #about-content.failure {
108
+ background-color: #fcc;
109
+ border: 1px solid #f00;
110
+ }
111
+ #about-content.failure p {
112
+ margin: 0;
113
+ padding: 10px;
114
+ }
115
+
116
+
117
+ #getting-started {
118
+ border-top: 1px solid #ccc;
119
+ margin-top: 25px;
120
+ padding-top: 15px;
121
+ }
122
+ #getting-started h1 {
123
+ margin: 0;
124
+ font-size: 20px;
125
+ }
126
+ #getting-started h2 {
127
+ margin: 0;
128
+ font-size: 14px;
129
+ font-weight: normal;
130
+ color: #333;
131
+ margin-bottom: 25px;
132
+ }
133
+ #getting-started ol {
134
+ margin-left: 0;
135
+ padding-left: 0;
136
+ }
137
+ #getting-started li {
138
+ font-size: 18px;
139
+ color: #888;
140
+ margin-bottom: 25px;
141
+ }
142
+ #getting-started li h2 {
143
+ margin: 0;
144
+ font-weight: normal;
145
+ font-size: 18px;
146
+ color: #333;
147
+ }
148
+ #getting-started li p {
149
+ color: #555;
150
+ font-size: 13px;
151
+ }
152
+
153
+
154
+ #sidebar ul {
155
+ margin-left: 0;
156
+ padding-left: 0;
157
+ }
158
+ #sidebar ul h3 {
159
+ margin-top: 25px;
160
+ font-size: 16px;
161
+ padding-bottom: 10px;
162
+ border-bottom: 1px solid #ccc;
163
+ }
164
+ #sidebar li {
165
+ list-style-type: none;
166
+ }
167
+ #sidebar ul.links li {
168
+ margin-bottom: 5px;
169
+ }
170
+
171
+ </style>
172
+ <script type="text/javascript">
173
+ function about() {
174
+ info = document.getElementById('about-content');
175
+ if (window.XMLHttpRequest)
176
+ { xhr = new XMLHttpRequest(); }
177
+ else
178
+ { xhr = new ActiveXObject("Microsoft.XMLHTTP"); }
179
+ xhr.open("GET","lolita/info/properties",false);
180
+ xhr.send("");
181
+ info.innerHTML = xhr.responseText;
182
+ info.style.display = 'block'
183
+ }
184
+ </script>
185
+ </head>
186
+ <body>
187
+ <div id="page">
188
+ <div id="sidebar">
189
+ <ul id="sidebar-items">
190
+ <li>
191
+ <h3>Browse the documentation</h3>
192
+ <ul class="links">
193
+ <li><a href="http://rdoc.info/github/ithouse/lolita/master/frames">Lolita API</a></li>
194
+ </ul>
195
+ </li>
196
+ </ul>
197
+ </div>
198
+
199
+ <div id="content">
200
+ <div id="header">
201
+ <h1>Welcome aboard</h1>
202
+ <h2>You&rsquo;re riding Lolita!</h2>
203
+ </div>
204
+
205
+ <div id="about">
206
+ <h3><a href="lolita/info/properties" onclick="about(); return false">About your application&rsquo;s environment</a></h3>
207
+ <div id="about-content" style="display: none"></div>
208
+ </div>
209
+
210
+ <div id="getting-started">
211
+ <h1>Getting started</h1>
212
+ <h2>Here&rsquo;s how to get rolling:</h2>
213
+
214
+ <ol>
215
+ <li>
216
+ <h2>Use <code>lolita_for</code> in config/routes.rb</h2>
217
+ <p>run it.</p>
218
+ </li>
219
+
220
+ <li>
221
+ <h2>Use <code>lolita</code> in your models</h2>
222
+ <p></p>
223
+ </li>
224
+
225
+ </ol>
226
+ </div>
227
+ </div>
228
+
229
+ <div id="footer">&nbsp;</div>
230
+ </div>
231
+ </body>
232
+ </html>
data/lib/lolita.rb CHANGED
@@ -36,6 +36,9 @@ module Lolita
36
36
  autoload(:VERSION,'lolita/version')
37
37
  autoload(:ObservedArray,'lolita/observed_array')
38
38
  autoload(:Builder,'lolita/builder')
39
+ module Builder
40
+ autoload(:Custom, 'lolita/builder')
41
+ end
39
42
  autoload(:BaseConfiguration,'lolita/base_configuration')
40
43
 
41
44
  module Adapter