cadmus 0.5.1 → 0.5.2

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: 1ec60a64ad92c23d2f945ebf3e954c3dc8b30920
4
- data.tar.gz: 213c4003f0c49f6d573de4d3158549af76aef486
3
+ metadata.gz: 25c8b4e53cfd255b409c868f3b8d713ee9ba529f
4
+ data.tar.gz: 0d63afd6ffe03f07c80b2e9a6ff6acfd8285c429
5
5
  SHA512:
6
- metadata.gz: d1d497d73e198e2c052b6f10e2e334d0028f7449a108de8135547d365102c715fb4ccf48a73d073891a2235aeaec7498cf3abb70b367f7ff2057d5c146128333
7
- data.tar.gz: f62c0c64feab4552bc33597fe890d2bc6a34e31d9ea54ebe8d681172af3a4c3a383b571bf289a04ab1f85b23c9c7c3dbb729d5d0c55b69d8e556d0383a3e80c3
6
+ metadata.gz: fa374b8cf36fd744d00c382eb62b64f013b53b5ea9a2ce30df22f640b4bcd56e85e3f3d98da8c9b8393d26738c2c6dff32c610ed0f6cbd16b7fafcd741850b1f
7
+ data.tar.gz: 6343c1b8a254081c5e2613665534af3cfda9a44837067b02c374916a87dc143a7ed975c1b4ac4c9a1ee7be35d249f13c03928033b93620c0b7d0ccbf32ec80ed
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## cadmus 0.5.2 (11-10-2016)
2
+
3
+ * Rails 5 compatibility fixes
4
+
1
5
  ## cadmus 0.5.1 (05-03-2015)
2
6
 
3
7
  * Support the sanitizer changes in Rails 4.2
@@ -1,5 +1,5 @@
1
1
  module Cadmus
2
-
2
+
3
3
  # A controller mixin that includes all the RESTful resource actions for viewing and administering Cadmus
4
4
  # pages. This mixin provides a great deal of flexibility for customizing the behavior of the resulting
5
5
  # controller.
@@ -38,7 +38,7 @@ module Cadmus
38
38
  # end
39
39
  # end
40
40
  #
41
- # A controller for pages inside a Book object. This controller uses URLs of the form
41
+ # A controller for pages inside a Book object. This controller uses URLs of the form
42
42
  # +/books/:book_id/pages/...+ The book_id parameter is a slug, not an ID. First, here's
43
43
  # the Book model:
44
44
  #
@@ -46,13 +46,13 @@ module Cadmus
46
46
  # # This association has to be called "pages" because that's what BookPagesController
47
47
  # # will expect to use to find them.
48
48
  # has_many :pages, :class_name => "BookPage"
49
- #
49
+ #
50
50
  # validates_uniqueness_of :slug
51
51
  # end
52
52
  #
53
53
  # class BookPagesController < ApplicationController
54
54
  # include Cadmus::PagesController
55
- #
55
+ #
56
56
  # self.page_parent_class = Book # pages must have a Book as their parent
57
57
  # self.page_parent_name = "book" # use params[:book_id] for finding Books
58
58
  # self.find_parent_by = "slug" # use the Book's slug field for finding Books
@@ -65,26 +65,26 @@ module Cadmus
65
65
  module PagesController
66
66
  extend ActiveSupport::Concern
67
67
  include Cadmus::Renderable
68
-
68
+
69
69
  included do
70
70
  class << self
71
71
  attr_accessor :page_parent_name, :page_parent_class, :find_parent_by
72
72
  end
73
-
74
- before_filter :load_parent_and_page
73
+
74
+ before_action :load_parent_and_page
75
75
  helper_method :cadmus_renderer
76
76
  end
77
-
77
+
78
78
  def index
79
79
  @pages = page_scope.order(:name).all
80
-
80
+
81
81
  respond_to do |format|
82
82
  format.html { render 'cadmus/pages/index' }
83
83
  format.xml { render :xml => @pages }
84
84
  format.json { render :json => @pages }
85
85
  end
86
86
  end
87
-
87
+
88
88
  def show
89
89
  respond_to do |format|
90
90
  format.html { render 'cadmus/pages/show' }
@@ -92,24 +92,24 @@ module Cadmus
92
92
  format.json { render :json => @page }
93
93
  end
94
94
  end
95
-
95
+
96
96
  def new
97
97
  @page = page_scope.new
98
-
98
+
99
99
  respond_to do |format|
100
100
  format.html { render 'cadmus/pages/new' }
101
101
  format.xml { render :xml => @page }
102
102
  format.json { render :json => @page }
103
103
  end
104
104
  end
105
-
106
- def edit
105
+
106
+ def edit
107
107
  render 'cadmus/pages/edit'
108
108
  end
109
-
109
+
110
110
  def create
111
111
  @page = page_scope.new(page_params)
112
-
112
+
113
113
  respond_to do |format|
114
114
  if @page.save
115
115
  dest = { :action => 'show', :page_glob => @page.slug }
@@ -123,7 +123,7 @@ module Cadmus
123
123
  end
124
124
  end
125
125
  end
126
-
126
+
127
127
  def update
128
128
  respond_to do |format|
129
129
  if @page.update_attributes(page_params)
@@ -138,19 +138,19 @@ module Cadmus
138
138
  end
139
139
  end
140
140
  end
141
-
141
+
142
142
  def destroy
143
143
  @page.destroy
144
-
144
+
145
145
  respond_to do |format|
146
146
  format.html { redirect_to(:action => :index) }
147
147
  format.xml { head :ok }
148
148
  format.json { head :ok }
149
149
  end
150
150
  end
151
-
151
+
152
152
  protected
153
-
153
+
154
154
  # This gets kind of meta.
155
155
  #
156
156
  # If page_parent_name and page_parent_class are both defined for this class, this method uses it to find
@@ -163,27 +163,27 @@ module Cadmus
163
163
  # what you want to use.
164
164
  def page_parent
165
165
  return @page_parent if @page_parent
166
-
166
+
167
167
  if page_parent_name && page_parent_class
168
168
  parent_id_param = "#{page_parent_name}_id"
169
- if params[parent_id_param]
169
+ if params[parent_id_param]
170
170
  @page_parent = page_parent_class.where(find_parent_by => params[parent_id_param]).first
171
171
  end
172
172
  end
173
-
173
+
174
174
  @page_parent
175
175
  end
176
-
176
+
177
177
  # Returns the name of the page parent object. This will be used for determining the parameter name for
178
178
  # finding the parent object. For example, if the page parent name is "wiki", the finder will look in
179
179
  # params["wiki_id"] to determine the object ID.
180
180
  #
181
- # By default, this will return the value of page_parent_name set at the controller class level, but can
181
+ # By default, this will return the value of page_parent_name set at the controller class level, but can
182
182
  # be overridden for cases where the page parent name must be determined on a per-request basis.
183
183
  def page_parent_name
184
184
  self.class.page_parent_name
185
185
  end
186
-
186
+
187
187
  # Returns the class of the page parent object. For example, if the pages used by this controller are
188
188
  # children of a Section object, this method should return the Section class.
189
189
  #
@@ -192,7 +192,7 @@ module Cadmus
192
192
  def page_parent_class
193
193
  self.class.page_parent_class
194
194
  end
195
-
195
+
196
196
  # Returns the field used to find the page parent object. By default this is :id, but if you need to
197
197
  # find the page parent object using a different parameter (for example, if you use a "slug" field for
198
198
  # part of the URL), this can be changed.
@@ -203,18 +203,18 @@ module Cadmus
203
203
  def find_parent_by
204
204
  self.class.find_parent_by || :id
205
205
  end
206
-
206
+
207
207
  # Returns the ActiveRecord::Relation that will be used for finding pages. If there is a page parent
208
208
  # for this request, this will be the "pages" scope defined by the parent object. If there isn't,
209
209
  # this will be the "global" scope of the page class (i.e. pages with no parent object).
210
210
  def page_scope
211
211
  @page_scope ||= page_parent ? page_parent.pages : page_class.global
212
212
  end
213
-
213
+
214
214
  def page_params
215
215
  params.require(:page).permit(:name, :slug, :content)
216
216
  end
217
-
217
+
218
218
  def load_parent_and_page
219
219
  if params[:page_glob]
220
220
  @page = page_scope.find_by_slug(params[:page_glob])
@@ -10,12 +10,12 @@ module Cadmus
10
10
  # is +test+, because +assert_recognizes+ doesn't always pass the full params hash
11
11
  # including globbed parameters.
12
12
  def matches?(request)
13
- page_glob = request.symbolized_path_parameters[:page_glob]
14
-
13
+ page_glob = request.path_parameters.symbolize_keys[:page_glob]
14
+
15
15
  # assert_recognizes doesn't pass the full params hash as we would in a real Rails
16
16
  # application. So we have to always pass this constraint if we're testing.
17
17
  return true if page_glob.nil? && Rails.env.test?
18
-
18
+
19
19
  page_glob.sub(/\A\//, '').split(/\//).all? do |part|
20
20
  part =~ /\A[a-z][a-z0-9\-]*\z/
21
21
  end
@@ -40,25 +40,25 @@ ActionDispatch::Routing::Mapper.class_eval do
40
40
  # * :controller - changes which controller it maps to. By default, it is "pages" (meaning PagesController).
41
41
  # * :shallow - if set to "true", the edit, show, update and destroy routes won't include the "/pages" prefix. Useful if you're
42
42
  # already inside a unique prefix.
43
- def cadmus_pages(options = nil)
43
+ def cadmus_pages(options = nil)
44
44
  options ||= {}
45
45
  options = options.with_indifferent_access
46
-
46
+
47
47
  controller = options[:controller] || 'pages'
48
-
48
+
49
49
  get "pages" => "#{controller}#index", :as => 'pages'
50
50
  get "pages/new" => "#{controller}#new", :as => 'new_page'
51
51
  post "pages" => "#{controller}#create"
52
52
 
53
53
  slug_constraint = Cadmus::SlugConstraint.new
54
-
54
+
55
55
  page_actions = Proc.new do
56
56
  get "*page_glob/edit" => "#{controller}#edit", :as => 'edit_page', :constraints => slug_constraint
57
57
  get "*page_glob" => "#{controller}#show", :as => 'page', :constraints => slug_constraint
58
58
  match "*page_glob" => "#{controller}#update", :constraints => slug_constraint, :via => [:put, :patch]
59
59
  delete "*page_glob" => "#{controller}#destroy", :constraints => slug_constraint
60
60
  end
61
-
61
+
62
62
  if options[:shallow]
63
63
  instance_eval(&page_actions)
64
64
  else
@@ -1,3 +1,3 @@
1
1
  module Cadmus
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cadmus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nat Budin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-03 00:00:00.000000000 Z
12
+ date: 2016-11-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  version: '0'
93
93
  requirements: []
94
94
  rubyforge_project:
95
- rubygems_version: 2.4.5
95
+ rubygems_version: 2.6.4
96
96
  signing_key:
97
97
  specification_version: 4
98
98
  summary: Embeddable CMS for Rails 3 apps