perron 0.0.1 → 0.5.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 +4 -4
- data/Gemfile +17 -0
- data/Gemfile.lock +269 -0
- data/README.md +182 -0
- data/Rakefile +9 -0
- data/app/helpers/meta_tags_helper.rb +17 -0
- data/app/helpers/perron/markdown_helper.rb +9 -0
- data/bin/console +10 -0
- data/bin/rails +17 -0
- data/bin/release +19 -0
- data/bin/setup +8 -0
- data/lib/generators/content/content_generator.rb +45 -0
- data/lib/generators/content/templates/controller.rb.tt +17 -0
- data/lib/generators/content/templates/index.html.erb.tt +11 -0
- data/lib/generators/content/templates/model.rb.tt +2 -0
- data/lib/generators/content/templates/root.erb.tt +5 -0
- data/lib/generators/content/templates/show.html.erb.tt +7 -0
- data/lib/generators/perron/install_generator.rb +9 -0
- data/lib/generators/perron/templates/initializer.rb.tt +22 -0
- data/lib/perron/configuration.rb +63 -0
- data/lib/perron/engine.rb +13 -0
- data/lib/perron/errors.rb +9 -0
- data/lib/perron/html_processor/target_blank.rb +23 -0
- data/lib/perron/html_processor.rb +28 -0
- data/lib/perron/markdown.rb +54 -0
- data/lib/perron/metatags.rb +82 -0
- data/lib/perron/refinements/delete_suffixes.rb +12 -0
- data/lib/perron/root.rb +13 -0
- data/lib/perron/site/builder/assets.rb +67 -0
- data/lib/perron/site/builder/page.rb +51 -0
- data/lib/perron/site/builder/paths.rb +40 -0
- data/lib/perron/site/builder/public_files.rb +40 -0
- data/lib/perron/site/builder.rb +44 -0
- data/lib/perron/site/collection.rb +28 -0
- data/lib/perron/site/resource/class_methods.rb +43 -0
- data/lib/perron/site/resource/context.rb +13 -0
- data/lib/perron/site/resource/core.rb +15 -0
- data/lib/perron/site/resource/publishable.rb +51 -0
- data/lib/perron/site/resource/separator.rb +31 -0
- data/lib/perron/site/resource/slug.rb +20 -0
- data/lib/perron/site/resource.rb +62 -0
- data/lib/perron/site.rb +33 -0
- data/lib/perron/tasks/perron.rake +12 -0
- data/lib/perron/version.rb +3 -0
- data/lib/perron.rb +11 -1
- data/perron.gemspec +22 -0
- metadata +69 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa3f2904ac098e13aff67d7153df4867f4301a9c273d06963d3ff0330f97fe86
|
4
|
+
data.tar.gz: e53143e80f15e7fd1cf00b789959e2c0399f1f547459a39ecf927f6859bfd8f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e7a6e6594f349a7f6f575d5e7bdc1a54234446846695b848c0ff1e982a2de22898c85749b39af4196f64ba44d991b4d25878f4f8451d5ef4fd8fb9fa093c1e6
|
7
|
+
data.tar.gz: 7055bbf79e0635ce0e2f38c3397f3e20bb76c70dd228ed5482be2fdf9bfe3d38d986e24a1a632420795adbad36cf5019cde704187fd7d9408cd990122fd209fe
|
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gemspec
|
6
|
+
|
7
|
+
gem "rails", "~> 7.2.0"
|
8
|
+
|
9
|
+
group :development do
|
10
|
+
gem "standard", "~> 1.50.0"
|
11
|
+
end
|
12
|
+
|
13
|
+
group :development, :test do
|
14
|
+
gem "rake", "~> 13.3.0"
|
15
|
+
gem "minitest", "~> 5.25", ">= 5.25.5"
|
16
|
+
gem "debug", "~> 1.11.0"
|
17
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,269 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
perron (0.5.0)
|
5
|
+
rails (>= 7.2.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actioncable (7.2.2.1)
|
11
|
+
actionpack (= 7.2.2.1)
|
12
|
+
activesupport (= 7.2.2.1)
|
13
|
+
nio4r (~> 2.0)
|
14
|
+
websocket-driver (>= 0.6.1)
|
15
|
+
zeitwerk (~> 2.6)
|
16
|
+
actionmailbox (7.2.2.1)
|
17
|
+
actionpack (= 7.2.2.1)
|
18
|
+
activejob (= 7.2.2.1)
|
19
|
+
activerecord (= 7.2.2.1)
|
20
|
+
activestorage (= 7.2.2.1)
|
21
|
+
activesupport (= 7.2.2.1)
|
22
|
+
mail (>= 2.8.0)
|
23
|
+
actionmailer (7.2.2.1)
|
24
|
+
actionpack (= 7.2.2.1)
|
25
|
+
actionview (= 7.2.2.1)
|
26
|
+
activejob (= 7.2.2.1)
|
27
|
+
activesupport (= 7.2.2.1)
|
28
|
+
mail (>= 2.8.0)
|
29
|
+
rails-dom-testing (~> 2.2)
|
30
|
+
actionpack (7.2.2.1)
|
31
|
+
actionview (= 7.2.2.1)
|
32
|
+
activesupport (= 7.2.2.1)
|
33
|
+
nokogiri (>= 1.8.5)
|
34
|
+
racc
|
35
|
+
rack (>= 2.2.4, < 3.2)
|
36
|
+
rack-session (>= 1.0.1)
|
37
|
+
rack-test (>= 0.6.3)
|
38
|
+
rails-dom-testing (~> 2.2)
|
39
|
+
rails-html-sanitizer (~> 1.6)
|
40
|
+
useragent (~> 0.16)
|
41
|
+
actiontext (7.2.2.1)
|
42
|
+
actionpack (= 7.2.2.1)
|
43
|
+
activerecord (= 7.2.2.1)
|
44
|
+
activestorage (= 7.2.2.1)
|
45
|
+
activesupport (= 7.2.2.1)
|
46
|
+
globalid (>= 0.6.0)
|
47
|
+
nokogiri (>= 1.8.5)
|
48
|
+
actionview (7.2.2.1)
|
49
|
+
activesupport (= 7.2.2.1)
|
50
|
+
builder (~> 3.1)
|
51
|
+
erubi (~> 1.11)
|
52
|
+
rails-dom-testing (~> 2.2)
|
53
|
+
rails-html-sanitizer (~> 1.6)
|
54
|
+
activejob (7.2.2.1)
|
55
|
+
activesupport (= 7.2.2.1)
|
56
|
+
globalid (>= 0.3.6)
|
57
|
+
activemodel (7.2.2.1)
|
58
|
+
activesupport (= 7.2.2.1)
|
59
|
+
activerecord (7.2.2.1)
|
60
|
+
activemodel (= 7.2.2.1)
|
61
|
+
activesupport (= 7.2.2.1)
|
62
|
+
timeout (>= 0.4.0)
|
63
|
+
activestorage (7.2.2.1)
|
64
|
+
actionpack (= 7.2.2.1)
|
65
|
+
activejob (= 7.2.2.1)
|
66
|
+
activerecord (= 7.2.2.1)
|
67
|
+
activesupport (= 7.2.2.1)
|
68
|
+
marcel (~> 1.0)
|
69
|
+
activesupport (7.2.2.1)
|
70
|
+
base64
|
71
|
+
benchmark (>= 0.3)
|
72
|
+
bigdecimal
|
73
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
74
|
+
connection_pool (>= 2.2.5)
|
75
|
+
drb
|
76
|
+
i18n (>= 1.6, < 2)
|
77
|
+
logger (>= 1.4.2)
|
78
|
+
minitest (>= 5.1)
|
79
|
+
securerandom (>= 0.3)
|
80
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
81
|
+
ast (2.4.3)
|
82
|
+
base64 (0.3.0)
|
83
|
+
benchmark (0.4.1)
|
84
|
+
bigdecimal (3.2.2)
|
85
|
+
builder (3.3.0)
|
86
|
+
concurrent-ruby (1.3.5)
|
87
|
+
connection_pool (2.5.3)
|
88
|
+
crass (1.0.6)
|
89
|
+
date (3.4.1)
|
90
|
+
debug (1.11.0)
|
91
|
+
irb (~> 1.10)
|
92
|
+
reline (>= 0.3.8)
|
93
|
+
drb (2.2.3)
|
94
|
+
erb (5.0.1)
|
95
|
+
erubi (1.13.1)
|
96
|
+
globalid (1.2.1)
|
97
|
+
activesupport (>= 6.1)
|
98
|
+
i18n (1.14.7)
|
99
|
+
concurrent-ruby (~> 1.0)
|
100
|
+
io-console (0.8.0)
|
101
|
+
irb (1.15.2)
|
102
|
+
pp (>= 0.6.0)
|
103
|
+
rdoc (>= 4.0.0)
|
104
|
+
reline (>= 0.4.2)
|
105
|
+
json (2.12.2)
|
106
|
+
language_server-protocol (3.17.0.5)
|
107
|
+
lint_roller (1.1.0)
|
108
|
+
logger (1.7.0)
|
109
|
+
loofah (2.24.1)
|
110
|
+
crass (~> 1.0.2)
|
111
|
+
nokogiri (>= 1.12.0)
|
112
|
+
mail (2.8.1)
|
113
|
+
mini_mime (>= 0.1.1)
|
114
|
+
net-imap
|
115
|
+
net-pop
|
116
|
+
net-smtp
|
117
|
+
marcel (1.0.4)
|
118
|
+
mini_mime (1.1.5)
|
119
|
+
minitest (5.25.5)
|
120
|
+
net-imap (0.5.9)
|
121
|
+
date
|
122
|
+
net-protocol
|
123
|
+
net-pop (0.1.2)
|
124
|
+
net-protocol
|
125
|
+
net-protocol (0.2.2)
|
126
|
+
timeout
|
127
|
+
net-smtp (0.5.1)
|
128
|
+
net-protocol
|
129
|
+
nio4r (2.7.4)
|
130
|
+
nokogiri (1.18.8-aarch64-linux-gnu)
|
131
|
+
racc (~> 1.4)
|
132
|
+
nokogiri (1.18.8-aarch64-linux-musl)
|
133
|
+
racc (~> 1.4)
|
134
|
+
nokogiri (1.18.8-arm-linux-gnu)
|
135
|
+
racc (~> 1.4)
|
136
|
+
nokogiri (1.18.8-arm-linux-musl)
|
137
|
+
racc (~> 1.4)
|
138
|
+
nokogiri (1.18.8-arm64-darwin)
|
139
|
+
racc (~> 1.4)
|
140
|
+
nokogiri (1.18.8-x86_64-darwin)
|
141
|
+
racc (~> 1.4)
|
142
|
+
nokogiri (1.18.8-x86_64-linux-gnu)
|
143
|
+
racc (~> 1.4)
|
144
|
+
nokogiri (1.18.8-x86_64-linux-musl)
|
145
|
+
racc (~> 1.4)
|
146
|
+
parallel (1.27.0)
|
147
|
+
parser (3.3.8.0)
|
148
|
+
ast (~> 2.4.1)
|
149
|
+
racc
|
150
|
+
pp (0.6.2)
|
151
|
+
prettyprint
|
152
|
+
prettyprint (0.2.0)
|
153
|
+
prism (1.4.0)
|
154
|
+
psych (5.2.6)
|
155
|
+
date
|
156
|
+
stringio
|
157
|
+
racc (1.8.1)
|
158
|
+
rack (3.1.16)
|
159
|
+
rack-session (2.1.1)
|
160
|
+
base64 (>= 0.1.0)
|
161
|
+
rack (>= 3.0.0)
|
162
|
+
rack-test (2.2.0)
|
163
|
+
rack (>= 1.3)
|
164
|
+
rackup (2.2.1)
|
165
|
+
rack (>= 3)
|
166
|
+
rails (7.2.2.1)
|
167
|
+
actioncable (= 7.2.2.1)
|
168
|
+
actionmailbox (= 7.2.2.1)
|
169
|
+
actionmailer (= 7.2.2.1)
|
170
|
+
actionpack (= 7.2.2.1)
|
171
|
+
actiontext (= 7.2.2.1)
|
172
|
+
actionview (= 7.2.2.1)
|
173
|
+
activejob (= 7.2.2.1)
|
174
|
+
activemodel (= 7.2.2.1)
|
175
|
+
activerecord (= 7.2.2.1)
|
176
|
+
activestorage (= 7.2.2.1)
|
177
|
+
activesupport (= 7.2.2.1)
|
178
|
+
bundler (>= 1.15.0)
|
179
|
+
railties (= 7.2.2.1)
|
180
|
+
rails-dom-testing (2.3.0)
|
181
|
+
activesupport (>= 5.0.0)
|
182
|
+
minitest
|
183
|
+
nokogiri (>= 1.6)
|
184
|
+
rails-html-sanitizer (1.6.2)
|
185
|
+
loofah (~> 2.21)
|
186
|
+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
187
|
+
railties (7.2.2.1)
|
188
|
+
actionpack (= 7.2.2.1)
|
189
|
+
activesupport (= 7.2.2.1)
|
190
|
+
irb (~> 1.13)
|
191
|
+
rackup (>= 1.0.0)
|
192
|
+
rake (>= 12.2)
|
193
|
+
thor (~> 1.0, >= 1.2.2)
|
194
|
+
zeitwerk (~> 2.6)
|
195
|
+
rainbow (3.1.1)
|
196
|
+
rake (13.3.0)
|
197
|
+
rdoc (6.14.2)
|
198
|
+
erb
|
199
|
+
psych (>= 4.0.0)
|
200
|
+
regexp_parser (2.10.0)
|
201
|
+
reline (0.6.1)
|
202
|
+
io-console (~> 0.5)
|
203
|
+
rubocop (1.75.8)
|
204
|
+
json (~> 2.3)
|
205
|
+
language_server-protocol (~> 3.17.0.2)
|
206
|
+
lint_roller (~> 1.1.0)
|
207
|
+
parallel (~> 1.10)
|
208
|
+
parser (>= 3.3.0.2)
|
209
|
+
rainbow (>= 2.2.2, < 4.0)
|
210
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
211
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
212
|
+
ruby-progressbar (~> 1.7)
|
213
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
214
|
+
rubocop-ast (1.45.1)
|
215
|
+
parser (>= 3.3.7.2)
|
216
|
+
prism (~> 1.4)
|
217
|
+
rubocop-performance (1.25.0)
|
218
|
+
lint_roller (~> 1.1)
|
219
|
+
rubocop (>= 1.75.0, < 2.0)
|
220
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
221
|
+
ruby-progressbar (1.13.0)
|
222
|
+
securerandom (0.4.1)
|
223
|
+
standard (1.50.0)
|
224
|
+
language_server-protocol (~> 3.17.0.2)
|
225
|
+
lint_roller (~> 1.0)
|
226
|
+
rubocop (~> 1.75.5)
|
227
|
+
standard-custom (~> 1.0.0)
|
228
|
+
standard-performance (~> 1.8)
|
229
|
+
standard-custom (1.0.2)
|
230
|
+
lint_roller (~> 1.0)
|
231
|
+
rubocop (~> 1.50)
|
232
|
+
standard-performance (1.8.0)
|
233
|
+
lint_roller (~> 1.1)
|
234
|
+
rubocop-performance (~> 1.25.0)
|
235
|
+
stringio (3.1.7)
|
236
|
+
thor (1.3.2)
|
237
|
+
timeout (0.4.3)
|
238
|
+
tzinfo (2.0.6)
|
239
|
+
concurrent-ruby (~> 1.0)
|
240
|
+
unicode-display_width (3.1.4)
|
241
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
242
|
+
unicode-emoji (4.0.4)
|
243
|
+
useragent (0.16.11)
|
244
|
+
websocket-driver (0.8.0)
|
245
|
+
base64
|
246
|
+
websocket-extensions (>= 0.1.0)
|
247
|
+
websocket-extensions (0.1.5)
|
248
|
+
zeitwerk (2.7.3)
|
249
|
+
|
250
|
+
PLATFORMS
|
251
|
+
aarch64-linux-gnu
|
252
|
+
aarch64-linux-musl
|
253
|
+
arm-linux-gnu
|
254
|
+
arm-linux-musl
|
255
|
+
arm64-darwin
|
256
|
+
x86_64-darwin
|
257
|
+
x86_64-linux-gnu
|
258
|
+
x86_64-linux-musl
|
259
|
+
|
260
|
+
DEPENDENCIES
|
261
|
+
debug (~> 1.11.0)
|
262
|
+
minitest (~> 5.25, >= 5.25.5)
|
263
|
+
perron!
|
264
|
+
rails (~> 7.2.0)
|
265
|
+
rake (~> 13.3.0)
|
266
|
+
standard (~> 1.50.0)
|
267
|
+
|
268
|
+
BUNDLED WITH
|
269
|
+
2.6.8
|
data/README.md
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
# Perron
|
2
|
+
|
3
|
+
A Rails-based static site generator.
|
4
|
+
|
5
|
+
**Sponsored By [Rails Designer](https://railsdesigner.com/)**
|
6
|
+
|
7
|
+
<a href="https://railsdesigner.com/" target="_blank">
|
8
|
+
<picture>
|
9
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Rails-Designer/perron/HEAD/.github/logo-dark.svg">
|
10
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/Rails-Designer/perron/HEAD/.github/logo-light.svg">
|
11
|
+
<img alt="Rails Designer" src="https://raw.githubusercontent.com/Rails-Designer/perron/HEAD/.github/logo-light.svg" width="240" style="max-width: 100%;">
|
12
|
+
</picture>
|
13
|
+
</a>
|
14
|
+
|
15
|
+
|
16
|
+
## Getting Started
|
17
|
+
|
18
|
+
### Installation
|
19
|
+
|
20
|
+
Start by generating the configuration file:
|
21
|
+
```bash
|
22
|
+
rails generate perron:install
|
23
|
+
```
|
24
|
+
|
25
|
+
This creates an initializer:
|
26
|
+
```ruby
|
27
|
+
Perron.configure do |config|
|
28
|
+
config.site_name = "AppRefresher"
|
29
|
+
|
30
|
+
# Override the defaults (meta) title suffix
|
31
|
+
# Default: `— Perron.configuration.site_name`
|
32
|
+
# config.title_suffix = nil
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
|
37
|
+
## Mode
|
38
|
+
|
39
|
+
Perron can operate in two modes, configured via `config.mode`. This allows you to build either a full static site or integrate pages into a dynamic Rails application.
|
40
|
+
|
41
|
+
| **Mode** | `:standalone` (default) | `:integrated` |
|
42
|
+
| :--- | :--- | :--- |
|
43
|
+
| **Use Case** | Full static site for hosts like Netlify/Vercel | Add static pages to a live Rails app |
|
44
|
+
| **Output** | `output/` directory | `public/` directory |
|
45
|
+
| **Asset Handling** | Via Perron | Via Asset Pipeline |
|
46
|
+
|
47
|
+
|
48
|
+
## Creating Content
|
49
|
+
|
50
|
+
Perron is, just like Rails, designed with convention over configuration in mind. Content is stored in `app/content/*/*.{erb,md}`. Content is backed by a class, located in `app/models/content/` that inherits from `Perron::Resource`.
|
51
|
+
|
52
|
+
The controllers are located in `app/controllers/content/`. To make them available, create a route: `resources :posts, module: :content, only: %w[index show]`.
|
53
|
+
|
54
|
+
|
55
|
+
### Collections
|
56
|
+
|
57
|
+
```bash
|
58
|
+
bin/rails generate content Post
|
59
|
+
```
|
60
|
+
|
61
|
+
This will create the following files:
|
62
|
+
|
63
|
+
* `app/models/content/post.rb`
|
64
|
+
* `app/controllers/content/posts_controller.rb`
|
65
|
+
* `app/views/content/posts/index.html.erb`
|
66
|
+
* `app/views/content/posts/show.html.erb`
|
67
|
+
* Adds route: `resources :posts, module: :content, only: %w[index show]`
|
68
|
+
|
69
|
+
|
70
|
+
### Setting a Root Page
|
71
|
+
|
72
|
+
To set a root page, include `Perron::Root` in your `Content::PagesController` and add a `app/content/pages/root.[md,erb]` file (make sure to set `slug: "/"` in its frontmatter).
|
73
|
+
|
74
|
+
This is automatically added when you create a `Page` collection.
|
75
|
+
|
76
|
+
|
77
|
+
## Markdown Support
|
78
|
+
|
79
|
+
Perron supports markdown with the `markdownify` helper.
|
80
|
+
|
81
|
+
There are no markdown gems bundled by default, so you'll need to add one of these:
|
82
|
+
|
83
|
+
- CommonMarker
|
84
|
+
- Kramdown
|
85
|
+
- Redcarpet
|
86
|
+
|
87
|
+
```bash
|
88
|
+
bundle add {commonmarker,kramdown,redcarpet}
|
89
|
+
```
|
90
|
+
|
91
|
+
|
92
|
+
## Metatags
|
93
|
+
|
94
|
+
The `meta_tags` helper automatically generates SEO and social sharing meta tags for your pages.
|
95
|
+
|
96
|
+
|
97
|
+
### Usage
|
98
|
+
|
99
|
+
In your layout (e.g., `app/views/layouts/application.html.erb`), add the helper to the `<head>` section:
|
100
|
+
```erb
|
101
|
+
<head>
|
102
|
+
…
|
103
|
+
<%= meta_tags %>
|
104
|
+
…
|
105
|
+
</head>
|
106
|
+
```
|
107
|
+
|
108
|
+
You can render specific subsets of tags:
|
109
|
+
```erb
|
110
|
+
<%= meta_tags only: %w[title description] %>
|
111
|
+
```
|
112
|
+
|
113
|
+
Or exclude certain tags:
|
114
|
+
```erb
|
115
|
+
<%= meta_tags except: %w[twitter_card twitter_image] %>
|
116
|
+
```
|
117
|
+
|
118
|
+
### Metadata Priority
|
119
|
+
|
120
|
+
Values are determined with the following precedence, from highest to lowest:
|
121
|
+
|
122
|
+
#### 1. Controller Action
|
123
|
+
|
124
|
+
Define a `@metadata` instance variable in your controller:
|
125
|
+
```ruby
|
126
|
+
class Content::PostsController < ApplicationController
|
127
|
+
def index
|
128
|
+
@metadata = {
|
129
|
+
title: "All Blog Posts",
|
130
|
+
description: "A collection of our articles."
|
131
|
+
}
|
132
|
+
@resources = Content::Post.all
|
133
|
+
end
|
134
|
+
end
|
135
|
+
```
|
136
|
+
|
137
|
+
#### 2. Page Frontmatter
|
138
|
+
|
139
|
+
Add values to the YAML frontmatter in content files:
|
140
|
+
|
141
|
+
```yaml
|
142
|
+
---
|
143
|
+
title: My Awesome Post
|
144
|
+
description: A deep dive into how meta tags work.
|
145
|
+
image: /assets/images/my-awesome-post.png
|
146
|
+
author: Kendall
|
147
|
+
---
|
148
|
+
|
149
|
+
Your content here…
|
150
|
+
```
|
151
|
+
|
152
|
+
#### 3. Default Values
|
153
|
+
|
154
|
+
Set site-wide defaults in the initializer:
|
155
|
+
```ruby
|
156
|
+
Perron.configure do |config|
|
157
|
+
# …
|
158
|
+
|
159
|
+
config.metadata.description = "AI-powered tool to keep your knowledge base articles images/screenshots and content up-to-date"
|
160
|
+
config.metadata.author = "Rails Designer"
|
161
|
+
end
|
162
|
+
```
|
163
|
+
|
164
|
+
|
165
|
+
## Building Your Static Site
|
166
|
+
|
167
|
+
When in `standalone` mode and you're ready to generate your static site, run:
|
168
|
+
```bash
|
169
|
+
RAILS_ENV=production rails perron:build
|
170
|
+
```
|
171
|
+
|
172
|
+
This will create your static site in the configured output directory (`output` by default).
|
173
|
+
|
174
|
+
|
175
|
+
## Contributing
|
176
|
+
|
177
|
+
This project uses [Standard](https://github.com/testdouble/standard) for formatting Ruby code. Please run `be standardrb` before submitting pull requests. Run tests with `rails test`.
|
178
|
+
|
179
|
+
|
180
|
+
## License
|
181
|
+
|
182
|
+
Perron is released under the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MetaTagsHelper
|
4
|
+
def meta_tags(options = {})
|
5
|
+
Perron::Metatags.new(source).render(options)
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
Source = Data.define(:path, :metadata, :published_at)
|
11
|
+
|
12
|
+
def source
|
13
|
+
return Source.new(request.path, @metadata, nil) if @metadata.present?
|
14
|
+
|
15
|
+
@resource || Source.new(request.path, {}, nil)
|
16
|
+
end
|
17
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "perron"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
require "irb"
|
10
|
+
IRB.start(__FILE__)
|
data/bin/rails
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails gems
|
3
|
+
# installed from the root of your application.
|
4
|
+
|
5
|
+
ENGINE_ROOT = File.expand_path("..", __dir__)
|
6
|
+
ENGINE_PATH = File.expand_path("../lib/perron/engine", __dir__)
|
7
|
+
|
8
|
+
# Set up gems listed in the Gemfile.
|
9
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
10
|
+
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
|
11
|
+
|
12
|
+
require "rails"
|
13
|
+
|
14
|
+
require "action_controller/railtie"
|
15
|
+
require "action_view/railtie"
|
16
|
+
|
17
|
+
require "rails/engine/commands"
|
data/bin/release
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
VERSION=$1
|
4
|
+
|
5
|
+
if [ -z "$VERSION" ]; then
|
6
|
+
echo "Error: The version number is required."
|
7
|
+
echo "Usage: $0 <version-number>"
|
8
|
+
exit 1
|
9
|
+
fi
|
10
|
+
|
11
|
+
printf "module Perron\n VERSION = \"$VERSION\"\nend\n" > ./lib/perron/version.rb
|
12
|
+
bundle
|
13
|
+
git add Gemfile.lock lib/perron/version.rb
|
14
|
+
git commit -m "Bump version for $VERSION"
|
15
|
+
git push
|
16
|
+
git tag v$VERSION
|
17
|
+
git push --tags
|
18
|
+
gem build perron.gemspec
|
19
|
+
gem push "perron-$VERSION.gem"
|
data/bin/setup
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require "rails/generators/base"
|
2
|
+
|
3
|
+
class ContentGenerator < Rails::Generators::NamedBase
|
4
|
+
source_root File.expand_path("templates", __dir__)
|
5
|
+
|
6
|
+
argument :actions, type: :array, default: %w[index show], desc: "Specify which actions to generate (index/show)"
|
7
|
+
|
8
|
+
def create_model
|
9
|
+
template "model.rb.tt", File.join("app/models/content", "#{file_name}.rb")
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_controller
|
13
|
+
template "controller.rb.tt", File.join("app/controllers/content", "#{plural_file_name}_controller.rb")
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_views
|
17
|
+
empty_directory view_directory
|
18
|
+
|
19
|
+
actions.each do |action|
|
20
|
+
template "#{action}.html.erb.tt", File.join(view_directory, "#{action}.html.erb")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_content_directory = FileUtils.mkdir_p(content_directory)
|
25
|
+
|
26
|
+
def create_pages_root
|
27
|
+
return unless pages_controller?
|
28
|
+
|
29
|
+
template "root.erb.tt", File.join(content_directory, "root.erb")
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_content_route
|
33
|
+
route "resources :#{plural_file_name}, module: :content, only: %w[#{actions.join(" ")}]"
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def view_directory = Rails.root.join("app", "views", "content", plural_file_name)
|
39
|
+
|
40
|
+
def content_directory = Rails.root.join("app", "content", plural_file_name)
|
41
|
+
|
42
|
+
def plural_class_name = plural_name.camelize
|
43
|
+
|
44
|
+
def pages_controller? = plural_file_name == "pages"
|
45
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Content::<%= plural_class_name %>Controller < ApplicationController
|
2
|
+
<%- if pages_controller? -%>
|
3
|
+
include Perron::Root
|
4
|
+
<%- end -%>
|
5
|
+
|
6
|
+
<%- if actions.include?("index") -%>
|
7
|
+
def index
|
8
|
+
@resources = Content::<%= class_name %>.all
|
9
|
+
end
|
10
|
+
|
11
|
+
<%- end -%>
|
12
|
+
<%- if actions.include?("show") -%>
|
13
|
+
def show
|
14
|
+
@resource = Content::<%= class_name %>.find(params[:id])
|
15
|
+
end
|
16
|
+
<%- end -%>
|
17
|
+
end
|