pbsimply 3.2.2 → 3.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/pbsimply-init +130 -355
- data/lib/pbsimply/frontmatter.rb +12 -3
- data/lib/pbsimply.rb +35 -3
- data/themes/contribute/README.md +2 -0
- data/themes/default.yaml +1 -0
- data/themes/kramdown/init322/.accsindex.erb +35 -0
- data/themes/kramdown/init322/.pbsimply.yaml +96 -0
- data/themes/kramdown/init322/.theme.yaml +5 -0
- data/themes/kramdown/init322/articles/.accs.yaml +2 -0
- data/themes/kramdown/init322/articles/20231028-untitled.md +22 -0
- data/themes/kramdown/init322/css/style.css +91 -0
- data/themes/kramdown/init322/index.md +10 -0
- data/themes/kramdown/init322/menu.yaml +3 -0
- data/themes/kramdown/init322/template.erb +32 -0
- data/themes/pandoc/_pandoc_base/.accsindex.erb +50 -0
- data/themes/pandoc/_pandoc_base/.pbsimply.yaml +107 -0
- data/themes/pandoc/_pandoc_base/css/base.css +84 -0
- data/themes/pandoc/_pandoc_base/css/layout.css +55 -0
- data/themes/pandoc/_pandoc_base/css/lightbox.css +9 -0
- data/themes/pandoc/_pandoc_base/css/skylightning.css +29 -0
- data/themes/pandoc/_pandoc_base/javascript/lightbox.js +69 -0
- data/themes/pandoc/_pandoc_base/post/.accs.yaml +1 -0
- data/themes/pandoc/_pandoc_base/post/20231028-untitled.md +22 -0
- data/themes/pandoc/_pandoc_base/template.html +70 -0
- data/themes/pandoc/_pandoc_new/.accsindex.erb +50 -0
- data/themes/pandoc/_pandoc_new/.pbsimply-bless.rb +10 -0
- data/themes/pandoc/_pandoc_new/.pbsimply.yaml +107 -0
- data/themes/pandoc/_pandoc_new/articles/.accs.yaml +2 -0
- data/themes/pandoc/_pandoc_new/articles/20231028-untitled.md +22 -0
- data/themes/pandoc/_pandoc_new/index.md +31 -0
- data/themes/pandoc/_pandoc_new/menu.yaml +5 -0
- data/themes/pandoc/_pandoc_new/template.html +68 -0
- data/themes/pandoc/bloggy/.theme.yaml +7 -0
- data/themes/pandoc/bloggy/css/base.css +137 -0
- data/themes/pandoc/bloggy/css/layout.css +54 -0
- data/themes/pandoc/bloggy/template.html +70 -0
- data/themes/pandoc/cooldark/.theme.yaml +7 -0
- data/themes/pandoc/cooldark/css/theme.css +117 -0
- data/themes/pandoc/cooldark/js/lightbox.js +62 -0
- data/themes/pandoc/paper/.theme.yaml +7 -0
- data/themes/pandoc/paper/css/theme.css +126 -0
- data/themes/pandoc/paper/js/lightbox.js +62 -0
- data/themes/pandoc/practical/.theme.yaml +7 -0
- data/themes/pandoc/practical/css/base.css +115 -0
- data/themes/pandoc/practical/css/layout.css +16 -0
- data/themes/pandoc/warm/.theme.yaml +7 -0
- data/themes/pandoc/warm/css/base.css +84 -0
- metadata +48 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38b7c82bfe81f73eb7ce562485bb9e624f9feb0ac6632b0161bef86039b4bf0d
|
4
|
+
data.tar.gz: 97d5d322aa777ae16cfd0064907e088fcfeec60923da4cd1c1fe9e370a863e51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9667151ac7f946cd50dcde20cc534c1aae15dbd288160b5927394cc9cfc64b60009cc9cf2eee6093e7734ebdea6adcbb20cdd20f3f0805e5e97d50ecd8b9094
|
7
|
+
data.tar.gz: ad3504af0ab19b7780e5890ac6329fbbfb6fd00ff9fc58b529cb9aa469d32571bd3987f3b6b38ff4106645058b2d12a42e1aef8350e6ea8a378a86b574bd3a11
|
data/bin/pbsimply-init
CHANGED
@@ -1,371 +1,146 @@
|
|
1
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
2
|
require 'yaml'
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
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] }
|
3
|
+
require 'fileutils'
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
class PBSimplyInit
|
7
|
+
def initialize
|
8
|
+
set_gemroot
|
9
|
+
load_default_theme
|
10
|
+
|
11
|
+
@cmdopts = {}
|
12
|
+
op = OptionParser.new
|
13
|
+
op.on("-t THEME", "--theme")
|
14
|
+
op.on("-f", "--force")
|
15
|
+
op.on("-l", "--list-themes")
|
16
|
+
op.on("-s", "--source-only")
|
17
|
+
op.parse!(ARGV, into: @cmdopts)
|
18
|
+
|
19
|
+
@filepath = ARGV.shift
|
20
|
+
@filepath ||= "."
|
21
|
+
|
22
|
+
if @cmdopts[:"source-only"]
|
23
|
+
@source_dir = @filepath
|
24
|
+
else
|
25
|
+
@source_dir = File.join(@filepath, "Source")
|
26
|
+
@build_dir = File.join(@filepath, "Build")
|
27
|
+
end
|
28
|
+
|
29
|
+
@config_home = (ENV["XDG_CONFIG_HOME"] ? ENV["XDG_CONFIG_HOME"] : [ENV["HOME"], ".config"])
|
30
|
+
@theme_dirs = [[@gemroot, "themes"], [@gemroot, "themes", "contribute"], [*@config_home, "pbsimply", "themes"]]
|
31
|
+
|
32
|
+
if @cmdopts[:"list-themes"]
|
33
|
+
list_theme
|
34
|
+
exit true
|
35
|
+
end
|
288
36
|
end
|
289
37
|
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
%
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
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
|
38
|
+
def list_theme
|
39
|
+
themes = {}
|
40
|
+
@theme_dirs.each do |dir|
|
41
|
+
Dir.glob(File.join(*dir, "**", ".theme.yaml")).each do |i|
|
42
|
+
theme_name = i.sub(%r:[\\/]\.theme.yaml$:, "").delete_prefix(File.join(*dir)).sub(%r:^[\\/]:, "")
|
43
|
+
themes[theme_name] ||= YAML.load File.read i
|
44
|
+
end
|
45
|
+
end
|
46
|
+
themes.each do |k, v|
|
47
|
+
puts [k, v["name"], v["description"]].join(" ")
|
48
|
+
end
|
49
|
+
end
|
328
50
|
|
329
|
-
|
330
|
-
|
331
|
-
|
51
|
+
def set_gemroot
|
52
|
+
pwd = __FILE__
|
53
|
+
pwd = File.readlink __FILE__ if File.symlink? __FILE__
|
54
|
+
pwd = File.join(File.dirname(pwd), "..")
|
55
|
+
pwd = File.expand_path(pwd)
|
56
|
+
@gemroot = pwd
|
57
|
+
end
|
332
58
|
|
333
|
-
|
334
|
-
|
59
|
+
def mkdir
|
60
|
+
filepath = @filepath
|
335
61
|
|
336
|
-
File.
|
337
|
-
|
338
|
-
end
|
62
|
+
if File.exist? filepath and (!File.directory? filepath)
|
63
|
+
abort "File #{filepath} is not a directory."
|
64
|
+
end
|
339
65
|
|
340
|
-
File.
|
341
|
-
|
342
|
-
end
|
66
|
+
if File.exist? filepath and Dir.children(filepath).length > 0 and !@cmdopts[:force]
|
67
|
+
abort "File #{filepath} is not empty."
|
68
|
+
end
|
343
69
|
|
344
|
-
|
345
|
-
|
346
|
-
end
|
70
|
+
FileUtils.mkdir_p(@source_dir)
|
71
|
+
FileUtils.mkdir_p(@build_dir) if @build_dir
|
72
|
+
end
|
347
73
|
|
348
|
-
|
349
|
-
|
350
|
-
|
74
|
+
def load_default_theme
|
75
|
+
@default = YAML.load(File.read File.join(@gemroot, "themes", "default.yaml"))
|
76
|
+
@default_theme = @default["default_theme"]
|
77
|
+
end
|
351
78
|
|
352
|
-
|
353
|
-
|
354
|
-
|
79
|
+
def select_theme
|
80
|
+
if @cmdopts[:theme]
|
81
|
+
@theme = @cmdopts[:theme].split("/")
|
82
|
+
else
|
83
|
+
@theme = @default_theme
|
84
|
+
end
|
85
|
+
theme_path = search_theme @theme
|
86
|
+
load_theme_yaml theme_path
|
87
|
+
end
|
355
88
|
|
356
|
-
|
357
|
-
File.
|
358
|
-
|
359
|
-
|
89
|
+
def search_theme theme_name
|
90
|
+
theme = @theme_dirs.map {|i| i + theme_name }.first {|i| File.exist? File.join(*i, ".theme.yaml")}
|
91
|
+
abort "No such theme" unless theme
|
92
|
+
puts "Theme found at #{File.join *theme}"
|
93
|
+
theme
|
94
|
+
end
|
360
95
|
|
361
|
-
|
96
|
+
def load_theme_yaml theme_path
|
97
|
+
@theme_yaml = YAML.load(File.read File.join(theme_path, ".theme.yaml"))
|
98
|
+
end
|
362
99
|
|
363
|
-
|
364
|
-
|
365
|
-
|
100
|
+
def install_theme
|
101
|
+
$stderr.puts "Installing theme..."
|
102
|
+
|
103
|
+
# Backup .pbsimply.yaml
|
104
|
+
if File.exist?(File.join(@source_dir, ".pbsimply.yaml"))
|
105
|
+
File.rename(File.join(@source_dir, ".pbsimply.yaml"), File.join(@source_dir, ".pbsimply.yaml.orig"))
|
106
|
+
end
|
107
|
+
|
108
|
+
# Install base theme
|
109
|
+
if @theme_yaml["initial_control"] && @theme_yaml["initial_control"]["base_theme"]
|
110
|
+
$stderr.puts "Install base theme..."
|
111
|
+
Dir.children(File.join(@gemroot, "themes", @theme_yaml["initial_control"]["base_theme"])).each do |i|
|
112
|
+
FileUtils.cp_r(File.join(@gemroot, "themes", *@theme_yaml["initial_control"]["base_theme"], i), File.join(@source_dir))
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
$stderr.puts "Install theme..."
|
117
|
+
Dir.children(File.join(@gemroot, "themes", *@theme)).each do |i|
|
118
|
+
FileUtils.cp_r(File.join(@gemroot, "themes", *@theme, i), File.join(@source_dir))
|
119
|
+
end
|
120
|
+
|
121
|
+
if @theme_yaml["initial_control"]
|
122
|
+
if @theme_yaml["initial_control"]["build_mkdirp"] && @build_dir
|
123
|
+
$stderr.puts "Create directories in Build directory..."
|
124
|
+
@theme_yaml["initial_control"]["build_mkdirp"].each do |i|
|
125
|
+
abort "The theme includes potentially dangerous command" if i.include? ".."
|
126
|
+
FileUtils.mkdir_p(File.join(@build_dir, *i))
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
if @theme_yaml["initial_control"]["build_cpr"] && @build_dir
|
131
|
+
$stderr.puts "Copy files in Build directory..."
|
132
|
+
@theme_yaml["initial_control"]["build_cpr"].each do |i|
|
133
|
+
abort "The theme includes potentially dangerous command" if i.include? ".."
|
134
|
+
FileUtils.cp_r(File.join(@source_dir, *i), @build_dir)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
$stderr.puts "Done"
|
140
|
+
end
|
366
141
|
end
|
367
142
|
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
143
|
+
initializer = PBSimplyInit.new
|
144
|
+
initializer.select_theme
|
145
|
+
initializer.mkdir
|
146
|
+
initializer.install_theme
|
data/lib/pbsimply/frontmatter.rb
CHANGED
@@ -126,14 +126,13 @@ module PBSimply::Frontmatter
|
|
126
126
|
abort "This document has no frontmatter" unless frontmatter
|
127
127
|
abort "This document has no title." unless frontmatter["title"]
|
128
128
|
|
129
|
-
outext = frontmatter["force_ext"] || ".html"
|
130
129
|
outpath = case
|
131
130
|
when @outfile
|
132
131
|
@outfile
|
133
132
|
when @accs_processing
|
134
|
-
File.join(@config["outdir"], @dir, "index") + outext
|
133
|
+
File.join(@config["outdir"], @dir, "index") + outext(frontmatter)
|
135
134
|
else
|
136
|
-
File.join(@config["outdir"], @dir, File.basename(filename, ".*")) + outext
|
135
|
+
File.join(@config["outdir"], @dir, File.basename(filename, ".*")) + outext(frontmatter)
|
137
136
|
end
|
138
137
|
|
139
138
|
absolute_current = File.absolute_path Dir.pwd
|
@@ -200,4 +199,14 @@ module PBSimply::Frontmatter
|
|
200
199
|
|
201
200
|
return frontmatter, pos
|
202
201
|
end
|
202
|
+
|
203
|
+
def outext frontmatter
|
204
|
+
return frontmatter["force_ext"] if frontmatter["force_ext"]
|
205
|
+
|
206
|
+
if @config["jsonout"]
|
207
|
+
".json"
|
208
|
+
else
|
209
|
+
".html"
|
210
|
+
end
|
211
|
+
end
|
203
212
|
end
|
data/lib/pbsimply.rb
CHANGED
@@ -367,6 +367,7 @@ class PBSimply
|
|
367
367
|
pre_plugins(procdoc, frontmatter)
|
368
368
|
@hooks.pre.run({procdoc: procdoc, frontmatter: frontmatter})
|
369
369
|
|
370
|
+
# Generated Document
|
370
371
|
doc = process_document(dir, filename, frontmatter, orig_filepath, ext, procdoc) # at sub-class
|
371
372
|
|
372
373
|
##### Post eRuby
|
@@ -378,9 +379,7 @@ class PBSimply
|
|
378
379
|
# Write out
|
379
380
|
outpath = frontmatter["dest_path"]
|
380
381
|
|
381
|
-
|
382
|
-
f.write(doc)
|
383
|
-
end
|
382
|
+
write_out outpath, frontmatter, doc
|
384
383
|
|
385
384
|
# Hooks for processed document.
|
386
385
|
@hooks.process.run({
|
@@ -399,6 +398,39 @@ class PBSimply
|
|
399
398
|
|
400
399
|
private
|
401
400
|
|
401
|
+
# Interface to write file
|
402
|
+
def write_out outpath, frontmatter, doc
|
403
|
+
if @config["jsonout"]
|
404
|
+
write_json outpath, frontmatter, doc
|
405
|
+
else
|
406
|
+
File.open(outpath, "w") do |f|
|
407
|
+
f.write(doc)
|
408
|
+
end
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
412
|
+
# Write file with JSON format
|
413
|
+
def write_json outpath, frontmatter, doc
|
414
|
+
fm = frontmatter.dup
|
415
|
+
if @config["jsonout_include"]
|
416
|
+
fm = {}
|
417
|
+
@config["jsonout_include"].each do |k|
|
418
|
+
fm[k] = frontmatter[k]
|
419
|
+
end
|
420
|
+
elsif @config["jsonout_exclude"]
|
421
|
+
@config["jsonout_exclude"].each do |k|
|
422
|
+
fm.delete k
|
423
|
+
end
|
424
|
+
end
|
425
|
+
|
426
|
+
File.open(outpath, "w") do |f|
|
427
|
+
f.write JSON_LIB.dump({
|
428
|
+
"frontmatter": fm,
|
429
|
+
"document": doc
|
430
|
+
})
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
402
434
|
# Check is the article modified? (or force update?)
|
403
435
|
def check_modify(filename, frontmatter)
|
404
436
|
modify = true
|
data/themes/default.yaml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
default_theme: [kramdown, init322]
|
@@ -0,0 +1,35 @@
|
|
1
|
+
---
|
2
|
+
title: <%= @index["title"] %>
|
3
|
+
date: <%= @index["date"] %>
|
4
|
+
accsindex: yes
|
5
|
+
---
|
6
|
+
|
7
|
+
<%
|
8
|
+
articles = Hash.new {|h,k| h[k] = Array.new }
|
9
|
+
|
10
|
+
@indexes.each do |filename, index|
|
11
|
+
articles[(index["category"] || "default")].push index
|
12
|
+
end
|
13
|
+
|
14
|
+
%>
|
15
|
+
|
16
|
+
% artkeys = articles.keys.sort
|
17
|
+
% artkeys.each do |catname|
|
18
|
+
% cat = articles[catname]
|
19
|
+
|
20
|
+
% if articles.length > 1
|
21
|
+
# <%= catname %>
|
22
|
+
% end
|
23
|
+
|
24
|
+
<%
|
25
|
+
list = if @config["accs_order"] == "desc" || @index["accs_order"] == "desc" || @index["blogmode"]
|
26
|
+
cat.sort_by {|i| [i["date"].to_s, i["title"].to_s, i["_last_update"].to_i] }.reverse
|
27
|
+
else
|
28
|
+
cat.sort_by {|i| [i["date"].to_s, i["title"].to_s, i["_last_update"].to_i] }
|
29
|
+
end
|
30
|
+
|
31
|
+
list.each do |i|
|
32
|
+
%>* [<%= i["title"].gsub('@', '\@') %>](<%= File.basename(i["_filename"].to_s, ".*") + ".html" %>) (<%= i["date"] %>)
|
33
|
+
<% end %>
|
34
|
+
|
35
|
+
% end
|