Skip to content

Commit cfb1151

Browse files
committed
more Rails 5 friendly (removing deprecation messages) + add views for password reset
1 parent 30360b9 commit cfb1151

21 files changed

+58
-24
lines changed

app/controllers/kms/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base
55
# For APIs, you may want to use :null_session instead.
66
protect_from_forgery with: :exception
77

8-
after_filter :set_csrf_cookie_for_ng
8+
after_action :set_csrf_cookie_for_ng
99

1010
def set_csrf_cookie_for_ng
1111
cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?

app/controllers/kms/public/pages_controller.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
module Kms
22
class Public::PagesController < ActionController::Base
33

4-
before_filter :eval_externals
4+
before_action :eval_externals
55

66
def show
77
page_result = Kms.template_manager.render(@page.register_id, @externals)
8-
# apply typograph to page content
9-
#page_result = EvilFront::Russian.typograph_html(page_result)
108
result = Kms.template_manager.render(@template.register_id, @externals.
119
merge(_inner_template: page_result))
1210

13-
render text: result, layout: false
11+
render html: result.html_safe
1412
end
1513

1614
protected

app/models/concerns/kms/compile_templates.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ module CompileTemplates
99
after_commit :compile_templates, on: [:create, :update]
1010
end
1111

12+
def register_id
13+
[self.class.name.parameterize(separator: "_"), id.to_s].join('_')
14+
end
15+
1216
protected
1317

1418
def compiled_templates

app/models/kms/page.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,5 @@ def fetch_item!(slug)
5454
templatable_type.constantize.find_by_slug!(slug)
5555
end
5656

57-
def register_id
58-
"#{self.class.name.parameterize("_")}_#{id}"
59-
end
6057
end
6158
end

app/models/kms/template.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,5 @@ class Template < ActiveRecord::Base
44

55
validates :name, presence: true
66

7-
def register_id
8-
"#{self.class.name.parameterize("_")}_#{id}"
9-
end
107
end
118
end
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<div class="wrapper">
2+
3+
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { class: 'form-signin', method: :put }) do |f| %>
4+
<h2 class="form-signin-heading">KMS</h2>
5+
<h4>Change your password</h4>
6+
<%= devise_error_messages! %>
7+
<%= f.hidden_field :reset_password_token %>
8+
9+
<% if @minimum_password_length %>
10+
<em>(<%= @minimum_password_length %> characters minimum)</em><br />
11+
<% end %>
12+
<%= f.password_field :password, autofocus: true, autocomplete: "off", class: 'form-control', placeholder: 'Password' %>
13+
14+
<%= f.password_field :password_confirmation, autocomplete: "off", class: 'form-control', placeholder: 'Password confirmation' %>
15+
16+
<%= f.submit "Change my password", class: "btn btn-lg btn-primary btn-block" %>
17+
18+
<br>
19+
<%= render "devise/shared/links" %>
20+
<% end %>
21+
22+
</div>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<div class="wrapper">
2+
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { class: 'form-signin', method: :post }) do |f| %>
3+
<h2 class="form-signin-heading">KMS</h2>
4+
<%= devise_error_messages! %>
5+
6+
<h4>Forgot your password?</h4>
7+
<%= f.email_field :email, autofocus: true, class: 'form-control', placeholder: 'Email' %>
8+
<br>
9+
<%= f.submit "Send reset password instructions", class: "btn btn-lg btn-primary btn-block" %>
10+
<br>
11+
<%= render "devise/shared/links" %>
12+
13+
<% end %>
14+
15+
</div>

db/migrate/20141027065341_create_pages.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class CreatePages < ActiveRecord::Migration
1+
class CreatePages < ActiveRecord::Migration[4.2]
22
def change
33
create_table :kms_pages do |t|
44
t.string :title

db/migrate/20141027083603_create_templates.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class CreateTemplates < ActiveRecord::Migration
1+
class CreateTemplates < ActiveRecord::Migration[4.2]
22
def change
33
create_table :kms_templates do |t|
44
t.string :name

db/migrate/20141027083633_add_template_id_to_pages.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class AddTemplateIdToPages < ActiveRecord::Migration
1+
class AddTemplateIdToPages < ActiveRecord::Migration[4.2]
22
def change
33
add_column :kms_pages, :template_id, :integer
44
add_foreign_key :kms_pages, :kms_templates if respond_to?(:add_foreign_key)

0 commit comments

Comments
 (0)