ppz 0.0.4 → 0.0.5

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: 3b73ebb97359023698601b83e6e081bc37860d7a0e698dfe42bdfc4e00b6c0b6
4
- data.tar.gz: 47d3ffb5a9d3e5aa6a4e5b6e48e6d1f36dfec625fc067014c712ce15914fd0d0
3
+ metadata.gz: 52c9495b0dd9d71eb9f4cd1a6dcaec7805fb10c450dc1d96d664ae7c30d16e0f
4
+ data.tar.gz: 1a2959299c61dcdf554f6923f5c28c713d8667eba7669b6c683b5196081c27b6
5
5
  SHA512:
6
- metadata.gz: 7f22341cf785fbe0becad3d299d2a9abd3b1c939489b37fca2f5e5120545178d6e1510e0d40b458b825a0f5b0eb8d15f82c5cd9902b8b84570556b478a89b676
7
- data.tar.gz: 891541f4789e74d18f9847b133f59e4ad1f0c171be6a11b7e070caba65f08f03adf9cbe41a3c3047ec563081153f8d2ae92f4f38215d3253e38d43a0b31f6757
6
+ metadata.gz: 4fc7fbcf2fc28272ab0f453477f8f23eff28bc51040b032896fd58ddb2fd6a28be3afba1ada77b956d577db0ab23e60f7fdb8c9ddd030891687f2893595f6323
7
+ data.tar.gz: 7f6013e0106ee614b07b0ba255e4b812cd4f3fb2773dd98fbb71c2098d51a723b3ef7cd47086a96a33db3370448be9397ae32977abfe889113b66056bacdbd57
data/asset/style/ppz.css CHANGED
@@ -1,90 +1,117 @@
1
- html {
2
- line-height: 1.5;
3
- }
4
- body,
5
- div,
6
- p,
7
- aside {
8
- box-sizing: border-box;
9
- }
10
- body {
11
- margin: 0;
12
- padding: 0;
13
- position: relative;
14
- }
15
- aside {
16
- overflow-y: auto;
17
- padding: 2rem 1rem;
18
- position: fixed;
19
- top: 0;
20
- left: 0;
21
- width: 188px;
22
- height: 100vh;
23
- }
24
- aside ul {
25
- margin: 0 0 0 1rem;
26
- padding: 0;
27
- list-style: none;
28
- }
29
- aside a {
30
- width: 100%;
31
- overflow: hidden;
32
- text-overflow: ellipsis;
33
- white-space: nowrap;
34
- }
35
- article {
36
- margin-left: 188px;
37
- padding: 1px 1rem;
38
- }
39
- h1 {
40
- font-size: 2rem;
41
- }
42
- h2 {
43
- font-size: 1.3rem;
44
- }
45
- h3 {
46
- font-size: 1.1rem;
47
- opacity: 0.9;
48
- }
49
- h1::before,
50
- h2::before,
51
- h3::before {
52
- content: '# ';
53
- opacity: 0.3;
54
- font-size: 1rem;
55
- }
56
- .comment-container {
57
- margin: 1rem 0;
58
- padding: 1rem 1.6rem;
59
- background: rgba(0,0,0,0.2);
60
- font-size: 0.9rem;
61
- border-radius: 4px;
62
- }
63
- .comment-item {
64
- opacity: 0.8;
65
- }
66
- .special-block-container {
67
- background: #141c22;
68
- overflow: auto;
69
- border-radius: 4px;
70
- color: #eee;
71
- font-family: monospace;
72
- white-space: pre;
73
- margin: 1rem 0;
74
- padding: 1rem;
75
- counter-reset: line-index;
76
- }
77
- .special-block-item::before {
78
- counter-increment: line-index;
79
- content: counter(line-index) " | ";
80
- opacity: 0.3;
81
- }
82
- .special-block-item:hover::before {
83
- opacity: 0.8;
84
- }
85
- .special-txt {
86
- background: rgba(27,31,35,0.05);
87
- border-radius: 4px;
88
- font-size: 0.9em;
89
- padding: 2px 4px;
90
- }
1
+ html {
2
+ line-height: 1.5;
3
+ }
4
+ body,
5
+ div,
6
+ p,
7
+ aside {
8
+ box-sizing: border-box;
9
+ }
10
+ body {
11
+ margin: 0;
12
+ padding: 0;
13
+ position: relative;
14
+ }
15
+ aside {
16
+ overflow-y: auto;
17
+ padding: 2rem 1rem;
18
+ position: fixed;
19
+ top: 0;
20
+ left: 0;
21
+ width: 188px;
22
+ height: 100vh;
23
+ }
24
+ aside ul {
25
+ margin: 0 0 0 1rem;
26
+ padding: 0;
27
+ list-style: none;
28
+ }
29
+ aside a {
30
+ width: 100%;
31
+ overflow: hidden;
32
+ text-overflow: ellipsis;
33
+ white-space: nowrap;
34
+ }
35
+ article {
36
+ margin-left: 188px;
37
+ padding: 1px 1rem;
38
+ }
39
+ h1 {
40
+ font-size: 2rem;
41
+ }
42
+ h2 {
43
+ font-size: 1.3rem;
44
+ }
45
+ h3 {
46
+ font-size: 1.1rem;
47
+ opacity: 0.9;
48
+ }
49
+ h1::before,
50
+ h2::before,
51
+ h3::before {
52
+ content: '# ';
53
+ opacity: 0.3;
54
+ font-size: 1rem;
55
+ }
56
+ .comment-container {
57
+ margin: 1rem 0;
58
+ padding: 1rem 1.6rem;
59
+ background: rgba(0,0,0,0.2);
60
+ font-size: 0.9rem;
61
+ border-radius: 4px;
62
+ }
63
+ .comment-item {
64
+ opacity: 0.8;
65
+ }
66
+ .special-block-container {
67
+ background: #141c22;
68
+ overflow: auto;
69
+ border-radius: 4px;
70
+ color: #eee;
71
+ font-family: monospace;
72
+ white-space: pre;
73
+ margin: 1rem 0;
74
+ padding: 1rem;
75
+ counter-reset: line-index;
76
+ }
77
+ .special-block-item::before {
78
+ counter-increment: line-index;
79
+ content: counter(line-index) " | ";
80
+ opacity: 0.3;
81
+ }
82
+ .special-block-item:hover::before {
83
+ opacity: 0.8;
84
+ }
85
+ .special-txt {
86
+ background: rgba(27,31,35,0.05);
87
+ border-radius: 4px;
88
+ font-size: 0.9em;
89
+ padding: 2px 4px;
90
+ }
91
+ .interpage-nav {
92
+ margin-left: 188px;
93
+ list-style: none;
94
+ padding: 0 1rem;
95
+ }
96
+ .interpage-nav .prev {
97
+ float: left;
98
+ }
99
+ .interpage-nav .prev::before {
100
+ content: '上一篇:';
101
+ opacity: 0.6;
102
+ }
103
+ .interpage-nav .next {
104
+ float: right;
105
+ }
106
+ .interpage-nav .next::before {
107
+ content: '下一篇:';
108
+ opacity: 0.6;
109
+ }
110
+ .interpage-nav::after {
111
+ content: '';
112
+ display: block;
113
+ clear: both;
114
+ }
115
+ .folder-nav {
116
+ margin: 2rem 3rem;
117
+ }
data/asset/style/ppz.styl CHANGED
@@ -1,3 +1,5 @@
1
+ nav-width = 188px
2
+
1
3
  html
2
4
  line-height 1.5
3
5
  body, div, p, aside
@@ -15,7 +17,7 @@ aside
15
17
  position fixed
16
18
  top 0
17
19
  left 0
18
- width 188px
20
+ width nav-width
19
21
  height 100vh
20
22
 
21
23
  ul
@@ -29,7 +31,7 @@ aside
29
31
  white-space nowrap
30
32
 
31
33
  article
32
- margin-left: 188px
34
+ margin-left: nav-width
33
35
  padding: 1px 1rem
34
36
  h1
35
37
  font-size 2rem
@@ -79,4 +81,26 @@ h1, h2, h3
79
81
  background rgba(27, 31, 35, 0.05)
80
82
  border-radius 4px
81
83
  font-size 0.9em
82
- padding 2px 4px
84
+ padding 2px 4px
85
+
86
+ .interpage-nav
87
+ margin-left nav-width
88
+ list-style none
89
+ padding 0 1rem
90
+ .prev
91
+ float left
92
+ &::before
93
+ content '上一篇:'
94
+ opacity 0.6
95
+ .next
96
+ float right
97
+ &::before
98
+ content '下一篇:'
99
+ opacity 0.6
100
+ &::after
101
+ content ''
102
+ display block
103
+ clear both
104
+
105
+ .folder-nav
106
+ margin 2rem 3rem
@@ -1,5 +1,6 @@
1
1
  module PPZ::Folder
2
2
  class AbstractFileModel < AbstractModel
3
+ attr_reader :name
3
4
  def self.from_path path, level
4
5
  if (File.extname path) == '.ppz'
5
6
  PPZFileModel.new path, level
@@ -1,9 +1,20 @@
1
1
  module PPZ::Folder
2
2
  class PPZFileModel < AbstractFileModel
3
+ attr_accessor :left, :right
4
+
3
5
  def _compile dir_out
4
6
  parser = PPZ::FileDocParser.new @path
5
- html_str = "<link rel=\"stylesheet\" href=\"#{get_css_path}\"/>" +
6
- parser.get_model.to_html
7
+ html_str = %!<link rel="stylesheet" href="#{get_css_path}"/>
8
+ <title>#{@name}</title>#{
9
+ parser.get_model.to_html
10
+ }<ul class="interpage-nav">#{
11
+ (@left ?
12
+ "<li class=\"prev\"><a href=\"#{@left.name}.html\">#{@left.name}</a></li>"
13
+ : "") +
14
+ (@right ?
15
+ "<li class=\"next\"><a href=\"#{@right.name}.html\">#{@right.name}</a></li>"
16
+ : "")
17
+ }</ul>!
7
18
  PPZ::Func::write_to_file (dir_out + '/' + @name + '.html'), html_str
8
19
  end
9
20
  end
@@ -7,27 +7,39 @@ module PPZ::Folder
7
7
  @name = $3
8
8
 
9
9
  @children = []
10
- (Dir.children path).each do |child_name|
10
+ (Dir.children path, encoding: 'utf-8').each do |child_name|
11
11
  @children.push AbstractModel.from_path (path + '/' + child_name), level
12
12
  end
13
13
  @children.sort! do |a, b|
14
14
  a.index <=> b.index
15
15
  end
16
+
17
+ left = right = nil
18
+ @children.each do |child|
19
+ next unless child.is_a? PPZFileModel
20
+ if left
21
+ left.right = child
22
+ child.left = left
23
+ end
24
+ left = child
25
+ end
26
+ end
27
+
28
+ def title
29
+ @name
16
30
  end
17
31
 
18
32
  def _compile out_dir # compile 是 _compile 的安全版本
19
- PPZ::Func.write_to_file (out_dir + '/' + @name + '.html'),
20
- "<link rel=\"stylesheet\" href=\"#{get_css_path}\"/><ul>#{
21
- @children
22
- .map do |child|
23
- if child.file_ext == '.ppz'
24
- "<li><a href=\"./#{@name}/#{child.name}.html\">#{child.name}</a></li>"
25
- else
26
- ''
27
- end
28
- end
29
- .join
30
- }</ul>"
33
+ PPZ::Func.write_to_file (out_dir + '/' + @name + '.html'), %!<title>#{title}</title>
34
+ <link rel="stylesheet" href="#{get_css_path}"/><div class="folder-nav"><ul>#{
35
+ @children
36
+ .map do |child|
37
+ child.file_ext == '.ppz' ?
38
+ "<li><a href=\"./#{@name}/#{child.name}.html\">#{child.name}</a></li>"
39
+ : ''
40
+ end
41
+ .join
42
+ }</ul></div>!
31
43
 
32
44
  children_dir = out_dir + '/' + @name
33
45
  Dir.mkdir children_dir
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ppz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - wuse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-09 00:00:00.000000000 Z
11
+ date: 2021-02-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: 372301467@qq.com