hyphae 0.2.1 → 0.3.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 +4 -4
- data/bin/hyphae +31 -5
- data/lib/hyphae.rb +17 -15
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1670c429ca926af6c3b09782b36692bc1085d563e47e3afcb972dad93c1a2a9d
|
4
|
+
data.tar.gz: 3d4c0ac0eb83219a4831c8313d566390dac69171f60115d04c7241df23d51c2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cf2606f5da537bc67f790c3bc9f3ec1bf51c41412895dedaa6b4942e6286397466787199ada09d47c7ef997a5890c888de2d2dcd3980de92b1826dc891be715
|
7
|
+
data.tar.gz: '093727d7c6bdd8b85d7f4f1ae6d0a22cdc9f888cd69584d3385e5925d543c0847fcfba2eee9b45e45ee09d61b03567f0c81bf4f01fafb8f72fcf4890548cb1aa'
|
data/bin/hyphae
CHANGED
@@ -1,20 +1,46 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
|
+
require 'optparse'
|
3
4
|
require 'hyphae'
|
4
5
|
|
5
6
|
###################
|
6
7
|
### Main Script ###
|
7
8
|
###################
|
8
9
|
|
9
|
-
#
|
10
|
-
|
10
|
+
# Default options
|
11
|
+
options = {
|
12
|
+
input_dir: 'site',
|
13
|
+
output_dir: '_build',
|
14
|
+
no_file_ext: false
|
15
|
+
}
|
16
|
+
|
17
|
+
# Get options
|
18
|
+
OptionParser.new do |opts|
|
19
|
+
opts.banner = "Usage: hyphae [options]"
|
20
|
+
|
21
|
+
opts.on("-i", "--input PATH", "Change input directory") do |path|
|
22
|
+
options[:input_dir] = path
|
23
|
+
end
|
24
|
+
|
25
|
+
opts.on("-o", "--output PATH", "Change output directory") do |path|
|
26
|
+
options[:output_dir] = path
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.on("-n", "--no-file-ext", "Name built page files without .html extension") do
|
30
|
+
options[:no_file_ext] = true
|
31
|
+
end
|
32
|
+
|
33
|
+
end.parse!
|
34
|
+
|
35
|
+
# Site input directory
|
36
|
+
input_dir = options[:input_dir]
|
11
37
|
if not Dir.exist?(input_dir) then
|
12
38
|
puts "ERROR: No input directory '#{input_dir}'"
|
13
39
|
exit
|
14
40
|
end
|
15
41
|
|
16
42
|
# The second argument is the rendered html site output directory
|
17
|
-
output_dir =
|
43
|
+
output_dir = options[:output_dir]
|
18
44
|
|
19
45
|
# Builds the page tree of the site
|
20
46
|
if not Dir.exist?(input_dir + "/pages") then
|
@@ -48,7 +74,7 @@ end
|
|
48
74
|
FileUtils.cp_r(input_dir + '/static', output_dir)
|
49
75
|
|
50
76
|
# Builds html pages
|
51
|
-
page_tree.build(output_dir, template)
|
77
|
+
page_tree.build(output_dir, template, options)
|
52
78
|
|
53
79
|
# Build site index
|
54
|
-
page_tree.build_index(output_dir, template, index_content)
|
80
|
+
page_tree.build_index(output_dir, template, index_content, options)
|
data/lib/hyphae.rb
CHANGED
@@ -90,28 +90,28 @@ module Hyphae
|
|
90
90
|
end
|
91
91
|
|
92
92
|
# Returns the html for each child's nav menu link
|
93
|
-
def menu_items(open_path=[])
|
94
|
-
@children.map { |x| x.nav_link(open_path) }.join
|
93
|
+
def menu_items(open_path=[], options={})
|
94
|
+
@children.map { |x| x.nav_link(open_path, options) }.join
|
95
95
|
end
|
96
96
|
|
97
97
|
# Returns the html for this SiteDir's nav menu link
|
98
|
-
def nav_link(open_path=[])
|
98
|
+
def nav_link(open_path=[], options={})
|
99
99
|
return "" if @hidden
|
100
100
|
link = Hyphae::make_tag('span', @name, {'class' => 'nav_menu_link'})
|
101
101
|
menu_attrs = { 'class' => 'nav_menu_items' }
|
102
102
|
menu_attrs['class'] += ' open' if open_path.first == @slug
|
103
|
-
menu = Hyphae::make_tag('div', menu_items(open_path[1..-1] || []), menu_attrs)
|
103
|
+
menu = Hyphae::make_tag('div', menu_items(open_path[1..-1] || [], options), menu_attrs)
|
104
104
|
Hyphae::make_tag('div', link + menu, {'class' => 'nav_menu'})
|
105
105
|
end
|
106
106
|
|
107
107
|
# Recursively builds pages for all children
|
108
|
-
def build(build_dir, template)
|
109
|
-
@children.each { |child| child.build(build_dir, template) }
|
108
|
+
def build(build_dir, template, options={})
|
109
|
+
@children.each { |child| child.build(build_dir, template, options) }
|
110
110
|
end
|
111
111
|
|
112
112
|
# Builds an index page for this SiteDir
|
113
|
-
def build_index(build_dir, template, index_content='')
|
114
|
-
page_html = template.gsub('{{navbar}}', menu_items).gsub("{{content}}", index_content).gsub('{{index_class}}', ' index_page')
|
113
|
+
def build_index(build_dir, template, index_content='', options={})
|
114
|
+
page_html = template.gsub('{{navbar}}', menu_items([], options)).gsub("{{content}}", index_content).gsub('{{index_class}}', ' index_page')
|
115
115
|
File.open("#{build_dir}/index.html", 'w') { |f| f << page_html }
|
116
116
|
end
|
117
117
|
end
|
@@ -126,20 +126,22 @@ module Hyphae
|
|
126
126
|
end
|
127
127
|
|
128
128
|
# Builds the nav menu tag for this page
|
129
|
-
def nav_link(open_path=[])
|
129
|
+
def nav_link(open_path=[], options={})
|
130
130
|
return "" if @hidden
|
131
|
-
|
131
|
+
file_ext = options[:no_file_ext] ? '' : '.html'
|
132
|
+
attrs = { 'class' => 'nav_page', 'href' => "/#{@path.join('/')}#{file_ext}" }
|
132
133
|
attrs['class'] += ' current_page' if @slug == open_path.first
|
133
134
|
Hyphae::make_tag('a', @name, attrs)
|
134
135
|
end
|
135
136
|
|
136
137
|
# Builds html page
|
137
|
-
def build(build_dir, template)
|
138
|
-
nav = root.menu_items(@path)
|
138
|
+
def build(build_dir, template, options={})
|
139
|
+
nav = root.menu_items(@path, options)
|
139
140
|
page_html = template.gsub('{{navbar}}', nav).gsub("{{content}}", @html).gsub('{{index_class}}', '')
|
140
141
|
page_dir_path = "#{build_dir}/#{@parent.path.join('/')}"
|
142
|
+
file_ext = options[:no_file_ext] ? '' : '.html'
|
141
143
|
FileUtils.mkdir_p page_dir_path
|
142
|
-
File.open("#{page_dir_path}/#{@slug}
|
144
|
+
File.open("#{page_dir_path}/#{@slug}#{file_ext}", 'w') { |f| f << page_html }
|
143
145
|
end
|
144
146
|
end
|
145
147
|
|
@@ -152,14 +154,14 @@ module Hyphae
|
|
152
154
|
end
|
153
155
|
|
154
156
|
# Builds the nav menu tag for this page
|
155
|
-
def nav_link(open_path=[])
|
157
|
+
def nav_link(open_path=[], options={})
|
156
158
|
return "" if @hidden
|
157
159
|
attrs = { 'class' => 'nav_link', 'href' => @link }
|
158
160
|
Hyphae::make_tag('a', @name, attrs)
|
159
161
|
end
|
160
162
|
|
161
163
|
# Builds html page (does nothing for a link)
|
162
|
-
def build(build_dir, template)
|
164
|
+
def build(build_dir, template, options={})
|
163
165
|
end
|
164
166
|
end
|
165
167
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyphae
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas Rakita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
54
|
requirements: []
|
55
|
-
rubygems_version: 3.3.
|
55
|
+
rubygems_version: 3.3.25
|
56
56
|
signing_key:
|
57
57
|
specification_version: 4
|
58
58
|
summary: Hyphae
|