pbsimply 3.1.0 → 3.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c2cee1a598dad5d08c823c51768afebae4d8e0459b3507658ca10a613c33bc4
4
- data.tar.gz: c13273c93cc68212ad5bb72b785dc01a640415c03bc5be98faccee449f8c54ee
3
+ metadata.gz: a7ba9b297d890ca650ba7e8e80481faeb37a94c853c2a6309306ffdb01bed604
4
+ data.tar.gz: 83083a80fcf51435a5dded559e7f455889367275752ab677f9affef66c91fe2c
5
5
  SHA512:
6
- metadata.gz: 1e90c599fc508e0e44aa1e882dca4de285f150dde10eecfaf7c22d20ca674cd4b29be5ace1a139a8fe36b5581afd1d81438c168c2823739a0ef1ddfbeacf1116
7
- data.tar.gz: e0a079093ca72cc0575b7858a687e838a8c848ff9c9eff036cba99e7678ee9de4f098890d619e1b5078049252f4b277bb20fc09c50d4db0488c4fb148e88ed58
6
+ metadata.gz: 377b47855124b9658c8dd3c82ab498dbd6719ec3fdd2ed1e727057c43ad2e544025a9cc2206d13776d9ce888f19356a7113ec5118a1e76b1f9b59a569d2d60a7
7
+ data.tar.gz: 8ea4cac700281cbccafc6b4acaa9c72249f9952c77183c265abdd6b41c4a871f2b4cbb784a8aac9d3b30745f31bb80d82b3bc015a49066a8667f6a70780e3efb
data/bin/pbsimply-init ADDED
@@ -0,0 +1,371 @@
1
+ #!/bin/env ruby
2
+ require 'fileutils'
3
+
4
+ module PBSimplyInit
5
+ end
6
+
7
+ PBSimplyInit::YAML = <<EOF
8
+ ---
9
+ # Built documents output path.
10
+ # ../Build means Build directory on Source document root's parent directory.
11
+ outdir: ../Build
12
+ #outdir: /home/foo/public_html/
13
+ #
14
+ # Template file path.
15
+ # ./template.html by default.
16
+ template: template.erb
17
+ #
18
+ # Loading CSS files (userd by Pandoc's default template.)
19
+ # This values must be *server's URL*.
20
+ # This settings is not avilable on rdoc, rdoc_markdown, kramdown, redcarpet or cmark engine.
21
+ #css:
22
+ # - /css/layout.css
23
+ # - /css/base.css#
24
+ # Enable TOC. true or false. false by default.
25
+ # This settings is not avilable on rdoc, rdoc_markdown, kramdown, redcarpet, cmark or docutils engine.
26
+ # toc: true
27
+ #
28
+ # Enable eRuby template expansion. true or false. false by default.
29
+ # This settings is not avilable on rdoc, rdoc_markdown, kramdown, redcarpet or cmark engine.
30
+ post_eruby: false
31
+ # Default metadata. If same key exists in document's frontmatter, document's frontmatter is given priority to this settings.
32
+ default_meta:
33
+ author: "John Doe"
34
+ site_title: "My first blog"
35
+ #
36
+ # Override every ACCS index page's frontmatter.
37
+ alt_frontmatter:
38
+ title: Serial documents by ACCS
39
+ #
40
+ # Testserver (pbsimply-testserver.rb)'s port. 8000 by default.
41
+ #testserver_port: 8000
42
+ #
43
+ # Generated document's URL absolute prefix. This value replaces reading /.
44
+ #self_url_prefix: /foowebsite/
45
+ #
46
+ # Generated document's URL absolute prefix. This value replaces reading /. Used by page_url_encoded_external.
47
+ self_url_external_prefix: https://example.com/
48
+ # Database format. use JSON if set json or oj.
49
+ #dbstyle: json
50
+ #
51
+ # Blessing way. If cmd given, you external command instead of Ruby function.
52
+ #bless_style: cmd
53
+ #
54
+ # Blessing external command
55
+ #bless_cmd: [echo, BLESS]
56
+ #
57
+ # Blessing external command on ACCS.
58
+ #bless_accscmd: [echo, ACCS]
59
+ #
60
+ # Method control for find ACCS next/prev.
61
+ # numbering, date, timestamp, lexical
62
+ #blessmethod_accs_rel: date
63
+ #
64
+ # Delete output file automatically when lose source document.
65
+ #auto_delete: yes
66
+ #
67
+ #################################################
68
+ # Pandoc engine option
69
+ #################################################
70
+ #pbsimply_processor: pandoc
71
+ #
72
+ # Pandoc's default file settings.
73
+ # It is merge into default file. See https://pandoc.org/MANUAL.html#default-files
74
+ # This option used only by pandoc engine.
75
+ #pandoc_additional_options:
76
+ # metadata:
77
+ # lang: ja
78
+ # title-prefix: "Powered by PureBuilder Simply"
79
+ # include-before-body:
80
+ # - before.html
81
+ # include-after-body:
82
+ # - after.html
83
+ #
84
+ #################################################
85
+ # Kramdown engine option
86
+ #################################################
87
+ pbsimply_processor: kramdown
88
+ # An associative array passed as the second argument to `Kramdown::Document.new`. See the https://kramdown.gettalong.org/rdoc/Kramdown/Options.html for detail.
89
+ #kramdown_features: {}
90
+ #
91
+ #################################################
92
+ # RedCarpet engine option
93
+ #################################################
94
+ #pbsimply_processor: redcarpet
95
+ # An associative array showing the extensions to Redcarpet. See the https://github.com/vmg/redcarpet for details.
96
+ #redcarpet_extensions: {}
97
+ #
98
+ #################################################
99
+ # Docutils engine option
100
+ #################################################
101
+ #pbsimply_processor: docutils
102
+ # rst2html5 command line options.
103
+ #docutils_options: []
104
+ EOF
105
+
106
+ PBSimplyInit::TEMPLATE = <<EOF
107
+ <!DOCTYPE html>
108
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
109
+ <head>
110
+ <meta charset="utf-8" />
111
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
112
+ <meta name="date" content="<%= frontmatter["date"] %>" />
113
+ <link rel="stylesheet" href="/css/style.css" />
114
+ <title><%= frontmatter["title"] %></title>
115
+ </head>
116
+ <body>
117
+ <div id="Overall">
118
+ <div id="BannerHeader">
119
+ <h1><%= frontmatter["site_title"] %></h1>
120
+ <h2><%= frontmatter["title"] %></h2>
121
+ </div>
122
+ <div id="ContentContainer">
123
+ <nav id="NavigationColumn">
124
+ <ul>
125
+ <%
126
+ require 'yaml'
127
+ menu = YAML.load File.read("menu.yaml")
128
+ %><% menu.each {|k, v| %><%= sprintf('<li><a href="%s">%s</a></li>', v, k) %><% } %>
129
+ </ul>
130
+ </nav>
131
+ <article id="MainArticle"><%= article_body %></aritcle>
132
+ </div>
133
+ <footer id="PBSimply">
134
+ Powered by <a href="https://purebuilder.app/">PureBuilder Simply</a>
135
+ </footer>
136
+ </div>
137
+ </body>
138
+ </html>
139
+ EOF
140
+
141
+ PBSimplyInit::CSS = <<EOF
142
+ body, html {
143
+ margin: 0;
144
+ padding: 0;
145
+ }
146
+ #Overall {
147
+ max-width: 800px;
148
+ margin: 0 auto;
149
+ }
150
+ #BannerHeader {
151
+ height: 200px;
152
+ width: 100%;
153
+ }
154
+ #ContentContainer {
155
+ display: flex;
156
+ width: 100%;
157
+ }
158
+ #BannerHeader {
159
+ background-color: #8eafe3;
160
+ border-radius: 2px;
161
+ color: #000;
162
+ }
163
+ #BannerHeader h1 {
164
+ font-size: 2.1rem;
165
+ text-align: center;
166
+ position: relative;
167
+ top: calc(50% - 1em);
168
+ }
169
+ #BannerHeader h2 {
170
+ font-size: 1.2rem;
171
+ text-align: center;
172
+ position: relative;
173
+ top: 1.25em;
174
+ }
175
+
176
+ #NavigationColumn ul {
177
+ list-style-type: none;
178
+ list-style-position: outside;
179
+ margin: 3px;
180
+ padding: 0;
181
+ text-align: center;
182
+ }
183
+ #NavigationColumn li {
184
+ background-color: #b9bced;
185
+ border: 2px solid #6367a1;
186
+ color: #000;
187
+ border-radius: 4px;
188
+ margin: 3px 1px;
189
+ padding: 2px;
190
+ }
191
+ #NavigationColumn a {
192
+ color: rgb(57, 18, 183);
193
+ text-decoration: none;
194
+ }
195
+ #MainArticle {
196
+ color: #666;
197
+ padding: 8px;
198
+ }
199
+ #MainArticle h1, #MainArticle h2, #MainArticle h3, #MainArticle h4, #MainArticle h5, #MainArticle h6 {
200
+ color: #333;
201
+ }
202
+ #PBSimply {
203
+ padding: 8px;
204
+ text-align: right;
205
+ border-top: 2px solid #6b84df;
206
+ }
207
+ @media screen and (min-width: 800px) {
208
+ #ContentContainer { flex-direction: row; }
209
+ #NavigationColumn {
210
+ order: 1;
211
+ width: 250px;
212
+ }
213
+ #MainArticle {
214
+ order: 2;
215
+ width: 550px;
216
+ }
217
+ }
218
+ @media screen and (max-width: 799px) {
219
+ #ContentContainer { flex-direction: column; }
220
+ #NavigationColumn {
221
+ order: 2;
222
+ width: 100%;
223
+ }
224
+ #MainArticle {
225
+ order: 1;
226
+ width: 100%;
227
+ }
228
+ }
229
+
230
+ a {
231
+ color: #4e1efd;
232
+ }
233
+ EOF
234
+
235
+ PBSimplyInit::INDEXMD = <<EOF
236
+ ---
237
+ title: First article
238
+ date: 1970-01-01
239
+ ---
240
+
241
+ # This is first article
242
+
243
+ This file is shown at top page.
244
+
245
+ The first step, edit index.md file on document source root.
246
+ EOF
247
+
248
+ PBSimplyInit::MENUYAML = <<EOF
249
+ ---
250
+ Top page: /
251
+ Article list: /articles
252
+ EOF
253
+
254
+ PBSimplyInit::ACCSYAML = <<EOF
255
+ ---
256
+ title: 1st series
257
+ EOF
258
+
259
+ PBSimplyInit::ACCSINDEX = <<EOF
260
+ ---
261
+ title: <%= @index["title"] %>
262
+ date: <%= @index["date"] %>
263
+ accsindex: yes
264
+ ---
265
+
266
+ <%
267
+ articles = Hash.new {|h,k| h[k] = Array.new }
268
+
269
+ @indexes.each do |filename, index|
270
+ articles[(index["category"] || "default")].push index
271
+ end
272
+
273
+ %>
274
+
275
+ % artkeys = articles.keys.sort
276
+ % artkeys.each do |catname|
277
+ % cat = articles[catname]
278
+
279
+ % if articles.length > 1
280
+ # <%= catname %>
281
+ % end
282
+
283
+ <%
284
+ list = if @config["accs_order"] == "desc" || @index["accs_order"] == "desc" || @index["blogmode"]
285
+ cat.sort_by {|i| [i["date"].to_s, i["title"].to_s, i["_last_update"].to_i] }.reverse
286
+ else
287
+ cat.sort_by {|i| [i["date"].to_s, i["title"].to_s, i["_last_update"].to_i] }
288
+ end
289
+
290
+ list.each do |i|
291
+ %>* [<%= i["title"].gsub('@', '\@') %>](<%= File.basename(i["_filename"].to_s, ".*") + ".html" %>) (<%= i["date"] %>)
292
+ <% end %>
293
+
294
+ % end
295
+ EOF
296
+
297
+ PBSimplyInit::ACCSARTICLE = <<EOF
298
+ ---
299
+ title: Untitled series 1
300
+ date: 2023-10-28
301
+ category: PureBuilder Simply
302
+ ---
303
+
304
+ # Untitled article
305
+
306
+ This is a series article sample.
307
+
308
+ `/articles` folder is set up as ACCS directory.
309
+ ACCS recognize articles as series, and generate index page automatically.
310
+
311
+ # How to add new article?
312
+
313
+ Add source document on `/articles`, and do `pbsimply articles`.
314
+
315
+ `pbsimply` will detect modified or new article and build it.
316
+
317
+ # How to remove this article?
318
+
319
+ Remove `/articles/20231028-untitled.md` and `../Build/articles/20231028-untitled.html`, and do `pbsimply articles`.
320
+ EOF
321
+
322
+ filepath = ARGV.shift
323
+ filepath ||= "."
324
+
325
+ if File.exist? filepath and (!File.directory? filepath)
326
+ abort "File #{filepath} is not directory."
327
+ end
328
+
329
+ if File.exist? filepath and Dir.children(filepath).length > 0
330
+ abort "File #{filepath} is not empty."
331
+ end
332
+
333
+ FileUtils.mkdir_p(File.join(filepath, "Source"))
334
+ FileUtils.mkdir_p(File.join(filepath, "Build"))
335
+
336
+ File.open(File.join(filepath, "Source", ".pbsimply.yaml"), "w") do |f|
337
+ f.puts PBSimplyInit::YAML
338
+ end
339
+
340
+ File.open(File.join(filepath, "Source", ".accsindex.erb"), "w") do |f|
341
+ f.puts PBSimplyInit::ACCSINDEX
342
+ end
343
+
344
+ File.open(File.join(filepath, "Source", "template.erb"), "w") do |f|
345
+ f.puts PBSimplyInit::TEMPLATE
346
+ end
347
+
348
+ File.open(File.join(filepath, "Source", "index.md"), "w") do |f|
349
+ f.puts PBSimplyInit::INDEXMD
350
+ end
351
+
352
+ File.open(File.join(filepath, "Source", "menu.yaml"), "w") do |f|
353
+ f.puts PBSimplyInit::MENUYAML
354
+ end
355
+
356
+ FileUtils.mkdir_p(File.join(filepath, "Source", "css"))
357
+ File.open(File.join(filepath, "Source", "css", "style.css"), "w") do |f|
358
+ f.puts PBSimplyInit::CSS
359
+ end
360
+
361
+ FileUtils.cp_r(File.join(filepath, "Source", "css"), File.join(filepath, "Build", "css"))
362
+
363
+ FileUtils.mkdir_p(File.join(filepath, "Source", "articles"))
364
+ File.open(File.join(filepath, "Source", "articles", ".accs.yaml"), "w") do |f|
365
+ f.puts PBSimplyInit::ACCSYAML
366
+ end
367
+
368
+ FileUtils.mkdir_p(File.join(filepath, "Source", "articles"))
369
+ File.open(File.join(filepath, "Source", "articles", "20231028-untitled.md"), "w") do |f|
370
+ f.puts PBSimplyInit::ACCSARTICLE
371
+ end
@@ -1,4 +1,4 @@
1
- #!/usr/bin/ruby
1
+ #!/bin/env ruby
2
2
  # -*- mode: ruby; coding: UTF-8 -*-
3
3
 
4
4
  require 'webrick'
@@ -15,13 +15,13 @@ class PBSimply
15
15
  # Abstruct super class.
16
16
  class DocDB
17
17
  def dump(object)
18
- File.open(File.join(@dir, ".indexes.#{@ext}"), "w") do |f|
18
+ File.open(File.join(@dir, ".indexes.#{@ext}"), wmode) do |f|
19
19
  f.write @store_class.dump(object)
20
20
  end
21
21
  end
22
22
 
23
23
  def load
24
- File.open(File.join(@dir, ".indexes.#{@ext}"), "r") do |f|
24
+ File.open(File.join(@dir, ".indexes.#{@ext}"), rmode) do |f|
25
25
  next @store_class.load(f)
26
26
  end
27
27
  end
@@ -38,6 +38,14 @@ class PBSimply
38
38
  @store_class.load(@store_class.dump(frontmatter))
39
39
  end
40
40
 
41
+ def wmode
42
+ "w"
43
+ end
44
+
45
+ def rmode
46
+ "r"
47
+ end
48
+
41
49
  # Use Ruby Marshal
42
50
  class Marshal < DocDB
43
51
  def initialize(dir)
@@ -49,6 +57,14 @@ class PBSimply
49
57
  def cmp_obj(frontmatter)
50
58
  frontmatter.dup
51
59
  end
60
+
61
+ def wmode
62
+ "wb"
63
+ end
64
+
65
+ def rmode
66
+ "rb"
67
+ end
52
68
  end
53
69
 
54
70
  # Use JSON with bundled library
@@ -56,10 +56,11 @@ class PBSimply
56
56
  File.open(@workfile_frontmatter, "w") {|f| YAML.dump(frontmatter, f)}
57
57
 
58
58
  # Go Pandoc
59
- pandoc_cmdline = ["pandoc"]
60
- pandoc_cmdline += ["-d", @workfile_pandoc_defaultfiles, "--metadata-file", @workfile_frontmatter, "-M", "title:#{frontmatter["title"]}"]
59
+ pandoc_cmdline = [(@config["pandoc_command"] || "pandoc")]
60
+ pandoc_cmdline += ["-d", @workfile_pandoc_defaultfiles, "--metadata-file", @workfile_frontmatter, "-M", "title:#{frontmatter["title"]}", "-w", "html5"]
61
61
  pandoc_cmdline += ["-f", frontmatter["input_format"]] if frontmatter["input_format"]
62
62
  pandoc_cmdline += [ procdoc ]
63
+ pp pandoc_cmdline if ENV["DEBUG"] == "yes"
63
64
  IO.popen((pandoc_cmdline)) do |io|
64
65
  doc = io.read
65
66
  end
@@ -59,8 +59,9 @@ class PBSimply::Hooks
59
59
  end
60
60
  end
61
61
 
62
- def initialize(pbsimply)
62
+ def initialize(pbsimply, config)
63
63
  @pbsimply = pbsimply
64
+ @config = config
64
65
  @hooks_loaded = false
65
66
 
66
67
  # Called first phase before generate. This hooks called before blessing.
@@ -111,4 +112,6 @@ class PBSimply::Hooks
111
112
  attr :delete
112
113
  attr :post
113
114
  attr :accs
115
+
116
+ attr :config
114
117
  end
data/lib/pbsimply.rb CHANGED
@@ -74,6 +74,8 @@ class PBSimply
74
74
  DocDB::JSON.new(dir)
75
75
  when "oj"
76
76
  DocDB::Oj.new(dir)
77
+ when "marshal"
78
+ DocDB::Marshal.new(dir)
77
79
  else
78
80
  DocDB::Marshal.new(dir)
79
81
  end
@@ -106,7 +108,7 @@ class PBSimply
106
108
  @accs = nil
107
109
  @accs_index = {}
108
110
  @now = Time.now
109
- @hooks = PBSimply::Hooks.new(self)
111
+ @hooks = PBSimply::Hooks.new(self, @config)
110
112
  end
111
113
 
112
114
  # Process command-line
@@ -334,9 +336,6 @@ class PBSimply
334
336
 
335
337
  @accs = true if File.exist?(File.join(@dir, ".accs.yaml"))
336
338
 
337
- # Check existing in indexes.
338
- @indexes.delete_if {|k,v| ! File.exist?([@dir, k].join("/")) }
339
-
340
339
  proc_dir
341
340
  end
342
341
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pbsimply
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaki Haruka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-16 00:00:00.000000000 Z
11
+ date: 2024-03-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Pre compile, static serving website builder.
14
14
  email:
@@ -16,10 +16,12 @@ email:
16
16
  executables:
17
17
  - pbsimply
18
18
  - pbsimply-testserver
19
+ - pbsimply-init
19
20
  extensions: []
20
21
  extra_rdoc_files: []
21
22
  files:
22
23
  - bin/pbsimply
24
+ - bin/pbsimply-init
23
25
  - bin/pbsimply-testserver
24
26
  - lib/pbsimply.rb
25
27
  - lib/pbsimply/accs.rb