mr-edward 0.5.0 → 0.6.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/src/page.rb +15 -13
- data/src/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cba75b99f925e933379311f179ad9bfd42de5837b8f620adf73dd9a3a3790bbc
|
|
4
|
+
data.tar.gz: 527c2cc38460e315b16338b82e8bc7ffaeddf15afa0ab2b8e7f92a29903937b7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6e50f960d5ac335485ac800ede80e1835927e446bd389261857a2a5288408699957d2f137328d85ba94b2b18c47aee59528f28d1ee2786e8377ba0a1eed0770b
|
|
7
|
+
data.tar.gz: ff50d23ecaf57f3ad070924845f831dc848732133c3e1830c60a1a057a80864ddb4b29ea44debb0e61b43980259b93bba6291f0814a744a57ee9a50f53728ba3
|
data/src/page.rb
CHANGED
|
@@ -17,12 +17,12 @@ module Edward
|
|
|
17
17
|
@template = Tilt[path].new(self[:options]) { @content }
|
|
18
18
|
add_layout(self[:layout]) if self[:layout]
|
|
19
19
|
end
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
# transform extensions from options to strings (for use in pipeline)
|
|
22
22
|
def transform_option_keys options
|
|
23
23
|
options&.transform_keys! { |k| Tilt.default_mapping.registered?(k.to_s) ? k.to_s : k }
|
|
24
24
|
end
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
# check if a file starts with yaml doc and can be mapped by tilt
|
|
27
27
|
def self.page? path
|
|
28
28
|
!Tilt.templates_for(path).empty? && YAML_FRONT_MATTER_REGEXP.match(File.read(path))
|
|
@@ -32,7 +32,7 @@ module Edward
|
|
|
32
32
|
ctx = Edward::RenderContext.new(self, builder)
|
|
33
33
|
@template.render(ctx, nil, &proc { @block.call(ctx) })
|
|
34
34
|
end
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
def self.extract_front_matter content
|
|
37
37
|
if content =~ YAML_FRONT_MATTER_REGEXP
|
|
38
38
|
yaml = YAML.safe_load(Regexp.last_match(1), symbolize_names: true, permitted_classes: [Symbol])
|
|
@@ -42,46 +42,48 @@ module Edward
|
|
|
42
42
|
[nil, content]
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
# wrap this page in a layout
|
|
47
47
|
def add_layout name
|
|
48
48
|
layout_path = "_layouts/#{name}"
|
|
49
49
|
yaml, content = Page.extract_front_matter(File.read(layout_path))
|
|
50
|
+
next_layout = yaml[:layout]
|
|
50
51
|
@yaml = yaml.deep_merge!(@yaml, knockout_prefix: "--") if yaml
|
|
51
52
|
transform_option_keys(self[:options])
|
|
52
53
|
inner_template = @template
|
|
53
54
|
inner_block = @block
|
|
54
55
|
@block = proc { |ctx| inner_template.render(ctx, nil, &inner_block) }
|
|
55
56
|
@template = Tilt[layout_path].new(self[:options]) { content }
|
|
57
|
+
add_layout(next_layout) if next_layout
|
|
56
58
|
end
|
|
57
|
-
|
|
59
|
+
|
|
58
60
|
def name
|
|
59
61
|
File.basename(@path)
|
|
60
62
|
end
|
|
61
|
-
|
|
63
|
+
|
|
62
64
|
# the name of the new file
|
|
63
65
|
def new_name
|
|
64
66
|
File.basename(@path, ".*")
|
|
65
67
|
end
|
|
66
|
-
|
|
68
|
+
|
|
67
69
|
def dirname
|
|
68
70
|
File.dirname(@path)
|
|
69
71
|
end
|
|
70
|
-
|
|
72
|
+
|
|
71
73
|
def new_path
|
|
72
74
|
"#{dirname}/#{new_name}"
|
|
73
75
|
end
|
|
74
|
-
|
|
76
|
+
|
|
75
77
|
# The directory name if new_name is index.html.
|
|
76
78
|
# Otherwise the full new path.
|
|
77
79
|
def href
|
|
78
80
|
if new_name == "index.html"
|
|
79
|
-
|
|
81
|
+
"/" + dirname
|
|
80
82
|
else
|
|
81
|
-
"
|
|
83
|
+
"/#{dirname}/#{new_name}"
|
|
82
84
|
end
|
|
83
85
|
end
|
|
84
|
-
|
|
86
|
+
|
|
85
87
|
def tag? tag
|
|
86
88
|
@yaml&.dig(:tags)&.include? tag
|
|
87
89
|
end
|
|
@@ -89,6 +91,6 @@ module Edward
|
|
|
89
91
|
def [](*keys)
|
|
90
92
|
@yaml&.dig(*keys)
|
|
91
93
|
end
|
|
92
|
-
|
|
94
|
+
|
|
93
95
|
end
|
|
94
96
|
end
|
data/src/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mr-edward
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rein Fernhout
|
|
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
96
|
version: '0'
|
|
97
97
|
requirements: []
|
|
98
|
-
rubygems_version: 4.0.
|
|
98
|
+
rubygems_version: 4.0.6
|
|
99
99
|
specification_version: 4
|
|
100
100
|
summary: Statis site generator
|
|
101
101
|
test_files: []
|