refinerycms 0.9.5.30 → 0.9.5.31

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/.yardopts +15 -5
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/bin/refinery +9 -9
  5. data/bin/refinery-update-core +8 -5
  6. data/config/environment.rb +1 -1
  7. data/config/routes.rb +1 -0
  8. data/contributors.md +18 -0
  9. data/db/migrate/20100127004649_add_reset_code_to_users.rb +9 -0
  10. data/db/schema.rb +2 -1
  11. data/db/seeds.rb +11 -1
  12. data/{LICENSE → license.md} +3 -3
  13. data/public/javascripts/admin.js +5 -0
  14. data/public/javascripts/refinery/boot_wym.js +1 -1
  15. data/public/stylesheets/refinery/refinery.css +7 -0
  16. data/readme.md +161 -0
  17. data/themes/demolicious.zip +0 -0
  18. data/themes/hemingway.zip +0 -0
  19. data/vendor/plugins/authentication/app/controllers/admin/users_controller.rb +0 -27
  20. data/vendor/plugins/authentication/app/controllers/sessions_controller.rb +3 -0
  21. data/vendor/plugins/authentication/app/controllers/users_controller.rb +36 -21
  22. data/vendor/plugins/authentication/app/models/user.rb +40 -41
  23. data/vendor/plugins/authentication/app/models/user_mailer.rb +5 -12
  24. data/vendor/plugins/authentication/app/views/sessions/new.html.erb +3 -0
  25. data/vendor/plugins/authentication/app/views/user_mailer/reset_notification.html.erb +6 -0
  26. data/vendor/plugins/authentication/app/views/users/forgot.html.erb +13 -0
  27. data/vendor/plugins/authentication/app/views/users/reset.html.erb +18 -0
  28. data/vendor/plugins/authentication/authentication.md +7 -0
  29. data/vendor/plugins/authentication/config/routes.rb +6 -1
  30. data/vendor/plugins/dashboard/dashboard.md +22 -0
  31. data/vendor/plugins/images/images.md +46 -0
  32. data/vendor/plugins/inquiries/app/controllers/inquiries_controller.rb +0 -8
  33. data/vendor/plugins/inquiries/app/views/admin/inquiries/show.html.erb +3 -3
  34. data/vendor/plugins/inquiries/inquiries.md +31 -0
  35. data/vendor/plugins/news/app/controllers/news_items_controller.rb +9 -19
  36. data/vendor/plugins/news/app/views/news_items/index.html.erb +1 -1
  37. data/vendor/plugins/news/app/views/news_items/show.html.erb +13 -18
  38. data/vendor/plugins/news/news.md +20 -0
  39. data/vendor/plugins/pages/app/controllers/pages_controller.rb +2 -12
  40. data/vendor/plugins/pages/app/models/page.rb +5 -5
  41. data/vendor/plugins/pages/app/presenters/page_presenter.rb +3 -0
  42. data/vendor/plugins/pages/pages.md +141 -0
  43. data/vendor/plugins/pages/rails/init.rb +1 -1
  44. data/vendor/plugins/refinery/app/views/admin/_head.html.erb +1 -0
  45. data/vendor/plugins/refinery/app/views/layouts/application.html.erb +2 -15
  46. data/vendor/plugins/refinery/app/views/shared/_head.html.erb +13 -0
  47. data/vendor/plugins/refinery/app/views/shared/_header.html.erb +1 -1
  48. data/vendor/plugins/refinery/app/views/shared/_menu.html.erb +4 -15
  49. data/vendor/plugins/refinery/app/views/shared/_menu_branch.html.erb +20 -25
  50. data/vendor/plugins/refinery/app/views/shared/_submenu.html.erb +5 -4
  51. data/vendor/plugins/refinery/crud.md +197 -0
  52. data/vendor/plugins/refinery/lib/generators/refinery/templates/public_controller.rb +6 -1
  53. data/vendor/plugins/refinery/lib/refinery/application_controller.rb +18 -5
  54. data/vendor/plugins/refinery/lib/refinery/application_helper.rb +31 -28
  55. data/vendor/plugins/refinery/lib/refinery/base_presenter.rb +27 -0
  56. data/vendor/plugins/refinery/lib/refinery/initializer.rb +7 -3
  57. data/vendor/plugins/refinery/lib/tasks/doc.rake +4 -4
  58. data/vendor/plugins/refinery/plugins.md +194 -0
  59. data/vendor/plugins/refinery/rails/init.rb +5 -0
  60. data/vendor/plugins/refinery_settings/settings.md +5 -0
  61. data/vendor/plugins/resources/resources.md +9 -0
  62. data/vendor/plugins/themes/app/controllers/themes_controller.rb +12 -15
  63. data/vendor/plugins/themes/app/models/theme.rb +8 -14
  64. data/vendor/plugins/themes/config/routes.rb +3 -3
  65. data/vendor/plugins/themes/themes.md +133 -0
  66. metadata +29 -38
  67. data/CONTRIBUTORS +0 -11
  68. data/README.rdoc +0 -78
  69. data/themes/demolicious/LICENSE +0 -21
  70. data/themes/demolicious/README +0 -1
  71. data/themes/demolicious/images/footer_background.png +0 -0
  72. data/themes/demolicious/images/header_background.png +0 -0
  73. data/themes/demolicious/preview.png +0 -0
  74. data/themes/demolicious/stylesheets/application.css +0 -94
  75. data/themes/demolicious/stylesheets/formatting.css +0 -36
  76. data/themes/demolicious/stylesheets/home.css +0 -11
  77. data/themes/demolicious/stylesheets/ie6.css +0 -0
  78. data/themes/demolicious/stylesheets/ie7.css +0 -0
  79. data/themes/demolicious/views/layouts/application.html.erb +0 -33
  80. data/themes/demolicious/views/pages/home.html.erb +0 -1
  81. data/themes/demolicious/views/pages/show.html.erb +0 -1
  82. data/themes/hemingway/LICENSE +0 -7
  83. data/themes/hemingway/README +0 -3
  84. data/themes/hemingway/images/archives.gif +0 -0
  85. data/themes/hemingway/images/footer_black.gif +0 -0
  86. data/themes/hemingway/images/kyle-header.jpg +0 -0
  87. data/themes/hemingway/images/readon_black.gif +0 -0
  88. data/themes/hemingway/images/search.gif +0 -0
  89. data/themes/hemingway/images/spinner.gif +0 -0
  90. data/themes/hemingway/images/trackback_pingback.gif +0 -0
  91. data/themes/hemingway/preview.png +0 -0
  92. data/themes/hemingway/stylesheets/application.css +0 -713
  93. data/themes/hemingway/views/layouts/application.html.erb +0 -64
  94. data/themes/hemingway/views/shared/content_page.html.erb +0 -0
  95. data/vendor/plugins/authentication/app/models/user_observer.rb +0 -11
  96. data/vendor/plugins/authentication/app/views/user_mailer/activation.html.erb +0 -3
  97. data/vendor/plugins/authentication/app/views/user_mailer/signup_notification.html.erb +0 -8
  98. data/vendor/plugins/themes/themes.rdoc +0 -131
@@ -5,12 +5,14 @@ class SessionsController < ApplicationController
5
5
 
6
6
  def create
7
7
  self.current_user = User.authenticate(params[:session][:login], params[:session][:password])
8
+
8
9
  if logged_in?
9
10
  if params[:session][:remember_me] == "1"
10
11
  current_user.remember_me unless current_user.remember_token?
11
12
  cookies[:auth_token] = {:value => self.current_user.remember_token ,
12
13
  :expires => self.current_user.remember_token_expires_at}
13
14
  end
15
+
14
16
  redirect_back_or_default(admin_root_url)
15
17
  flash[:notice] = "Logged in successfully"
16
18
  else
@@ -28,6 +30,7 @@ class SessionsController < ApplicationController
28
30
  end
29
31
 
30
32
  protected
33
+
31
34
  def take_down_for_maintenance?;end
32
35
 
33
36
  end
@@ -1,7 +1,6 @@
1
1
  class UsersController < ApplicationController
2
2
 
3
3
  # Protect these actions behind an admin login
4
- # before_filter :admin_required, :only => [:suspend, :unsuspend, :destroy, :purge]
5
4
  before_filter :find_user, :only => [:suspend, :unsuspend, :destroy, :purge]
6
5
 
7
6
  filter_parameter_logging 'password', 'password_confirmation'
@@ -32,8 +31,8 @@ class UsersController < ApplicationController
32
31
  current_user.activate!
33
32
  current_user.update_attribute(:superuser, true) if User.count == 1 # this is the superuser if this user is the only user.
34
33
  redirect_back_or_default(admin_root_url)
35
-
36
34
  flash[:notice] = "Welcome to Refinery, #{current_user.login}."
35
+
37
36
  if User.count == 1 or RefinerySetting[:site_name] == "Company Name"
38
37
  refinery_setting = RefinerySetting.find_by_name("site_name")
39
38
  flash[:notice] << "<br/>First let's give the site a name. <a href='#{edit_admin_refinery_setting_url(refinery_setting)}'>Go here</a> to edit your website's name"
@@ -47,39 +46,55 @@ class UsersController < ApplicationController
47
46
 
48
47
  def activate
49
48
  self.current_user = params[:activation_code].blank? ? false : User.find_by_activation_code(params[:activation_code])
49
+
50
50
  if logged_in? && !current_user.active?
51
51
  current_user.activate!
52
52
  flash[:notice] = "Signup complete!"
53
53
  end
54
+
54
55
  redirect_back_or_default(root_url)
55
56
  end
56
57
 
57
- def suspend
58
- @user.suspend!
59
- redirect_to users_path
60
- end
58
+ def forgot
59
+ if request.post?
60
+ user = User.find_by_email(params[:user][:email])
61
+
62
+ if user
63
+ user.create_reset_code
64
+
65
+ begin
66
+ flash[:notice] = "An email has been sent to #{user.email} with a link to reset your password."
67
+ UserMailer.deliver_reset_notification(user, request)
68
+ rescue
69
+ info.logger "error: email could not be sent for user password reset"
70
+ end
71
+ else
72
+ flash[:notice] = "Sorry, #{params[:user][:email]} isn't associated with any acounts. Are you sure you typed the correct email address?"
73
+ end
61
74
 
62
- def unsuspend
63
- @user.unsuspend!
64
- redirect_to users_path
75
+ redirect_back_or_default(forgot_url)
76
+ end
65
77
  end
66
78
 
67
- def destroy
68
- @user.delete!
69
- redirect_to users_path
70
- end
79
+ def reset
80
+ @user = User.find_by_reset_code(params[:reset_code]) unless params[:reset_code].nil?
71
81
 
72
- def purge
73
- @user.destroy
74
- redirect_to users_path
75
- end
82
+ if request.post?
83
+ if @user.update_attributes(:password => params[:user][:password], :password_confirmation => params[:user][:password_confirmation])
84
+ self.current_user = @user
85
+ @user.delete_reset_code
86
+
87
+ flash[:notice] = "Password reset successfully for #{@user.email}"
88
+ redirect_back_or_default(admin_root_url)
89
+ else
90
+ render :action => :reset
91
+ end
92
+ end
93
+ end
76
94
 
77
95
  protected
78
- def take_down_for_maintenance?;end
79
96
 
80
- def find_user
81
- @user = User.find(params[:id])
82
- end
97
+ def take_down_for_maintenance?;end
83
98
 
84
99
  def can_create_public_user
85
100
  User.count == 0
@@ -1,5 +1,6 @@
1
1
  require 'digest/sha1'
2
2
  class User < ActiveRecord::Base
3
+
3
4
  # Hack: Allow "rake gems:install" to run when this class is missing its gem dependency.
4
5
  # For further clarification on why, refer to:
5
6
  # https://rails.lighthouseapp.com/projects/8994/tickets/780-rake-gems-install-doesn-t-work-if-plugins-are-missing-gem-dependencies
@@ -10,8 +11,6 @@ class User < ActiveRecord::Base
10
11
  aasm_state :passive
11
12
  aasm_state :pending, :enter => :make_activation_code
12
13
  aasm_state :active, :enter => :do_activate
13
- aasm_state :suspended
14
- aasm_state :deleted, :enter => :do_delete
15
14
 
16
15
  aasm_event :register do
17
16
  transitions :from => :passive, :to => :pending, :guard => Proc.new {|u| !(u.crypted_password.blank? && u.password.blank?) }
@@ -20,20 +19,6 @@ class User < ActiveRecord::Base
20
19
  aasm_event :activate do
21
20
  transitions :from => :pending, :to => :active
22
21
  end
23
-
24
- aasm_event :suspend do
25
- transitions :from => [:passive, :pending, :active], :to => :suspended
26
- end
27
-
28
- aasm_event :delete do
29
- transitions :from => [:passive, :pending, :active, :suspended], :to => :deleted
30
- end
31
-
32
- aasm_event :unsuspend do
33
- transitions :from => :suspended, :to => :active, :guard => Proc.new {|u| !u.activated_at.blank? }
34
- transitions :from => :suspended, :to => :pending, :guard => Proc.new {|u| !u.activation_code.blank? }
35
- transitions :from => :suspended, :to => :passive
36
- end
37
22
  end
38
23
 
39
24
  # Virtual attribute for the unencrypted password
@@ -49,13 +34,13 @@ class User < ActiveRecord::Base
49
34
  validates_uniqueness_of :login, :email, :case_sensitive => false
50
35
  before_save :encrypt_password
51
36
 
52
- serialize :plugins_column#, Array # this is seriously deprecated and will be removed later.
37
+ serialize :plugins_column # Array # this is seriously deprecated and will be removed later.
53
38
 
54
39
  has_many :plugins, :class_name => "UserPlugin", :order => "position ASC"
55
40
 
56
41
  # prevents a user from submitting a crafted form that bypasses activation
57
42
  # anything else you want your user to change should be added here.
58
- attr_accessible :login, :email, :password, :password_confirmation, :plugins
43
+ attr_accessible :login, :email, :password, :password_confirmation, :plugins, :reset_code
59
44
 
60
45
  # Authenticates a user by their login name and unencrypted password. Returns the user or nil.
61
46
  def self.authenticate(login, password)
@@ -125,30 +110,44 @@ class User < ActiveRecord::Base
125
110
  !self.superuser and User.count > 1 and (current_user.nil? or self.id != current_user.id)
126
111
  end
127
112
 
128
- protected
129
- # before filter
130
- def encrypt_password
131
- return if password.blank?
132
- self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record?
133
- self.crypted_password = encrypt(password)
134
- end
113
+ def create_reset_code
114
+ @reset = true
115
+ code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )
116
+ self.attributes = {:reset_code => code[0..6]}
117
+ save(false)
118
+ end
119
+
120
+ def recently_reset?
121
+ @reset
122
+ end
135
123
 
136
- def password_required?
137
- crypted_password.blank? || !password.blank?
138
- end
124
+ def delete_reset_code
125
+ self.attributes = {:reset_code => nil}
126
+ save(false)
127
+ end
139
128
 
140
- def make_activation_code
141
- self.deleted_at = nil
142
- self.activation_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )
143
- end
129
+ protected
144
130
 
145
- def do_delete
146
- self.deleted_at = Time.now.utc
147
- end
131
+ # before filter
132
+ def encrypt_password
133
+ return if password.blank?
134
+ self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record?
135
+ self.crypted_password = encrypt(password)
136
+ end
148
137
 
149
- def do_activate
150
- @activated = true
151
- self.activated_at = Time.now.utc
152
- self.deleted_at = self.activation_code = nil
153
- end
154
- end
138
+ def password_required?
139
+ crypted_password.blank? || !password.blank?
140
+ end
141
+
142
+ def make_activation_code
143
+ self.deleted_at = nil
144
+ self.activation_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )
145
+ end
146
+
147
+ def do_activate
148
+ @activated = true
149
+ self.activated_at = Time.now.utc
150
+ self.deleted_at = self.activation_code = nil
151
+ end
152
+
153
+ end
@@ -1,23 +1,16 @@
1
1
  class UserMailer < ActionMailer::Base
2
2
 
3
- def signup_notification(user)
3
+ def reset_notification(user, request)
4
4
  setup_email(user)
5
- @subject += 'Please activate your new account'
6
- @body[:url] = "http://YOURSITE/activate/#{user.activation_code}"
7
- end
8
-
9
- def activation(user)
10
- setup_email(user)
11
- @subject += 'Your account has been activated!'
12
- @body[:url] = "http://YOURSITE/"
5
+ @subject += 'Link to reset your password'
6
+ @body[:url] = "#{request.protocol}#{request.host_with_port}/reset/#{user.reset_code}"
13
7
  end
14
8
 
15
9
  protected
16
10
 
17
11
  def setup_email(user)
18
- @recipients = "#{user.email}"
19
- @from = "ADMINEMAIL"
20
- @subject = "[YOURSITE] "
12
+ @recipients = user.email
13
+ @subject = ""
21
14
  @sent_on = Time.now
22
15
  @body[:user] = user
23
16
  end
@@ -9,6 +9,9 @@
9
9
  <%= f.password_field :password %>
10
10
  </div>
11
11
  </div>
12
+ <div class='field forgot_password'>
13
+ <%= link_to "I forgot my password", forgot_url %>
14
+ </div>
12
15
  <div class='field remember_me'>
13
16
  <%= f.label :remember_me, nil %>
14
17
  <%= f.check_box :remember_me %>
@@ -0,0 +1,6 @@
1
+ Request to reset password received for <%= @user.login %>
2
+
3
+ Visit this url to choose a new password:
4
+ <%= @url %>
5
+
6
+ (Your password will remain the same if no action is taken)
@@ -0,0 +1,13 @@
1
+ <%= error_messages_for :user %>
2
+ <% form_for :user do |f| -%>
3
+ <p>Enter the email address for your account.</p>
4
+ <div class='field'>
5
+ <%= f.label :email %>
6
+ <%= f.text_field :email %>
7
+ </div>
8
+ <div class='form-actions'>
9
+ <%= submit_tag 'Reset password' %>
10
+ or
11
+ <%= link_to "Cancel", login_url %>
12
+ </div>
13
+ <% end -%>
@@ -0,0 +1,18 @@
1
+ <%= error_messages_for :user %>
2
+ <% form_for :user do |f| -%>
3
+ <p>Pick a new password for <%= @user.email %></p>
4
+ <div class='field'>
5
+ <%= f.label :password %>
6
+ <%= f.password_field :password %>
7
+ </div>
8
+ <div class='field'>
9
+ <%= f.label :password_confirmation %>
10
+ <%= f.password_field :password_confirmation %>
11
+ </div>
12
+
13
+ <div class='form-actions'>
14
+ <%= submit_tag 'Reset password' %>
15
+ or
16
+ <%= link_to "Cancel", login_url %>
17
+ </div>
18
+ <% end -%>
@@ -0,0 +1,7 @@
1
+ # Authentication
2
+
3
+ ## About
4
+
5
+ At the heart of Refinery's user management is the authentication plugin located in ``vendor/plugins/authentication``
6
+
7
+ What this really is is just a standard [RESTFul authentication](http://github.com/technoweenie/restful-authentication) install extended with a few extra features like "I forgot my password" and hooked directly into the heart of Refinery's plugin system.
@@ -1,10 +1,15 @@
1
1
  ActionController::Routing::Routes.draw do |map|
2
+
2
3
  map.resources :users
3
4
  map.resource :session
5
+
4
6
  map.namespace(:admin) do |admin|
5
7
  admin.resources :users
6
8
  end
7
9
 
8
10
  map.login '/login', :controller => 'sessions', :action => 'new'
9
11
  map.logout '/logout', :controller => 'sessions', :action => 'destroy'
10
- end
12
+ map.forgot '/forgot', :controller => 'users', :action => 'forgot'
13
+ map.reset 'reset/:reset_code', :controller => 'users', :action => 'reset'
14
+
15
+ end
@@ -0,0 +1,22 @@
1
+ # Dashboard
2
+
3
+ ![Refinery Dashboard](http://refinerycms.com/system/images/0000/0576/dashboard.png)
4
+
5
+ ## About
6
+
7
+ Refinery's dashboard is a plugin that does two simple things
8
+
9
+ * Reports recent activity on all the core plugins
10
+ * Provides convenient links to common tasks.
11
+
12
+ ## How do I hook my custom plugin into the recent activity log?
13
+
14
+ Read in plugins.rdoc the section titled "Getting your plugin to report activity in the dashboard"
15
+
16
+ ## Related Settings
17
+
18
+ ### "Activity Show Limit"
19
+
20
+ This allows you to specify how many items should show up in your recent activity list.
21
+
22
+ Example: if we set the activity show limit to 5, only 5 items will show in the recent activity.
@@ -0,0 +1,46 @@
1
+ # Images
2
+
3
+ ![Refinery Images](http://refinerycms.com/system/images/0000/0616/images.png)
4
+
5
+ ## About
6
+
7
+ All Refinery's images are stored in one place, the images plugin. This plugin:
8
+
9
+ * Reports recent activity on all the core plugins
10
+ * Provides convenient links to common tasks.
11
+
12
+ ## Generating Thumbnails
13
+
14
+ Refinery lets you generate a range of thumbnails when an image is uploaded so you can output this on a page in an appropriate size.
15
+
16
+ To specify the sizes of your thumbnails edit the "Image Thumbnails" setting.
17
+
18
+ This setting is stored as a serialize hash and is directly passed to attachment_fu
19
+
20
+ Here's what the default looks like
21
+
22
+ ---
23
+ :grid: c135x135
24
+ :lightbox: 500x500>
25
+ :dialog_thumb: c106x106
26
+ :medium: 225x255
27
+ :preview: c96x96
28
+ :thumb: 50x50
29
+ :side_body: 300x500
30
+
31
+ Refinery requires some of these so you won't want to delete any, but add new ones to meet your design needs. Each thumbnail is not just a size guide but a RMagick geometry string that allows you to define min and max size too.
32
+
33
+ Refinery also extends the geometry string support to allow cropping. Here's some examples
34
+
35
+ :grid: c135x135
36
+
37
+ This will crop (_that's what the "c" stands for_) the image down to ``135x135`` exactly without stretching the image.
38
+
39
+ _Note: you will have to restart your web server after changing this setting for the changes to take effect._
40
+
41
+ ## Related Settings
42
+
43
+ ### "Preferred Image View"
44
+
45
+ Set to ``"grid"`` to get your images to display as a grid of thumbnails
46
+ Set to ``"list"`` to get your images to display as a list with image titles.
@@ -4,18 +4,10 @@ class InquiriesController < ApplicationController
4
4
 
5
5
  def thank_you
6
6
  @page = Page.find_by_menu_match("^/inquiries/thank_you$", :include => [:parts, :slugs])
7
-
8
- respond_to do |wants|
9
- wants.html
10
- end
11
7
  end
12
8
 
13
9
  def new
14
10
  @inquiry = Inquiry.new
15
-
16
- respond_to do |wants|
17
- wants.html
18
- end
19
11
  end
20
12
 
21
13
  def create
@@ -27,7 +27,7 @@
27
27
  <strong>From</strong>
28
28
  </td>
29
29
  <td>
30
- <%= @inquiry.name %> [<%= mail_to @inquiry.email, @inquiry.email, {:title => "Click to email this address"} %>]
30
+ <%=h @inquiry.name %> [<%= mail_to @inquiry.email, @inquiry.email, {:title => "Click to email this address"} %>]
31
31
  </td>
32
32
  </tr>
33
33
  <% unless @inquiry.phone.blank? %>
@@ -36,7 +36,7 @@
36
36
  <strong>Phone</strong>
37
37
  </td>
38
38
  <td>
39
- <%= @inquiry.phone %>
39
+ <%=h @inquiry.phone %>
40
40
  </td>
41
41
  </tr>
42
42
  <% end %>
@@ -54,7 +54,7 @@
54
54
  </td>
55
55
  <td>
56
56
  <p style='margin-top: 0px'>
57
- <%= @inquiry.message.gsub("\r\n\r\n", "\r\n").gsub("\r\n", "</p><p>") %>
57
+ <%=h @inquiry.message.gsub("\r\n\r\n", "\r\n").gsub("\r\n", "</p><p>") %>
58
58
  </p>
59
59
  </td>
60
60
  </tr>