impression 0.6 → 0.7
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/CHANGELOG.md +4 -0
- data/Gemfile.lock +3 -3
- data/impression.gemspec +1 -1
- data/lib/impression/jamstack.rb +16 -11
- data/lib/impression/version.rb +1 -1
- data/test/jamstack/_layouts/default.rb +1 -1
- data/test/test_jamstack.rb +15 -15
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 871b003a25f9dd74ea137c483c2c208bdad9cf505d544c085f1f84eff394a278
|
4
|
+
data.tar.gz: 55623ee42bbc7213ef37c6632b1d4807b882301d133bc324607878857b7110c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29437cfb294efff3d90c7bcfa82bf05bba184b0ea4f68f13097650c2af17440e2d1294d95e06c17b981a4066c58dde70ac77fd3b8fbacb9ca7a676d08dfc71be
|
7
|
+
data.tar.gz: a787832534b192c37bc936f96a0c7b92c97b516dc2857b49fbefedab3a152c73301b6ce09e6b1bf581a77dd14bd8a2fa455c84e693b1ac29d5eb74208058bf33
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
impression (0.
|
4
|
+
impression (0.7)
|
5
5
|
modulation (~> 1.1)
|
6
|
-
papercraft (~> 0.
|
6
|
+
papercraft (~> 0.17)
|
7
7
|
polyphony (~> 0.73.1)
|
8
8
|
qeweney (~> 0.16)
|
9
9
|
tipi (~> 0.45)
|
@@ -52,7 +52,7 @@ GEM
|
|
52
52
|
modulation (1.1)
|
53
53
|
msgpack (1.4.4)
|
54
54
|
multipart-post (2.1.1)
|
55
|
-
papercraft (0.
|
55
|
+
papercraft (0.17)
|
56
56
|
escape_utils (~> 1.2.1)
|
57
57
|
kramdown (~> 2.3.1)
|
58
58
|
kramdown-parser-gfm (~> 1.1.0)
|
data/impression.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.add_runtime_dependency 'qeweney', '~>0.16'
|
28
28
|
|
29
29
|
# s.add_runtime_dependency 'rb-inotify', '~>0.10.1'
|
30
|
-
s.add_runtime_dependency 'papercraft', '~>0.
|
30
|
+
s.add_runtime_dependency 'papercraft', '~>0.17'
|
31
31
|
s.add_runtime_dependency 'modulation', '~>1.1'
|
32
32
|
|
33
33
|
|
data/lib/impression/jamstack.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'fileutils'
|
4
|
-
require 'yaml'
|
5
4
|
require 'date'
|
5
|
+
require 'yaml'
|
6
6
|
require 'modulation'
|
7
7
|
require 'papercraft'
|
8
8
|
|
@@ -36,10 +36,13 @@ module Impression
|
|
36
36
|
private
|
37
37
|
|
38
38
|
DATE_REGEXP = /(\d{4}\-\d{2}\-\d{2})/.freeze
|
39
|
-
|
39
|
+
FRONT_MATTER_REGEXP = /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m.freeze
|
40
40
|
MD_EXT_REGEXP = /\.md$/.freeze
|
41
41
|
PAGE_EXT_REGEXP = /^(.+)\.(md|html|rb)$/.freeze
|
42
42
|
INDEX_PAGE_REGEXP = /^(.+)?\/index$/.freeze
|
43
|
+
YAML_OPTS = {
|
44
|
+
permitted_classes: [Date]
|
45
|
+
}.freeze
|
43
46
|
|
44
47
|
# Returns the path info for the given file path.
|
45
48
|
#
|
@@ -51,7 +54,7 @@ module Impression
|
|
51
54
|
when '.md'
|
52
55
|
atts, content = parse_markdown_file(path)
|
53
56
|
info = info.merge(atts)
|
54
|
-
info[:
|
57
|
+
info[:html_content] = Papercraft.markdown(content)
|
55
58
|
when '.rb'
|
56
59
|
info[:module] = import(path)
|
57
60
|
end
|
@@ -99,8 +102,9 @@ module Impression
|
|
99
102
|
# @param path_info [Hash] path info
|
100
103
|
# @return [void]
|
101
104
|
def render_papercraft_module(req, path_info)
|
102
|
-
|
103
|
-
|
105
|
+
template = Papercraft.html(path_info[:module])
|
106
|
+
body = template.render(request: req, resource: self)
|
107
|
+
req.respond(body, 'Content-Type' => template.mime_type)
|
104
108
|
end
|
105
109
|
|
106
110
|
# Renders a markdown file using a layout.
|
@@ -112,7 +116,7 @@ module Impression
|
|
112
116
|
layout = get_layout(path_info[:layout])
|
113
117
|
|
114
118
|
html = layout.render(request: req, resource: self, **path_info) {
|
115
|
-
|
119
|
+
emit path_info[:html_content]
|
116
120
|
}
|
117
121
|
req.respond(html, 'Content-Type' => Qeweney::MimeTypes[:html])
|
118
122
|
end
|
@@ -135,7 +139,7 @@ module Impression
|
|
135
139
|
# @param path [String] file path
|
136
140
|
# @return [Array] an tuple containing properties<Hash>, contents<String>
|
137
141
|
def parse_markdown_file(path)
|
138
|
-
|
142
|
+
content = IO.read(path) || ''
|
139
143
|
atts = {}
|
140
144
|
|
141
145
|
# Parse date from file name
|
@@ -143,16 +147,17 @@ module Impression
|
|
143
147
|
atts[:date] ||= Date.parse(m[1])
|
144
148
|
end
|
145
149
|
|
146
|
-
if (m =
|
150
|
+
if (m = content.match(FRONT_MATTER_REGEXP))
|
147
151
|
front_matter = m[1]
|
148
|
-
|
152
|
+
content = m.post_match
|
149
153
|
|
150
|
-
YAML.load(front_matter
|
154
|
+
yaml = YAML.load(front_matter, **YAML_OPTS)
|
155
|
+
yaml.each_with_object(atts) do |(k, v), h|
|
151
156
|
h[k.to_sym] = v
|
152
157
|
end
|
153
158
|
end
|
154
159
|
|
155
|
-
[atts,
|
160
|
+
[atts, content]
|
156
161
|
end
|
157
162
|
|
158
163
|
# Returns the supported path extensions used for searching for files based
|
data/lib/impression/version.rb
CHANGED
data/test/test_jamstack.rb
CHANGED
@@ -48,7 +48,7 @@ class JamstackTest < MiniTest::Test
|
|
48
48
|
req = mock_req(':method' => 'GET', ':path' => '/foo')
|
49
49
|
@jamstack.route_and_call(req)
|
50
50
|
|
51
|
-
foo =
|
51
|
+
foo = Papercraft.html {
|
52
52
|
html5 {
|
53
53
|
head {
|
54
54
|
title 'Foo title'
|
@@ -63,7 +63,7 @@ class JamstackTest < MiniTest::Test
|
|
63
63
|
req = mock_req(':method' => 'GET', ':path' => '/index')
|
64
64
|
@jamstack.route_and_call(req)
|
65
65
|
|
66
|
-
index =
|
66
|
+
index = Papercraft.html {
|
67
67
|
html5 {
|
68
68
|
head {
|
69
69
|
title 'Hello'
|
@@ -86,7 +86,7 @@ class JamstackTest < MiniTest::Test
|
|
86
86
|
req = mock_req(':method' => 'GET', ':path' => '/baz')
|
87
87
|
@jamstack.route_and_call(req)
|
88
88
|
|
89
|
-
baz_index =
|
89
|
+
baz_index = Papercraft.html {
|
90
90
|
html5 {
|
91
91
|
head {
|
92
92
|
title 'BarBar'
|
@@ -101,7 +101,7 @@ class JamstackTest < MiniTest::Test
|
|
101
101
|
req = mock_req(':method' => 'GET', ':path' => '/articles/a')
|
102
102
|
@jamstack.route_and_call(req)
|
103
103
|
|
104
|
-
a =
|
104
|
+
a = Papercraft.html {
|
105
105
|
html5 {
|
106
106
|
head {
|
107
107
|
title 'AAA'
|
@@ -138,7 +138,7 @@ class JamstackTest < MiniTest::Test
|
|
138
138
|
req = mock_req(':method' => 'GET', ':path' => '/app/foo')
|
139
139
|
@jamstack.route_and_call(req)
|
140
140
|
|
141
|
-
foo =
|
141
|
+
foo = Papercraft.html {
|
142
142
|
html5 {
|
143
143
|
head {
|
144
144
|
title 'Foo title'
|
@@ -153,7 +153,7 @@ class JamstackTest < MiniTest::Test
|
|
153
153
|
req = mock_req(':method' => 'GET', ':path' => '/app/index')
|
154
154
|
@jamstack.route_and_call(req)
|
155
155
|
|
156
|
-
index =
|
156
|
+
index = Papercraft.html {
|
157
157
|
html5 {
|
158
158
|
head {
|
159
159
|
title 'Hello'
|
@@ -176,7 +176,7 @@ class JamstackTest < MiniTest::Test
|
|
176
176
|
req = mock_req(':method' => 'GET', ':path' => '/app/baz')
|
177
177
|
@jamstack.route_and_call(req)
|
178
178
|
|
179
|
-
baz_index =
|
179
|
+
baz_index = Papercraft.html {
|
180
180
|
html5 {
|
181
181
|
head {
|
182
182
|
title 'BarBar'
|
@@ -191,7 +191,7 @@ class JamstackTest < MiniTest::Test
|
|
191
191
|
req = mock_req(':method' => 'GET', ':path' => '/app/articles/a')
|
192
192
|
@jamstack.route_and_call(req)
|
193
193
|
|
194
|
-
a =
|
194
|
+
a = Papercraft.html {
|
195
195
|
html5 {
|
196
196
|
head {
|
197
197
|
title 'AAA'
|
@@ -213,7 +213,7 @@ class JamstackTest < MiniTest::Test
|
|
213
213
|
assert_equal [
|
214
214
|
{ kind: :file, path: File.join(JAMSTACK_PATH, 'bar.html'), ext: '.html', url: '/app/bar' },
|
215
215
|
{ kind: :file, path: File.join(JAMSTACK_PATH, 'index.md'), ext: '.md', url: '/app',
|
216
|
-
title: 'Hello', foo: 'BarBar',
|
216
|
+
title: 'Hello', foo: 'BarBar', html_content: "<h1>Index</h1>\n" },
|
217
217
|
], list
|
218
218
|
|
219
219
|
|
@@ -227,7 +227,7 @@ class JamstackTest < MiniTest::Test
|
|
227
227
|
ext: '.md',
|
228
228
|
title: 'MMM',
|
229
229
|
layout: 'article',
|
230
|
-
|
230
|
+
html_content: "<h2 id=\"bbb\">BBB</h2>\n",
|
231
231
|
date: Date.new(2008, 06, 14)
|
232
232
|
},
|
233
233
|
{
|
@@ -237,7 +237,7 @@ class JamstackTest < MiniTest::Test
|
|
237
237
|
ext: '.md',
|
238
238
|
title: 'NNN',
|
239
239
|
layout: 'article',
|
240
|
-
|
240
|
+
html_content: "<h2 id=\"ccc\">CCC</h2>\n",
|
241
241
|
date: Date.new(2009, 06, 12)
|
242
242
|
},
|
243
243
|
{
|
@@ -247,7 +247,7 @@ class JamstackTest < MiniTest::Test
|
|
247
247
|
ext: '.md',
|
248
248
|
title: 'AAA',
|
249
249
|
layout: 'article',
|
250
|
-
|
250
|
+
html_content: "<h2 id=\"zzz\">ZZZ</h2>\n",
|
251
251
|
},
|
252
252
|
], list
|
253
253
|
end
|
@@ -256,7 +256,7 @@ class JamstackTest < MiniTest::Test
|
|
256
256
|
req = mock_req(':method' => 'GET', ':path' => '/foobar?q=42')
|
257
257
|
@jamstack.route_and_call(req)
|
258
258
|
|
259
|
-
foo =
|
259
|
+
foo = Papercraft.html {
|
260
260
|
html5 {
|
261
261
|
head {
|
262
262
|
title 'Foobar'
|
@@ -284,7 +284,7 @@ class JamstackTest < MiniTest::Test
|
|
284
284
|
url: '/',
|
285
285
|
title: 'Hello',
|
286
286
|
foo: 'BarBar',
|
287
|
-
|
287
|
+
html_content: "<h1>Index</h1>\n"
|
288
288
|
}, path_info('/index'))
|
289
289
|
|
290
290
|
assert_equal({
|
@@ -294,7 +294,7 @@ class JamstackTest < MiniTest::Test
|
|
294
294
|
url: '/',
|
295
295
|
title: 'Hello',
|
296
296
|
foo: 'BarBar',
|
297
|
-
|
297
|
+
html_content: "<h1>Index</h1>\n"
|
298
298
|
}, path_info('/'))
|
299
299
|
|
300
300
|
assert_equal({
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: impression
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.7'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: polyphony
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
61
|
+
version: '0.17'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0.
|
68
|
+
version: '0.17'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: modulation
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|