railspress-engine 0.1.0 → 0.1.2
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/app/assets/stylesheets/railspress/admin.css +9 -1
- data/app/controllers/railspress/admin/base_controller.rb +8 -3
- data/app/views/railspress/admin/posts/_form.html.erb +1 -1
- data/app/views/railspress/admin/posts/show.html.erb +1 -1
- data/db/migrate/20241218000003_create_railspress_posts.rb +2 -0
- data/lib/generators/railspress/install/install_generator.rb +3 -3
- data/lib/railspress/version.rb +1 -1
- data/lib/railspress-engine.rb +5 -0
- data/lib/railspress.rb +6 -0
- metadata +2 -4
- data/lib/generators/railspress/authors/authors_generator.rb +0 -73
- data/lib/generators/railspress/authors/templates/add_author_to_railspress_posts.rb.tt +0 -8
- data/lib/generators/railspress/authors/templates/railspress.rb.tt +0 -31
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 23a09596799a0a89eefd920154a5aefdcae1a4247ebbfb8f161781a87adaa462
|
|
4
|
+
data.tar.gz: 3b8b24840927df71dedc373457eeb082cf429932e6542eceeec06cf59195cfea
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4ad75a1e6057939610e32fef6b4add2a5d4eb4b5ff47621801f45a74414205c0d30ac5e308e21b612e26d774d19f6cd488e7655dd4626772a8c7e837997680d2
|
|
7
|
+
data.tar.gz: 4f011c5faf57b329fb81ae904ff2da1ef0df5a373b7e3c41c31c16af5bc661eeddb67430daf8e8def0b9cc4f899802217287ebbfeb235e51cf1567d0067aa0d1
|
|
@@ -662,7 +662,7 @@ textarea.rp-input {
|
|
|
662
662
|
|
|
663
663
|
/* Rich text placeholder */
|
|
664
664
|
.rp-rich-text {
|
|
665
|
-
min-height:
|
|
665
|
+
min-height: 670px;
|
|
666
666
|
border: 1px solid var(--rp-border);
|
|
667
667
|
border-radius: var(--rp-radius);
|
|
668
668
|
background: var(--rp-bg-elevated);
|
|
@@ -1197,3 +1197,11 @@ textarea.rp-input {
|
|
|
1197
1197
|
height: 16px;
|
|
1198
1198
|
cursor: pointer;
|
|
1199
1199
|
}
|
|
1200
|
+
|
|
1201
|
+
/* ============================================
|
|
1202
|
+
Lexxy
|
|
1203
|
+
============================================ */
|
|
1204
|
+
|
|
1205
|
+
:where(lexxy-toolbar){
|
|
1206
|
+
margin-bottom: 20px;
|
|
1207
|
+
}
|
|
@@ -24,9 +24,14 @@ module Railspress
|
|
|
24
24
|
|
|
25
25
|
def current_author
|
|
26
26
|
return nil unless authors_enabled?
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
|
|
28
|
+
# Use proc if configured (most flexible)
|
|
29
|
+
if Railspress.current_author_proc
|
|
30
|
+
instance_exec(&Railspress.current_author_proc)
|
|
31
|
+
# Otherwise try to call the configured method on self
|
|
32
|
+
elsif respond_to?(Railspress.current_author_method, true)
|
|
33
|
+
send(Railspress.current_author_method)
|
|
34
|
+
end
|
|
30
35
|
end
|
|
31
36
|
|
|
32
37
|
def available_authors
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
<div class="rp-form-group">
|
|
84
84
|
<% if @post.header_image.attached? %>
|
|
85
85
|
<div class="rp-header-image-preview">
|
|
86
|
-
<%= image_tag @post.header_image.variant(resize_to_limit: [400, 300]), class: "rp-header-image-thumb" %>
|
|
86
|
+
<%= image_tag main_app.url_for(@post.header_image.variant(resize_to_limit: [400, 300])), class: "rp-header-image-thumb" %>
|
|
87
87
|
</div>
|
|
88
88
|
<% end %>
|
|
89
89
|
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
<% if header_images_enabled? && @post.header_image.attached? %>
|
|
30
30
|
<div class="rp-header-image">
|
|
31
|
-
<%= image_tag @post.header_image.variant(resize_to_limit: [1200, 630]), class: "rp-header-image-full" %>
|
|
31
|
+
<%= image_tag main_app.url_for(@post.header_image.variant(resize_to_limit: [1200, 630])), class: "rp-header-image-full" %>
|
|
32
32
|
</div>
|
|
33
33
|
<% end %>
|
|
34
34
|
|
|
@@ -4,6 +4,7 @@ class CreateRailspressPosts < ActiveRecord::Migration[8.0]
|
|
|
4
4
|
t.string :title, null: false
|
|
5
5
|
t.string :slug, null: false
|
|
6
6
|
t.references :category, null: true, foreign_key: { to_table: :railspress_categories }
|
|
7
|
+
t.bigint :author_id
|
|
7
8
|
t.integer :status, default: 0, null: false
|
|
8
9
|
t.datetime :published_at
|
|
9
10
|
t.string :meta_title
|
|
@@ -15,5 +16,6 @@ class CreateRailspressPosts < ActiveRecord::Migration[8.0]
|
|
|
15
16
|
add_index :railspress_posts, :slug, unique: true
|
|
16
17
|
add_index :railspress_posts, :status
|
|
17
18
|
add_index :railspress_posts, :published_at
|
|
19
|
+
add_index :railspress_posts, :author_id
|
|
18
20
|
end
|
|
19
21
|
end
|
|
@@ -11,7 +11,7 @@ module Railspress
|
|
|
11
11
|
desc "Install RailsPress: copy migrations, mount engine, and configure JavaScript"
|
|
12
12
|
|
|
13
13
|
def copy_railspress_migrations
|
|
14
|
-
rake
|
|
14
|
+
run "bundle exec rake railspress:install:migrations"
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def copy_action_text_migrations
|
|
@@ -19,7 +19,7 @@ module Railspress
|
|
|
19
19
|
say_status :skip, "ActionText migrations already exist", :yellow
|
|
20
20
|
else
|
|
21
21
|
say_status :create, "ActionText migrations", :green
|
|
22
|
-
rake
|
|
22
|
+
run "bundle exec rake railties:install:migrations FROM=action_text"
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
@@ -28,7 +28,7 @@ module Railspress
|
|
|
28
28
|
say_status :skip, "ActiveStorage migrations already exist", :yellow
|
|
29
29
|
else
|
|
30
30
|
say_status :create, "ActiveStorage migrations", :green
|
|
31
|
-
rake
|
|
31
|
+
run "bundle exec rake railties:install:migrations FROM=active_storage"
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
data/lib/railspress/version.rb
CHANGED
data/lib/railspress.rb
CHANGED
|
@@ -6,6 +6,7 @@ module Railspress
|
|
|
6
6
|
class Configuration
|
|
7
7
|
attr_accessor :author_class_name,
|
|
8
8
|
:current_author_method,
|
|
9
|
+
:current_author_proc,
|
|
9
10
|
:author_scope,
|
|
10
11
|
:author_display_method
|
|
11
12
|
|
|
@@ -16,6 +17,7 @@ module Railspress
|
|
|
16
17
|
@header_images_enabled = false
|
|
17
18
|
@author_class_name = "User"
|
|
18
19
|
@current_author_method = :current_user
|
|
20
|
+
@current_author_proc = nil
|
|
19
21
|
@author_scope = nil
|
|
20
22
|
@author_display_method = :name
|
|
21
23
|
end
|
|
@@ -75,5 +77,9 @@ module Railspress
|
|
|
75
77
|
def current_author_method
|
|
76
78
|
configuration.current_author_method
|
|
77
79
|
end
|
|
80
|
+
|
|
81
|
+
def current_author_proc
|
|
82
|
+
configuration.current_author_proc
|
|
83
|
+
end
|
|
78
84
|
end
|
|
79
85
|
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: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Avi Flombaum
|
|
@@ -91,10 +91,8 @@ files:
|
|
|
91
91
|
- db/migrate/20241218000002_create_railspress_tags.rb
|
|
92
92
|
- db/migrate/20241218000003_create_railspress_posts.rb
|
|
93
93
|
- db/migrate/20241218000004_create_railspress_post_tags.rb
|
|
94
|
-
- lib/generators/railspress/authors/authors_generator.rb
|
|
95
|
-
- lib/generators/railspress/authors/templates/add_author_to_railspress_posts.rb.tt
|
|
96
|
-
- lib/generators/railspress/authors/templates/railspress.rb.tt
|
|
97
94
|
- lib/generators/railspress/install/install_generator.rb
|
|
95
|
+
- lib/railspress-engine.rb
|
|
98
96
|
- lib/railspress.rb
|
|
99
97
|
- lib/railspress/engine.rb
|
|
100
98
|
- lib/railspress/version.rb
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "rails/generators"
|
|
4
|
-
require "rails/generators/base"
|
|
5
|
-
|
|
6
|
-
module Railspress
|
|
7
|
-
module Generators
|
|
8
|
-
class AuthorsGenerator < Rails::Generators::Base
|
|
9
|
-
source_root File.expand_path("templates", __dir__)
|
|
10
|
-
|
|
11
|
-
desc "Enable author support for RailsPress posts"
|
|
12
|
-
|
|
13
|
-
def create_migration
|
|
14
|
-
migration_template(
|
|
15
|
-
"add_author_to_railspress_posts.rb.tt",
|
|
16
|
-
"db/migrate/add_author_to_railspress_posts.rb",
|
|
17
|
-
migration_version: migration_version
|
|
18
|
-
)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def create_initializer
|
|
22
|
-
if initializer_exists?
|
|
23
|
-
say_status :skip, "config/initializers/railspress.rb already exists", :yellow
|
|
24
|
-
say ""
|
|
25
|
-
say "Add the following to your existing initializer:", :yellow
|
|
26
|
-
say ""
|
|
27
|
-
say " config.enable_authors", :cyan
|
|
28
|
-
say " config.author_class_name = \"User\"", :cyan
|
|
29
|
-
say " # config.author_scope = :admins", :cyan
|
|
30
|
-
say " # config.author_display_method = :name", :cyan
|
|
31
|
-
say ""
|
|
32
|
-
else
|
|
33
|
-
template "railspress.rb.tt", "config/initializers/railspress.rb"
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def show_post_install_message
|
|
38
|
-
say ""
|
|
39
|
-
say "=" * 60, :green
|
|
40
|
-
say " RailsPress Authors enabled!", :green
|
|
41
|
-
say "=" * 60, :green
|
|
42
|
-
say ""
|
|
43
|
-
say "Next steps:", :yellow
|
|
44
|
-
say ""
|
|
45
|
-
say " 1. Run migrations:"
|
|
46
|
-
say " $ rails db:migrate", :cyan
|
|
47
|
-
say ""
|
|
48
|
-
say " 2. Configure authors in config/initializers/railspress.rb", :cyan
|
|
49
|
-
say ""
|
|
50
|
-
say " 3. (Optional) Add an author scope to your User model:"
|
|
51
|
-
say " scope :authors, -> { where(role: :admin) }", :cyan
|
|
52
|
-
say ""
|
|
53
|
-
say "=" * 60, :green
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
private
|
|
57
|
-
|
|
58
|
-
def initializer_exists?
|
|
59
|
-
File.exist?(Rails.root.join("config", "initializers", "railspress.rb"))
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def migration_version
|
|
63
|
-
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
# Required for migration_template to work
|
|
67
|
-
def self.next_migration_number(dirname)
|
|
68
|
-
next_migration_number = current_migration_number(dirname) + 1
|
|
69
|
-
ActiveRecord::Migration.next_migration_number(next_migration_number)
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
Railspress.configure do |config|
|
|
4
|
-
# ==========================================================================
|
|
5
|
-
# Authors
|
|
6
|
-
# ==========================================================================
|
|
7
|
-
|
|
8
|
-
# Enable author tracking on posts
|
|
9
|
-
# When enabled, posts can have an author and the admin form shows an author select
|
|
10
|
-
config.enable_authors
|
|
11
|
-
|
|
12
|
-
# The class name of your author model (default: "User")
|
|
13
|
-
config.author_class_name = "User"
|
|
14
|
-
|
|
15
|
-
# Controller method that returns the current user (default: :current_user)
|
|
16
|
-
# Used to pre-select the author on new posts
|
|
17
|
-
# config.current_author_method = :current_user
|
|
18
|
-
|
|
19
|
-
# Scope for which users appear in the author dropdown (default: nil = all)
|
|
20
|
-
# Pass a symbol to call a scope on the author class, or a lambda for custom logic
|
|
21
|
-
#
|
|
22
|
-
# Examples:
|
|
23
|
-
# config.author_scope = :admins # calls User.admins
|
|
24
|
-
# config.author_scope = :authors # calls User.authors
|
|
25
|
-
# config.author_scope = ->(klass) { klass.active } # custom filtering
|
|
26
|
-
#
|
|
27
|
-
# config.author_scope = nil
|
|
28
|
-
|
|
29
|
-
# Method called on author to display in the dropdown (default: :name)
|
|
30
|
-
# config.author_display_method = :name
|
|
31
|
-
end
|