railspress-engine 0.1.0
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +67 -0
- data/Rakefile +10 -0
- data/app/assets/javascripts/railspress/admin.js +210 -0
- data/app/assets/stylesheets/actiontext.css +440 -0
- data/app/assets/stylesheets/railspress/admin.css +1199 -0
- data/app/assets/stylesheets/railspress/application.css +15 -0
- data/app/controllers/railspress/admin/base_controller.rb +38 -0
- data/app/controllers/railspress/admin/categories_controller.rb +53 -0
- data/app/controllers/railspress/admin/dashboard_controller.rb +12 -0
- data/app/controllers/railspress/admin/posts_controller.rb +71 -0
- data/app/controllers/railspress/admin/tags_controller.rb +50 -0
- data/app/controllers/railspress/application_controller.rb +4 -0
- data/app/helpers/railspress/application_helper.rb +4 -0
- data/app/jobs/railspress/application_job.rb +4 -0
- data/app/mailers/railspress/application_mailer.rb +6 -0
- data/app/models/railspress/application_record.rb +6 -0
- data/app/models/railspress/category.rb +18 -0
- data/app/models/railspress/post.rb +74 -0
- data/app/models/railspress/post_tag.rb +8 -0
- data/app/models/railspress/tag.rb +32 -0
- data/app/views/active_storage/blobs/_blob.html.erb +14 -0
- data/app/views/layouts/action_text/contents/_content.html.erb +3 -0
- data/app/views/layouts/railspress/admin.html.erb +41 -0
- data/app/views/layouts/railspress/application.html.erb +17 -0
- data/app/views/railspress/admin/categories/_form.html.erb +32 -0
- data/app/views/railspress/admin/categories/edit.html.erb +6 -0
- data/app/views/railspress/admin/categories/index.html.erb +42 -0
- data/app/views/railspress/admin/categories/new.html.erb +6 -0
- data/app/views/railspress/admin/dashboard/index.html.erb +45 -0
- data/app/views/railspress/admin/posts/_form.html.erb +129 -0
- data/app/views/railspress/admin/posts/edit.html.erb +2 -0
- data/app/views/railspress/admin/posts/index.html.erb +55 -0
- data/app/views/railspress/admin/posts/new.html.erb +2 -0
- data/app/views/railspress/admin/posts/show.html.erb +47 -0
- data/app/views/railspress/admin/shared/_flash.html.erb +5 -0
- data/app/views/railspress/admin/shared/_sidebar.html.erb +38 -0
- data/app/views/railspress/admin/tags/_form.html.erb +27 -0
- data/app/views/railspress/admin/tags/edit.html.erb +6 -0
- data/app/views/railspress/admin/tags/index.html.erb +42 -0
- data/app/views/railspress/admin/tags/new.html.erb +6 -0
- data/config/routes.rb +9 -0
- data/db/migrate/20241218000001_create_railspress_categories.rb +14 -0
- data/db/migrate/20241218000002_create_railspress_tags.rb +13 -0
- data/db/migrate/20241218000003_create_railspress_posts.rb +19 -0
- data/db/migrate/20241218000004_create_railspress_post_tags.rb +12 -0
- data/lib/generators/railspress/authors/authors_generator.rb +73 -0
- data/lib/generators/railspress/authors/templates/add_author_to_railspress_posts.rb.tt +8 -0
- data/lib/generators/railspress/authors/templates/railspress.rb.tt +31 -0
- data/lib/generators/railspress/install/install_generator.rb +144 -0
- data/lib/railspress/engine.rb +14 -0
- data/lib/railspress/version.rb +3 -0
- data/lib/railspress.rb +79 -0
- data/lib/tasks/railspress_tasks.rake +4 -0
- metadata +141 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 83cef2533b9cfb4d04ebbe72a8683d015b0c39bb39e02b30ec1f66123fca7206
|
|
4
|
+
data.tar.gz: 1921da5342d848aeccf0d3c5ae5cd6cd4be5cc2ea27904a47c302aa127b851a5
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 1ba3aba96da1e28537df7e157809719ad079275c39a92fc7626b6a138caece96eef402e017fe02be62eb1fa2c834882f31528e68eea3033889303cde5c053986
|
|
7
|
+
data.tar.gz: c517a5f11a6d36b372a79bf14e191c281de0b23be9dc54160077c62c247fe2690e33389af4489094486a4133e83f510bcf409a5b8e86ed4106153d214ae38297
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright Avi Flombaum
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# RailsPress
|
|
2
|
+
|
|
3
|
+
A simple blog engine for Rails 8 applications.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Blog posts with rich text editing (ActionText)
|
|
8
|
+
- Categories and tags
|
|
9
|
+
- SEO metadata (meta title, meta description)
|
|
10
|
+
- Draft/published workflow with automatic publish timestamps
|
|
11
|
+
- Admin interface for content management
|
|
12
|
+
|
|
13
|
+
## Requirements
|
|
14
|
+
|
|
15
|
+
- Rails 8.0+
|
|
16
|
+
- Ruby 3.3+
|
|
17
|
+
- ActionText (for rich text)
|
|
18
|
+
- Active Storage (for image uploads)
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
Add to your Gemfile:
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
gem "railspress"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Install the gem and copy migrations:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
bundle install
|
|
32
|
+
rails railspress:install:migrations
|
|
33
|
+
rails db:migrate
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Mount the engine in your routes:
|
|
37
|
+
|
|
38
|
+
```ruby
|
|
39
|
+
# config/routes.rb
|
|
40
|
+
Rails.application.routes.draw do
|
|
41
|
+
mount Railspress::Engine => "/blog", as: :railspress
|
|
42
|
+
end
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
Access the admin interface at `/blog/admin`.
|
|
48
|
+
|
|
49
|
+
From there you can:
|
|
50
|
+
- Create and manage blog posts with rich text content
|
|
51
|
+
- Organize posts with categories
|
|
52
|
+
- Tag posts (enter tags as comma-separated values)
|
|
53
|
+
- Save posts as drafts or publish them
|
|
54
|
+
|
|
55
|
+
## Development
|
|
56
|
+
|
|
57
|
+
After checking out the repo:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
bundle install
|
|
61
|
+
cd spec/dummy && bundle exec rails db:migrate && cd ../..
|
|
62
|
+
bundle exec rspec
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## License
|
|
66
|
+
|
|
67
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RailsPress Admin JavaScript
|
|
3
|
+
* Vanilla JS for mobile menu and slug generation
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
(function() {
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
// ============================================
|
|
10
|
+
// Mobile Menu Toggle
|
|
11
|
+
// ============================================
|
|
12
|
+
|
|
13
|
+
function initMobileMenu() {
|
|
14
|
+
const hamburger = document.querySelector('.rp-hamburger');
|
|
15
|
+
const sidebar = document.querySelector('.rp-sidebar');
|
|
16
|
+
const overlay = document.querySelector('.rp-overlay');
|
|
17
|
+
|
|
18
|
+
if (!hamburger || !sidebar) return;
|
|
19
|
+
|
|
20
|
+
function openMenu() {
|
|
21
|
+
sidebar.classList.add('rp-sidebar--open');
|
|
22
|
+
overlay?.classList.add('rp-overlay--visible');
|
|
23
|
+
document.body.style.overflow = 'hidden';
|
|
24
|
+
hamburger.setAttribute('aria-expanded', 'true');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function closeMenu() {
|
|
28
|
+
sidebar.classList.remove('rp-sidebar--open');
|
|
29
|
+
overlay?.classList.remove('rp-overlay--visible');
|
|
30
|
+
document.body.style.overflow = '';
|
|
31
|
+
hamburger.setAttribute('aria-expanded', 'false');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
hamburger.addEventListener('click', function() {
|
|
35
|
+
const isOpen = sidebar.classList.contains('rp-sidebar--open');
|
|
36
|
+
if (isOpen) {
|
|
37
|
+
closeMenu();
|
|
38
|
+
} else {
|
|
39
|
+
openMenu();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
overlay?.addEventListener('click', closeMenu);
|
|
44
|
+
|
|
45
|
+
// Close on escape key
|
|
46
|
+
document.addEventListener('keydown', function(e) {
|
|
47
|
+
if (e.key === 'Escape' && sidebar.classList.contains('rp-sidebar--open')) {
|
|
48
|
+
closeMenu();
|
|
49
|
+
hamburger.focus();
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Close on nav link click (mobile)
|
|
54
|
+
const navLinks = sidebar.querySelectorAll('.rp-nav-link');
|
|
55
|
+
navLinks.forEach(function(link) {
|
|
56
|
+
link.addEventListener('click', function() {
|
|
57
|
+
if (window.innerWidth < 768) {
|
|
58
|
+
closeMenu();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Handle resize
|
|
64
|
+
let resizeTimer;
|
|
65
|
+
window.addEventListener('resize', function() {
|
|
66
|
+
clearTimeout(resizeTimer);
|
|
67
|
+
resizeTimer = setTimeout(function() {
|
|
68
|
+
if (window.innerWidth >= 768) {
|
|
69
|
+
closeMenu();
|
|
70
|
+
}
|
|
71
|
+
}, 100);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ============================================
|
|
76
|
+
// Slug Generator
|
|
77
|
+
// ============================================
|
|
78
|
+
|
|
79
|
+
function initSlugGenerator() {
|
|
80
|
+
const sourceInput = document.querySelector('[data-slug-source]');
|
|
81
|
+
const slugInput = document.querySelector('[data-slug-target]');
|
|
82
|
+
|
|
83
|
+
if (!sourceInput || !slugInput) return;
|
|
84
|
+
|
|
85
|
+
let isAutoGenerated = !slugInput.value;
|
|
86
|
+
|
|
87
|
+
function generateSlug(text) {
|
|
88
|
+
return text
|
|
89
|
+
.toLowerCase()
|
|
90
|
+
.trim()
|
|
91
|
+
.replace(/[^\w\s-]/g, '') // Remove special chars
|
|
92
|
+
.replace(/\s+/g, '-') // Replace spaces with dashes
|
|
93
|
+
.replace(/-+/g, '-') // Collapse multiple dashes
|
|
94
|
+
.replace(/^-+|-+$/g, ''); // Trim dashes from ends
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
sourceInput.addEventListener('input', function() {
|
|
98
|
+
if (isAutoGenerated) {
|
|
99
|
+
slugInput.value = generateSlug(this.value);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// Stop auto-generating if user manually edits slug
|
|
104
|
+
slugInput.addEventListener('input', function() {
|
|
105
|
+
isAutoGenerated = false;
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Resume auto-generation if slug is cleared
|
|
109
|
+
slugInput.addEventListener('blur', function() {
|
|
110
|
+
if (!this.value) {
|
|
111
|
+
isAutoGenerated = true;
|
|
112
|
+
if (sourceInput.value) {
|
|
113
|
+
this.value = generateSlug(sourceInput.value);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// ============================================
|
|
120
|
+
// Delete Confirmation
|
|
121
|
+
// ============================================
|
|
122
|
+
|
|
123
|
+
function initDeleteConfirmation() {
|
|
124
|
+
const deleteButtons = document.querySelectorAll('[data-confirm]');
|
|
125
|
+
|
|
126
|
+
deleteButtons.forEach(function(button) {
|
|
127
|
+
button.addEventListener('click', function(e) {
|
|
128
|
+
const message = this.dataset.confirm || 'Are you sure?';
|
|
129
|
+
if (!confirm(message)) {
|
|
130
|
+
e.preventDefault();
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// ============================================
|
|
137
|
+
// Flash Message Auto-dismiss
|
|
138
|
+
// ============================================
|
|
139
|
+
|
|
140
|
+
function initFlashMessages() {
|
|
141
|
+
const flashes = document.querySelectorAll('.rp-flash');
|
|
142
|
+
|
|
143
|
+
flashes.forEach(function(flash) {
|
|
144
|
+
// Add close button
|
|
145
|
+
const closeBtn = document.createElement('button');
|
|
146
|
+
closeBtn.innerHTML = '×';
|
|
147
|
+
closeBtn.className = 'rp-flash-close';
|
|
148
|
+
closeBtn.style.cssText = 'background: none; border: none; font-size: 1.25rem; cursor: pointer; margin-left: auto; opacity: 0.7;';
|
|
149
|
+
closeBtn.setAttribute('aria-label', 'Dismiss');
|
|
150
|
+
|
|
151
|
+
closeBtn.addEventListener('click', function() {
|
|
152
|
+
flash.style.opacity = '0';
|
|
153
|
+
flash.style.transform = 'translateY(-10px)';
|
|
154
|
+
setTimeout(function() {
|
|
155
|
+
flash.remove();
|
|
156
|
+
}, 200);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
flash.appendChild(closeBtn);
|
|
160
|
+
|
|
161
|
+
// Auto-dismiss after 5 seconds
|
|
162
|
+
setTimeout(function() {
|
|
163
|
+
flash.style.opacity = '0';
|
|
164
|
+
flash.style.transform = 'translateY(-10px)';
|
|
165
|
+
setTimeout(function() {
|
|
166
|
+
flash.remove();
|
|
167
|
+
}, 200);
|
|
168
|
+
}, 5000);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// ============================================
|
|
173
|
+
// Form Validation Styles
|
|
174
|
+
// ============================================
|
|
175
|
+
|
|
176
|
+
function initFormValidation() {
|
|
177
|
+
const inputs = document.querySelectorAll('.rp-input, .rp-select');
|
|
178
|
+
|
|
179
|
+
inputs.forEach(function(input) {
|
|
180
|
+
input.addEventListener('invalid', function() {
|
|
181
|
+
this.style.borderColor = 'var(--rp-danger)';
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
input.addEventListener('input', function() {
|
|
185
|
+
if (this.validity.valid) {
|
|
186
|
+
this.style.borderColor = '';
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// ============================================
|
|
193
|
+
// Initialize on DOM Ready
|
|
194
|
+
// ============================================
|
|
195
|
+
|
|
196
|
+
function init() {
|
|
197
|
+
initMobileMenu();
|
|
198
|
+
initSlugGenerator();
|
|
199
|
+
initDeleteConfirmation();
|
|
200
|
+
initFlashMessages();
|
|
201
|
+
initFormValidation();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (document.readyState === 'loading') {
|
|
205
|
+
document.addEventListener('DOMContentLoaded', init);
|
|
206
|
+
} else {
|
|
207
|
+
init();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
})();
|