zarchitect 1.2.0 → 1.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/data/_zarchitect.yaml +11 -1
- data/data/post.md.erb +1 -0
- data/lib/zarchitect/category.rb +1 -1
- data/lib/zarchitect/cmd_new.rb +23 -1
- data/lib/zarchitect/cmd_sitemap.rb +124 -0
- data/lib/zarchitect/html.rb +1 -0
- data/lib/zarchitect/index.rb +88 -4
- data/lib/zarchitect/post.rb +75 -6
- data/lib/zarchitect/section.rb +2 -1
- data/lib/zarchitect/tag.rb +19 -2
- data/lib/zarchitect.rb +10 -0
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d3c85171bc5002d2fc4d485b41efdd70ab1031c4b028766a2c2d534c50ec0f6a
|
|
4
|
+
data.tar.gz: cceb00da64b1ed2d61f6c4be6f6c2375e43dc7a51b9426383457b74524c6d9e6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8ff57eaf919aae4fbfd9e1e98814794adbc2832c81ca446dbb89a998fb9371be779eb16062485657ba6eb76e00c2a83a47856f87686f94daaf1983ff6d9d409a
|
|
7
|
+
data.tar.gz: e0ff271242382ed66211c997c9b98c82b075ea1e6a2e340552bd4095151a31b8a0c254fce70074683d22258884b33ff0b5ba21fd701c606367afe786eff81c58
|
data/data/_zarchitect.yaml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
url: http://www.example.com
|
|
3
3
|
email: user@example.com
|
|
4
4
|
site_name: example.com
|
|
5
|
-
site_slogan: the best
|
|
5
|
+
site_slogan: the best example
|
|
6
6
|
site_description: "a short description of this website"
|
|
7
7
|
admin: webmaster_name
|
|
8
8
|
origin_year: 2020 # can be used for dynamic copyright notices
|
|
@@ -20,3 +20,13 @@ exclude_assets: # files with these extensions don't get copied into html tree
|
|
|
20
20
|
- .scss
|
|
21
21
|
- .scss.swp
|
|
22
22
|
- .css.map
|
|
23
|
+
|
|
24
|
+
# optional settings
|
|
25
|
+
#og_image:
|
|
26
|
+
#og_image_alt:
|
|
27
|
+
#og_image_width:
|
|
28
|
+
#og_image_height:
|
|
29
|
+
sm_post_changefreq: monthly
|
|
30
|
+
sm_post_prio: 1.0
|
|
31
|
+
sm_index_changefreq: weekly
|
|
32
|
+
sm_index_prio: 0.5
|
data/data/post.md.erb
CHANGED
data/lib/zarchitect/category.rb
CHANGED
data/lib/zarchitect/cmd_new.rb
CHANGED
|
@@ -10,8 +10,8 @@ module CMD
|
|
|
10
10
|
"not exist."
|
|
11
11
|
GPI.quit
|
|
12
12
|
end
|
|
13
|
+
@category = nil
|
|
13
14
|
if GPI::CLU.parameters.size > 2
|
|
14
|
-
@category = nil
|
|
15
15
|
@category = @section.find_category(GPI::CLU.parameters[1])
|
|
16
16
|
if @category.nil?
|
|
17
17
|
GPI.print "Error: category with key #{GPI::CLU.parameters[1]} " +
|
|
@@ -27,11 +27,13 @@ module CMD
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def run
|
|
30
|
+
check_key
|
|
30
31
|
@id = get_id
|
|
31
32
|
# write file
|
|
32
33
|
a = ZERB.new(File.join(Util.path_to_data, "post.md.erb"))
|
|
33
34
|
data = Hash.new
|
|
34
35
|
data["title"] = @title
|
|
36
|
+
data["key"] = @title
|
|
35
37
|
data["date"] = Time.now
|
|
36
38
|
data["author"] = Zarchitect.conf.admin
|
|
37
39
|
data["id"] = @id
|
|
@@ -52,6 +54,26 @@ module CMD
|
|
|
52
54
|
|
|
53
55
|
private
|
|
54
56
|
|
|
57
|
+
def check_key
|
|
58
|
+
duplicate_key = false
|
|
59
|
+
context = ""
|
|
60
|
+
unless @category.nil?
|
|
61
|
+
@category.posts.each do |post|
|
|
62
|
+
duplicate_key = true if @title == post.key
|
|
63
|
+
context = "#{@section.key}/#{@category.key}"
|
|
64
|
+
end
|
|
65
|
+
else
|
|
66
|
+
@section.posts.each do |post|
|
|
67
|
+
duplicate_key = true if @title == post.key
|
|
68
|
+
context = "#{@section.key}"
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
if duplicate_key
|
|
72
|
+
GPI.print "Error: key {#{@title}} already present in #{context}."
|
|
73
|
+
GPI.quit
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
55
77
|
def get_id
|
|
56
78
|
t = Time.now.to_i
|
|
57
79
|
id = t.to_s(16).downcase
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
module CMD
|
|
2
|
+
|
|
3
|
+
class Sitemap < Zarchitect
|
|
4
|
+
|
|
5
|
+
def initialize
|
|
6
|
+
Zarchitect.sconf.each { |s| Zarchitect.add_section(s) }
|
|
7
|
+
if GPI::CLU.check_option('v')
|
|
8
|
+
SitemapGenerator.verbose = true
|
|
9
|
+
SitemapGenerator::Sitemap.verbose = true
|
|
10
|
+
else
|
|
11
|
+
SitemapGenerator.verbose = false
|
|
12
|
+
SitemapGenerator::Sitemap.verbose = false
|
|
13
|
+
end
|
|
14
|
+
SitemapGenerator::Sitemap.default_host = Zarchitect.conf.url
|
|
15
|
+
SitemapGenerator::Sitemap.create_index = :auto
|
|
16
|
+
SitemapGenerator::Sitemap.public_path = Zarchitect::HTMLDIR
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def run
|
|
20
|
+
reset_sitemap
|
|
21
|
+
build_sitemap
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def reset_sitemap
|
|
27
|
+
Dir.glob(File.join(HTMLDIR,"sitemap*.xml.gz")) do |path|
|
|
28
|
+
if GPI::CLU.check_option('v')
|
|
29
|
+
GPI.print "Attempting to remove '#{path}'"
|
|
30
|
+
end
|
|
31
|
+
File.delete(path)
|
|
32
|
+
GPI.print "Removed '#{path}'" if GPI::CLU.check_option('v')
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def build_sitemap
|
|
37
|
+
SitemapGenerator::Sitemap.create do
|
|
38
|
+
Zarchitect.sections.each do |section|
|
|
39
|
+
# skip sections not meant to be included in sitemap
|
|
40
|
+
if section.conf.has_option?("sitemap")
|
|
41
|
+
next if section.conf.sitemap == 'exclude'
|
|
42
|
+
end
|
|
43
|
+
# set priority and changefrequency values
|
|
44
|
+
post_prio = 1.0
|
|
45
|
+
post_changefreq = 'monthly'
|
|
46
|
+
index_prio = 0.5
|
|
47
|
+
index_changefreq = 'weekly'
|
|
48
|
+
if section.conf.has_option?("sm_post_prio")
|
|
49
|
+
post_prio = section.conf.sm_post_prio
|
|
50
|
+
elsif Zarchitect.conf.has_option?("sm_post_prio")
|
|
51
|
+
post_prio = Zarchitect.conf.sm_post_prio
|
|
52
|
+
end
|
|
53
|
+
if section.conf.has_option?("sm_post_changefreq")
|
|
54
|
+
post_changefreq = section.conf.sm_post_changefreq
|
|
55
|
+
elsif Zarchitect.conf.has_option?("sm_post_changefreq")
|
|
56
|
+
post_changefreq = Zarchitect.conf.sm_post_changefreq
|
|
57
|
+
end
|
|
58
|
+
if section.conf.has_option?("sm_index_prio")
|
|
59
|
+
index_prio = section.conf.sm_index_prio
|
|
60
|
+
elsif Zarchitect.conf.has_option?("sm_index_prio")
|
|
61
|
+
index_prio = Zarchitect.conf.sm_index_prio
|
|
62
|
+
end
|
|
63
|
+
if section.conf.has_option?("sm_index_changefreq")
|
|
64
|
+
index_changefreq = section.conf.sm_index_changefreq
|
|
65
|
+
elsif Zarchitect.conf.has_option?("sm_index_changefreq")
|
|
66
|
+
index_changefreq = Zarchitect.conf.sm_index_changefreq
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# add section indices
|
|
70
|
+
if section.index
|
|
71
|
+
section.index.pages.each do |index|
|
|
72
|
+
add index.url, :changefreq => index_changefreq,
|
|
73
|
+
:lastmod => File.mtime(index.path).strftime("%FT%T%:z"),
|
|
74
|
+
:priority => index_prio
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
# add category and tag indices
|
|
78
|
+
if section.conf.collection && section.conf.categorize
|
|
79
|
+
section.categories.each do |cat|
|
|
80
|
+
cat.index.pages.each do |index|
|
|
81
|
+
add index.url, :changefreq => index_changefreq,
|
|
82
|
+
:lastmod => File.mtime(index.path).strftime("%FT%T%:z"),
|
|
83
|
+
:priority => index_prio
|
|
84
|
+
end
|
|
85
|
+
if cat.tags
|
|
86
|
+
cat.tags.each do |tag|
|
|
87
|
+
tag.index.pages.each do |index|
|
|
88
|
+
add index.url, :changefreq => index_changefreq,
|
|
89
|
+
:lastmod => File.mtime(index.path).strftime("%FT%T%:z"),
|
|
90
|
+
:priority => index_prio
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
# add posts and section contents
|
|
97
|
+
section.posts.each do |post|
|
|
98
|
+
# skip posts not meant to be included
|
|
99
|
+
if post.conf.has_option?("sitemap")
|
|
100
|
+
next if post.conf.sitemap == 'exclude'
|
|
101
|
+
end
|
|
102
|
+
prio = nil
|
|
103
|
+
changefreq = nil
|
|
104
|
+
if post.conf.has_option?("sm_prio")
|
|
105
|
+
prio = post.conf.sm_prio
|
|
106
|
+
else
|
|
107
|
+
prio = post_prio
|
|
108
|
+
end
|
|
109
|
+
if post.conf.has_option?("sm_changefreq")
|
|
110
|
+
changefreq = post.conf.sm_changefreq
|
|
111
|
+
else
|
|
112
|
+
changefreq = post_changefreq
|
|
113
|
+
end
|
|
114
|
+
add post.url, :changefreq => changefreq,
|
|
115
|
+
:lastmod => File.mtime(post.source_path).strftime("%FT%T%:z"),
|
|
116
|
+
:priority => prio
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
end
|
data/lib/zarchitect/html.rb
CHANGED
data/lib/zarchitect/index.rb
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
class Index < Zarchitect
|
|
2
|
+
attr_reader :pages
|
|
2
3
|
|
|
3
4
|
def initialize(parent)
|
|
5
|
+
@pages = Array.new
|
|
4
6
|
@parent = parent
|
|
5
7
|
@ptype = @parent.class.to_s
|
|
6
8
|
# index owns paginator
|
|
@@ -41,17 +43,39 @@ class Index < Zarchitect
|
|
|
41
43
|
def setup_html
|
|
42
44
|
@html = Array.new
|
|
43
45
|
if @paginator.posts_per_page == 0
|
|
44
|
-
|
|
46
|
+
url = File.join(base_url, "index.html")
|
|
47
|
+
path = File.join(Dir.getwd,HTMLDIR,base_url,"index.html")
|
|
48
|
+
@pages.push(IndexPage.new(path, url))
|
|
49
|
+
html = HTML.new(path)
|
|
45
50
|
html.set_templates(layout, view)
|
|
51
|
+
html.set_data("url", url)
|
|
46
52
|
html.set_data("section", section)
|
|
47
53
|
html.set_data("category", category)
|
|
48
54
|
html.set_data("tag", tag)
|
|
49
55
|
html.set_data("posts", posts)
|
|
50
56
|
html.set_data("index", true)
|
|
57
|
+
|
|
51
58
|
html.set_meta("title", meta_title)
|
|
52
59
|
html.set_meta("keywords", meta_keywords)
|
|
53
60
|
html.set_meta("author", meta_author)
|
|
54
61
|
html.set_meta("description", meta_description)
|
|
62
|
+
|
|
63
|
+
html.set_meta("og_type", "website")
|
|
64
|
+
html.set_meta("og_image", meta_og_image)
|
|
65
|
+
html.set_meta("og_image_alt", meta_og_image_alt)
|
|
66
|
+
html.set_meta("og_image_width", meta_og_image_width)
|
|
67
|
+
html.set_meta("og_image_height", meta_og_image_height)
|
|
68
|
+
|
|
69
|
+
unless html.meta["og_image"].nil?
|
|
70
|
+
if html.meta["og_image_width"] == html.meta["og_image_height"]
|
|
71
|
+
html.set_meta("twitter_card", "summary")
|
|
72
|
+
else
|
|
73
|
+
html.set_meta("twitter_card", "summary_large_image")
|
|
74
|
+
end
|
|
75
|
+
else
|
|
76
|
+
html.set_meta("twitter_card", nil)
|
|
77
|
+
end
|
|
78
|
+
|
|
55
79
|
@html.push html
|
|
56
80
|
return
|
|
57
81
|
end
|
|
@@ -73,21 +97,43 @@ class Index < Zarchitect
|
|
|
73
97
|
@paginator.posts_per_page)
|
|
74
98
|
if i == 0
|
|
75
99
|
path = File.join(Dir.getwd,HTMLDIR,base_url, "index.html")
|
|
100
|
+
url = File.join(base_url, "index.html")
|
|
76
101
|
else
|
|
77
102
|
path = File.join(Dir.getwd,HTMLDIR,base_url, "index-#{i+1}.html")
|
|
103
|
+
url = File.join(base_url, "index-#{i+1}.html")
|
|
78
104
|
end
|
|
105
|
+
@pages.push(IndexPage.new(path, url))
|
|
79
106
|
html = HTML.new(path)
|
|
80
107
|
html.set_templates(layout, view)
|
|
108
|
+
html.set_data("url", url)
|
|
81
109
|
html.set_data("section", section)
|
|
82
110
|
html.set_data("category", category)
|
|
83
111
|
html.set_data("tag", tag)
|
|
84
112
|
html.set_data("posts", rposts)
|
|
85
113
|
html.set_data("paginator", @paginator.clone)
|
|
86
114
|
html.set_data("index", true)
|
|
115
|
+
|
|
87
116
|
html.set_meta("title", meta_title)
|
|
88
117
|
html.set_meta("keywords", meta_keywords)
|
|
89
118
|
html.set_meta("author", meta_author)
|
|
90
119
|
html.set_meta("description", meta_description)
|
|
120
|
+
|
|
121
|
+
html.set_meta("og_type", "website")
|
|
122
|
+
html.set_meta("og_image", meta_og_image)
|
|
123
|
+
html.set_meta("og_image_alt", meta_og_image_alt)
|
|
124
|
+
html.set_meta("og_image_width", meta_og_image_width)
|
|
125
|
+
html.set_meta("og_image_height", meta_og_image_height)
|
|
126
|
+
|
|
127
|
+
unless html.meta["og_image"].nil?
|
|
128
|
+
if html.meta["og_image_width"] == html.meta["og_image_height"]
|
|
129
|
+
html.set_meta("twitter_card", "summary")
|
|
130
|
+
else
|
|
131
|
+
html.set_meta("twitter_card", "summary_large_image")
|
|
132
|
+
end
|
|
133
|
+
else
|
|
134
|
+
html.set_meta("twitter_card", nil)
|
|
135
|
+
end
|
|
136
|
+
|
|
91
137
|
@html.push html
|
|
92
138
|
i += 1
|
|
93
139
|
@paginator.next
|
|
@@ -192,6 +238,16 @@ class Index < Zarchitect
|
|
|
192
238
|
end
|
|
193
239
|
end
|
|
194
240
|
|
|
241
|
+
def get_shared_option(opt)
|
|
242
|
+
if section.conf.has_option?(opt)
|
|
243
|
+
return section.conf.method(opt).call
|
|
244
|
+
elsif Zarchitect.conf.has_option?(opt)
|
|
245
|
+
return Zarchitect.conf.method(opt).call
|
|
246
|
+
else
|
|
247
|
+
return nil
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
|
|
195
251
|
##############################################
|
|
196
252
|
# meta data
|
|
197
253
|
#
|
|
@@ -213,11 +269,39 @@ class Index < Zarchitect
|
|
|
213
269
|
end
|
|
214
270
|
|
|
215
271
|
def meta_description
|
|
216
|
-
if
|
|
217
|
-
section.
|
|
272
|
+
if section.conf.has_option?("description")
|
|
273
|
+
section.conf.description
|
|
274
|
+
elsif category
|
|
275
|
+
"#{section.name}:#{category.name}"
|
|
218
276
|
else
|
|
219
|
-
section.name
|
|
277
|
+
"#{section.name}"
|
|
220
278
|
end
|
|
221
279
|
end
|
|
222
280
|
|
|
281
|
+
def meta_og_image
|
|
282
|
+
return get_shared_option("og_image")
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
def meta_og_image_alt
|
|
286
|
+
return get_shared_option("og_image_alt")
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
def meta_og_image_width
|
|
290
|
+
return get_shared_option("og_image_width")
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
def meta_og_image_height
|
|
294
|
+
return get_shared_option("og_image_height")
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
class IndexPage
|
|
300
|
+
attr_reader :url, :path
|
|
301
|
+
|
|
302
|
+
def initialize(path, url)
|
|
303
|
+
@url = url
|
|
304
|
+
@path = path
|
|
305
|
+
end
|
|
306
|
+
|
|
223
307
|
end
|
data/lib/zarchitect/post.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class Post < Zarchitect
|
|
2
2
|
attr_reader :source_path, :html_path, :conf, :content, :name, :draft, :date,
|
|
3
|
-
:description, :url, :category
|
|
3
|
+
:description, :url, :category, :key
|
|
4
4
|
attr_accessor :write_block
|
|
5
5
|
|
|
6
6
|
def initialize(path, section)
|
|
@@ -11,6 +11,11 @@ class Post < Zarchitect
|
|
|
11
11
|
@conf.validate_post
|
|
12
12
|
@conf.setup
|
|
13
13
|
@id = @conf.id.clone if @conf.has_option?("id")
|
|
14
|
+
if @conf.has_option?("key")
|
|
15
|
+
@key = @conf.key.clone
|
|
16
|
+
else
|
|
17
|
+
@key = @id.clone
|
|
18
|
+
end
|
|
14
19
|
if @conf.has_option?("always_write")
|
|
15
20
|
@always_write = @conf.always_write.clone
|
|
16
21
|
else
|
|
@@ -72,7 +77,7 @@ class Post < Zarchitect
|
|
|
72
77
|
@category = c if @conf.category == c.key
|
|
73
78
|
end
|
|
74
79
|
if @category.nil?
|
|
75
|
-
GPI.print "Unable to find category #{@conf.category}."
|
|
80
|
+
GPI.print "Error: Unable to find category #{@conf.category}."
|
|
76
81
|
GPI.quit
|
|
77
82
|
end
|
|
78
83
|
end
|
|
@@ -90,9 +95,11 @@ class Post < Zarchitect
|
|
|
90
95
|
def set_url
|
|
91
96
|
if @section.conf.collection
|
|
92
97
|
if @section.conf.categorize
|
|
93
|
-
|
|
98
|
+
#@url = "/#{@section.key}/#{@category.key}/#{@id}/index.html"
|
|
99
|
+
@url = "/#{@section.key}/#{@category.key}/#{@key}.html"
|
|
94
100
|
else
|
|
95
|
-
|
|
101
|
+
#@url = "/#{@section.key}/#{@id}/index.html"
|
|
102
|
+
@url = "/#{@section.key}/#{@key}.html"
|
|
96
103
|
end
|
|
97
104
|
else
|
|
98
105
|
@url = "/#{@section.key}/index.html"
|
|
@@ -107,9 +114,9 @@ class Post < Zarchitect
|
|
|
107
114
|
|
|
108
115
|
def create_dir
|
|
109
116
|
if @section.conf.collection && @section.conf.categorize
|
|
110
|
-
Util.mkdir(File.join(HTMLDIR, @section.key, @category.key
|
|
117
|
+
Util.mkdir(File.join(HTMLDIR, @section.key, @category.key))
|
|
111
118
|
elsif @section.conf.collection
|
|
112
|
-
Util.mkdir(File.join(HTMLDIR, @section.key
|
|
119
|
+
Util.mkdir(File.join(HTMLDIR, @section.key))
|
|
113
120
|
end
|
|
114
121
|
end
|
|
115
122
|
|
|
@@ -178,6 +185,7 @@ class Post < Zarchitect
|
|
|
178
185
|
@html = HTML.new(@html_path)
|
|
179
186
|
@html.set_templates(@section.conf.layout, @section.conf.view)
|
|
180
187
|
|
|
188
|
+
@html.set_data("url", @url)
|
|
181
189
|
@html.set_data("section", @section)
|
|
182
190
|
@html.set_data("category", @category)
|
|
183
191
|
@html.set_data("post", self)
|
|
@@ -188,12 +196,61 @@ class Post < Zarchitect
|
|
|
188
196
|
@html.set_meta("keywords", meta_keywords)
|
|
189
197
|
@html.set_meta("author", meta_author)
|
|
190
198
|
@html.set_meta("description", @description)
|
|
199
|
+
|
|
200
|
+
@html.set_meta("og_type", meta_og_type)
|
|
201
|
+
@html.set_meta("og_image", meta_og_image)
|
|
202
|
+
@html.set_meta("og_image_alt", meta_og_image_alt)
|
|
203
|
+
@html.set_meta("og_image_width", meta_og_image_width)
|
|
204
|
+
@html.set_meta("og_image_height", meta_og_image_height)
|
|
205
|
+
@html.set_meta("twitter_card", meta_twitter_card)
|
|
191
206
|
end
|
|
192
207
|
|
|
193
208
|
######################################
|
|
194
209
|
# meta data
|
|
195
210
|
#
|
|
196
211
|
|
|
212
|
+
def meta_twitter_card
|
|
213
|
+
if @conf.has_option?("twitter_card")
|
|
214
|
+
return @conf.twitter_card
|
|
215
|
+
else
|
|
216
|
+
unless @html.meta["og_image"].nil?
|
|
217
|
+
if @html.meta["og_image_width"] == @html.meta["og_image_height"]
|
|
218
|
+
return "summary"
|
|
219
|
+
else
|
|
220
|
+
return "summary_large_image"
|
|
221
|
+
end
|
|
222
|
+
else
|
|
223
|
+
return nil
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
def meta_og_image
|
|
229
|
+
return get_shared_option("og_image")
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
def meta_og_image_alt
|
|
233
|
+
return get_shared_option("og_image_alt")
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def meta_og_image_width
|
|
237
|
+
return get_shared_option("og_image_width")
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def meta_og_image_height
|
|
241
|
+
return get_shared_option("og_image_height")
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
def meta_og_type
|
|
245
|
+
if @conf.has_option?("og_type")
|
|
246
|
+
return @conf.og_type
|
|
247
|
+
elsif @section.conf.collection
|
|
248
|
+
return "article"
|
|
249
|
+
else
|
|
250
|
+
return "website"
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
|
|
197
254
|
def meta_title
|
|
198
255
|
title = "#{@name} - #{Zarchitect.conf.site_name}"
|
|
199
256
|
if @section.conf.collection
|
|
@@ -225,4 +282,16 @@ class Post < Zarchitect
|
|
|
225
282
|
end
|
|
226
283
|
end
|
|
227
284
|
|
|
285
|
+
def get_shared_option(opt)
|
|
286
|
+
if @conf.has_option?(opt)
|
|
287
|
+
return @conf.method(opt).call
|
|
288
|
+
elsif @section.conf.has_option?(opt)
|
|
289
|
+
return @section.conf.method(opt).call
|
|
290
|
+
elsif Zarchitect.conf.has_option?(opt)
|
|
291
|
+
return Zarchitect.conf.method(opt).call
|
|
292
|
+
else
|
|
293
|
+
return nil
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
|
|
228
297
|
end
|
data/lib/zarchitect/section.rb
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
class Section < Zarchitect
|
|
2
|
-
attr_reader :key, :conf, :name, :categories, :url
|
|
2
|
+
attr_reader :key, :conf, :name, :categories, :url, :index
|
|
3
3
|
|
|
4
4
|
def initialize(conf)
|
|
5
|
+
@index = false
|
|
5
6
|
GPI.print "Initializing Section #{conf.key}.", GPI::CLU.check_option('v')
|
|
6
7
|
@conf = conf
|
|
7
8
|
@key = conf.key
|
data/lib/zarchitect/tag.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
class Tag < Zarchitect
|
|
2
|
-
attr_accessor :category, :name, :key, :url
|
|
2
|
+
attr_accessor :category, :name, :key, :url, :index
|
|
3
3
|
|
|
4
4
|
def initialize(str, cat)
|
|
5
5
|
@category = cat
|
|
6
6
|
@name = str
|
|
7
|
-
|
|
7
|
+
set_key
|
|
8
8
|
@url = "/#{@category.section.key}/#{@category.key}/#{@key}/index.html"
|
|
9
9
|
create_dir
|
|
10
10
|
setup_index
|
|
@@ -43,4 +43,21 @@ class Tag < Zarchitect
|
|
|
43
43
|
str2.to_s(16).downcase
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
+
private
|
|
47
|
+
|
|
48
|
+
def set_key
|
|
49
|
+
if Zarchitect.conf.has_option?("tags")
|
|
50
|
+
@key = Zarchitect.conf.tags.key(@name)
|
|
51
|
+
if (@key == nil)
|
|
52
|
+
@key = Zarchitect.conf.tags.key(@name.downcase)
|
|
53
|
+
if (@key == nil)
|
|
54
|
+
GPI.print "Error: No tag key found for '#{@name}'."
|
|
55
|
+
GPI.quit
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
else
|
|
59
|
+
@key = hash(str)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
46
63
|
end
|
data/lib/zarchitect.rb
CHANGED
|
@@ -5,9 +5,11 @@ require 'sanitize'
|
|
|
5
5
|
require 'rss'
|
|
6
6
|
require 'nokogiri'
|
|
7
7
|
require 'katex'
|
|
8
|
+
require 'sitemap_generator'
|
|
8
9
|
|
|
9
10
|
class Zarchitect
|
|
10
11
|
|
|
12
|
+
VERSION = "1.6.0"
|
|
11
13
|
HTMLDIR = "_html"
|
|
12
14
|
BUILDIR = "_build"
|
|
13
15
|
NODEDIR = "_build/nodes"
|
|
@@ -35,6 +37,9 @@ class Zarchitect
|
|
|
35
37
|
GPI::CLU.use_command("u", [0], "rvqdD")
|
|
36
38
|
GPI::CLU.use_command("update", [0], "rvqdD")
|
|
37
39
|
|
|
40
|
+
GPI::CLU.use_command("s", [0], "v")
|
|
41
|
+
GPI::CLU.use_command("sitemap", [0], "v")
|
|
42
|
+
|
|
38
43
|
GPI::CLU.use_command("ua", [0], "v")
|
|
39
44
|
GPI::CLU.use_command("update-assets", [0], "v")
|
|
40
45
|
|
|
@@ -60,6 +65,10 @@ class Zarchitect
|
|
|
60
65
|
load_conf
|
|
61
66
|
cmd = CMD::New.new
|
|
62
67
|
cmd.run
|
|
68
|
+
when "sitemap", "s"
|
|
69
|
+
load_conf
|
|
70
|
+
cmd = CMD::Sitemap.new
|
|
71
|
+
cmd.run
|
|
63
72
|
when "update","u"
|
|
64
73
|
load_conf
|
|
65
74
|
cmd = CMD::Update.new
|
|
@@ -179,6 +188,7 @@ require 'zarchitect/image_set.rb'
|
|
|
179
188
|
require 'zarchitect/index.rb'
|
|
180
189
|
require 'zarchitect/cmd_misc.rb'
|
|
181
190
|
require 'zarchitect/cmd_new.rb'
|
|
191
|
+
require 'zarchitect/cmd_sitemap.rb'
|
|
182
192
|
require 'zarchitect/cmd_update.rb'
|
|
183
193
|
require 'zarchitect/misc_file.rb'
|
|
184
194
|
require 'zarchitect/post.rb'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zarchitect
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ryu
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-
|
|
11
|
+
date: 2023-04-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Yet another static website generator
|
|
14
14
|
email: ryu@tohya.net
|
|
@@ -26,6 +26,7 @@ files:
|
|
|
26
26
|
- lib/zarchitect/category.rb
|
|
27
27
|
- lib/zarchitect/cmd_misc.rb
|
|
28
28
|
- lib/zarchitect/cmd_new.rb
|
|
29
|
+
- lib/zarchitect/cmd_sitemap.rb
|
|
29
30
|
- lib/zarchitect/cmd_update.rb
|
|
30
31
|
- lib/zarchitect/config.rb
|
|
31
32
|
- lib/zarchitect/content.rb
|
|
@@ -46,7 +47,7 @@ files:
|
|
|
46
47
|
- lib/zarchitect/util.rb
|
|
47
48
|
- lib/zarchitect/video.rb
|
|
48
49
|
- lib/zarchitect/zerb.rb
|
|
49
|
-
homepage: https://www.tohya.net/projects/
|
|
50
|
+
homepage: https://www.tohya.net/projects/web/zarchitect.html
|
|
50
51
|
licenses:
|
|
51
52
|
- GPL-3.0
|
|
52
53
|
metadata: {}
|