mr-edward 0.0.2 → 0.4.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/bin/edward +1 -1
- data/{lib → src}/builder.rb +17 -5
- data/{lib → src}/cli.rb +4 -0
- data/src/context.rb +21 -0
- data/{lib → src}/page.rb +8 -1
- data/src/version.rb +4 -0
- metadata +10 -10
- data/lib/context.rb +0 -15
- data/lib/version.rb +0 -3
- /data/{lib → src}/edward.rb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3a9220176669d7089cdf418e72f2694c9155ac9f4f1e7221396cbc313b1b311b
|
|
4
|
+
data.tar.gz: 3062475cca120f2246d75ae857c229bbd417d00cd106faaee1ed0c82c52f8535
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 60827cee11a1dff53cc072b97d23354ec1df9770fd91df71898caa2824b4cdfbcbe5ada7c5ec5631284fe89c0d21f2f9625c8cfeecf129bc12df96b52c1564bb
|
|
7
|
+
data.tar.gz: 39aeb57d0c7c60dd8486f698d02baccddda67ace4f0dacb1b1378ac7fc530d7f307b2b9c585d054376267ee236b94656a2ec2a3603dcfa0a4372784da487ca96
|
data/bin/edward
CHANGED
data/{lib → src}/builder.rb
RENAMED
|
@@ -5,14 +5,18 @@ require "tilt"
|
|
|
5
5
|
module Edward
|
|
6
6
|
# Builds a website
|
|
7
7
|
class Builder
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
attr_reader :target
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
def initialize
|
|
12
12
|
@target = "_site"
|
|
13
13
|
@gitignore = File.read(".gitignore").lines rescue []
|
|
14
|
+
@edwardignore = File.read(".edwardignore").lines rescue []
|
|
15
|
+
Tilt.register_pipeline("adoc_erb", :templates => ["erb", "adoc"])
|
|
16
|
+
Tilt::AsciidoctorTemplate.include(AsciiDoctorUnsafeByDefault)
|
|
17
|
+
load("./_setup.rb") if File.exist? "_setup.rb"
|
|
14
18
|
end
|
|
15
|
-
|
|
19
|
+
|
|
16
20
|
def start
|
|
17
21
|
FileUtils.rm_r @target if File.exist? @target
|
|
18
22
|
FileUtils.mkdir_p @target
|
|
@@ -25,8 +29,9 @@ module Edward
|
|
|
25
29
|
def visit_file? path
|
|
26
30
|
File.file?(path) &&
|
|
27
31
|
!path.start_with?("_") &&
|
|
28
|
-
!["Gemfile", "Gemfile.lock"].include?(path) &&
|
|
29
|
-
!@gitignore.include?(path)
|
|
32
|
+
!["Gemfile", "Gemfile.lock", "Rakefile"].include?(path) &&
|
|
33
|
+
!@gitignore.include?(path) &&
|
|
34
|
+
!@edwardignore.include?(path)
|
|
30
35
|
end
|
|
31
36
|
|
|
32
37
|
def visit_file path
|
|
@@ -48,3 +53,10 @@ module Edward
|
|
|
48
53
|
|
|
49
54
|
end
|
|
50
55
|
end
|
|
56
|
+
|
|
57
|
+
module AsciiDoctorUnsafeByDefault
|
|
58
|
+
def prepare
|
|
59
|
+
@options[:safe] = :unsafe if @options[:safe].nil?
|
|
60
|
+
super
|
|
61
|
+
end
|
|
62
|
+
end
|
data/{lib → src}/cli.rb
RENAMED
|
@@ -22,6 +22,7 @@ module Edward
|
|
|
22
22
|
@server = WEBrick::HTTPServer.new :Port => port, :DocumentRoot => @builder.target
|
|
23
23
|
trap("INT") { @server.shutdown }
|
|
24
24
|
listen
|
|
25
|
+
@builder.start
|
|
25
26
|
puts "visit edward at http://127.0.0.1:#{@server.config[:Port]}"
|
|
26
27
|
@server.start
|
|
27
28
|
end
|
|
@@ -30,6 +31,9 @@ module Edward
|
|
|
30
31
|
require "listen"
|
|
31
32
|
Listen.to('.', ignore: /_site/) { |modified, added, removed|
|
|
32
33
|
puts "rebuilding"
|
|
34
|
+
if [modified, added, removed].flatten.map(&File.method(:basename)).include? "_setup.rb"
|
|
35
|
+
puts "WARNING: restart to apply changes to _setup.rb"
|
|
36
|
+
end
|
|
33
37
|
@builder.start
|
|
34
38
|
}.start
|
|
35
39
|
end
|
data/src/context.rb
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Edward
|
|
2
|
+
# Context for a template to run in
|
|
3
|
+
class RenderContext
|
|
4
|
+
def initialize page
|
|
5
|
+
@page = page
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# Include a partial file.
|
|
9
|
+
# The file is searched for in _include,
|
|
10
|
+
# rendered and returned.
|
|
11
|
+
#
|
|
12
|
+
# If you need to include a file plainly consider
|
|
13
|
+
# just using File.read or use an ERB template.
|
|
14
|
+
def include file, locals = {}, &block
|
|
15
|
+
include_path = "_include/" + file
|
|
16
|
+
yaml, content = Page.extract_front_matter(File.read(include_path))
|
|
17
|
+
options = (yaml&.dig(:options) || {}).merge(fixed_locals: "(locals:)")
|
|
18
|
+
Tilt[include_path].new(options) { content }.render(self, { local: locals }, &block)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
data/{lib → src}/page.rb
RENAMED
|
@@ -13,10 +13,16 @@ module Edward
|
|
|
13
13
|
content = File.read(path)
|
|
14
14
|
@yaml, @content = Page.extract_front_matter(content)
|
|
15
15
|
@block = nil
|
|
16
|
+
transform_option_keys(self[:options])
|
|
16
17
|
@template = Tilt[path].new(self[:options]) { @content }
|
|
17
18
|
add_layout(self[:layout]) if self[:layout]
|
|
18
19
|
end
|
|
19
20
|
|
|
21
|
+
# transform extensions from options to strings (for use in pipeline)
|
|
22
|
+
def transform_option_keys options
|
|
23
|
+
options&.transform_keys! { |k| Tilt.default_mapping.registered?(k.to_s) ? k.to_s : k }
|
|
24
|
+
end
|
|
25
|
+
|
|
20
26
|
# check if a file starts with yaml doc and can be mapped by tilt
|
|
21
27
|
def self.page? path
|
|
22
28
|
!Tilt.templates_for(path).empty? && YAML_FRONT_MATTER_REGEXP.match(File.read(path))
|
|
@@ -38,9 +44,10 @@ module Edward
|
|
|
38
44
|
|
|
39
45
|
# wrap this page in a layout
|
|
40
46
|
def add_layout name
|
|
41
|
-
layout_path = "_layouts/#{name}
|
|
47
|
+
layout_path = "_layouts/#{name}"
|
|
42
48
|
yaml, content = Page.extract_front_matter(File.read(layout_path))
|
|
43
49
|
@yaml = yaml.deep_merge!(@yaml, knockout_prefix: "--") if yaml
|
|
50
|
+
transform_option_keys(self[:options])
|
|
44
51
|
inner_template = @template
|
|
45
52
|
inner_block = @block
|
|
46
53
|
@block = proc { inner_template.render(Edward::RenderContext.new(self), nil, &inner_block) }
|
data/src/version.rb
ADDED
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.0
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rein Fernhout
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '2.
|
|
18
|
+
version: '2.7'
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '2.
|
|
25
|
+
version: '2.7'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: webrick
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -71,12 +71,12 @@ extensions: []
|
|
|
71
71
|
extra_rdoc_files: []
|
|
72
72
|
files:
|
|
73
73
|
- bin/edward
|
|
74
|
-
-
|
|
75
|
-
-
|
|
76
|
-
-
|
|
77
|
-
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
74
|
+
- src/builder.rb
|
|
75
|
+
- src/cli.rb
|
|
76
|
+
- src/context.rb
|
|
77
|
+
- src/edward.rb
|
|
78
|
+
- src/page.rb
|
|
79
|
+
- src/version.rb
|
|
80
80
|
homepage: https://github.com/LevitatingBusinessMan/edward
|
|
81
81
|
licenses:
|
|
82
82
|
- MIT
|
|
@@ -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:
|
|
98
|
+
rubygems_version: 4.0.3
|
|
99
99
|
specification_version: 4
|
|
100
100
|
summary: Statis site generator
|
|
101
101
|
test_files: []
|
data/lib/context.rb
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module Edward
|
|
2
|
-
# Context for a template to run in
|
|
3
|
-
class RenderContext
|
|
4
|
-
def initialize page
|
|
5
|
-
@page = page
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def include file, locals = {}, &block
|
|
9
|
-
include_path = "_include/" + file
|
|
10
|
-
# yaml in includes is currently ignored
|
|
11
|
-
_yaml, content = Page.extract_front_matter(File.read(include_path))
|
|
12
|
-
Tilt[include_path].new(@page[:options]&.merge(fixed_locals: "(locals:)")){ content }.render(self, { local: locals }, &block)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
data/lib/version.rb
DELETED
/data/{lib → src}/edward.rb
RENAMED
|
File without changes
|