vitepress-rails 0.1.1 → 0.1.3
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: 13c5b41037eb03ea1741a3c22c26852bb30c55fe06d9fd462e1bfd9b36df3753
|
4
|
+
data.tar.gz: 619b3b0f6f5fce0f5307911951802f8c3ad919daf783d177ffc261c841e0d5a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 278a577f49d1227a645636c0064c92e508dcec77f9e9311c9d87c227bab55945402f9d606631aae80d7b3c152c0dab5eccff2980fca7b2995757fc88760a399e
|
7
|
+
data.tar.gz: 95142f46e97aeec20ec8ef2852bbbe13b30fa29e55fec443738808bf25f48e359ab1ba7c7bc6deb410dbacafa77650c5e2622ad635a09e9b8ce3b37b61fd8606
|
@@ -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.3
|
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
|