impression 0.5 → 0.8
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 +17 -0
- data/Gemfile.lock +15 -15
- data/examples/hello.rb +13 -0
- data/impression.gemspec +4 -4
- data/lib/impression/file_tree.rb +33 -3
- data/lib/impression/jamstack.rb +46 -54
- data/lib/impression/version.rb +1 -1
- data/test/jamstack/_layouts/default.rb +1 -1
- data/test/jamstack/articles/2008-06-14-manu.md +3 -0
- data/test/jamstack/articles/2009-06-12-noatche.md +1 -1
- data/test/jamstack/articles/a.md +1 -1
- data/test/jamstack/index.md +1 -0
- data/test/test_file_tree.rb +38 -0
- data/test/test_jamstack.rb +67 -14
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33edd48c3f1fbbabd726045828fbe2e2bb1a06910bf43d3959b07a9781a52e68
|
4
|
+
data.tar.gz: 59f6c0c1183f11fa558e6f2ba821c7ccd590c933f6137d60d965ac5133da9b5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09c8e1b06c237554c2536a4e134d6d64aac604da5036c84f3feb757a802049c3b4b5596980e32a949a4ae9fe6a2cd524510dc61429a4782bb4f4364a34f27c38'
|
7
|
+
data.tar.gz: b942a1a7925feb5084adb35049d44f9b794777d78785d5b7dd0252c1a193304d19416cae2a3c2ce4eedf3ca924fc3e22040ec5e5262505261e61d20c9ff4d9c8
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
## 0.8 2022-02-01
|
2
|
+
|
3
|
+
- Update dependencies
|
4
|
+
|
5
|
+
# 0.7.1 2022-01-24
|
6
|
+
|
7
|
+
- Improve YAML front matter loading
|
8
|
+
|
9
|
+
# 0.7 2022-01-23
|
10
|
+
|
11
|
+
- Update Papercraft, Refactor Jamstack resource
|
12
|
+
|
13
|
+
# 0.6 2022-01-22
|
14
|
+
|
15
|
+
- Unify page_list entries and page_info cache entries (#10)
|
16
|
+
- Refactor FileTree#path_info to return more information
|
17
|
+
|
1
18
|
# 0.5 2022-01-20
|
2
19
|
|
3
20
|
- Pass resource and request to rendered templates (#8)
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
impression (0.
|
4
|
+
impression (0.7.1)
|
5
5
|
modulation (~> 1.1)
|
6
|
-
papercraft (~> 0.
|
7
|
-
polyphony (~> 0.
|
8
|
-
qeweney (~> 0.
|
9
|
-
tipi (~> 0.
|
6
|
+
papercraft (~> 0.17)
|
7
|
+
polyphony (~> 0.74)
|
8
|
+
qeweney (~> 0.16)
|
9
|
+
tipi (~> 0.46)
|
10
10
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
@@ -50,27 +50,27 @@ GEM
|
|
50
50
|
localhost (1.1.9)
|
51
51
|
minitest (5.11.3)
|
52
52
|
modulation (1.1)
|
53
|
-
msgpack (1.4.
|
53
|
+
msgpack (1.4.4)
|
54
54
|
multipart-post (2.1.1)
|
55
|
-
papercraft (0.
|
56
|
-
escape_utils (
|
57
|
-
kramdown (~> 2.3.
|
55
|
+
papercraft (0.17)
|
56
|
+
escape_utils (~> 1.2.1)
|
57
|
+
kramdown (~> 2.3.1)
|
58
58
|
kramdown-parser-gfm (~> 1.1.0)
|
59
|
-
rouge (~> 3.
|
60
|
-
polyphony (0.
|
61
|
-
qeweney (0.
|
59
|
+
rouge (~> 3.27.0)
|
60
|
+
polyphony (0.74)
|
61
|
+
qeweney (0.16)
|
62
62
|
escape_utils (~> 1.2.1)
|
63
63
|
rack (2.2.3)
|
64
64
|
rake (12.3.3)
|
65
65
|
rexml (3.2.5)
|
66
|
-
rouge (3.
|
66
|
+
rouge (3.27.0)
|
67
67
|
ruby2_keywords (0.0.5)
|
68
68
|
simplecov (0.17.1)
|
69
69
|
docile (~> 1.1)
|
70
70
|
json (>= 1.8, < 3)
|
71
71
|
simplecov-html (~> 0.10.0)
|
72
72
|
simplecov-html (0.10.2)
|
73
|
-
tipi (0.
|
73
|
+
tipi (0.46)
|
74
74
|
acme-client (~> 2.0.8)
|
75
75
|
ever (~> 0.1)
|
76
76
|
extralite (~> 1.2)
|
@@ -85,7 +85,7 @@ GEM
|
|
85
85
|
websocket (1.2.9)
|
86
86
|
|
87
87
|
PLATFORMS
|
88
|
-
|
88
|
+
ruby
|
89
89
|
|
90
90
|
DEPENDENCIES
|
91
91
|
impression!
|
data/examples/hello.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'impression'
|
2
|
+
|
3
|
+
app = Impression.app do
|
4
|
+
mount '/' => text_response('Hello, world!')
|
5
|
+
end
|
6
|
+
|
7
|
+
# class App < Impression::Resource
|
8
|
+
# def route(req)
|
9
|
+
# @response ||= text_response('Hello, world!')
|
10
|
+
# end
|
11
|
+
# end
|
12
|
+
|
13
|
+
# run { |req| req.respond_text('Hello, world!') }
|
data/impression.gemspec
CHANGED
@@ -22,12 +22,12 @@ Gem::Specification.new do |s|
|
|
22
22
|
|
23
23
|
# s.executables = ['impression']
|
24
24
|
|
25
|
-
s.add_runtime_dependency 'polyphony', '~>0.
|
26
|
-
s.add_runtime_dependency 'tipi', '~>0.
|
27
|
-
s.add_runtime_dependency 'qeweney', '~>0.
|
25
|
+
s.add_runtime_dependency 'polyphony', '~>0.74'
|
26
|
+
s.add_runtime_dependency 'tipi', '~>0.46'
|
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/file_tree.rb
CHANGED
@@ -27,8 +27,6 @@ module Impression
|
|
27
27
|
render_from_path_info(req, path_info)
|
28
28
|
end
|
29
29
|
|
30
|
-
private
|
31
|
-
|
32
30
|
# Renders a response from the given response kind and path.
|
33
31
|
#
|
34
32
|
# @param req [Qeweney::Request] request
|
@@ -47,6 +45,9 @@ module Impression
|
|
47
45
|
|
48
46
|
private
|
49
47
|
|
48
|
+
PAGE_EXT_REGEXP = /^(.+)\.html$/.freeze
|
49
|
+
INDEX_PAGE_REGEXP = /^(.+)?\/index$/.freeze
|
50
|
+
|
50
51
|
# Renders a file response for the given request and the given path info.
|
51
52
|
#
|
52
53
|
# @param req [Qeweney::Request] request
|
@@ -89,8 +90,37 @@ module Impression
|
|
89
90
|
elsif stat.directory?
|
90
91
|
return directory_path_info(path)
|
91
92
|
else
|
92
|
-
|
93
|
+
file_info(path)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# Returns the path info for the given file path.
|
98
|
+
#
|
99
|
+
# @param path [String] file path
|
100
|
+
# @return [Hash] path info
|
101
|
+
def file_info(path)
|
102
|
+
relative_path = path.gsub(/^#{@directory}/, '')
|
103
|
+
{
|
104
|
+
kind: :file,
|
105
|
+
path: path,
|
106
|
+
ext: File.extname(path),
|
107
|
+
url: pretty_url(relative_path)
|
108
|
+
}
|
109
|
+
end
|
110
|
+
|
111
|
+
# Returns the pretty URL for the given relative path. For pages, the
|
112
|
+
# extension is removed. For index pages, the index suffix is removed.
|
113
|
+
#
|
114
|
+
# @param relative_path [String] relative path
|
115
|
+
# @return [String] pretty URL
|
116
|
+
def pretty_url(relative_path)
|
117
|
+
if (m = relative_path.match(PAGE_EXT_REGEXP))
|
118
|
+
relative_path = m[1]
|
119
|
+
end
|
120
|
+
if (m = relative_path.match(INDEX_PAGE_REGEXP))
|
121
|
+
relative_path = m[1] || '/'
|
93
122
|
end
|
123
|
+
relative_path == '/' ? absolute_path : File.join(absolute_path, relative_path)
|
94
124
|
end
|
95
125
|
|
96
126
|
# Calculates the path info for a directory. If an index file exists, its
|
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
|
|
@@ -29,39 +29,41 @@ module Impression
|
|
29
29
|
def page_list(dir)
|
30
30
|
base = File.join(@directory, dir)
|
31
31
|
Dir.glob('*.{html,md}', base: base)
|
32
|
-
.map { |fn| page_entry(fn, dir) }
|
32
|
+
.map { |fn| get_path_info(File.join(dir, fn)) }# page_entry(fn, dir) }
|
33
33
|
.sort_by { |i| i[:path] }
|
34
34
|
end
|
35
35
|
|
36
36
|
private
|
37
37
|
|
38
|
-
DATE_REGEXP =
|
39
|
-
|
38
|
+
DATE_REGEXP = /(\d{4}\-\d{2}\-\d{2})/.freeze
|
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
|
-
INDEX_PAGE_REGEXP = /^(.+)
|
42
|
+
INDEX_PAGE_REGEXP = /^(.+)?\/index$/.freeze
|
43
|
+
|
44
|
+
YAML_OPTS = {
|
45
|
+
permitted_classes: [Date],
|
46
|
+
symbolize_names: true
|
47
|
+
}.freeze
|
43
48
|
|
44
|
-
# Returns
|
49
|
+
# Returns the path info for the given file path.
|
45
50
|
#
|
46
|
-
# @param
|
47
|
-
# @
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
atts, _ = parse_markdown_file(absolute_path)
|
58
|
-
info.merge!(atts)
|
51
|
+
# @param path [String] file path
|
52
|
+
# @return [Hash] path info
|
53
|
+
def file_info(path)
|
54
|
+
info = super
|
55
|
+
case info[:ext]
|
56
|
+
when '.md'
|
57
|
+
atts, content = parse_markdown_file(path)
|
58
|
+
info = info.merge(atts)
|
59
|
+
info[:html_content] = Papercraft.markdown(content)
|
60
|
+
when '.rb'
|
61
|
+
info[:module] = import(path)
|
59
62
|
end
|
60
|
-
|
61
|
-
if (m = fn.match(DATE_REGEXP))
|
63
|
+
if (m = path.match(DATE_REGEXP))
|
62
64
|
info[:date] ||= Date.parse(m[1])
|
63
65
|
end
|
64
|
-
|
66
|
+
|
65
67
|
info
|
66
68
|
end
|
67
69
|
|
@@ -75,9 +77,9 @@ module Impression
|
|
75
77
|
relative_path = m[1]
|
76
78
|
end
|
77
79
|
if (m = relative_path.match(INDEX_PAGE_REGEXP))
|
78
|
-
relative_path = m[1]
|
80
|
+
relative_path = m[1] || '/'
|
79
81
|
end
|
80
|
-
File.join(absolute_path, relative_path)
|
82
|
+
relative_path == '/' ? absolute_path : File.join(absolute_path, relative_path)
|
81
83
|
end
|
82
84
|
|
83
85
|
# Renders a file response for the given request and the given path info.
|
@@ -88,9 +90,9 @@ module Impression
|
|
88
90
|
def render_file(req, path_info)
|
89
91
|
case path_info[:ext]
|
90
92
|
when '.rb'
|
91
|
-
render_papercraft_module(req, path_info
|
93
|
+
render_papercraft_module(req, path_info)
|
92
94
|
when '.md'
|
93
|
-
render_markdown_file(req, path_info
|
95
|
+
render_markdown_file(req, path_info)
|
94
96
|
else
|
95
97
|
req.serve_file(path_info[:path])
|
96
98
|
end
|
@@ -99,27 +101,26 @@ module Impression
|
|
99
101
|
# Renders a Papercraft module. The module is loaded using Modulation.
|
100
102
|
#
|
101
103
|
# @param req [Qeweney::Request] reqest
|
102
|
-
# @param
|
104
|
+
# @param path_info [Hash] path info
|
103
105
|
# @return [void]
|
104
|
-
def render_papercraft_module(req,
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
req.respond(html, 'Content-Type' => Qeweney::MimeTypes[:html])
|
106
|
+
def render_papercraft_module(req, path_info)
|
107
|
+
template = Papercraft.html(path_info[:module])
|
108
|
+
body = template.render(request: req, resource: self)
|
109
|
+
req.respond(body, 'Content-Type' => template.mime_type)
|
109
110
|
end
|
110
111
|
|
111
112
|
# Renders a markdown file using a layout.
|
112
113
|
#
|
113
114
|
# @param req [Qeweney::Request] reqest
|
114
|
-
# @param
|
115
|
+
# @param path_info [Hash] path info
|
115
116
|
# @return [void]
|
116
|
-
def render_markdown_file(req,
|
117
|
-
|
117
|
+
def render_markdown_file(req, path_info)
|
118
|
+
layout = get_layout(path_info[:layout])
|
118
119
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
req.respond(html, 'Content-Type' =>
|
120
|
+
html = layout.render(request: req, resource: self, **path_info) {
|
121
|
+
emit path_info[:html_content]
|
122
|
+
}
|
123
|
+
req.respond(html, 'Content-Type' => layout.mime_type)
|
123
124
|
end
|
124
125
|
|
125
126
|
# Returns a layout component based on the given name. The given name
|
@@ -140,7 +141,7 @@ module Impression
|
|
140
141
|
# @param path [String] file path
|
141
142
|
# @return [Array] an tuple containing properties<Hash>, contents<String>
|
142
143
|
def parse_markdown_file(path)
|
143
|
-
|
144
|
+
content = IO.read(path) || ''
|
144
145
|
atts = {}
|
145
146
|
|
146
147
|
# Parse date from file name
|
@@ -148,24 +149,15 @@ module Impression
|
|
148
149
|
atts[:date] ||= Date.parse(m[1])
|
149
150
|
end
|
150
151
|
|
151
|
-
if (m =
|
152
|
+
if (m = content.match(FRONT_MATTER_REGEXP))
|
152
153
|
front_matter = m[1]
|
153
|
-
|
154
|
+
content = m.post_match
|
154
155
|
|
155
|
-
YAML.
|
156
|
-
|
157
|
-
end
|
156
|
+
yaml = YAML.safe_load(front_matter, **YAML_OPTS)
|
157
|
+
atts = atts.merge(yaml)
|
158
158
|
end
|
159
159
|
|
160
|
-
[atts,
|
161
|
-
end
|
162
|
-
|
163
|
-
# Converts a hash with string keys to one with symbol keys.
|
164
|
-
#
|
165
|
-
# @param hash [Hash] input hash
|
166
|
-
# @return [Hash] output hash
|
167
|
-
def symbolize_keys(hash)
|
168
|
-
|
160
|
+
[atts, content]
|
169
161
|
end
|
170
162
|
|
171
163
|
# Returns the supported path extensions used for searching for files based
|
data/lib/impression/version.rb
CHANGED
data/test/jamstack/articles/a.md
CHANGED
data/test/jamstack/index.md
CHANGED
data/test/test_file_tree.rb
CHANGED
@@ -113,4 +113,42 @@ class FileTreeTest < MiniTest::Test
|
|
113
113
|
@file_tree.route_and_call(req)
|
114
114
|
assert_response static('bar/index.html'), :html, req
|
115
115
|
end
|
116
|
+
|
117
|
+
def path_info(path)
|
118
|
+
@file_tree.send(:get_path_info, path)
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_path_info
|
122
|
+
assert_equal({
|
123
|
+
kind: :file,
|
124
|
+
path: File.join(__dir__, 'static/index.html'),
|
125
|
+
ext: '.html',
|
126
|
+
url: '/'
|
127
|
+
}, path_info('/index.html'))
|
128
|
+
|
129
|
+
assert_equal({
|
130
|
+
kind: :file,
|
131
|
+
path: File.join(__dir__, 'static/index.html'),
|
132
|
+
ext: '.html',
|
133
|
+
url: '/'
|
134
|
+
}, path_info('/index'))
|
135
|
+
|
136
|
+
assert_equal({
|
137
|
+
kind: :file,
|
138
|
+
path: File.join(__dir__, 'static/index.html'),
|
139
|
+
ext: '.html',
|
140
|
+
url: '/'
|
141
|
+
}, path_info('/'))
|
142
|
+
|
143
|
+
assert_equal({
|
144
|
+
kind: :file,
|
145
|
+
path: File.join(__dir__, 'static/js/a.js'),
|
146
|
+
ext: '.js',
|
147
|
+
url: '/js/a.js'
|
148
|
+
}, path_info('/js/a.js'))
|
149
|
+
|
150
|
+
assert_equal({
|
151
|
+
kind: :not_found,
|
152
|
+
}, path_info('/js/b.js'))
|
153
|
+
end
|
116
154
|
end
|
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,14 +101,14 @@ 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'
|
108
108
|
}
|
109
109
|
body {
|
110
110
|
article {
|
111
|
-
h2 '
|
111
|
+
h2 'ZZZ', id: 'zzz'
|
112
112
|
}
|
113
113
|
}
|
114
114
|
}
|
@@ -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,14 +191,14 @@ 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'
|
198
198
|
}
|
199
199
|
body {
|
200
200
|
article {
|
201
|
-
h2 '
|
201
|
+
h2 'ZZZ', id: 'zzz'
|
202
202
|
}
|
203
203
|
}
|
204
204
|
}
|
@@ -211,32 +211,48 @@ class JamstackTest < MiniTest::Test
|
|
211
211
|
|
212
212
|
list = @jamstack.page_list('/')
|
213
213
|
assert_equal [
|
214
|
-
{ path: File.join(JAMSTACK_PATH, 'bar.html'), url: '/app/bar' },
|
215
|
-
{ path: File.join(JAMSTACK_PATH, 'index.md'),
|
214
|
+
{ kind: :file, path: File.join(JAMSTACK_PATH, 'bar.html'), ext: '.html', url: '/app/bar' },
|
215
|
+
{ kind: :file, path: File.join(JAMSTACK_PATH, 'index.md'), ext: '.md', url: '/app',
|
216
|
+
title: 'Hello', foo: 'BarBar', html_content: "<h1>Index</h1>\n" },
|
216
217
|
], list
|
217
218
|
|
218
219
|
|
219
220
|
list = @jamstack.page_list('/articles')
|
221
|
+
|
220
222
|
assert_equal [
|
221
223
|
{
|
224
|
+
kind: :file,
|
222
225
|
path: File.join(JAMSTACK_PATH, 'articles/2008-06-14-manu.md'),
|
223
226
|
url: '/app/articles/2008-06-14-manu',
|
227
|
+
ext: '.md',
|
224
228
|
title: 'MMM',
|
225
229
|
layout: 'article',
|
230
|
+
foo: {
|
231
|
+
bar: {
|
232
|
+
baz: 42
|
233
|
+
}
|
234
|
+
},
|
235
|
+
html_content: "<h2 id=\"bbb\">BBB</h2>\n",
|
226
236
|
date: Date.new(2008, 06, 14)
|
227
237
|
},
|
228
238
|
{
|
239
|
+
kind: :file,
|
229
240
|
path: File.join(JAMSTACK_PATH, 'articles/2009-06-12-noatche.md'),
|
230
241
|
url: '/app/articles/2009-06-12-noatche',
|
242
|
+
ext: '.md',
|
231
243
|
title: 'NNN',
|
232
244
|
layout: 'article',
|
245
|
+
html_content: "<h2 id=\"ccc\">CCC</h2>\n",
|
233
246
|
date: Date.new(2009, 06, 12)
|
234
247
|
},
|
235
248
|
{
|
249
|
+
kind: :file,
|
236
250
|
path: File.join(JAMSTACK_PATH, 'articles/a.md'),
|
237
251
|
url: '/app/articles/a',
|
252
|
+
ext: '.md',
|
238
253
|
title: 'AAA',
|
239
|
-
layout: 'article'
|
254
|
+
layout: 'article',
|
255
|
+
html_content: "<h2 id=\"zzz\">ZZZ</h2>\n",
|
240
256
|
},
|
241
257
|
], list
|
242
258
|
end
|
@@ -245,7 +261,7 @@ class JamstackTest < MiniTest::Test
|
|
245
261
|
req = mock_req(':method' => 'GET', ':path' => '/foobar?q=42')
|
246
262
|
@jamstack.route_and_call(req)
|
247
263
|
|
248
|
-
foo =
|
264
|
+
foo = Papercraft.html {
|
249
265
|
html5 {
|
250
266
|
head {
|
251
267
|
title 'Foobar'
|
@@ -260,4 +276,41 @@ class JamstackTest < MiniTest::Test
|
|
260
276
|
}
|
261
277
|
assert_response foo.render, :html, req
|
262
278
|
end
|
279
|
+
|
280
|
+
def path_info(path)
|
281
|
+
@jamstack.send(:get_path_info, path)
|
282
|
+
end
|
283
|
+
|
284
|
+
def test_path_info
|
285
|
+
assert_equal({
|
286
|
+
kind: :file,
|
287
|
+
path: File.join(JAMSTACK_PATH, 'index.md'),
|
288
|
+
ext: '.md',
|
289
|
+
url: '/',
|
290
|
+
title: 'Hello',
|
291
|
+
foo: 'BarBar',
|
292
|
+
html_content: "<h1>Index</h1>\n"
|
293
|
+
}, path_info('/index'))
|
294
|
+
|
295
|
+
assert_equal({
|
296
|
+
kind: :file,
|
297
|
+
path: File.join(JAMSTACK_PATH, 'index.md'),
|
298
|
+
ext: '.md',
|
299
|
+
url: '/',
|
300
|
+
title: 'Hello',
|
301
|
+
foo: 'BarBar',
|
302
|
+
html_content: "<h1>Index</h1>\n"
|
303
|
+
}, path_info('/'))
|
304
|
+
|
305
|
+
assert_equal({
|
306
|
+
kind: :file,
|
307
|
+
path: File.join(JAMSTACK_PATH, 'assets/js/a.js'),
|
308
|
+
ext: '.js',
|
309
|
+
url: '/assets/js/a.js'
|
310
|
+
}, path_info('/assets/js/a.js'))
|
311
|
+
|
312
|
+
assert_equal({
|
313
|
+
kind: :not_found,
|
314
|
+
}, path_info('/js/b.js'))
|
315
|
+
end
|
263
316
|
end
|
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.8'
|
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-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: polyphony
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: '0.74'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: '0.74'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: tipi
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.46'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
40
|
+
version: '0.46'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: qeweney
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0.
|
47
|
+
version: '0.16'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0.
|
54
|
+
version: '0.16'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: papercraft
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
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
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- README.md
|
140
140
|
- Rakefile
|
141
141
|
- TODO.md
|
142
|
+
- examples/hello.rb
|
142
143
|
- examples/markdown/_assets/style.css
|
143
144
|
- examples/markdown/app.rb
|
144
145
|
- examples/markdown/docs/index.md
|