pbsimply 3.8.0 → 3.9.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/lib/pbsimply/frontmatter.rb +1 -0
- data/lib/pbsimply/utils.rb +83 -0
- data/lib/pbsimply.rb +9 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 975c294c043cdc42f1a27b4ca670452598895f14bf8f4d4af5861e8c042827c2
|
|
4
|
+
data.tar.gz: fea3998951bb0c26638d11bbc53bd74644ae3b768b8676a8636888b02c89357f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 23b6806940f2c7498d99df6ded9f50c6cd4c35a97f768e75ef5411330307accdfc696026202540e2f7a6ad1f097e1b1cd014ddf8deb6234f1c727bb7c3333628
|
|
7
|
+
data.tar.gz: a09f739635c30597857f7401fa6df02266dc26476a41f4afff13d0692a41bec6836224ea475ef9bcee0470934780458c75730ea03e134864738357d6d5a5cf0d
|
data/lib/pbsimply/frontmatter.rb
CHANGED
|
@@ -168,6 +168,7 @@ module PBSimply::Frontmatter
|
|
|
168
168
|
this_url.sub!(%r!/\.([^/]+.html)$!, '/\1')
|
|
169
169
|
this_url_external.sub!(%r!/\.([^/]+.html)$!, '/\1')
|
|
170
170
|
frontmatter["page_url"] = this_url
|
|
171
|
+
frontmatter["page_url_external"] = this_url_external
|
|
171
172
|
# URL in site with URI encode.
|
|
172
173
|
frontmatter["page_url_encoded"] = ERB::Util.url_encode(this_url)
|
|
173
174
|
frontmatter["page_url_encoded_external"] = ERB::Util.url_encode(this_url_external)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
class PBSimply
|
|
4
|
+
class Utils
|
|
5
|
+
def self.normalize_source_path path
|
|
6
|
+
root = File.expand_path Dir.pwd
|
|
7
|
+
path = File.expand_path path
|
|
8
|
+
unless root == path[0, root.length]
|
|
9
|
+
raise InvalidPathError.new("source path not match to document root.")
|
|
10
|
+
end
|
|
11
|
+
path[root.length..].sub(%r:^/:, "")
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class JsonlLogger
|
|
16
|
+
def initialize enabled
|
|
17
|
+
@logfile = nil
|
|
18
|
+
if enabled
|
|
19
|
+
unless File.exist? ".pbsimply_var"
|
|
20
|
+
Dir.mkdir(".pbsimply_var")
|
|
21
|
+
end
|
|
22
|
+
@logfile = File.open(File.join(".pbsimply_var", "log.jsonl"), "a")
|
|
23
|
+
@logfile.flock(File::LOCK_EX)
|
|
24
|
+
@logfile.seek(0, IO::SEEK_END)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def generate frontmatter
|
|
29
|
+
return unless @logfile
|
|
30
|
+
@logfile.puts JSON.generate({
|
|
31
|
+
"action" => "generate",
|
|
32
|
+
"filepath" => frontmatter["source_path"],
|
|
33
|
+
"timestamp" => Time.now.to_i,
|
|
34
|
+
"title" => frontmatter["title"],
|
|
35
|
+
"url" => frontmatter["page_url"],
|
|
36
|
+
"size" => frontmatter["_size"],
|
|
37
|
+
"format" => frontmatter["_docformat"]
|
|
38
|
+
})
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def delete fp
|
|
42
|
+
return unless @logfile
|
|
43
|
+
@logfile.puts JSON.generate({
|
|
44
|
+
"action" => "delete",
|
|
45
|
+
"filepath" => Utils.normalize_source_path(fp),
|
|
46
|
+
"timestamp" => Time.now.to_i
|
|
47
|
+
})
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class TitleMapDB
|
|
52
|
+
def initialize enabled
|
|
53
|
+
@db = nil
|
|
54
|
+
if enabled
|
|
55
|
+
require 'dbm'
|
|
56
|
+
unless File.exist? ".pbsimply_var"
|
|
57
|
+
Dir.mkdir(".pbsimply_var")
|
|
58
|
+
end
|
|
59
|
+
@db = DBM.new(File.join(".pbsimply_var", "titlemap"))
|
|
60
|
+
@key = "title"
|
|
61
|
+
@key = "title_encoded" if enabled == "url_encoded"
|
|
62
|
+
@key = "title_html_escaped" if enabled == "html_escaped"
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def []=(path, frontmatter)
|
|
67
|
+
return unless @db
|
|
68
|
+
now = Time.now.to_i
|
|
69
|
+
val = @db[path]
|
|
70
|
+
val = val ? JSON.load(val) : {}
|
|
71
|
+
if val[frontmatter[@key]]
|
|
72
|
+
val[frontmatter[@key]]["last_update"] = now
|
|
73
|
+
else
|
|
74
|
+
val[frontmatter[@key]] = {
|
|
75
|
+
"since" => now,
|
|
76
|
+
"last_update" => now
|
|
77
|
+
}
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
@db[path] = val
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
data/lib/pbsimply.rb
CHANGED
|
@@ -21,6 +21,7 @@ require 'pbsimply/config-checker'
|
|
|
21
21
|
require 'pbsimply/document'
|
|
22
22
|
require 'pbsimply/eruby'
|
|
23
23
|
require 'pbsimply/template-engine'
|
|
24
|
+
require 'pbsimply/utils'
|
|
24
25
|
|
|
25
26
|
class PBSimply
|
|
26
27
|
include Prayer
|
|
@@ -62,6 +63,8 @@ class PBSimply
|
|
|
62
63
|
class InvalidConfigError < PBSimplyError
|
|
63
64
|
end
|
|
64
65
|
end
|
|
66
|
+
class InvalidPathError < PBSimplyError
|
|
67
|
+
end
|
|
65
68
|
|
|
66
69
|
# Use Oj as JSON library for frontmatter passing if possible.
|
|
67
70
|
begin
|
|
@@ -165,6 +168,9 @@ class PBSimply
|
|
|
165
168
|
@frontmatter = {}
|
|
166
169
|
@accs_processing = false
|
|
167
170
|
|
|
171
|
+
@logger = JsonlLogger.new config["enable_jsonl_log"]
|
|
172
|
+
@titlemap_db = TitleMapDB.new config["enable_titlemap"]
|
|
173
|
+
|
|
168
174
|
$debug = (ENV["DEBUG"] == "yes")
|
|
169
175
|
end
|
|
170
176
|
|
|
@@ -349,6 +355,7 @@ class PBSimply
|
|
|
349
355
|
tfp = File.join(@config["outdir"], @dir, tfn)
|
|
350
356
|
if File.file?(tfp)
|
|
351
357
|
$stderr.puts "#{df} was turn to draft."
|
|
358
|
+
@logger.delete dah[:source_file_path]
|
|
352
359
|
@hooks.delete.run({target_file_path: tfp, source_file_path: dah[:source_file_path]})
|
|
353
360
|
File.delete tfp if @config["auto_delete"]
|
|
354
361
|
end
|
|
@@ -367,6 +374,7 @@ class PBSimply
|
|
|
367
374
|
unless File.exist? v["source_path"]
|
|
368
375
|
$stderr.puts "#{k} is missing."
|
|
369
376
|
missing_keys.push k
|
|
377
|
+
@logger.delete v["source_path"]
|
|
370
378
|
@hooks.delete.run({target_file_path: v["dest_path"] ,source_file_path: v["source_path"]})
|
|
371
379
|
File.delete v["dest_path"] if @config["auto_delete"]
|
|
372
380
|
end
|
|
@@ -448,6 +456,7 @@ class PBSimply
|
|
|
448
456
|
|
|
449
457
|
# Generated Document
|
|
450
458
|
doc = process_document(dir, filename, frontmatter, orig_filepath, ext, procdoc) # at sub-class
|
|
459
|
+
@logger.generate frontmatter
|
|
451
460
|
|
|
452
461
|
##### Post eRuby
|
|
453
462
|
if @config["post_eruby"]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pbsimply
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Masaki Haruka
|
|
@@ -43,6 +43,7 @@ files:
|
|
|
43
43
|
- lib/pbsimply/plugger.rb
|
|
44
44
|
- lib/pbsimply/prayer.rb
|
|
45
45
|
- lib/pbsimply/template-engine.rb
|
|
46
|
+
- lib/pbsimply/utils.rb
|
|
46
47
|
- themes/contribute/README.md
|
|
47
48
|
- themes/default.yaml
|
|
48
49
|
- themes/pandoc/_pandoc_base/.accsindex.erb
|
|
@@ -110,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
110
111
|
- !ruby/object:Gem::Version
|
|
111
112
|
version: '0'
|
|
112
113
|
requirements: []
|
|
113
|
-
rubygems_version: 4.0.
|
|
114
|
+
rubygems_version: 4.0.16
|
|
114
115
|
specification_version: 4
|
|
115
116
|
summary: Flexible and programmable static site generator with pluggable Markdown engines
|
|
116
117
|
test_files: []
|