refinerycms-members2 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/.gitignore +7 -0
  2. data/Gemfile +8 -0
  3. data/Gemfile.lock +227 -0
  4. data/README.md +76 -0
  5. data/Rakefile +13 -0
  6. data/app/controllers/refinery/members/admin/members_controller.rb +10 -0
  7. data/app/controllers/refinery/members/passwords_controller.rb +2 -0
  8. data/app/controllers/refinery/members/registrations_controller.rb +2 -0
  9. data/app/controllers/refinery/members/sessions_controller.rb +2 -0
  10. data/app/models/refinery/members/member.rb +15 -0
  11. data/app/views/refinery/members/admin/members/_actions.html.erb +21 -0
  12. data/app/views/refinery/members/admin/members/_form.html.erb +14 -0
  13. data/app/views/refinery/members/admin/members/_member.html.erb +16 -0
  14. data/app/views/refinery/members/admin/members/_records.html.erb +16 -0
  15. data/app/views/refinery/members/admin/members/_sortable_list.html.erb +4 -0
  16. data/app/views/refinery/members/admin/members/edit.html.erb +1 -0
  17. data/app/views/refinery/members/admin/members/index.html.erb +7 -0
  18. data/app/views/refinery/members/admin/members/new.html.erb +1 -0
  19. data/config/initializers/devise.rb +144 -0
  20. data/config/locales/en.yml +24 -0
  21. data/config/locales/lolcat.yml +25 -0
  22. data/config/locales/nb.yml +21 -0
  23. data/config/locales/nl.yml +21 -0
  24. data/config/routes.rb +13 -0
  25. data/db/migrate/20130113101005_add_need_login_to_pages.rb +5 -0
  26. data/db/migrate/20130113101006_create_members.rb +26 -0
  27. data/db/seeds/members.rb +6 -0
  28. data/lib/generators/refinery/members/members_generator.rb +5 -0
  29. data/lib/refinery/members/engine.rb +33 -0
  30. data/lib/refinery/members/instance_methods.rb +21 -0
  31. data/lib/refinery/members.rb +22 -0
  32. data/lib/refinerycms-members.rb +1 -0
  33. data/refinerycms-members2.gemspec +16 -0
  34. data/spec/controllers/refinery/members/admin/members_controller_spec.rb +11 -0
  35. data/spec/controllers/refinery/members/sessions_controller_spec.rb +25 -0
  36. data/spec/factories/members.rb +6 -0
  37. data/spec/factories/users.rb +17 -0
  38. data/spec/spec_helper.rb +3 -0
  39. data/spec/support/refinery_testing.rb +4 -0
  40. data/spec/views/refinery/members/admin/members/index_spec.rb +19 -0
  41. data/spec/views/refinery/members/admin/members/new_spec.rb +12 -0
  42. data/test/fixtures/members.yml +11 -0
  43. data/test/test_helper.rb +3 -0
  44. data/test/unit/member_test.rb +7 -0
  45. metadata +133 -0
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *~
2
+ .*~
3
+
4
+ /bin
5
+ *.gem
6
+ /.bundle
7
+ /spec/dummy
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem "sqlite3"
7
+ gem "refinerycms-testing", :require => false
8
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,227 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ refinerycms-members2 (0.3.0)
5
+ refinerycms (~> 2.0.0)
6
+ refinerycms-pages (~> 2.0.0)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ actionmailer (3.2.11)
12
+ actionpack (= 3.2.11)
13
+ mail (~> 2.4.4)
14
+ actionpack (3.2.11)
15
+ activemodel (= 3.2.11)
16
+ activesupport (= 3.2.11)
17
+ builder (~> 3.0.0)
18
+ erubis (~> 2.7.0)
19
+ journey (~> 1.0.4)
20
+ rack (~> 1.4.0)
21
+ rack-cache (~> 1.2)
22
+ rack-test (~> 0.6.1)
23
+ sprockets (~> 2.2.1)
24
+ activemodel (3.2.11)
25
+ activesupport (= 3.2.11)
26
+ builder (~> 3.0.0)
27
+ activerecord (3.2.11)
28
+ activemodel (= 3.2.11)
29
+ activesupport (= 3.2.11)
30
+ arel (~> 3.0.2)
31
+ tzinfo (~> 0.3.29)
32
+ activeresource (3.2.11)
33
+ activemodel (= 3.2.11)
34
+ activesupport (= 3.2.11)
35
+ activesupport (3.2.11)
36
+ i18n (~> 0.6)
37
+ multi_json (~> 1.0)
38
+ acts_as_indexed (0.7.8)
39
+ arel (3.0.2)
40
+ awesome_nested_set (2.1.5)
41
+ activerecord (>= 3.0.0)
42
+ babosa (0.3.9)
43
+ bcrypt-ruby (3.0.1)
44
+ builder (3.0.4)
45
+ capybara (1.1.4)
46
+ mime-types (>= 1.16)
47
+ nokogiri (>= 1.3.3)
48
+ rack (>= 1.0.0)
49
+ rack-test (>= 0.5.4)
50
+ selenium-webdriver (~> 2.0)
51
+ xpath (~> 0.1.4)
52
+ childprocess (0.3.7)
53
+ ffi (~> 1.0, >= 1.0.6)
54
+ coffee-rails (3.2.2)
55
+ coffee-script (>= 2.2.0)
56
+ railties (~> 3.2.0)
57
+ coffee-script (2.2.0)
58
+ coffee-script-source
59
+ execjs
60
+ coffee-script-source (1.4.0)
61
+ database_cleaner (0.7.2)
62
+ devise (2.0.5)
63
+ bcrypt-ruby (~> 3.0)
64
+ orm_adapter (~> 0.0.3)
65
+ railties (~> 3.1)
66
+ warden (~> 1.1.1)
67
+ diff-lcs (1.1.3)
68
+ dragonfly (0.9.14)
69
+ multi_json (~> 1.0)
70
+ rack
71
+ erubis (2.7.0)
72
+ execjs (1.4.0)
73
+ multi_json (~> 1.0)
74
+ factory_girl (2.6.4)
75
+ activesupport (>= 2.3.9)
76
+ factory_girl_rails (1.7.0)
77
+ factory_girl (~> 2.6.0)
78
+ railties (>= 3.0.0)
79
+ ffi (1.3.1)
80
+ friendly_id (4.0.9)
81
+ globalize3 (0.2.0)
82
+ activemodel (>= 3.0.0)
83
+ activerecord (>= 3.0.0)
84
+ paper_trail (~> 2)
85
+ hike (1.2.1)
86
+ i18n (0.6.1)
87
+ journey (1.0.4)
88
+ jquery-rails (2.0.3)
89
+ railties (>= 3.1.0, < 5.0)
90
+ thor (~> 0.14)
91
+ json (1.7.6)
92
+ mail (2.4.4)
93
+ i18n (>= 0.4.0)
94
+ mime-types (~> 1.16)
95
+ treetop (~> 1.4.8)
96
+ mime-types (1.19)
97
+ multi_json (1.5.0)
98
+ nokogiri (1.5.6)
99
+ orm_adapter (0.0.7)
100
+ paper_trail (2.7.0)
101
+ activerecord (~> 3.0)
102
+ railties (~> 3.0)
103
+ polyglot (0.3.3)
104
+ rack (1.4.4)
105
+ rack-cache (1.2)
106
+ rack (>= 0.4)
107
+ rack-ssl (1.3.3)
108
+ rack
109
+ rack-test (0.6.2)
110
+ rack (>= 1.0)
111
+ rails (3.2.11)
112
+ actionmailer (= 3.2.11)
113
+ actionpack (= 3.2.11)
114
+ activerecord (= 3.2.11)
115
+ activeresource (= 3.2.11)
116
+ activesupport (= 3.2.11)
117
+ bundler (~> 1.0)
118
+ railties (= 3.2.11)
119
+ railties (3.2.11)
120
+ actionpack (= 3.2.11)
121
+ activesupport (= 3.2.11)
122
+ rack-ssl (~> 1.3.2)
123
+ rake (>= 0.8.7)
124
+ rdoc (~> 3.4)
125
+ thor (>= 0.14.6, < 2.0)
126
+ rake (10.0.3)
127
+ rdoc (3.12)
128
+ json (~> 1.4)
129
+ refinerycms (2.0.9)
130
+ bundler (~> 1.0)
131
+ refinerycms-authentication (= 2.0.9)
132
+ refinerycms-core (= 2.0.9)
133
+ refinerycms-dashboard (= 2.0.9)
134
+ refinerycms-images (= 2.0.9)
135
+ refinerycms-pages (= 2.0.9)
136
+ refinerycms-resources (= 2.0.9)
137
+ refinerycms-authentication (2.0.9)
138
+ devise (~> 2.0.0)
139
+ orm_adapter (~> 0.0.7)
140
+ refinerycms-core (= 2.0.9)
141
+ refinerycms-core (2.0.9)
142
+ acts_as_indexed (~> 0.7.7)
143
+ awesome_nested_set (~> 2.1.3)
144
+ coffee-rails (~> 3.2.1)
145
+ friendly_id (~> 4.0.1)
146
+ globalize3 (~> 0.2.0)
147
+ jquery-rails (~> 2.0.0)
148
+ rails (>= 3.1.3, < 3.3)
149
+ sass-rails (~> 3.2.3)
150
+ truncate_html (~> 0.5)
151
+ uglifier (>= 1.0.3)
152
+ will_paginate (~> 3.0.2)
153
+ refinerycms-dashboard (2.0.9)
154
+ refinerycms-core (= 2.0.9)
155
+ refinerycms-images (2.0.9)
156
+ dragonfly (~> 0.9.8)
157
+ rack-cache (>= 0.5.3)
158
+ refinerycms-core (= 2.0.9)
159
+ refinerycms-pages (2.0.9)
160
+ awesome_nested_set (~> 2.1.3)
161
+ babosa (!= 0.3.6)
162
+ refinerycms-core (= 2.0.9)
163
+ seo_meta (~> 1.3.0)
164
+ refinerycms-resources (2.0.9)
165
+ dragonfly (~> 0.9.8)
166
+ rack-cache (>= 0.5.3)
167
+ refinerycms-core (= 2.0.9)
168
+ refinerycms-testing (2.0.9)
169
+ capybara (~> 1.1.2)
170
+ database_cleaner (~> 0.7.2)
171
+ factory_girl_rails (~> 1.7.0)
172
+ refinerycms-core (= 2.0.9)
173
+ rspec-rails (~> 2.11)
174
+ rspec-core (2.12.2)
175
+ rspec-expectations (2.12.1)
176
+ diff-lcs (~> 1.1.3)
177
+ rspec-mocks (2.12.2)
178
+ rspec-rails (2.12.2)
179
+ actionpack (>= 3.0)
180
+ activesupport (>= 3.0)
181
+ railties (>= 3.0)
182
+ rspec-core (~> 2.12.0)
183
+ rspec-expectations (~> 2.12.0)
184
+ rspec-mocks (~> 2.12.0)
185
+ rubyzip (0.9.9)
186
+ sass (3.2.5)
187
+ sass-rails (3.2.6)
188
+ railties (~> 3.2.0)
189
+ sass (>= 3.1.10)
190
+ tilt (~> 1.3)
191
+ selenium-webdriver (2.29.0)
192
+ childprocess (>= 0.2.5)
193
+ multi_json (~> 1.0)
194
+ rubyzip
195
+ websocket (~> 1.0.4)
196
+ seo_meta (1.3.0)
197
+ railties (>= 3.0.0)
198
+ sprockets (2.2.2)
199
+ hike (~> 1.2)
200
+ multi_json (~> 1.0)
201
+ rack (~> 1.0)
202
+ tilt (~> 1.1, != 1.3.0)
203
+ sqlite3 (1.3.7)
204
+ thor (0.17.0)
205
+ tilt (1.3.3)
206
+ treetop (1.4.12)
207
+ polyglot
208
+ polyglot (>= 0.3.1)
209
+ truncate_html (0.9.2)
210
+ tzinfo (0.3.35)
211
+ uglifier (1.3.0)
212
+ execjs (>= 0.3.0)
213
+ multi_json (~> 1.0, >= 1.0.2)
214
+ warden (1.1.1)
215
+ rack (>= 1.0)
216
+ websocket (1.0.7)
217
+ will_paginate (3.0.4)
218
+ xpath (0.1.4)
219
+ nokogiri (~> 1.3)
220
+
221
+ PLATFORMS
222
+ ruby
223
+
224
+ DEPENDENCIES
225
+ refinerycms-members2!
226
+ refinerycms-testing
227
+ sqlite3
data/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # Refinery CMS Members
2
+
3
+ Simple member engine for [Refinery CMS](http://refinerycms.com). It supports member management and page privilege setting.
4
+
5
+ This version of `refinerycms-members` supports Rails 3.2.x, RefineryCMS 2.0 and above.
6
+
7
+ ## Install
8
+
9
+ Open up your `Gemfile` and add:
10
+
11
+ gem 'refinerycms-members2'
12
+
13
+ Run `bundle install`
14
+
15
+ Next, to install the members plugin run:
16
+
17
+ rails generate refinery:members
18
+
19
+ Note that the above task copies `*.refinery_members.rb` migration files to your `db/migrate` directory.
20
+ You should examine `*_create_members.refinery_members.rb` file and adjust it (if necessary)
21
+ to enable or disable Devise strategies and options that are appropriate for your flavor of members.
22
+
23
+ > **WARNING**: Rails 3 has a bug (fixed in Rails 4) which causes `rake railties:install:migrations`
24
+ > to copy engine migration files without a particular order. Since `refinerycms-members2`
25
+ > depends on the database table generated by `refinerycms-pages`, the migrations may be copied
26
+ > in a wrong order and thus will not run. Either start your project without `refinerycms-members2`
27
+ > and add this gem later, or rename `*.refinery_members.rb` migrations to follow
28
+ > `*_create_pages.refinery_pages.rb` migration before running `rake db:migrate` for the first time.
29
+
30
+ Finally migrate your database and you're done.
31
+
32
+ rake db:migrate
33
+
34
+ ## Testing
35
+
36
+ This section is intended for developers of refinerycms-members2.
37
+ You may skip it if you just use the gem.
38
+
39
+ Refinery-members2 uses refinery-testing gem for testing.
40
+ Follow the guidelines at http://refinerycms.com/guides/testing to setup the dummy app.
41
+ However, I couldn't get `rake spec` to work as easily as suggested at the guidelines.
42
+ If (after completing all previous steps) you find that `rake spec` does not work for you,
43
+ here's what you can do:
44
+
45
+ cd spec/dummy
46
+ rails g refinery:testing
47
+
48
+ At this step you should have `Guardfile` in `spec/dummy` and `spec_helper.rb` in `spec/dummy/spec`.
49
+
50
+ rake db:test:prepare
51
+
52
+ Now we're done with the final steps of setting up the dummy app.
53
+ You can go back from `spec/dummy` to the root directory of your engine:
54
+
55
+ cd ../..
56
+
57
+ Place your specs in `spec` directory, as usual. Run the tests as follows:
58
+
59
+ rake spec
60
+
61
+ Apparently, one can add the finalizing steps in your `Rakefile`, by creating
62
+ `refinery:testing:setup_extension` task as suggested in `lib/refinery/tasks/testing.rake` file
63
+ of `refinery-testing` gem.
64
+
65
+ ## How to build this engine as a gem
66
+
67
+ gem build refinerycms-members2.gemspec
68
+ gem install refinerycms-members2.gem
69
+
70
+ # Sign up for a http://rubygems.org/ account and publish the gem
71
+ gem push refinerycms-members2.gem
72
+
73
+ # Authors
74
+
75
+ - [n5ken](https://github.com/n5ken)
76
+ - [Slava Kravchenko](https://github.com/cordawyn)
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ ENV["RAILS_ENV"] ||= "test"
2
+
3
+ ENGINE_PATH = File.dirname(__FILE__)
4
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
5
+
6
+ require "rspec/core/rake_task"
7
+ RSpec::Core::RakeTask.new
8
+
9
+ load 'rails/tasks/engine.rake' if File.exists?(APP_RAKEFILE)
10
+
11
+ require "refinerycms-testing"
12
+ Refinery::Testing::Railtie.load_tasks
13
+ Refinery::Testing::Railtie.load_dummy_tasks(ENGINE_PATH)
@@ -0,0 +1,10 @@
1
+ module Refinery
2
+ module Members
3
+ module Admin
4
+ class MembersController < ::Refinery::AdminController
5
+ crudify :"refinery/members/member",
6
+ :title_attribute => 'email', :xhr_paging => true
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,2 @@
1
+ class Refinery::Members::PasswordsController < Devise::PasswordsController
2
+ end
@@ -0,0 +1,2 @@
1
+ class Refinery::Members::RegistrationsController < Devise::RegistrationsController
2
+ end
@@ -0,0 +1,2 @@
1
+ class Refinery::Members::SessionsController < Devise::SessionsController
2
+ end
@@ -0,0 +1,15 @@
1
+ module Refinery
2
+ module Members
3
+ class Member < Refinery::Core::BaseModel
4
+ self.table_name = 'refinery_members'
5
+
6
+ # Include default devise modules. Others available are:
7
+ # :token_authenticatable, :confirmable, :lockable and :timeoutable
8
+ devise :database_authenticatable, :registerable,
9
+ :recoverable, :rememberable, :trackable, :validatable
10
+
11
+ # Setup accessible (or protected) attributes for your model
12
+ attr_accessible :email, :password, :password_confirmation, :remember_me, :position
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,21 @@
1
+ <ul>
2
+ <li>
3
+ <%= render "/refinery/admin/search", :url => refinery.members_admin_members_path %>
4
+ </li>
5
+ <li>
6
+ <%= link_to t(".create_new"), refinery.new_members_admin_member_path,
7
+ :class => "add_icon" %>
8
+ </li>
9
+ <% if @members.many? && !searching? %>
10
+ <li>
11
+ <%= link_to t(".reorder_members", what: "Members"), refinery.members_admin_members_path,
12
+ :id => "reorder_action",
13
+ :class => "reorder_icon" %>
14
+
15
+ <%= link_to t(".reorder_done", what: "Members"), refinery.members_admin_members_path,
16
+ :id => "reorder_action_done",
17
+ :style => "display: none;",
18
+ :class => "reorder_icon" %>
19
+ </li>
20
+ <% end %>
21
+ </ul>
@@ -0,0 +1,14 @@
1
+ <%= form_for [refinery, :members_admin, @member] do |f| -%>
2
+ <%= render "/refinery/admin/error_messages", :object => @member, :include_object_name => true %>
3
+
4
+ <div class='field'>
5
+ <%= f.label :email -%>
6
+ <%= f.text_field :email, :class => 'larger widest' -%>
7
+ </div>
8
+
9
+ <%= render "/refinery/admin/form_actions", :f => f,
10
+ :continue_editing => false,
11
+ :delete_title => t('delete', :scope => 'refinery.admin.members'),
12
+ :delete_confirmation => t('message', :scope => 'refinery.admin.delete', :title => @member.email)
13
+ %>
14
+ <% end -%>
@@ -0,0 +1,16 @@
1
+ <li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(member) -%>">
2
+ <span class='title'>
3
+ <%= member.email %>
4
+ <span class="preview">&nbsp;</span>
5
+ </span>
6
+ <span class='actions'>
7
+ <%= link_to refinery_icon_tag("application_edit.png"), refinery.edit_members_admin_member_path(member),
8
+ :title => t(".edit") %>
9
+ <%= link_to refinery_icon_tag("delete.png"), refinery.members_admin_member_path(member),
10
+ :class => "cancel confirm-delete",
11
+ :title => t(".delete"),
12
+ :confirm => t('message', :scope => 'refinery.admin.delete', :title => member.email),
13
+ :method => :delete
14
+ %>
15
+ </span>
16
+ </li>
@@ -0,0 +1,16 @@
1
+ <% if searching? %>
2
+ <h2><%= t('results_for', :scope => 'refinery.admin.search', :query => params[:search]) %></h2>
3
+ <% end %>
4
+ <div class='pagination_container'>
5
+ <% if @members.any? %>
6
+ <%= render 'sortable_list' %>
7
+ <% else %>
8
+ <p>
9
+ <% unless searching? %>
10
+ <strong><%= t('.no_items_yet') %></strong>
11
+ <% else %>
12
+ <%= t('no_results', :scope => 'refinery.admin.search') %>
13
+ <% end %>
14
+ </p>
15
+ <% end %>
16
+ </div>
@@ -0,0 +1,4 @@
1
+ <ul id='sortable_list'>
2
+ <%= render :partial => 'member', :collection => @members %>
3
+ </ul>
4
+ <%= render "/refinery/admin/sortable_list", :continue_reordering => !!local_assigns[:continue_reordering] %>
@@ -0,0 +1 @@
1
+ <%= render "form" %>
@@ -0,0 +1,7 @@
1
+ <section id='records'>
2
+ <%= render 'records' %>
3
+ </section>
4
+ <section id='actions'>
5
+ <%= render 'actions' %>
6
+ </section>
7
+ <%= render '/refinery/admin/make_sortable', :tree => false if @members.many? -%>
@@ -0,0 +1 @@
1
+ <%= render :partial => "form" %>
@@ -0,0 +1,144 @@
1
+ require 'devise'
2
+
3
+ # Use this hook to configure devise mailer, warden hooks and so forth. The first
4
+ # four configuration values can also be set straight in your models.
5
+ ::Devise.setup do |config|
6
+ # ==> Mailer Configuration
7
+ # Configure the e-mail address which will be shown in DeviseMailer.
8
+ config.mailer_sender = "please-change-me@config-initializers-devise.com"
9
+
10
+ # Configure the class responsible to send e-mails.
11
+ # config.mailer = "::Devise::Mailer"
12
+
13
+ # ==> ORM configuration
14
+ # Load and configure the ORM. Supports :active_record (default) and
15
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
16
+ # available as additional gems.
17
+ require 'devise/orm/active_record'
18
+
19
+ # ==> Configuration for any authentication mechanism
20
+ # Configure which keys are used when authenticating an user. By default is
21
+ # just :email. You can configure it to use [:username, :subdomain], so for
22
+ # authenticating an user, both parameters are required. Remember that those
23
+ # parameters are used only when authenticating and not when retrieving from
24
+ # session. If you need permissions, you should implement that in a before filter.
25
+ config.authentication_keys = [ :email ]
26
+
27
+ # Tell if authentication through request.params is enabled. True by default.
28
+ # config.params_authenticatable = true
29
+
30
+ # Tell if authentication through HTTP Basic Auth is enabled. False by default.
31
+ # config.http_authenticatable = false
32
+
33
+ # Set this to true to use Basic Auth for AJAX requests. True by default.
34
+ # config.http_authenticatable_on_xhr = true
35
+
36
+ # The realm used in Http Basic Authentication
37
+ # config.http_authentication_realm = "Application"
38
+
39
+ # ==> Configuration for :database_authenticatable
40
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
41
+ # using other encryptors, it sets how many times you want the password re-encrypted.
42
+ # config.stretches = 20
43
+
44
+ # Define which will be the encryption algorithm. Devise also supports encryptors
45
+ # from others authentication tools as :clearance_sha1, :authlogic_sha512 (then
46
+ # you should set stretches above to 20 for default behavior) and :restful_authentication_sha1
47
+ # (then you should set stretches to 10, and copy REST_AUTH_SITE_KEY to pepper)
48
+ # config.encryptor = :bcrypt
49
+
50
+ # Setup a pepper to generate the encrypted password.
51
+ # config.pepper = "2e20a8abdd34d729ba6d05f679e513cfea9fbb1e83c81f84b29e9e4fdbd4ee59b56a32200064082a15a72b05a4d4a6a2c3784a09c0554b3a47a67cc8333ccbc7"
52
+
53
+ # ==> Configuration for :confirmable
54
+ # The time you want to give your user to confirm his account. During this time
55
+ # he will be able to access your application without confirming. Default is nil.
56
+ # When confirm_within is zero, the user won't be able to sign in without confirming.
57
+ # You can use this to let your user access some features of your application
58
+ # without confirming the account, but blocking it after a certain period
59
+ # (ie 2 days).
60
+ # config.confirm_within = 2.days
61
+
62
+ # ==> Configuration for :rememberable
63
+ # The time the user will be remembered without asking for credentials again.
64
+ # config.remember_for = 2.weeks
65
+
66
+ # If true, a valid remember token can be re-used between multiple browsers.
67
+ # config.remember_across_browsers = true
68
+
69
+ # If true, extends the user's remember period when remembered via cookie.
70
+ # config.extend_remember_period = false
71
+
72
+ # ==> Configuration for :validatable
73
+ # Range for password length
74
+ config.password_length = 4..20
75
+
76
+ # Regex to use to validate the email address
77
+ # config.email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
78
+
79
+ # ==> Configuration for :timeoutable
80
+ # The time you want to timeout the user session without activity. After this
81
+ # time the user will be asked for credentials again.
82
+ # config.timeout_in = 10.minutes
83
+
84
+ # ==> Configuration for :lockable
85
+ # Defines which strategy will be used to lock an account.
86
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
87
+ # :none = No lock strategy. You should handle locking by yourself.
88
+ # config.lock_strategy = :failed_attempts
89
+
90
+ # Defines which strategy will be used to unlock an account.
91
+ # :email = Sends an unlock link to the user email
92
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
93
+ # :both = Enables both strategies
94
+ # :none = No unlock strategy. You should handle unlocking by yourself.
95
+ # config.unlock_strategy = :both
96
+
97
+ # Number of authentication tries before locking an account if lock_strategy
98
+ # is failed attempts.
99
+ # config.maximum_attempts = 20
100
+
101
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
102
+ # config.unlock_in = 1.hour
103
+
104
+ # ==> Configuration for :token_authenticatable
105
+ # Defines name of the authentication token params key
106
+ # config.token_authentication_key = :auth_token
107
+
108
+ # ==> Scopes configuration
109
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
110
+ # "users/sessions/new". It's turned off by default because it's slower if you
111
+ # are using only default views.
112
+ # config.scoped_views = true
113
+
114
+ # Configure the default scope given to Warden. By default it's the first
115
+ # devise role declared in your routes.
116
+ config.default_scope = :member
117
+
118
+ # Configure sign_out behavior.
119
+ # By default sign_out is scoped (i.e. /users/sign_out affects only :user scope).
120
+ # In case of sign_out_all_scopes set to true any logout action will sign out all active scopes.
121
+ # config.sign_out_all_scopes = false
122
+
123
+ # ==> Navigation configuration
124
+ # Lists the formats that should be treated as navigational. Formats like
125
+ # :html, should redirect to the sign in page when the user does not have
126
+ # access, but formats like :xml or :json, should return 401.
127
+ # If you have any extra navigational formats, like :iphone or :mobile, you
128
+ # should add them to the navigational formats lists. Default is [:html]
129
+ # config.navigational_formats = [:html, :iphone]
130
+
131
+ # ==> Warden configuration
132
+ # If you want to use other strategies, that are not (yet) supported by Devise,
133
+ # you can configure them inside the config.warden block. The example below
134
+ # allows you to setup OAuth, using http://github.com/roman/warden_oauth
135
+ #
136
+ # config.warden do |manager|
137
+ # manager.oauth(:twitter) do |twitter|
138
+ # twitter.consumer_secret = <YOUR CONSUMER SECRET>
139
+ # twitter.consumer_key = <YOUR CONSUMER KEY>
140
+ # twitter.options :site => 'http://twitter.com'
141
+ # end
142
+ # manager.default_strategies(:scope => :user).unshift :twitter_oauth
143
+ # end
144
+ end
@@ -0,0 +1,24 @@
1
+ en:
2
+ refinery:
3
+ plugins:
4
+ members:
5
+ title: Members
6
+ members:
7
+ admin:
8
+ members:
9
+ actions:
10
+ create_new: Add New Member
11
+ reorder: Reorder Members
12
+ reorder_done: Done Reordering Members
13
+ member:
14
+ delete: Remove this member forever
15
+ edit: Edit this member
16
+ view_live_html: View this member live <br/><em>(opens in a new window)</em>
17
+ records:
18
+ no_items_yet: There are no Members yet. Click "Add New Member" to add your first member.
19
+ title: Members
20
+ sorry_no_results: Sorry! There are no results found.
21
+ members:
22
+ show:
23
+ need_login: You must be a logged-in member to view this page
24
+ other: Other Members
@@ -0,0 +1,25 @@
1
+ lolcat:
2
+ shared:
3
+ admin:
4
+ image_picker:
5
+ image: IMAGE
6
+ plugins:
7
+ members:
8
+ title: Members
9
+ admin:
10
+ members:
11
+ actions:
12
+ create_new: CREATE NEW Member
13
+ reorder: REORDR Members
14
+ reorder_done: DUN REORDERIN Members
15
+ records:
16
+ title: Members
17
+ sorry_no_results: SRY! THAR R NO RESULTS FINDZ.
18
+ no_items_yet: THAR R NO Members YET. CLICK "CREATE NEW Member" 2 ADD UR FURST member.
19
+ member:
20
+ view_live_html: VIEW DIS member LIV <BR/><EM>(OPENS IN NEW WINDOW)</EM>
21
+ edit: EDIT DIS member
22
+ delete: REMOOV DIS member FOREVR
23
+ members:
24
+ show:
25
+ other: OTHR Members
@@ -0,0 +1,21 @@
1
+ nb:
2
+ plugins:
3
+ members:
4
+ title: Members
5
+ admin:
6
+ members:
7
+ actions:
8
+ create_new: Lag en ny Member
9
+ reorder: Endre rekkefølgen på Members
10
+ reorder_done: Ferdig å endre rekkefølgen Members
11
+ records:
12
+ title: Members
13
+ sorry_no_results: Beklager! Vi fant ikke noen resultater.
14
+ no_items_yet: Det er ingen Members enda. Klikk på "Lag en ny Member" for å legge til din første member.
15
+ member:
16
+ view_live_html: Vis hvordan denne member ser ut offentlig <br/><em>(åpner i et nytt vindu)</em>
17
+ edit: Rediger denne member
18
+ delete: Fjern denne member permanent
19
+ members:
20
+ show:
21
+ other: Andre Members
@@ -0,0 +1,21 @@
1
+ nl:
2
+ plugins:
3
+ members:
4
+ title: Members
5
+ admin:
6
+ members:
7
+ actions:
8
+ create_new: Maak een nieuwe Member
9
+ reorder: Wijzig de volgorde van de Members
10
+ reorder_done: Klaar met het wijzingen van de volgorde van de Members
11
+ records:
12
+ title: Members
13
+ sorry_no_results: Helaas! Er zijn geen resultaten gevonden.
14
+ no_items_yet: Er zijn nog geen Members. Druk op 'Maak een nieuwe Member' om de eerste aan te maken.
15
+ member:
16
+ view_live_html: Bekijk deze member op de website <br/><em>(opent een nieuw venster)</em>
17
+ edit: Bewerk deze member
18
+ delete: Verwijder deze member voor eeuwig
19
+ members:
20
+ show:
21
+ other: Andere Members
data/config/routes.rb ADDED
@@ -0,0 +1,13 @@
1
+ Refinery::Core::Engine.routes.draw do
2
+ devise_for :members, :class_name => "Refinery::Members::Member", :module => "refinery/members"
3
+
4
+ namespace :members, :path => '' do
5
+ namespace :admin, :path => 'refinery' do
6
+ resources :members, :except => :show do
7
+ collection do
8
+ post :update_positions
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ class AddNeedLoginToPages < ActiveRecord::Migration
2
+ def change
3
+ add_column :refinery_pages, :need_login, :boolean, :default => 0
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ class CreateMembers < ActiveRecord::Migration
2
+ def change
3
+ create_table(:refinery_members) do |t|
4
+ t.string :email, :null => false, :default => ""
5
+ t.string :encrypted_password, :null => false, :default => ""
6
+
7
+ t.string :reset_password_token
8
+ t.datetime :reset_password_sent_at
9
+
10
+ t.datetime :remember_created_at
11
+
12
+ t.integer :sign_in_count, :default => 0
13
+ t.datetime :current_sign_in_at
14
+ t.datetime :last_sign_in_at
15
+ t.string :current_sign_in_ip
16
+ t.string :last_sign_in_ip
17
+
18
+ t.integer :position
19
+
20
+ t.timestamps
21
+ end
22
+
23
+ add_index :refinery_members, :email, :unique => true
24
+ add_index :refinery_members, :reset_password_token, :unique => true
25
+ end
26
+ end
@@ -0,0 +1,6 @@
1
+ User.find(:all).each do |user|
2
+ if user.plugins.find_by_name('members').nil?
3
+ user.plugins.create(:name => 'members',
4
+ :position => (user.plugins.maximum(:position) || -1) +1)
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Refinery
2
+ class MembersGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('../templates', __FILE__)
4
+ end
5
+ end
@@ -0,0 +1,33 @@
1
+ module Refinery
2
+ module Members
3
+ class Engine < ::Rails::Engine
4
+ include Refinery::Engine
5
+
6
+ engine_name :refinery_members
7
+ isolate_namespace Refinery::Members
8
+
9
+ config.autoload_paths += %W( #{config.root}/lib )
10
+
11
+ after_inclusion do
12
+ Refinery::PagesController.send :include, Refinery::Members::InstanceMethods
13
+ end
14
+
15
+ initializer "register refinery_members plugin" do
16
+ Refinery::Plugin.register do |plugin|
17
+ plugin.pathname = root
18
+ plugin.name = "members"
19
+ plugin.menu_match = %r{refinery\/members(\/.+?)?$}
20
+ plugin.activity = {
21
+ :class_name => :"refinery/members/member",
22
+ :title => "email"
23
+ }
24
+ plugin.url = proc { Refinery::Core::Engine.routes.url_helpers.members_admin_members_path }
25
+ end
26
+ end
27
+
28
+ config.after_initialize do
29
+ Refinery.register_extension(Refinery::Members)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,21 @@
1
+ module Refinery
2
+ module Members
3
+ module InstanceMethods
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ alias_method_chain :current_user_can_view_page?, :members
8
+ end
9
+
10
+ protected
11
+
12
+ def current_user_can_view_page_with_members?
13
+ if page.need_login? && !member_signed_in?
14
+ false
15
+ else
16
+ current_user_can_view_page_without_members?
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ require "refinerycms-core"
2
+
3
+ module Refinery
4
+ autoload :MembersGenerator, "generators/refinery/members/members_generator"
5
+
6
+ module Members
7
+ require "refinery/members/engine"
8
+
9
+ autoload :InstanceMethods, "refinery/members/instance_methods"
10
+
11
+ class << self
12
+ def root
13
+ @root ||= Pathname.new(File.expand_path('../../../', __FILE__))
14
+ end
15
+
16
+ def factory_paths
17
+ # TODO?
18
+ @factory_paths ||= [ root.join("spec/factories").to_s ]
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1 @@
1
+ require "refinery/members"
@@ -0,0 +1,16 @@
1
+ Gem::Specification.new do |s|
2
+ s.platform = Gem::Platform::RUBY
3
+ s.name = 'refinerycms-members2'
4
+ s.version = '0.3.0'
5
+ s.summary = 'Members engine for Refinery CMS'
6
+ s.description = 'Ruby on Rails Members engine for Refinery CMS 2.0'
7
+ s.authors = ['n5ken', 'Slava Kravchenko']
8
+ s.homepage = "https://github.com/cordawyn/refinerycms-members2"
9
+
10
+ s.files = `git ls-files`.split($\)
11
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
12
+ s.require_paths = %w(lib)
13
+
14
+ s.add_dependency "refinerycms", "~> 2.0.0"
15
+ s.add_dependency "refinerycms-pages", "~> 2.0.0"
16
+ end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ describe Refinery::Members::Admin::MembersController do
4
+ login_refinery_superuser
5
+
6
+ describe "GET index" do
7
+ subject { get :index }
8
+
9
+ it { should be_success }
10
+ end
11
+ end
@@ -0,0 +1,25 @@
1
+ require "spec_helper"
2
+
3
+ describe Refinery::Members::SessionsController do
4
+ before do
5
+ FactoryGirl.create(:refinery_user)
6
+ @request.env["devise.mapping"] = Devise.mappings[:member]
7
+ end
8
+
9
+ describe "GET new" do
10
+ subject { get :new }
11
+
12
+ it { should be_success }
13
+ end
14
+
15
+ describe "POST create" do
16
+ subject { post :create, member: {email: "nobody@nowhere.net", password: "secret123"} }
17
+
18
+ before do
19
+ FactoryGirl.create(:refinery_member, email: "nobody@nowhere.net", password: "secret123")
20
+ end
21
+
22
+ it { should redirect_to "/" }
23
+ it { should_not render_template "new" }
24
+ end
25
+ end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory :refinery_member, :class => "Refinery::Members::Member" do
3
+ sequence(:email) { |n| "member#{n}@factory.com" }
4
+ password "secret123"
5
+ end
6
+ end
@@ -0,0 +1,17 @@
1
+ FactoryGirl.define do
2
+ factory :refinery_user, :class => "Refinery::User" do
3
+ sequence(:username) { |n| "girl#{n}" }
4
+ email { "#{username}@factory.com" }
5
+ password "secret123"
6
+
7
+ after_create do |u|
8
+ u.roles << Refinery::Role.find_or_create_by_title("Refinery")
9
+ end
10
+ end
11
+
12
+ factory :refinery_superuser, :parent => :refinery_user do
13
+ after_create do |u|
14
+ u.roles << Refinery::Role.find_or_create_by_title("Superuser")
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ require "refinerycms-members"
2
+ require "refinery/testing"
3
+ require File.expand_path("../dummy/spec/spec_helper", __FILE__)
@@ -0,0 +1,4 @@
1
+ RSpec.configure do |config|
2
+ config.include Refinery::Testing::ControllerMacros::Authentication, :type => :controller
3
+ config.include Refinery::Testing::ControllerMacros::Methods, :type => :controller
4
+ end
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+
3
+ describe "/refinery/members/admin/members/index" do
4
+ subject { render }
5
+
6
+ let(:member) { FactoryGirl.create(:refinery_member) }
7
+
8
+ before do
9
+ view.stub(refinery_icon_tag: "")
10
+ end
11
+
12
+ before do
13
+ view.stub(searching?: false)
14
+ view.stub(from_dialog?: false)
15
+ assign(:members, [member])
16
+ end
17
+
18
+ it { should have_css "#member_#{member.id}" }
19
+ end
@@ -0,0 +1,12 @@
1
+ require "spec_helper"
2
+
3
+ describe "/refinery/members/admin/members/new" do
4
+ subject { render }
5
+
6
+ before do
7
+ assign(:member, Refinery::Members::Member.new)
8
+ view.stub(from_dialog?: false)
9
+ end
10
+
11
+ it { should have_css "form[action='/refinery/members']" }
12
+ end
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ # This model initially had no columns defined. If you add columns to the
4
+ # model remove the '{}' from the fixture names and add the columns immediately
5
+ # below each fixture, per the syntax in the comments below
6
+ #
7
+ one: {}
8
+ # column: value
9
+ #
10
+ two: {}
11
+ # column: value
@@ -0,0 +1,3 @@
1
+ require "minitest/autorun"
2
+
3
+ # TODO
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ describe Refinery::Member do
4
+ subject { Refinery::Member.new }
5
+
6
+ it { should_not be_valid }
7
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: refinerycms-members2
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.3.0
6
+ platform: ruby
7
+ authors:
8
+ - n5ken
9
+ - Slava Kravchenko
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-03-05 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: 2.0.0
21
+ none: false
22
+ name: refinerycms
23
+ type: :runtime
24
+ prerelease: false
25
+ requirement: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 2.0.0
30
+ none: false
31
+ - !ruby/object:Gem::Dependency
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ~>
35
+ - !ruby/object:Gem::Version
36
+ version: 2.0.0
37
+ none: false
38
+ name: refinerycms-pages
39
+ type: :runtime
40
+ prerelease: false
41
+ requirement: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.0.0
46
+ none: false
47
+ description: Ruby on Rails Members engine for Refinery CMS 2.0
48
+ email:
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - Gemfile.lock
56
+ - README.md
57
+ - Rakefile
58
+ - app/controllers/refinery/members/admin/members_controller.rb
59
+ - app/controllers/refinery/members/passwords_controller.rb
60
+ - app/controllers/refinery/members/registrations_controller.rb
61
+ - app/controllers/refinery/members/sessions_controller.rb
62
+ - app/models/refinery/members/member.rb
63
+ - app/views/refinery/members/admin/members/_actions.html.erb
64
+ - app/views/refinery/members/admin/members/_form.html.erb
65
+ - app/views/refinery/members/admin/members/_member.html.erb
66
+ - app/views/refinery/members/admin/members/_records.html.erb
67
+ - app/views/refinery/members/admin/members/_sortable_list.html.erb
68
+ - app/views/refinery/members/admin/members/edit.html.erb
69
+ - app/views/refinery/members/admin/members/index.html.erb
70
+ - app/views/refinery/members/admin/members/new.html.erb
71
+ - config/initializers/devise.rb
72
+ - config/locales/en.yml
73
+ - config/locales/lolcat.yml
74
+ - config/locales/nb.yml
75
+ - config/locales/nl.yml
76
+ - config/routes.rb
77
+ - db/migrate/20130113101005_add_need_login_to_pages.rb
78
+ - db/migrate/20130113101006_create_members.rb
79
+ - db/seeds/members.rb
80
+ - lib/generators/refinery/members/members_generator.rb
81
+ - lib/refinery/members.rb
82
+ - lib/refinery/members/engine.rb
83
+ - lib/refinery/members/instance_methods.rb
84
+ - lib/refinerycms-members.rb
85
+ - refinerycms-members2.gemspec
86
+ - spec/controllers/refinery/members/admin/members_controller_spec.rb
87
+ - spec/controllers/refinery/members/sessions_controller_spec.rb
88
+ - spec/factories/members.rb
89
+ - spec/factories/users.rb
90
+ - spec/spec_helper.rb
91
+ - spec/support/refinery_testing.rb
92
+ - spec/views/refinery/members/admin/members/index_spec.rb
93
+ - spec/views/refinery/members/admin/members/new_spec.rb
94
+ - test/fixtures/members.yml
95
+ - test/test_helper.rb
96
+ - test/unit/member_test.rb
97
+ homepage: https://github.com/cordawyn/refinerycms-members2
98
+ licenses: []
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ none: false
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ none: false
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 1.8.24
118
+ signing_key:
119
+ specification_version: 3
120
+ summary: Members engine for Refinery CMS
121
+ test_files:
122
+ - spec/controllers/refinery/members/admin/members_controller_spec.rb
123
+ - spec/controllers/refinery/members/sessions_controller_spec.rb
124
+ - spec/factories/members.rb
125
+ - spec/factories/users.rb
126
+ - spec/spec_helper.rb
127
+ - spec/support/refinery_testing.rb
128
+ - spec/views/refinery/members/admin/members/index_spec.rb
129
+ - spec/views/refinery/members/admin/members/new_spec.rb
130
+ - test/fixtures/members.yml
131
+ - test/test_helper.rb
132
+ - test/unit/member_test.rb
133
+ has_rdoc: