caseadilla 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c48623f5e7e79c4b923b12eb91e1095c3851f3af
4
- data.tar.gz: fb1c957602e8e67f40e6e7d90a341883e8e5e3bd
3
+ metadata.gz: 54ebd4a33e0d42a43de0ba6dfc91d9c9820311e7
4
+ data.tar.gz: 7db6e8357cccc11831ad407d1e22afa464803093
5
5
  SHA512:
6
- metadata.gz: 7ea31aa4da299bf4fdbeb44ddee077b0b510f3dca717e1d9cda39b357c0987a5611f6519c819b25142d2863920bd59795e6411b1cbd807185feadf84ba885c32
7
- data.tar.gz: 7f7c79861c19cba634f9adefa3f8e1f1793b672ce0c448820501808b4a2b972f79d79f3787cae847d44bc6b85bf473b5cef2d770c17be05207e1cc7d741bb5b9
6
+ metadata.gz: 2c1debf8ad153706c0e443ff70521a91d33fc431e7b765392ff5bb979b17f09e6e8b5c5349581c9a09c4df7bf89b979af46bbb11b6d90eabb418b28b834d41a5
7
+ data.tar.gz: 1fec81f2551558ed11f961937802fa3b3839e3fbac80304c930e352d39410d3a1b5bc940e0effa0f3da6d979328a4a3b56f37281c461ba310b5efe0762248d1c
@@ -1,5 +1,6 @@
1
1
  module Caseadilla
2
2
  class CaseadillaController < ApplicationController
3
+ # filter_access_to [:index, :blank]
3
4
 
4
5
  require 'caseadilla/caseadilla_helper'
5
6
  include Caseadilla::CaseadillaHelper
@@ -11,10 +12,12 @@ module Caseadilla
11
12
 
12
13
  # before_filter :set_time_zone
13
14
  before_action :require_sign_in
14
-
15
+ before_action :redirect_if_not_authorized
16
+ # skip_before_action :redirect_if_not_authorized, only: :index
17
+
15
18
  ActionView::Base.field_error_proc = proc { |input, instance| "#{input}".html_safe }
16
19
 
17
- def index
20
+ def index
18
21
  redirect_to caseadilla_config_dashboard_url
19
22
  end
20
23
 
@@ -35,16 +38,23 @@ module Caseadilla
35
38
  def veggie?
36
39
  return false unless Caseadilla::Engine.flavor = :veggie
37
40
  end
38
-
41
+
39
42
  # def set_time_zone
40
43
  # Time.zone = current_user.time_zone if current_user
41
44
  # end
42
-
45
+
43
46
  def redirect_back_or_default(default)
44
47
  redirect_to(session[:return_to] || default)
45
48
  session[:return_to] = nil
46
49
  end
47
50
 
51
+ def redirect_if_not_authorized
52
+ auth = Authorization::Engine.new
53
+ unless auth.permit? :access, user: current_user, context: :caseadilla
54
+ redirect_to root_path, alert: "You are not authorized to access that page."
55
+ end
56
+ end
57
+
48
58
  def sort_order(default)
49
59
  "#{(params[:c] || default.to_s).gsub(/[\s;'\"]/,'')} #{'ASC' if params[:d] == 'up'} #{'DESC' if params[:d] == 'down'}"
50
60
  end
@@ -54,4 +64,4 @@ module Caseadilla
54
64
  end
55
65
 
56
66
  end
57
- end
67
+ end
@@ -1,15 +1,17 @@
1
1
  module Caseadilla
2
2
  class CaseadillaUserSessionsController < Caseadilla::CaseadillaController
3
-
3
+ # filter_access_to [:create]
4
+
4
5
  skip_before_action :require_sign_in, :only => [:new, :create]
6
+ skip_before_action :redirect_if_not_authorized, only: [:new, :create]
5
7
  before_filter :requires_no_session_user, :except => [:destroy]
6
-
8
+
7
9
  layout 'caseadilla_auth'
8
-
10
+
9
11
  def new
10
12
  @user_session = nil
11
13
  end
12
-
14
+
13
15
  def create
14
16
  @user_session = nil
15
17
  if @user_session.save
@@ -18,14 +20,14 @@ module Caseadilla
18
20
  render :action => :new
19
21
  end
20
22
  end
21
-
23
+
22
24
  def destroy
23
25
  current_user_session.destroy
24
26
  redirect_back_or_default new_caseadilla_user_session_url
25
27
  end
26
28
 
27
29
  private
28
-
30
+
29
31
  def requires_no_session_user
30
32
  if current_user
31
33
  redirect_to :controller => :caseadilla, :action => :index
@@ -33,4 +35,4 @@ module Caseadilla
33
35
  end
34
36
 
35
37
  end
36
- end
38
+ end
@@ -1,6 +1,6 @@
1
1
  module Caseadilla
2
2
  module CaseadillaHelper
3
-
3
+
4
4
  def caseadilla_get_footer_string include_version = false
5
5
  if include_version
6
6
  "Running on #{link_to 'Caseadilla', 'http://www.github.com/zeiv/caseadilla'} #{caseadilla_get_full_version_string}, an open-source project.".html_safe
@@ -8,65 +8,65 @@ module Caseadilla
8
8
  "Running on #{link_to 'Caseadilla', 'http://www.github.com/zeiv/caseadilla'}, an open-source project.".html_safe
9
9
  end
10
10
  end
11
-
11
+
12
12
  def caseadilla_get_full_version_string
13
13
  Caseadilla::VERSION
14
14
  end
15
-
15
+
16
16
  def caseadilla_get_short_version_string
17
17
  Caseadilla::VERSION.slice(0..(str.index('.')))
18
18
  end
19
-
19
+
20
20
  def caseadilla_generate_page_title
21
-
21
+
22
22
  if @caseadilla_page_title.nil?
23
23
  return caseadilla_config_website_name
24
24
  end
25
-
26
- caseadilla_config_website_name + " > " + @caseadilla_page_title
25
+
26
+ caseadilla_config_website_name + " > " + @caseadilla_page_title
27
27
  end
28
-
28
+
29
29
  def caseadilla_get_access_level_text level
30
30
  case level
31
- when $CASEIN_USER_ACCESS_LEVEL_ADMIN
31
+ when $caseadilla_USER_ACCESS_LEVEL_ADMIN
32
32
  return "Administrator"
33
- when $CASEIN_USER_ACCESS_LEVEL_USER
33
+ when $caseadilla_USER_ACCESS_LEVEL_USER
34
34
  return "User"
35
35
  else
36
36
  return "Unknown"
37
37
  end
38
38
  end
39
-
39
+
40
40
  def caseadilla_get_access_level_array
41
- [["Administrator", $CASEIN_USER_ACCESS_LEVEL_ADMIN], ["User", $CASEIN_USER_ACCESS_LEVEL_USER]]
41
+ [["Administrator", $caseadilla_USER_ACCESS_LEVEL_ADMIN], ["User", $caseadilla_USER_ACCESS_LEVEL_USER]]
42
42
  end
43
43
 
44
44
  def caseadilla_pagination_details objs
45
45
  " <small class='pagination-details'>/ page #{objs.current_page} of #{objs.total_pages}</small>".html_safe if objs.current_page && objs.total_pages > 1
46
46
  end
47
-
47
+
48
48
  def caseadilla_table_cell_link contents, link, options = {}
49
-
49
+
50
50
  if options.key? :caseadilla_truncate
51
51
  contents = truncate(contents, :length => options[:caseadilla_truncate], :omission => "...")
52
52
  end
53
-
53
+
54
54
  link_to "#{contents}".html_safe, link, options
55
55
  end
56
-
56
+
57
57
  def caseadilla_table_cell_no_link contents, options = {}
58
-
58
+
59
59
  if options.key? :caseadilla_truncate
60
60
  contents = truncate(contents, :length => options[:caseadilla_truncate], :omission => "...")
61
61
  end
62
-
62
+
63
63
  "<div class='no-link'>#{contents}</div>".html_safe
64
64
  end
65
-
65
+
66
66
  def caseadilla_show_icon icon_name
67
67
  "<div class='icon'><span class='glyphicon glyphicon-#{icon_name}'></span></div>".html_safe
68
68
  end
69
-
69
+
70
70
  def caseadilla_show_row_icon icon_name
71
71
  "<div class='iconRow'><span class='glyphicon glyphicon-#{icon_name}'></span></div>".html_safe
72
72
  end
@@ -109,77 +109,77 @@ module Caseadilla
109
109
  return "<span class='label label-success'>No</span>".html_safe
110
110
  end
111
111
  end
112
-
112
+
113
113
  # Styled form tag helpers
114
-
114
+
115
115
  def caseadilla_text_field form, obj, attribute, options = {}
116
116
  caseadilla_form_tag_wrapper(form.text_field(attribute, strip_caseadilla_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe
117
117
  end
118
-
118
+
119
119
  def caseadilla_password_field form, obj, attribute, options = {}
120
120
  caseadilla_form_tag_wrapper(form.password_field(attribute, strip_caseadilla_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe
121
121
  end
122
-
122
+
123
123
  def caseadilla_text_area form, obj, attribute, options = {}
124
124
  caseadilla_form_tag_wrapper(form.text_area(attribute, strip_caseadilla_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe
125
125
  end
126
-
126
+
127
127
  def caseadilla_text_area_wysiwyg form, obj, attribute, options = {}
128
128
  options.reverse_merge!({style: "height: 250px;"})
129
129
  caseadilla_form_tag_wrapper(form.text_area(attribute, strip_caseadilla_options(options_hash_with_merged_classes(options, 'form-control wysihtml5'))), form, obj, attribute, options).html_safe
130
130
  end
131
-
131
+
132
132
  def caseadilla_check_box form, obj, attribute, options = {}
133
133
  form_tag = "<div class='check-box'>#{form.check_box(attribute, strip_caseadilla_options(options))}</div>".html_safe
134
134
  caseadilla_form_tag_wrapper(form_tag, form, obj, attribute, options).html_safe
135
135
  end
136
-
136
+
137
137
  def caseadilla_check_box_group form, obj, check_boxes = {}
138
138
  form_tags = ""
139
-
139
+
140
140
  for check_box in check_boxes
141
141
  form_tags += caseadilla_check_box form, obj, check_box[0], check_box[1]
142
142
  end
143
-
143
+
144
144
  caseadilla_form_tag_wrapper(form_tag, form, obj, attribute, options)
145
145
  end
146
-
146
+
147
147
  def caseadilla_radio_button form, obj, attribute, tag_value, options = {}
148
148
  form_tag = form.radio_button(obj, attribute, tag_value, strip_caseadilla_options(options))
149
-
149
+
150
150
  if options.key? :caseadilla_button_label
151
151
  form_tag = "<div>" + form_tag + "<span class=\"rcText\">#{options[:caseadilla_button_label]}</span></div>".html_safe
152
152
  end
153
-
153
+
154
154
  caseadilla_form_tag_wrapper(form_tag, form, obj, attribute, options).html_safe
155
155
  end
156
-
156
+
157
157
  def caseadilla_radio_button_group form, obj, radio_buttons = {}
158
158
  form_tags = ""
159
-
159
+
160
160
  for radio_button in radio_buttons
161
161
  form_tags += caseadilla_radio_button form, obj, check_box[0], check_box[1], check_box[2]
162
162
  end
163
-
163
+
164
164
  caseadilla_form_tag_wrapper(form_tag, form, obj, attribute, options).html_safe
165
165
  end
166
-
166
+
167
167
  def caseadilla_select form, obj, attribute, option_tags, options = {}
168
168
  caseadilla_form_tag_wrapper(form.select(attribute, option_tags, strip_caseadilla_options(options), merged_class_hash(options, 'form-control')), form, obj, attribute, options).html_safe
169
169
  end
170
-
170
+
171
171
  def caseadilla_time_zone_select form, obj, attribute, option_tags, options = {}
172
172
  caseadilla_form_tag_wrapper(form.time_zone_select(attribute, option_tags, strip_caseadilla_options(options), merged_class_hash(options, 'form-control')), form, obj, attribute, options).html_safe
173
173
  end
174
-
174
+
175
175
  def caseadilla_collection_select form, obj, attribute, collection, value_method, text_method, options = {}
176
176
  caseadilla_form_tag_wrapper(collection_select(obj.class.name.downcase.to_sym, attribute, collection, value_method, text_method, strip_caseadilla_options(options), merged_class_hash(options, 'form-control')), form, obj, attribute, options).html_safe
177
177
  end
178
-
178
+
179
179
  def caseadilla_collection_check_boxes form, obj, attribute, collection, value_method, text_method, options = {}
180
180
  caseadilla_form_tag_wrapper(collection_check_boxes(obj.class.name.downcase.to_sym, attribute, collection, value_method, text_method, strip_caseadilla_options(options), merged_class_hash(options, 'form-control')), form, obj, attribute, options).html_safe
181
181
  end
182
-
182
+
183
183
  def caseadilla_date_select form, obj, attribute, options = {}
184
184
  caseadilla_form_tag_wrapper("<div class='caseadilla-date-select'>".html_safe + form.date_select(attribute, strip_caseadilla_options(options), merged_class_hash(options, 'form-control')) + "</div>".html_safe, form, obj, attribute, options).html_safe
185
185
  end
@@ -187,11 +187,11 @@ module Caseadilla
187
187
  def caseadilla_time_select form, obj, attribute, options = {}
188
188
  caseadilla_form_tag_wrapper("<div class='caseadilla-time-select'>".html_safe + form.time_select(attribute, strip_caseadilla_options(options), merged_class_hash(options, 'form-control')) + "</div>".html_safe, form, obj, attribute, options).html_safe
189
189
  end
190
-
190
+
191
191
  def caseadilla_datetime_select form, obj, attribute, options = {}
192
192
  caseadilla_form_tag_wrapper("<div class='caseadilla-datetime-select'>".html_safe + form.datetime_select(attribute, strip_caseadilla_options(options), merged_class_hash(options, 'form-control')) + "</div>".html_safe, form, obj, attribute, options).html_safe
193
193
  end
194
-
194
+
195
195
  def caseadilla_file_field form, obj, object_name, attribute, options = {}
196
196
  class_hash = merged_class_hash(options, 'form-control')
197
197
  contents = "<div class='#{class_hash[:class]}'>" + file_field(object_name, attribute, strip_caseadilla_options(options)) + '</div>'
@@ -202,7 +202,7 @@ module Caseadilla
202
202
 
203
203
  caseadilla_form_tag_wrapper(contents, form, obj, attribute, options).html_safe
204
204
  end
205
-
205
+
206
206
  def caseadilla_hidden_field form, obj, attribute, options = {}
207
207
  form.hidden_field(attribute, strip_caseadilla_options(options)).html_safe
208
208
  end
@@ -210,21 +210,73 @@ module Caseadilla
210
210
  def caseadilla_custom_field form, obj, attribute, custom_contents, options = {}
211
211
  caseadilla_form_tag_wrapper(custom_contents, form, obj, attribute, options).html_safe
212
212
  end
213
-
213
+
214
+ def caseadilla_color_field form, obj, attribute, options = {}
215
+ caseadilla_form_tag_wrapper(form.color_field(attribute, strip_caseadilla_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe
216
+ end
217
+
218
+ def caseadilla_search_field form, obj, attribute, options = {}
219
+ caseadilla_form_tag_wrapper(form.search_field(attribute, strip_caseadilla_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe
220
+ end
221
+
222
+ def caseadilla_telephone_field form, obj, attribute, options = {}
223
+ caseadilla_form_tag_wrapper(form.telephone_field(attribute, strip_caseadilla_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe
224
+ end
225
+
226
+ def caseadilla_url_field form, obj, attribute, options = {}
227
+ caseadilla_form_tag_wrapper(form.url_field(attribute, strip_caseadilla_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe
228
+ end
229
+
230
+ def caseadilla_email_field form, obj, attribute, options = {}
231
+ caseadilla_form_tag_wrapper(form.email_field(attribute, strip_caseadilla_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe
232
+ end
233
+
234
+ def caseadilla_date_field form, obj, attribute, options = {}
235
+ caseadilla_form_tag_wrapper(form.date_field(attribute, strip_caseadilla_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe
236
+ end
237
+
238
+ def caseadilla_datetime_field form, obj, attribute, options = {}
239
+ caseadilla_form_tag_wrapper(form.datetime_field(attribute, strip_caseadilla_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe
240
+ end
241
+
242
+ def caseadilla_datetime_local_field form, obj, attribute, options = {}
243
+ caseadilla_form_tag_wrapper(form.datetime_local_field(attribute, strip_caseadilla_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe
244
+ end
245
+
246
+ def caseadilla_month_field form, obj, attribute, options = {}
247
+ caseadilla_form_tag_wrapper(form.month_field(attribute, strip_caseadilla_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe
248
+ end
249
+
250
+ def caseadilla_week_field form, obj, attribute, options = {}
251
+ caseadilla_form_tag_wrapper(form.week_field(attribute, strip_caseadilla_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe
252
+ end
253
+
254
+ def caseadilla_time_field form, obj, attribute, options = {}
255
+ caseadilla_form_tag_wrapper(form.time_field(attribute, strip_caseadilla_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe
256
+ end
257
+
258
+ def caseadilla_number_field form, obj, attribute, options = {}
259
+ caseadilla_form_tag_wrapper(form.number_field(attribute, strip_caseadilla_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe
260
+ end
261
+
262
+ def caseadilla_range_field form, obj, attribute, options = {}
263
+ caseadilla_form_tag_wrapper(form.range_field(attribute, strip_caseadilla_options(options_hash_with_merged_classes(options, 'form-control'))), form, obj, attribute, options).html_safe
264
+ end
265
+
214
266
  protected
215
267
 
216
268
  def strip_caseadilla_options options
217
269
  options.reject {|key, value| key.to_s.include? "caseadilla_" }
218
270
  end
219
-
271
+
220
272
  def merged_class_hash options, new_class
221
273
  if options.key? :class
222
274
  new_class += " #{options[:class]}"
223
275
  end
224
-
276
+
225
277
  {:class => new_class}
226
278
  end
227
-
279
+
228
280
  def options_hash_with_merged_classes options, new_class
229
281
  if options.key? :class
230
282
  new_class += " #{options[:class]}"
@@ -259,4 +311,4 @@ module Caseadilla
259
311
  html += "<div class='well'>#{form_tag}</div></div>"
260
312
  end
261
313
  end
262
- end
314
+ end
@@ -6,5 +6,5 @@
6
6
  <p>You&rsquo;re ready to begin scaffolding and customizing!</p>
7
7
  <p><small style="font-size: 0.7em;">To remove this screen, set <code>caseadilla_config_dashboard_url</code></small></p>
8
8
  <br />
9
- <p><a href="https://github.com/zeiv/caseadilla/blob/master/README.rdoc" class="btn btn-primary btn-large">View README on GitHub</a></p>
10
- </div>
9
+ <p><a href="https://github.com/zeiv/caseadilla/blob/master/README.md" class="btn btn-primary btn-large">View README on GitHub</a></p>
10
+ </div>
@@ -12,7 +12,7 @@
12
12
  <%= flash[:notice] %>
13
13
  </div>
14
14
  <% end %>
15
-
15
+
16
16
  <div class="form-group">
17
17
  <%= f.text_field :email, :placeholder => "Email", :class => "form-control input-lg" %>
18
18
  </div>
@@ -35,5 +35,5 @@
35
35
  <div class="form-group">
36
36
  <%= link_to "Forgot your password?", new_password_path(:user) %>
37
37
  </div>
38
-
39
- <% end %>
38
+
39
+ <% end %>
@@ -27,16 +27,41 @@
27
27
  </div>
28
28
 
29
29
  <p class="submits">
30
- <%= link_to 'Cancel', caseadilla_users_path, :class => 'btn btn-mini btn-danger' %>
30
+ <%= link_to 'Cancel', caseadilla_users_path, :class => 'btn btn-mini btn-danger' %>
31
31
  <%= f.submit "Save changes", :class => "btn btn-mini btn-primary" %>
32
32
  </p>
33
+
34
+ <% end %>
35
+
36
+ <% if current_user.role_id < @user.role_id %>
37
+ <%= simple_form_for @caseadilla_user, as: resource_name, url: caseadilla_user_path(@caseadilla_user), html:{ method: :put } do |f| %>
38
+ <h2>Reset password <small>(admin action &mdash; use carefully)</small></h2>
39
+ <div class="row">
40
+ <div class="col-lg-6">
41
+ <%= caseadilla_password_field f, f.object, :password, {:caseadilla_label => "New password"} %>
42
+ </div>
43
+ <div class="col-lg-6">
44
+ <%= caseadilla_password_field f, f.object, :password_confirmation, {:caseadilla_label => "Repeat new password"} %>
45
+ </div>
46
+ <div class="col-lg-12 password-checkbox">
47
+ <div class="checkbox">
48
+ <label>
49
+ <%= check_box_tag :generate_random_password, "1", false, {:id => 'generate-random-password-checkbox'} %> Generate random password
50
+ </label>
51
+ </div>
52
+ </div>
53
+ </div>
54
+ <p class="submits">
55
+ <%= f.submit "Reset password", :class => "btn btn-mini btn-warning" %>
56
+ </p>
57
+ <% end %>
33
58
  <% end %>
34
59
 
35
60
  <%= content_for :sidebar do %>
36
61
  <% if current_user #.is_admin? %>
37
- <li><%= link_to "#{caseadilla_show_icon('th-list')}Back to list".html_safe, caseadilla_users_path %></li>
38
- <% if current_user == @caseadilla_user %>
39
- <li><%= link_to "#{caseadilla_show_icon('pencil')}Change password".html_safe, change_password_caseadilla_user_path %></li>
40
- <% end %>
62
+ <li><%= link_to "#{caseadilla_show_icon('th-list')}Back to list".html_safe, caseadilla_users_path %></li>
63
+ <% if current_user == @caseadilla_user %>
64
+ <li><%= link_to "#{caseadilla_show_icon('pencil')}Change password".html_safe, change_password_caseadilla_user_path %></li>
65
+ <% end %>
41
66
  <% end %>
42
- <% end %>
67
+ <% end %>
@@ -9,7 +9,7 @@
9
9
  <%= stylesheet_link_tag(stylesheet) %>
10
10
  <% end %>
11
11
  <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jasny-bootstrap/3.1.3/css/jasny-bootstrap.min.css">
12
-
12
+
13
13
  <% caseadilla_config_javascript_includes.each do |javascript| %>
14
14
  <%= javascript_include_tag(javascript) %>
15
15
  <% end %>
@@ -35,7 +35,7 @@
35
35
  <div id="user-info">
36
36
  <ul>
37
37
  <li>Hello <%= link_to current_user.first_name, caseadilla_user_path(current_user) %></li>
38
- <li><%= Time.zone.name %></li>
38
+ <li><%= current_user.time_zone || Time.zone.name %></li>
39
39
 
40
40
  <% if current_user #.is_admin? %>
41
41
  <li><%= link_to 'Users', caseadilla_users_path %></li>
@@ -57,17 +57,17 @@
57
57
  <span class="icon-bar"></span>
58
58
  <span class="icon-bar"></span>
59
59
  <span class="icon-bar"></span>
60
- </button>
60
+ </button>
61
61
  </div>
62
62
 
63
- <div class="container hidden-xs">
63
+ <div class="container hidden-xs">
64
64
  <ul class="nav navbar-nav">
65
65
  <%= render :partial => '/caseadilla/layouts/tab_navigation' %>
66
66
  </ul>
67
67
  </div>
68
68
 
69
69
  <div class='navbar-offcanvas offcanvas navbar-inverse'>
70
- <div class="container hidden-sm hidden-md hidden-lg">
70
+ <div class="container hidden-sm hidden-md hidden-lg">
71
71
  <ul class="nav navbar-nav">
72
72
  <li><%= link_to 'Home', caseadilla_root_path %></li>
73
73
  <li class="divider"></li>
@@ -121,9 +121,9 @@
121
121
  <%= yield :help %>
122
122
  </div>
123
123
  <% end %>
124
-
124
+
125
125
  <%= yield %>
126
-
126
+
127
127
  </div>
128
128
 
129
129
  </div>
@@ -138,4 +138,4 @@
138
138
  </div>
139
139
  </div>
140
140
  </body>
141
- </html>
141
+ </html>
@@ -10,8 +10,9 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["fxb9500@gmail.com"]
11
11
  spec.description = "Caseadilla is a CMS for Rails based on Casein and Comfortable Mexican Sofa. It is designed to allow you to easily fit the CMS to your app, not the other way around. By default, Caseadilla installs with Devise for authentication and Declarative Authorization, however it can be installed without either if you want to use an existing auth system."
12
12
  spec.summary = "A powerful yet unobtrusive CMS and data management system for Rails."
13
- spec.homepage = ""
13
+ spec.homepage = "http://www.xavierbick.com"
14
14
  spec.license = "MIT"
15
+ spec.required_ruby_version = "2.0.0"
15
16
 
16
17
  spec.files = `git ls-files`.split($/)
17
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -19,31 +20,28 @@ Gem::Specification.new do |spec|
19
20
  spec.require_paths = ["lib"]
20
21
 
21
22
  spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rake", "> 0"
23
24
  if spec.respond_to? :specification_version then
24
25
  spec.specification_version = 4
25
26
 
26
27
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
- spec.add_runtime_dependency(%q<caseadilla>, [">= 0"])
28
- spec.add_runtime_dependency(%q<will_paginate>, ["= 3.0.5"])
29
- spec.add_runtime_dependency(%q<devise>, [">= 3.2"])
30
- spec.add_runtime_dependency(%q<declarative_authorization>, [">= 0.5.7"])
31
- spec.add_runtime_dependency(%q<scrypt>, ["= 1.2.1"])
32
- spec.add_runtime_dependency(%q<jquery-rails>, [">= 0"])
28
+ spec.add_runtime_dependency(%q<will_paginate>, ["~> 3.0"])
29
+ spec.add_runtime_dependency(%q<devise>, ["~> 3.2"])
30
+ spec.add_runtime_dependency(%q<zeiv-declarative_authorization>, [">= 1.0.0.pre"])
31
+ spec.add_runtime_dependency(%q<scrypt>, ["~> 1.2"])
32
+ spec.add_runtime_dependency(%q<jquery-rails>, ["> 0"])
33
33
  else
34
- spec.add_dependency(%q<caseadilla>, [">= 0"])
35
- spec.add_dependency(%q<will_paginate>, ["= 3.0.5"])
36
- spec.add_dependency(%q<devise>, [">= 3.2"])
37
- spec.add_dependency(%q<declarative_authorization>, [">= 0.5.7"])
38
- spec.add_dependency(%q<scrypt>, ["= 1.2.1"])
39
- spec.add_dependency(%q<jquery-rails>, [">= 0"])
34
+ spec.add_dependency(%q<will_paginate>, ["~> 3.0"])
35
+ spec.add_dependency(%q<devise>, ["~> 3.2"])
36
+ spec.add_dependency(%q<zeiv-declarative_authorization>, [">= 1.0.0.pre"])
37
+ spec.add_dependency(%q<scrypt>, ["~> 1.2.1"])
38
+ spec.add_dependency(%q<jquery-rails>, ["> 0"])
40
39
  end
41
40
  else
42
- spec.add_dependency(%q<caseadilla>, [">= 0"])
43
- spec.add_dependency(%q<will_paginate>, ["= 3.0.5"])
44
- spec.add_dependency(%q<devise>, ["= 3.2"])
45
- spec.add_dependency(%q<declarative_authorization>, [">= 0.5.7"])
46
- spec.add_dependency(%q<scrypt>, ["= 1.2.1"])
47
- spec.add_dependency(%q<jquery-rails>, [">= 0"])
41
+ spec.add_dependency(%q<will_paginate>, ["~> 3.0"])
42
+ spec.add_dependency(%q<devise>, ["~> 3.2"])
43
+ spec.add_dependency(%q<zeiv-declarative_authorization>, [">= 1.0.0.pre"])
44
+ spec.add_dependency(%q<scrypt>, ["~> 1.2"])
45
+ spec.add_dependency(%q<jquery-rails>, ["> 0"])
48
46
  end
49
- end
47
+ end
@@ -1,9 +1,9 @@
1
1
  Rails.application.routes.draw do
2
-
2
+
3
3
  match "/admin" => redirect("/caseadilla"), :via => :get
4
-
4
+
5
5
  namespace :caseadilla do
6
-
6
+
7
7
  if Caseadilla::Engine.flavor = :steak
8
8
  resources :users do
9
9
  member do
@@ -12,13 +12,13 @@ Rails.application.routes.draw do
12
12
  end
13
13
  end
14
14
  resources :roles
15
-
16
- match "/sign_in" => "caseadilla_user_sessions#new", via: :get
15
+
16
+ get "/sign_in" => "caseadilla_user_sessions#new"
17
17
  # resource :password_reset, :only => [:create, :edit, :update]
18
18
  end
19
-
19
+
20
20
  match "/blank" => "caseadilla#blank", :via => :get
21
21
  root :to => "caseadilla#index"
22
22
  end
23
-
24
- end
23
+
24
+ end
@@ -1,3 +1,3 @@
1
1
  module Caseadilla
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  module Caseadilla
2
2
  class InstallGenerator < Rails::Generators::Base
3
-
3
+
4
4
  include Rails::Generators::Migration
5
5
  source_root File.expand_path('../templates', __FILE__)
6
6
  argument :flavor, type: :string, default: "auto"
@@ -53,6 +53,15 @@ module Caseadilla
53
53
  migration_template 'steak/db/migrate/add_name_to_users.rb', "db/migrate/add_name_to_users.rb"
54
54
  rake 'db:migrate' unless options[:no_commit]
55
55
 
56
+ inject_into_file "app/controllers/application_controller.rb", after: ":exception" do <<-'RUBY'
57
+
58
+
59
+ def after_sign_in_path_for(resource)
60
+ URI(request.referer).path == '/caseadilla/sign_in' ? caseadilla_root_path : root_path
61
+ end
62
+ RUBY
63
+ end
64
+
56
65
  inject_into_file "app/models/#{options[:auth_model].downcase}.rb", " before_create :add_user_role", after: "belongs_to :role\n"
57
66
  inject_into_file "app/models/#{options[:auth_model].downcase}.rb", after: /def role_symbols.*?end\n/m do <<-'RUBY'
58
67
 
@@ -105,6 +114,7 @@ module Caseadilla
105
114
  inject_into_file 'config/authorization_rules.rb', after: "authorization do\n" do <<-'RUBY'
106
115
 
107
116
  role :admin do
117
+ has_permission_on :caseadilla, to: :access
108
118
  has_permission_on :caseadilla_users, to: [:manage, :change_password]
109
119
  has_permission_on :caseadilla_roles, to: :manage
110
120
  end
@@ -151,4 +161,4 @@ module Caseadilla
151
161
  # @flavor = f
152
162
  # end
153
163
  end
154
- end
164
+ end
@@ -1,14 +1,14 @@
1
1
  module Caseadilla
2
2
  class ScaffoldGenerator < Rails::Generators::NamedBase
3
-
3
+
4
4
  include Caseadilla::CaseadillaHelper
5
5
  include Rails::Generators::Migration
6
6
  source_root File.expand_path('../templates', __FILE__)
7
-
7
+
8
8
  argument :attributes, :type => :array, :required => true, :desc => "attribute list required"
9
-
9
+
10
10
  class_options :create_model => false, :read_only => false, :no_index => false
11
-
11
+
12
12
  def self.next_migration_number dirname
13
13
  if ActiveRecord::Base.timestamped_migrations
14
14
  Time.now.utc.strftime("%Y%m%d%H%M%S")
@@ -16,7 +16,7 @@ module Caseadilla
16
16
  "%.3d" % (current_migration_number(dirname) + 1)
17
17
  end
18
18
  end
19
-
19
+
20
20
  def generate_files
21
21
  @plural_route = (plural_name != singular_name) ? plural_name : "#{plural_name}_index"
22
22
  @read_only = options[:read_only]
@@ -28,19 +28,19 @@ module Caseadilla
28
28
  template 'views/new.html.erb', "app/views/caseadilla/#{plural_name}/new.html.erb" unless @read_only
29
29
  template 'views/_form.html.erb', "app/views/caseadilla/#{plural_name}/_form.html.erb"
30
30
  template 'views/_table.html.erb', "app/views/caseadilla/#{plural_name}/_table.html.erb"
31
-
31
+
32
32
  add_namespace_to_routes
33
33
  add_to_routes
34
34
  add_to_navigation unless @no_index
35
-
35
+
36
36
  if options[:create_model]
37
37
  template 'model.rb', "app/models/#{singular_name}.rb"
38
38
  migration_template 'migration.rb', "db/migrate/create_#{plural_name}.rb"
39
39
  end
40
40
  end
41
-
41
+
42
42
  protected
43
-
43
+
44
44
  #replacements for standard Rails generator route. This one only adds once
45
45
  def add_namespace_to_routes
46
46
  puts " caseadilla adding namespace to routes.rb"
@@ -51,7 +51,7 @@ module Caseadilla
51
51
  gsub_add_once plural_name, file_to_update, "\n\t#Caseadilla routes\n\t" + line_to_add + "\n\tend\n", insert_sentinel
52
52
  end
53
53
  end
54
-
54
+
55
55
  def add_to_routes
56
56
  puts " caseadilla adding #{plural_name} resources to routes.rb"
57
57
  file_to_update = Rails.root + 'config/routes.rb'
@@ -77,7 +77,7 @@ module Caseadilla
77
77
  insert_sentinel = '<!-- SCAFFOLD_INSERT -->'
78
78
  gsub_add_once plural_name, file_to_update, line_to_add, insert_sentinel
79
79
  end
80
-
80
+
81
81
  def gsub_add_once m, file, line, sentinel
82
82
  unless options[:pretend]
83
83
  gsub_file file, /(#{Regexp.escape("\n#{line}")})/mi do |match|
@@ -88,12 +88,12 @@ module Caseadilla
88
88
  end
89
89
  end
90
90
  end
91
-
91
+
92
92
  def gsub_file(path, regexp, *args, &block)
93
93
  content = File.read(path).gsub(regexp, *args, &block)
94
94
  File.open(path, 'wb') { |file| file.write(content) }
95
95
  end
96
-
96
+
97
97
  def field_type(type)
98
98
  case type.to_s.to_sym
99
99
  when :integer, :float, :decimal then :text_field
@@ -101,11 +101,11 @@ module Caseadilla
101
101
  when :time, :timestamp then :time_select
102
102
  when :datetime then :datetime_select
103
103
  when :string then :text_field
104
- when :text then :text_area
104
+ when :text then :text_area_wysiwyg
105
105
  when :boolean then :check_box
106
106
  else
107
107
  :text_field
108
- end
108
+ end
109
109
  end
110
110
  end
111
- end
111
+ end
@@ -7,21 +7,24 @@ namespace :caseadilla do
7
7
  desc "Create default admin user"
8
8
  task create_admin: :environment do
9
9
 
10
- raise "Usage: specify email address, e.g. rake [task] email=mail@caseadillacms.com" unless ENV.include?("email")
10
+ unless ENV.include?("email") and ENV.include?("first_name") and ENV.include?("last_name") and ENV.include?("password")
11
+ raise "Usage: specify email address, first and last name, and a password. \nE.g. rake [task] email=mail@example.com first_name=John last_name=Doe password=password123"
12
+ end
11
13
 
12
- random_password = random_string = SecureRandom.hex
13
- admin = Caseadilla::AdminUser.new({ login: 'admin', name: 'Admin', email: ENV['email'], access_level: $CASEIN_USER_ACCESS_LEVEL_ADMIN, password: random_password, password_confirmation: random_password })
14
+ admin = User.new({email: ENV['email'], first_name: ENV['first_name'], last_name: ENV['last_name'], password: ENV['password'] })
14
15
 
15
16
  unless admin.save
16
- puts "[Caseadilla] Failed: check that the 'admin' account doesn't already exist."
17
+ puts "[Caseadilla] Failed: check that the account doesn't already exist."
17
18
  else
18
- puts "[Caseadilla] Created new admin user with username 'admin' and password '#{random_password}'"
19
+ puts "[Caseadilla] Created new admin user with email '#{ENV['email']}' and password '#{ENV['password']}'"
19
20
  end
21
+ admin.role = Role.find_by_title 'admin'
22
+ admin.save!
20
23
  end
21
24
 
22
25
  desc "Remove all users"
23
26
  task remove_all: :environment do
24
- users = Caseadilla::AdminUser.all
27
+ users = User.all
25
28
  num_users = users.size
26
29
  users.destroy_all
27
30
  puts "[Caseadilla] Removed #{num_users} user(s)"
@@ -29,4 +32,4 @@ namespace :caseadilla do
29
32
 
30
33
  end
31
34
 
32
- end
35
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caseadilla
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xavier Bick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-21 00:00:00.000000000 Z
11
+ date: 2015-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,98 +28,84 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - ">"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: caseadilla
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
38
+ - - ">"
53
39
  - !ruby/object:Gem::Version
54
40
  version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: will_paginate
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - '='
45
+ - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: 3.0.5
47
+ version: '3.0'
62
48
  type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - '='
52
+ - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: 3.0.5
54
+ version: '3.0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: devise
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - ">="
59
+ - - "~>"
74
60
  - !ruby/object:Gem::Version
75
61
  version: '3.2'
76
62
  type: :runtime
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - ">="
66
+ - - "~>"
81
67
  - !ruby/object:Gem::Version
82
68
  version: '3.2'
83
69
  - !ruby/object:Gem::Dependency
84
- name: declarative_authorization
70
+ name: zeiv-declarative_authorization
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - ">="
88
74
  - !ruby/object:Gem::Version
89
- version: 0.5.7
75
+ version: 1.0.0.pre
90
76
  type: :runtime
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - ">="
95
81
  - !ruby/object:Gem::Version
96
- version: 0.5.7
82
+ version: 1.0.0.pre
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: scrypt
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
- - - '='
87
+ - - "~>"
102
88
  - !ruby/object:Gem::Version
103
- version: 1.2.1
89
+ version: '1.2'
104
90
  type: :runtime
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
- - - '='
94
+ - - "~>"
109
95
  - !ruby/object:Gem::Version
110
- version: 1.2.1
96
+ version: '1.2'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: jquery-rails
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
- - - ">="
101
+ - - ">"
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
- - - ">="
108
+ - - ">"
123
109
  - !ruby/object:Gem::Version
124
110
  version: '0'
125
111
  description: Caseadilla is a CMS for Rails based on Casein and Comfortable Mexican
@@ -205,7 +191,7 @@ files:
205
191
  - lib/generators/caseadilla/scaffold/templates/views/new.html.erb
206
192
  - lib/generators/caseadilla/scaffold/templates/views/show.html.erb
207
193
  - lib/railties/tasks.rake
208
- homepage: ''
194
+ homepage: http://www.xavierbick.com
209
195
  licenses:
210
196
  - MIT
211
197
  metadata: {}
@@ -215,9 +201,9 @@ require_paths:
215
201
  - lib
216
202
  required_ruby_version: !ruby/object:Gem::Requirement
217
203
  requirements:
218
- - - ">="
204
+ - - '='
219
205
  - !ruby/object:Gem::Version
220
- version: '0'
206
+ version: 2.0.0
221
207
  required_rubygems_version: !ruby/object:Gem::Requirement
222
208
  requirements:
223
209
  - - ">="
@@ -225,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
211
  version: '0'
226
212
  requirements: []
227
213
  rubyforge_project:
228
- rubygems_version: 2.2.2
214
+ rubygems_version: 2.4.7
229
215
  signing_key:
230
216
  specification_version: 4
231
217
  summary: A powerful yet unobtrusive CMS and data management system for Rails.