vitepress-rails 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/vitepress/page.rb +47 -0
- data/app/controllers/vitepress/application_controller.rb +6 -0
- data/app/controllers/vitepress/pages_controller.rb +14 -0
- data/config/initializers/high_voltage.rb +9 -0
- data/config/routes.rb +6 -0
- data/lib/vitepress/rails/version.rb +1 -1
- data/lib/vitepress/tasks/vitepress/init/install.rb +3 -1
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d64f48a9f8abd212ee36a355e82e1d7c5ef3597686cf113717a8d8a547bdd2a0
|
4
|
+
data.tar.gz: 96a030364f74346b7d236c6aa83ca97b9ee8289526e514ea155b25e0900f8d46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fe415c7cd6a3fad89df4b595b5ecc6fcbc2f936b4bd90478bfed3e528a13225b76334663fbb32983a11167e303ebf0225e478b309c3d5ed1e7c75923128a7b7
|
7
|
+
data.tar.gz: 5586b99a9a74563f2d69a8c41a72a638c40c24b59d66123fe7b658584cd61693df4a105781b477cadc653fb6e16e49ab1f93c7522278e9be3dfe8ca90425bb17
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Inspired from https://github.com/thoughtbot/high_voltage/blob/main/app/controllers/concerns/high_voltage/static_page.rb
|
4
|
+
require "vitepress/rails/finder"
|
5
|
+
|
6
|
+
module Vitepress::Page
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
layout ->(_) { HighVoltage.layout }
|
11
|
+
|
12
|
+
rescue_from ActionView::MissingTemplate do |exception|
|
13
|
+
if /Missing template #{page_finder.content_path}/.match?(exception.message)
|
14
|
+
invalid_page
|
15
|
+
else
|
16
|
+
raise exception
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
rescue_from HighVoltage::InvalidPageIdError, with: :invalid_page
|
21
|
+
end
|
22
|
+
|
23
|
+
def show
|
24
|
+
render(
|
25
|
+
template: current_page,
|
26
|
+
locals: { current_page: current_page },
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def invalid_page
|
31
|
+
raise ActionController::RoutingError, "No such page: #{params[:id]}"
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def current_page
|
37
|
+
page_finder.find
|
38
|
+
end
|
39
|
+
|
40
|
+
def page_finder
|
41
|
+
page_finder_factory.new(params[:id])
|
42
|
+
end
|
43
|
+
|
44
|
+
def page_finder_factory
|
45
|
+
Vitepress::Rails::Finder
|
46
|
+
end
|
47
|
+
end
|
data/config/routes.rb
ADDED
@@ -4,7 +4,9 @@ if Rails.root.join(".gitignore").exist?
|
|
4
4
|
# High voltage genereated files
|
5
5
|
append_to_file(".gitignore", %(\n/app/views/pages/*\n!app/views/pages/.keep\n))
|
6
6
|
# Vitepress generated files
|
7
|
-
append_to_file(".gitignore", %(\
|
7
|
+
append_to_file(".gitignore", %(\ndocs/.vitepress/dist\ndocs/.vitepress/cache\n))
|
8
|
+
# Public assets for rails
|
9
|
+
append_to_file(".gitignore", %(\npublic/assets\n))
|
8
10
|
end
|
9
11
|
|
10
12
|
unless Rails.root.join("package.json").exist?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vitepress-rails
|
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
|
- PedroAugustoRamalhoDuarte
|
@@ -48,9 +48,14 @@ files:
|
|
48
48
|
- Gemfile
|
49
49
|
- README.md
|
50
50
|
- Rakefile
|
51
|
+
- app/controllers/concerns/vitepress/page.rb
|
52
|
+
- app/controllers/vitepress/application_controller.rb
|
53
|
+
- app/controllers/vitepress/pages_controller.rb
|
51
54
|
- bin/console
|
52
55
|
- bin/rails
|
53
56
|
- bin/setup
|
57
|
+
- config/initializers/high_voltage.rb
|
58
|
+
- config/routes.rb
|
54
59
|
- lib/vitepress/engine.rb
|
55
60
|
- lib/vitepress/rails.rb
|
56
61
|
- lib/vitepress/rails/finder.rb
|