railspress-engine 1.4.1 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -9
- data/app/controllers/railspress/admin/posts_controller.rb +3 -3
- data/app/controllers/railspress/api/v1/posts_controller.rb +2 -2
- data/app/models/railspress/post.rb +10 -2
- data/lib/railspress/engine.rb +4 -2
- data/lib/railspress/entity.rb +19 -3
- data/lib/railspress/version.rb +1 -1
- data/lib/railspress.rb +6 -0
- metadata +29 -9
- /data/{app/helpers → lib}/railspress/cms_helper.rb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5a843f07c6d903605a67314573c816bbff6099640947e622e9c59a89ff88cbea
|
|
4
|
+
data.tar.gz: 17f4e1697c1dd88947460d5e93cb42cee3652677ce69fc456e4da1821e56b9b1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9bb75c97d3ace5d1fb54d6281d6ce4c2d17ac29cfd3d71821ba92cb22ecb7b4634a60b1015b0226755b52bc75e778d5ef9f1062976382843a03faa6b686990c8
|
|
7
|
+
data.tar.gz: 2aaca7f4a20c3f875bac0c37817f5eadb853c317ef72bf9d00100ad5ddf865ed000214b8e0e15155dd90033b21a1b1426a7ce3f576d610e5819398e6aa535ca7
|
data/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
<p align="center">
|
|
7
7
|
<a href="https://rubygems.org/gems/railspress-engine"><img src="https://img.shields.io/gem/v/railspress-engine.svg?style=flat&bump=true" alt="Gem Version"></a>
|
|
8
|
-
<img src="https://img.shields.io/badge/Rails-8.1%2B-red.svg?style=flat" alt="Rails 8.1+">
|
|
8
|
+
<img src="https://img.shields.io/badge/Rails-8.1.3.1%2B-red.svg?style=flat" alt="Rails 8.1.3.1+">
|
|
9
9
|
<img src="https://img.shields.io/badge/Ruby-3.3%2B-red.svg?style=flat" alt="Ruby 3.3+">
|
|
10
10
|
<a href="https://osaasy.dev/"><img src="https://img.shields.io/badge/License-O'Saasy-blue.svg?style=flat" alt="License"></a>
|
|
11
11
|
</p>
|
|
@@ -78,7 +78,7 @@ Most content doesn't fit neatly into "blog posts." A portfolio piece isn't a pos
|
|
|
78
78
|
|
|
79
79
|
## Requirements
|
|
80
80
|
|
|
81
|
-
- Rails 8.1+
|
|
81
|
+
- Rails 8.1.3.1+
|
|
82
82
|
- Ruby 3.3+
|
|
83
83
|
- ActionText
|
|
84
84
|
- Active Storage
|
|
@@ -94,21 +94,19 @@ rails active_storage:install
|
|
|
94
94
|
|
|
95
95
|
### Image variants
|
|
96
96
|
|
|
97
|
-
RailsPress can generate resized image variants for post header images and image helpers.
|
|
97
|
+
RailsPress can generate resized image variants for post header images and image helpers. RailsPress includes a secure version of `image_processing`, but Active Storage still needs a processor gem and its native system library.
|
|
98
98
|
|
|
99
|
-
Choose one processor and add
|
|
99
|
+
Choose one processor and add its gem to your application's `Gemfile`:
|
|
100
100
|
|
|
101
101
|
```ruby
|
|
102
|
-
# Recommended for
|
|
103
|
-
gem "
|
|
104
|
-
gem "ruby-vips", "~> 2.0"
|
|
102
|
+
# Recommended for Rails 8.1.3.1+ applications
|
|
103
|
+
gem "ruby-vips", "~> 2.2", ">= 2.2.1"
|
|
105
104
|
|
|
106
105
|
# Or use ImageMagick instead
|
|
107
|
-
# gem "image_processing", "~> 2.0"
|
|
108
106
|
# gem "mini_magick", "~> 5.0"
|
|
109
107
|
```
|
|
110
108
|
|
|
111
|
-
Install the matching system library in every environment where variants are generated:
|
|
109
|
+
Install the matching system library in every environment where variants are generated: libvips `8.13+` for `ruby-vips`, or [ImageMagick](https://imagemagick.org/) for `mini_magick`. Rails and ruby-vips cannot safely block untrusted libvips operations on older libvips releases. If your app uses ImageMagick, select it explicitly:
|
|
112
110
|
|
|
113
111
|
```ruby
|
|
114
112
|
# config/application.rb
|
|
@@ -9,15 +9,15 @@ module Railspress
|
|
|
9
9
|
@direction = params[:direction].presence || "desc"
|
|
10
10
|
|
|
11
11
|
@posts = Post.includes(:category, :tags)
|
|
12
|
-
.
|
|
12
|
+
.rp_search(params[:q])
|
|
13
13
|
.by_category(params[:category_id])
|
|
14
14
|
.by_status(params[:status])
|
|
15
15
|
.sorted_by(@sort, @direction)
|
|
16
16
|
|
|
17
17
|
@total_count = @posts.count
|
|
18
18
|
@page = [ params[:page].to_i, 1 ].max
|
|
19
|
-
@total_pages = (@total_count.to_f / Post
|
|
20
|
-
@posts = @posts.
|
|
19
|
+
@total_pages = (@total_count.to_f / Post.rp_per_page_count).ceil
|
|
20
|
+
@posts = @posts.rp_page(@page)
|
|
21
21
|
|
|
22
22
|
@categories = Category.ordered
|
|
23
23
|
end
|
|
@@ -102,8 +102,8 @@ module Railspress
|
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
def per_page
|
|
105
|
-
requested = params.fetch(:per, Railspress::Post.
|
|
106
|
-
requested = Railspress::Post.
|
|
105
|
+
requested = params.fetch(:per, Railspress::Post.rp_per_page_count).to_i
|
|
106
|
+
requested = Railspress::Post.rp_per_page_count if requested <= 0
|
|
107
107
|
[ requested, 100 ].min
|
|
108
108
|
end
|
|
109
109
|
|
|
@@ -74,14 +74,22 @@ module Railspress
|
|
|
74
74
|
before_save :set_published_at
|
|
75
75
|
before_save :set_reading_time, if: -> { reading_time.blank? && content.present? }
|
|
76
76
|
|
|
77
|
-
# Generic scopes (ordered, recent) and pagination (
|
|
77
|
+
# Generic scopes (ordered, recent) and pagination (rp_page) provided by Entity concern
|
|
78
78
|
# Post-specific scopes below:
|
|
79
79
|
scope :published, -> { where(status: :published).where(published_at: ..Time.current) }
|
|
80
80
|
scope :drafts, -> { where(status: :draft) }
|
|
81
81
|
scope :scheduled, -> { where(status: :published).where("published_at > ?", Time.current) }
|
|
82
82
|
scope :live, -> { published } # Alias for semantic clarity
|
|
83
83
|
scope :by_author, ->(author) { where(author_id: author.id) }
|
|
84
|
-
scope :
|
|
84
|
+
scope :rp_search, ->(query) {
|
|
85
|
+
query.present? ? where(arel_table[:title].matches("%#{query}%", nil, false)) : all
|
|
86
|
+
}
|
|
87
|
+
unless respond_to?(:search)
|
|
88
|
+
scope :search, ->(query) {
|
|
89
|
+
Railspress.deprecator.warn("search is deprecated and will be removed in RailsPress 2.0; use rp_search instead")
|
|
90
|
+
rp_search(query)
|
|
91
|
+
}
|
|
92
|
+
end
|
|
85
93
|
scope :by_category, ->(category_id) { where(category_id: category_id) if category_id.present? }
|
|
86
94
|
scope :by_status, ->(status) {
|
|
87
95
|
case status.to_s
|
data/lib/railspress/engine.rb
CHANGED
|
@@ -2,6 +2,10 @@ module Railspress
|
|
|
2
2
|
class Engine < ::Rails::Engine
|
|
3
3
|
isolate_namespace Railspress
|
|
4
4
|
|
|
5
|
+
initializer "railspress.deprecator" do |app|
|
|
6
|
+
app.deprecators[:railspress] = Railspress.deprecator
|
|
7
|
+
end
|
|
8
|
+
|
|
5
9
|
# Register engine assets with the asset pipeline (Propshaft)
|
|
6
10
|
initializer "railspress.assets" do |app|
|
|
7
11
|
if app.config.respond_to?(:assets)
|
|
@@ -15,8 +19,6 @@ module Railspress
|
|
|
15
19
|
|
|
16
20
|
# Make CMS helper available to host application views (or stub when disabled)
|
|
17
21
|
initializer "railspress.cms_helper" do
|
|
18
|
-
ActiveSupport::Dependencies.require_dependency(root.join("app/helpers/railspress/cms_helper").to_s)
|
|
19
|
-
|
|
20
22
|
ActiveSupport.on_load(:action_view) do
|
|
21
23
|
if Railspress.cms_enabled?
|
|
22
24
|
include Railspress::CmsHelper
|
data/lib/railspress/entity.rb
CHANGED
|
@@ -149,6 +149,22 @@ module Railspress
|
|
|
149
149
|
# Default scopes available to all entities
|
|
150
150
|
scope :ordered, -> { order(created_at: :desc) }
|
|
151
151
|
scope :recent, -> { ordered.limit(10) }
|
|
152
|
+
|
|
153
|
+
unless respond_to?(:page)
|
|
154
|
+
scope :page, ->(page_number) {
|
|
155
|
+
Railspress.deprecator.warn("page is deprecated and will be removed in RailsPress 2.0; use rp_page instead")
|
|
156
|
+
rp_page(page_number)
|
|
157
|
+
}
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
unless respond_to?(:per_page_count)
|
|
161
|
+
define_singleton_method(:per_page_count) do
|
|
162
|
+
Railspress.deprecator.warn(
|
|
163
|
+
"per_page_count is deprecated and will be removed in RailsPress 2.0; use rp_per_page_count instead"
|
|
164
|
+
)
|
|
165
|
+
rp_per_page_count
|
|
166
|
+
end
|
|
167
|
+
end
|
|
152
168
|
end
|
|
153
169
|
|
|
154
170
|
# Default pagination - can be overridden in model
|
|
@@ -156,13 +172,13 @@ module Railspress
|
|
|
156
172
|
|
|
157
173
|
class_methods do
|
|
158
174
|
# Simple pagination for index views
|
|
159
|
-
def
|
|
175
|
+
def rp_page(page_number)
|
|
160
176
|
page_number = [ page_number.to_i, 1 ].max
|
|
161
|
-
offset((page_number - 1) *
|
|
177
|
+
offset((page_number - 1) * rp_per_page_count).limit(rp_per_page_count)
|
|
162
178
|
end
|
|
163
179
|
|
|
164
180
|
# Allow models to override PER_PAGE
|
|
165
|
-
def
|
|
181
|
+
def rp_per_page_count
|
|
166
182
|
const_defined?(:PER_PAGE, false) ? const_get(:PER_PAGE) : Railspress::Entity::PER_PAGE
|
|
167
183
|
end
|
|
168
184
|
|
data/lib/railspress/version.rb
CHANGED
data/lib/railspress.rb
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
require "railspress/version"
|
|
2
|
+
require "active_support/deprecation"
|
|
3
|
+
require "railspress/cms_helper"
|
|
2
4
|
require "railspress/engine"
|
|
3
5
|
require "railspress/entity"
|
|
4
6
|
require "lexxy"
|
|
@@ -194,6 +196,10 @@ module Railspress
|
|
|
194
196
|
end
|
|
195
197
|
|
|
196
198
|
class << self
|
|
199
|
+
def deprecator
|
|
200
|
+
@deprecator ||= ActiveSupport::Deprecation.new("2.0", "RailsPress")
|
|
201
|
+
end
|
|
202
|
+
|
|
197
203
|
def configuration
|
|
198
204
|
@configuration ||= Configuration.new
|
|
199
205
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: railspress-engine
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.4.
|
|
4
|
+
version: 1.4.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Avi Flombaum
|
|
@@ -15,28 +15,48 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version:
|
|
18
|
+
version: 8.1.3.1
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version:
|
|
25
|
+
version: 8.1.3.1
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: lexxy
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version:
|
|
32
|
+
version: 0.9.29
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version:
|
|
39
|
+
version: 0.9.29
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: image_processing
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '2.0'
|
|
47
|
+
- - ">="
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: 2.0.3
|
|
50
|
+
type: :runtime
|
|
51
|
+
prerelease: false
|
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
53
|
+
requirements:
|
|
54
|
+
- - "~>"
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: '2.0'
|
|
57
|
+
- - ">="
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: 2.0.3
|
|
40
60
|
- !ruby/object:Gem::Dependency
|
|
41
61
|
name: rubyzip
|
|
42
62
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -187,7 +207,6 @@ files:
|
|
|
187
207
|
- app/controllers/railspress/application_controller.rb
|
|
188
208
|
- app/helpers/railspress/admin_helper.rb
|
|
189
209
|
- app/helpers/railspress/application_helper.rb
|
|
190
|
-
- app/helpers/railspress/cms_helper.rb
|
|
191
210
|
- app/javascript/railspress/controllers/cms_inline_editor_controller.js
|
|
192
211
|
- app/javascript/railspress/controllers/content_element_form_controller.js
|
|
193
212
|
- app/javascript/railspress/controllers/crop_controller.js
|
|
@@ -308,15 +327,16 @@ files:
|
|
|
308
327
|
- lib/railspress-engine.rb
|
|
309
328
|
- lib/railspress.rb
|
|
310
329
|
- lib/railspress/cms.rb
|
|
330
|
+
- lib/railspress/cms_helper.rb
|
|
311
331
|
- lib/railspress/engine.rb
|
|
312
332
|
- lib/railspress/entity.rb
|
|
313
333
|
- lib/railspress/version.rb
|
|
314
334
|
- lib/tasks/railspress_tasks.rake
|
|
315
|
-
homepage: https://
|
|
335
|
+
homepage: https://railspress.org
|
|
316
336
|
licenses:
|
|
317
337
|
- Nonstandard
|
|
318
338
|
metadata:
|
|
319
|
-
homepage_uri: https://
|
|
339
|
+
homepage_uri: https://railspress.org
|
|
320
340
|
source_code_uri: https://github.com/aviflombaum/railspress-engine
|
|
321
341
|
changelog_uri: https://github.com/aviflombaum/railspress-engine/blob/main/CHANGELOG.md
|
|
322
342
|
rubygems_mfa_required: 'true'
|
|
@@ -352,7 +372,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
352
372
|
- !ruby/object:Gem::Version
|
|
353
373
|
version: '0'
|
|
354
374
|
requirements: []
|
|
355
|
-
rubygems_version: 4.0.
|
|
375
|
+
rubygems_version: 4.0.18
|
|
356
376
|
specification_version: 4
|
|
357
377
|
summary: A mountable blog + CMS engine for Rails 8+
|
|
358
378
|
test_files: []
|
|
File without changes
|