satanic_pages 0.1.0 → 0.1.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 987d127931d6e1d4de5d33ca3f32152548398400f15b98f44b7cc2d4ce0c8a1e
|
4
|
+
data.tar.gz: 8ed37d65b7f3d28fc15a2cb3ac5c8a70622c9e6e477776e89e5bc034e3b9f6b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32a1ba9449540998e948cafeb851c7147116f2283803c47e9c2af158b99a4fad2c9be5a3c9e64fde362eac3ef4ecec45774e4acb49a52f55d72f0b3e194dec8b
|
7
|
+
data.tar.gz: 696de60cfd8b96e8988260f1c53892d6f2b38054348eb17e898cc64fae83ea3888d5ac8bbebc0b87973a00e6ebfc7e16b990658ddaa2963fc28058109f094d8b
|
@@ -44,7 +44,10 @@ module SatanicPages
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def render_static_page
|
47
|
-
render
|
47
|
+
# For nested pages, we need to render the template directly using its full path
|
48
|
+
# Construct the template path based on the controller's view path and the page path
|
49
|
+
template_path = "#{controller_path}/#{current_page.path}"
|
50
|
+
render(template: template_path)
|
48
51
|
end
|
49
52
|
end
|
50
53
|
end
|
data/lib/satanic_pages/page.rb
CHANGED
@@ -4,15 +4,17 @@ require "ostruct"
|
|
4
4
|
|
5
5
|
module SatanicPages
|
6
6
|
class Page
|
7
|
-
def initialize(full_path)
|
7
|
+
def initialize(full_path, base_path)
|
8
8
|
@full_path = full_path
|
9
|
+
@base_path = base_path
|
10
|
+
@path = nil
|
9
11
|
@slug = nil
|
10
12
|
@content = nil
|
11
13
|
@data = nil
|
12
14
|
parse!
|
13
15
|
end
|
14
16
|
|
15
|
-
attr_reader :slug, :full_path, :content, :data
|
17
|
+
attr_reader :slug, :path, :full_path, :content, :data
|
16
18
|
|
17
19
|
delegate_missing_to :data
|
18
20
|
|
@@ -21,7 +23,10 @@ module SatanicPages
|
|
21
23
|
def parse!
|
22
24
|
@slug = File
|
23
25
|
.basename(full_path)
|
24
|
-
.gsub(/(
|
26
|
+
.gsub(/(\..+)+$/, "")
|
27
|
+
|
28
|
+
rel_path = full_path.to_s.sub("#{@base_path}/", "")
|
29
|
+
@path = rel_path.gsub(/(\..+)+$/, "")
|
25
30
|
|
26
31
|
@raw = File.read(full_path)
|
27
32
|
|
@@ -31,10 +36,11 @@ module SatanicPages
|
|
31
36
|
nil
|
32
37
|
rescue => e
|
33
38
|
Rails.logger.error("Error parsing frontmatter: #{e.message}")
|
34
|
-
@data = OpenStruct.new
|
35
39
|
$&
|
36
40
|
end
|
37
41
|
end
|
42
|
+
|
43
|
+
@data ||= OpenStruct.new
|
38
44
|
end
|
39
45
|
end
|
40
46
|
end
|
@@ -11,21 +11,21 @@ module SatanicPages
|
|
11
11
|
@pages = Dir[base_path + "**/*.html*"]
|
12
12
|
.reject { |path| path.match?(/(^_|\/_)/) }
|
13
13
|
.each_with_object({}) do |full_path, hash|
|
14
|
-
page = Page.new(full_path)
|
15
|
-
hash[page.
|
14
|
+
page = Page.new(full_path, base_path)
|
15
|
+
hash[page.path] = page
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
attr_reader :base_path, :pages
|
20
20
|
|
21
|
-
def find(
|
22
|
-
@pages.fetch(
|
21
|
+
def find(path)
|
22
|
+
@pages.fetch(path)
|
23
23
|
rescue KeyError
|
24
|
-
raise PageNotFound, "No page `#{
|
24
|
+
raise PageNotFound, "No page `#{path}' found at #{base_path}"
|
25
25
|
end
|
26
26
|
|
27
|
-
def match?(
|
28
|
-
path =
|
27
|
+
def match?(req_path)
|
28
|
+
path = req_path.gsub(/^\//, "")
|
29
29
|
pages.keys.include?(path)
|
30
30
|
end
|
31
31
|
end
|