PlainSite 1.2.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.
Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +43 -0
  4. data/LICENSE +20 -0
  5. data/PlainSite.gemspec +40 -0
  6. data/README.md +276 -0
  7. data/Rakefile +34 -0
  8. data/_config.yml +6 -0
  9. data/bin/plainsite +76 -0
  10. data/lib/PlainSite.rb +5 -0
  11. data/lib/PlainSite/Commands.rb +76 -0
  12. data/lib/PlainSite/Data/Category.rb +235 -0
  13. data/lib/PlainSite/Data/FrontMatterFile.rb +64 -0
  14. data/lib/PlainSite/Data/Post.rb +237 -0
  15. data/lib/PlainSite/Data/PostList.rb +164 -0
  16. data/lib/PlainSite/Data/PostListPage.rb +80 -0
  17. data/lib/PlainSite/RenderTask.rb +235 -0
  18. data/lib/PlainSite/Site.rb +330 -0
  19. data/lib/PlainSite/SocketPatch.rb +15 -0
  20. data/lib/PlainSite/Tpl/ExtMethods.rb +55 -0
  21. data/lib/PlainSite/Tpl/LayErb.rb +73 -0
  22. data/lib/PlainSite/Utils.rb +79 -0
  23. data/lib/PlainSite/_scaffold/_src/assets/README.md +5 -0
  24. data/lib/PlainSite/_scaffold/_src/assets/css/style.css +506 -0
  25. data/lib/PlainSite/_scaffold/_src/assets/favicon.ico +0 -0
  26. data/lib/PlainSite/_scaffold/_src/config.yml +10 -0
  27. data/lib/PlainSite/_scaffold/_src/data/essays/game-of-life.md +15 -0
  28. data/lib/PlainSite/_scaffold/_src/data/essays/phoenix-rebirth.html +15 -0
  29. data/lib/PlainSite/_scaffold/_src/data/programming/hello-world.md +48 -0
  30. data/lib/PlainSite/_scaffold/_src/extensions/TplExt.rb +23 -0
  31. data/lib/PlainSite/_scaffold/_src/routes.rb +49 -0
  32. data/lib/PlainSite/_scaffold/_src/templates/404.html +16 -0
  33. data/lib/PlainSite/_scaffold/_src/templates/about.html +11 -0
  34. data/lib/PlainSite/_scaffold/_src/templates/base.html +32 -0
  35. data/lib/PlainSite/_scaffold/_src/templates/header.html +8 -0
  36. data/lib/PlainSite/_scaffold/_src/templates/index.html +25 -0
  37. data/lib/PlainSite/_scaffold/_src/templates/list.html +41 -0
  38. data/lib/PlainSite/_scaffold/_src/templates/post.html +81 -0
  39. data/lib/PlainSite/_scaffold/_src/templates/rss.erb +29 -0
  40. data/test/CategoryTest.rb +63 -0
  41. data/test/FrontMatterFileTest.rb +40 -0
  42. data/test/LayErbTest.rb +20 -0
  43. data/test/ObjectProxyTest.rb +30 -0
  44. data/test/PostListTest.rb +55 -0
  45. data/test/PostTest.rb +48 -0
  46. data/test/SiteTest.rb +105 -0
  47. data/test/fixtures/2012-06-12-test.md +7 -0
  48. data/test/fixtures/category-demo/2012-06-12-post1.md +7 -0
  49. data/test/fixtures/category-demo/2013-05-01-post2.md +7 -0
  50. data/test/fixtures/category-demo/_meta.yml +1 -0
  51. data/test/fixtures/category-demo/index.md +6 -0
  52. data/test/fixtures/category-demo/sub-category1/sub-post1.md +1 -0
  53. data/test/fixtures/category-demo/sub-category2/sub-post2.md +1 -0
  54. data/test/fixtures/include.erb +1 -0
  55. data/test/fixtures/invalid-front-matter.html +7 -0
  56. data/test/fixtures/layout.erb +1 -0
  57. data/test/fixtures/no-front-matter.html +2 -0
  58. data/test/fixtures/tpl.erb +7 -0
  59. data/test/fixtures/valid-front-matter.html +14 -0
  60. data/test/runtest +6 -0
  61. metadata +202 -0
@@ -0,0 +1,79 @@
1
+ #coding:utf-8
2
+ module PlainSite;end
3
+ module PlainSite::Utils
4
+ require 'fileutils'
5
+
6
+ class ObjectProxy
7
+ attr_reader :objects
8
+ def initialize(*objects)
9
+ @objects=objects
10
+ end
11
+
12
+ def <<(*objects)
13
+ @objects.concat objects
14
+ end
15
+
16
+ def dup
17
+ ObjectProxy.new *@objects
18
+ end
19
+
20
+ def clone
21
+ ObjectProxy.new self
22
+ end
23
+
24
+ def respond_to?(name)
25
+ return true if @objects.any? do |o|
26
+ o.respond_to? name || ((o.respond_to? :key?) && ((o.key? name) || (o.key? name.to_s)))
27
+ end
28
+ super
29
+ end
30
+
31
+ def method_missing(name,*args,&block)
32
+ o=@objects.detect {|o|o.respond_to? name}
33
+ if o
34
+ define_singleton_method(name) do |*a,&b|
35
+ o.send name,*a,&b
36
+ end
37
+ return o.send name,*args,&block
38
+ end
39
+ if args.empty? && block.nil?
40
+ o=@objects.detect {|o|(o.respond_to? :key?) && ((o.key? name) || (o.key? name.to_s))}
41
+ if o
42
+ define_singleton_method(name) do
43
+ o[name] || o[name.to_s]
44
+ end
45
+ return o[name] || o[name.to_s]
46
+ end
47
+ end
48
+ super
49
+ end
50
+
51
+ def get_binding
52
+ binding
53
+ end
54
+ end
55
+
56
+ # Copy src folder's contents to dest folder recursively merge
57
+ # src - The String source directory
58
+ # dest - The String destination directory
59
+ # override - The Boolean value to indicate whether override exist file,default is false
60
+ def self.merge_folder(src,dest,override=false)
61
+ src=File.realpath src
62
+ files=Dir.glob src+'/**/*',File::FNM_DOTMATCH
63
+ prefix_len=src.length+1
64
+ files.each do |src_path|
65
+ rel_path=src_path[prefix_len..-1]
66
+ dest_path=File.join(dest,rel_path)
67
+ if File.directory? src_path
68
+ FileUtils.mkdir_p dest_path
69
+ else
70
+ if override || !(File.exist? dest_path)
71
+ FileUtils.copy_file src_path,dest_path
72
+ end
73
+ end
74
+ end
75
+ end
76
+
77
+ end
78
+
79
+
@@ -0,0 +1,5 @@
1
+ Demo Blog
2
+ ===========
3
+
4
+
5
+ Powerd by [PlainSite](https://jex.im/)!
@@ -0,0 +1,506 @@
1
+ @charset "utf-8";
2
+
3
+ /*Reset*/
4
+ html,body, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, textarea, p, blockquote, th, td, hr, button, article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
5
+ margin: 0;
6
+ padding: 0;
7
+ }
8
+
9
+ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
10
+ display: block;
11
+ }
12
+
13
+ audio, canvas, video {
14
+ display: inline-block;
15
+ }
16
+ img {border:0;}
17
+
18
+ html {
19
+ font-size:18px;
20
+ height: 100%;
21
+ color: #333222;
22
+ background-color: darkgreen;
23
+ }
24
+
25
+ body {
26
+ text-rendering: optimizeLegibility;
27
+ font-family:"Microsoft Yahei","WenQuanYi Micro Hei",helvetica,arial,sans-serif;
28
+ margin:0 auto;
29
+ padding:0 40px;
30
+ padding:0 36px;
31
+ word-wrap:break-word;
32
+ max-width:68rem;
33
+ min-height: 100%;
34
+ position:relative;
35
+ line-height:160%;
36
+ width:1024px\9;
37
+ background:#F4FCFC;
38
+ }
39
+
40
+ h1,h2,h3,h4,h5,h6 {
41
+ display:block;
42
+ margin:34px 0 8px 0;
43
+ font-weight:bold;
44
+ color:#2c3e50;
45
+ line-height:140%;
46
+ }
47
+ h1:lang(zh),h2:lang(zh),h3:lang(zh),
48
+ :lang(zh) h1,:lang(zh) h2,:lang(zh) h3 {
49
+ text-align:center;
50
+ }
51
+ h1 {font-size:32px;margin-bottom:16px;}
52
+ h2 {font-size:30px;margin-bottom:14px;}
53
+ h3 {font-size:26px;margin-bottom:12px;}
54
+ h4 {font-size:24px;margin-top:22px;}
55
+ h5 {font-size:22px;margin-top:18px;}
56
+ h6 {font-size:20px;margin-top:16px;}
57
+
58
+ p {
59
+ margin:8px 0 14px 0;
60
+ }
61
+ :lang(zh) p,p:lang(zh) {
62
+ text-indent:2em;
63
+ }
64
+
65
+ ul,ol {
66
+ margin:10px 2em;
67
+ }
68
+ ol:lang(zh) {
69
+ list-style-type:cjk-ideographic ;
70
+ }
71
+ ul { list-style-type: circle; }
72
+ li {
73
+ margin:2px 0;
74
+ }
75
+ li ul {
76
+ list-style-type:cycle(disc circle square circle);
77
+ }
78
+ ul ul {
79
+ list-style-type: disc;
80
+ }
81
+ ul ul ul {
82
+ list-style-type: circle;
83
+ }
84
+ ul ul ul ul {
85
+ list-style-type: square;
86
+ }
87
+ ul ul ul ul ul {
88
+ list-style-type: circle;
89
+ }
90
+ ul ul ul ul ul ul { /*It's funny!Huh?*/
91
+ list-style-type: disc;
92
+ }
93
+
94
+ li {
95
+ padding:4px 0;
96
+ }
97
+
98
+ hr{
99
+ border:none;
100
+ border-bottom:1px solid #cfcfcf;
101
+ margin:12px 0;
102
+ height:0px;
103
+ }
104
+
105
+ br {
106
+ display:block;
107
+ float:none;
108
+ clear:both;
109
+ width:0;
110
+ height:0;
111
+ line-height:0;
112
+ overflow:hidden;
113
+ }
114
+
115
+ blockquote {
116
+ margin: 12px 0;
117
+ color:#555;
118
+ padding: 8px 1em;
119
+ background:#F8FAF8;
120
+ border-left: 6px solid #CCF;
121
+ }
122
+ blockquote blockquote {
123
+ padding: 0 0 0 1em;
124
+ margin-left: 2em;
125
+ }
126
+ acronym, abbr {border-bottom: 1px dotted;cursor:help;}
127
+ del {text-decoration: line-through;}
128
+ q:before,q:after {content:''}
129
+ :lang(zh) q:before,q:lang(zh):before {content: '「';}
130
+ :lang(zh) q:after,q:lang(zh):after {content: '」';}
131
+
132
+ em,cite {
133
+ font-style:normal;
134
+ padding:0 4px;
135
+ color:#000;
136
+ }
137
+ i {
138
+ font-style:italic;
139
+ }
140
+
141
+ sub, sup {
142
+ font-size: 70%;
143
+ line-height: 0;
144
+ position: relative;
145
+ vertical-align: baseline;
146
+ }
147
+ sup {top: -0.5em;}
148
+ sub {bottom: -0.25em;}
149
+
150
+ a {
151
+ text-decoration: none;
152
+ color:#1abc9c;
153
+ cursor:pointer;
154
+ }
155
+ a:hover {
156
+ color:#00B;
157
+ text-decoration: underline;
158
+ }
159
+ a:active {
160
+ color:#DD4B39;
161
+ }
162
+ a:visited {
163
+ color:#609;
164
+ }
165
+
166
+ li a,li a:hover,.link-list a,.link-list a:hover,
167
+ small a,small a:hover {
168
+ color:#4450A2;
169
+ }
170
+
171
+ li a:visited,.link-list a:visited,small a:visited {
172
+ color:#7240AF;
173
+ }
174
+
175
+ h1 a,h2 a,h3 a,h4 a {
176
+ color:inherit;
177
+ }
178
+
179
+ ins {text-decoration: none;}
180
+ u {text-decoration: underline;}
181
+
182
+ mark {background: #F8FFE4;}
183
+ small, figcaption {
184
+ font-size: 60%;
185
+ color: #44444E;
186
+ }
187
+
188
+ pre, code {
189
+ font-family:"DejaVu Sans Mono","WenQuanYi Micro Hei Mono","Ubuntu Mono",Menlo,Monaco,"Courier New", Courier, monospace;
190
+ white-space: pre;
191
+ word-wrap: break-word;
192
+ }
193
+
194
+ pre {
195
+ line-height:120%;
196
+ }
197
+ pre code {
198
+ white-space: pre;
199
+ }
200
+
201
+ div:not(.highlight) pre {
202
+ background:#F8F8F8;
203
+ background-clip: border-box;
204
+ padding:10px;
205
+ border:1px solid #EEF;
206
+ border-radius:12px;
207
+ color:#D0D0E0;
208
+ }
209
+
210
+ code {
211
+ color:#080;
212
+ }
213
+
214
+
215
+ div.highlight {
216
+ padding:6px;
217
+ background-clip: border-box;
218
+ border-radius:8px;
219
+ margin:6px 0;
220
+ display:table;
221
+ }
222
+ span.highlight {
223
+ padding:2px 4px;
224
+ background-clip: border-box;
225
+ border-radius:3px;
226
+ margin:0 2px;
227
+ background:#F8F8F8;
228
+ color:black;
229
+ white-space: nowrap;
230
+ }
231
+ .highlight pre,.highlighttable pre {
232
+ margin:0;
233
+ background:inherit;
234
+ border:0;
235
+ padding:0;
236
+ }
237
+
238
+ .highlighttable {
239
+ border-collapse: collapse;
240
+ border-spacing: 0;
241
+ background-color:#F8F8F8;
242
+ border-radius:8px;
243
+ margin:0;
244
+ margin-bottom:18px;
245
+ }
246
+
247
+ .highlighttable div.highlight {
248
+ padding:0;
249
+ border-radius:0;
250
+ margin:0;
251
+ }
252
+ .highlighttable pre {
253
+ margin:0;
254
+ border:none;
255
+ }
256
+ .highlighttable td {
257
+ padding:6px;
258
+ }
259
+ .highlighttable td.linenos {
260
+ border-right:1px solid #9A9;
261
+ }
262
+
263
+ table {
264
+ margin:14px auto;
265
+ border-color:#FFE;
266
+ border-width:2px;
267
+ }
268
+ table td ,table th {
269
+ padding:8px;
270
+ }
271
+
272
+ table.plain {
273
+ border-collapse: collapse;
274
+ border-spacing: 0;
275
+ border:none;
276
+ }
277
+
278
+ table.plain th, table.plain td,table.plain caption{
279
+ border: 1px solid #DDD;
280
+ }
281
+ table.plain th {
282
+ background: #fbfbfb;
283
+ font-weight:bold;
284
+ color:#666;
285
+ }
286
+ table.plain caption {
287
+ color:#666;
288
+ }
289
+ table.plain thead th{
290
+ background: #f1f1f1;
291
+ }
292
+ table.plain .caption {
293
+ border-bottom:none;
294
+ }
295
+
296
+ .vertical-thead th {
297
+ text-align:center;
298
+ width:1em;
299
+ }
300
+
301
+ .site-header {
302
+ padding-bottom:6px;
303
+ margin-bottom:8px;
304
+ border-bottom:1px solid #CFCFCF;
305
+ padding-top:2px;
306
+ }
307
+ .site-header h1 {
308
+ font-size:200%;
309
+ }
310
+
311
+ nav.header {
312
+ line-height:2em;
313
+ }
314
+ nav.header a {
315
+ display:inline-block;
316
+ width:6em;
317
+ height:2em;
318
+ line-height:2em;
319
+ background:#666;
320
+ color:#F9F9FF;
321
+ margin-right:4px;
322
+ text-align:center;
323
+ margin-bottom:4px;
324
+ }
325
+ nav.header a:hover {
326
+ text-decoration:none;
327
+ }
328
+
329
+ .site-title a,.site-title a:hover,.site-title a:visited {
330
+ color:inherit;
331
+ text-decoration:none;
332
+ }
333
+
334
+
335
+ .site-footer {
336
+ height:15px;
337
+ text-align:center;
338
+ padding:30px 0;
339
+ border-top:1px solid #CFCFCF;
340
+ margin-top:12px;
341
+ }
342
+ .site-footer img {
343
+ vertical-align:middle;
344
+ }
345
+ .site-footer small {
346
+ font-size:12px;
347
+ line-height:14px;
348
+ }
349
+ section.category-posts {
350
+ float:left;
351
+ margin-right:40px;
352
+ margin-right:16px;
353
+ }
354
+ section.category-posts h2 a,
355
+ section.category-posts h2 a:hover {
356
+ color:inherit;
357
+ }
358
+
359
+ ul.posts-list li {
360
+ list-style-type:square;
361
+ color:#889;
362
+ border-bottom:1px dashed #CCF;
363
+ font-size:120%;
364
+ padding-right:4px;
365
+ padding-left:2px;
366
+ }
367
+
368
+ ul.posts-list li small {
369
+ float:right;
370
+ clear:both;
371
+ padding-left:30px;
372
+ padding-left:1em;
373
+ }
374
+
375
+ nav.near-posts {
376
+ height:36px;
377
+ padding:0 44px;
378
+ }
379
+ nav.near-posts a {
380
+ display:block;
381
+ width:50%;
382
+ height:36px;
383
+ line-height:36px;
384
+ text-decoration:none;
385
+ position:relative;
386
+ float:left;
387
+ }
388
+ nav.near-posts a i {
389
+ position:absolute;
390
+ top:0;
391
+ padding:0;
392
+ color:gray;
393
+ font-size:36px;
394
+ font-style:normal;
395
+ display:block;
396
+ height:36px;
397
+ width:36px;
398
+ }
399
+ nav.near-posts a em {
400
+ display:block;
401
+ width:100%;
402
+ height:36px;
403
+ line-height:44px;
404
+ overflow:hidden;
405
+ white-space: nowrap;
406
+ text-overflow: ellipsis;
407
+ color:inherit;
408
+ padding:0;
409
+ }
410
+ nav.near-posts a:hover {
411
+ text-decoration:none;
412
+ }
413
+ nav.near-posts a:hover em {
414
+ text-decoration:underline;
415
+ }
416
+ nav.near-posts a[rel=prev] {
417
+ float:right;
418
+ }
419
+ nav.near-posts a[rel=prev] i {
420
+ right:-40px;
421
+ padding-left:4px;
422
+ }
423
+ nav.near-posts a[rel=prev] em,
424
+ nav.near-posts a.prev em {
425
+ text-align:right;
426
+ }
427
+ nav.near-posts a[rel=next] i {
428
+ left:-40px;
429
+ padding-right:4px;
430
+ }
431
+
432
+
433
+ .error {
434
+ color:cornflowerblue;
435
+ }
436
+
437
+ .category-page h2 {
438
+ padding:0 2px 4px 0;
439
+ margin:8px 0;
440
+ line-height:180%;
441
+ border-bottom:1px dashed #AAA;
442
+ }
443
+ .category-page h2 small {
444
+ float:right;
445
+ font-weight:normal;
446
+ }
447
+
448
+ .category-page h2 a {
449
+ text-decoration:none;
450
+ color:#333;
451
+ }
452
+
453
+ article {
454
+ padding-bottom:30px;
455
+ }
456
+ .article-title {
457
+ margin:30px auto;
458
+ padding-bottom:16px;
459
+ border-bottom:1px solid #DDF;
460
+ color:darkgreen;
461
+ text-align:center;
462
+ line-height:200%;
463
+ padding:12px 40px;
464
+ }
465
+ .article-title a,.article-title a:hover,.article-title a:visited {
466
+ color:inherit;
467
+ text-decoration:none;
468
+ }
469
+
470
+ .article-title small {
471
+ display:block;
472
+ font-weight:normal;
473
+ color:#888;
474
+ line-height:100%;
475
+ }
476
+
477
+ .category-path {
478
+ font-size:12px;
479
+ width:100%;
480
+ line-height:22px;
481
+ border-bottom:1px dashed gray;
482
+ }
483
+ .category-path em {
484
+ color:#888;
485
+ }
486
+
487
+ .github-fork {
488
+ display:block;
489
+ width:149px;
490
+ height:149px;
491
+ position:absolute;
492
+ right:-1px;
493
+ top:0;
494
+ }
495
+
496
+
497
+ p.project-link {
498
+ margin:24px 0;
499
+ }
500
+
501
+
502
+ #disqus_thread {
503
+ margin:18px auto;
504
+ }
505
+
506
+