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: 27039023737b744f359ee8ecff3085761338d9a7418220cf37657fe84572402e
4
- data.tar.gz: 285411e1a9e1360bf16231ec4077940e15981848485efe1d1540863497d38282
3
+ metadata.gz: 987d127931d6e1d4de5d33ca3f32152548398400f15b98f44b7cc2d4ce0c8a1e
4
+ data.tar.gz: 8ed37d65b7f3d28fc15a2cb3ac5c8a70622c9e6e477776e89e5bc034e3b9f6b3
5
5
  SHA512:
6
- metadata.gz: 240fc63f3d3ef88e0e6fab247ba49ebf742acc4f7bc4df6ec7d735973bc898fadd039c480d18b269de0e3e7f25776e79e6f88ddf407cbaf78ed798beadf7875e
7
- data.tar.gz: 5c9a82247c92fb5ff4bff9ee5916debd5f9487c02afc365b4439d1955c42903da295d2253efef2b38e0a850e120d2602f8f2b3428ed083cb05baf400a4eca8f5
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(current_page.slug)
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
@@ -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(/(\.\w+)+$/, "")
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.slug] = 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(slug)
22
- @pages.fetch(slug)
21
+ def find(path)
22
+ @pages.fetch(path)
23
23
  rescue KeyError
24
- raise PageNotFound, "No page `#{slug}' found at #{base_path}"
24
+ raise PageNotFound, "No page `#{path}' found at #{base_path}"
25
25
  end
26
26
 
27
- def match?(path)
28
- path = path.gsub(/^\//, "")
27
+ def match?(req_path)
28
+ path = req_path.gsub(/^\//, "")
29
29
  pages.keys.include?(path)
30
30
  end
31
31
  end
@@ -1,3 +1,3 @@
1
1
  module SatanicPages
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: satanic_pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikkel Malmberg