ppz-bin 0.0.1 → 0.0.2

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: dc9adcc9753795a84dc0f393f422d577d56ee6c02845c0cb69181e4183322bd8
4
- data.tar.gz: 81969839bb90602d99b0d3417784548509ec66c95e3e6b7de4bd8000a98caed9
3
+ metadata.gz: b708dc603c1c5a8e155fa10666314994cecaa3e2e315f500ca48c5e4d4c04657
4
+ data.tar.gz: f7c89c354991d4784364b5695850bdcc971c7c9620a12dac9d1fe23c9079087a
5
5
  SHA512:
6
- metadata.gz: a903bddfebbd87a722a81d0c3f02bb4977a800a9e08fad0dc87db272e45c9df3e2f03b019151d73c18af9df195bba1dea3730a90e74e03683912277eb2b05aa3
7
- data.tar.gz: e71b0fd6ba195ed5ae272711af392843cbc9a8dfd2851fbae2ba7b7bf399c89c7c661d062fe264dccb1d5f83672f6dd4bee6b215a2296c96aad6d1d8ee5c227e
6
+ metadata.gz: 537541541679c87e62e3fe71b3a147d4a0457a4419406601496402bd5ada458be4dfa2b6a782ce1794452b87535ca1646d1df675881b5bff579b1182f9cbb59b
7
+ data.tar.gz: 33ed934e920622237bd294b145d417f7c2101e94a6596c32cf2357c8bcb74e0b74f0b58db95261fe357d489dcee98567fe141198e1d5e41ee084d891f9ad264a
Binary file
Binary file
Binary file
data/asset/js/index.js ADDED
@@ -0,0 +1,16 @@
1
+ console.log('welcome!')
2
+
3
+ specialBlock()
4
+
5
+ function specialBlock(){
6
+ let list = document.querySelectorAll('.special-block-container')
7
+ list.forEach(function(block){
8
+ let rawChildren = Array.from(block.children) // 下面添加按钮的操作,会改变 children 对象,但变成数组后,就不会了
9
+ let copyBtn = document.createElement('button')
10
+ copyBtn.onclick = function(){
11
+ navigator.clipboard.writeText(rawChildren.map(child => child.innerHTML).join('\n'))
12
+ }
13
+ copyBtn.classList.add('copy')
14
+ block.appendChild(copyBtn)
15
+ })
16
+ }
@@ -1,141 +1,165 @@
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
- display: block;
32
- overflow: hidden;
33
- text-overflow: ellipsis;
34
- white-space: nowrap;
35
- }
36
- .ancestor-nav ul {
37
- margin: 0;
38
- padding: 0;
39
- list-style: none;
40
- font-size: 0.8rem;
41
- margin: 1rem 2rem 0 0;
42
- text-align: right;
43
- }
44
- .ancestor-nav li {
45
- margin: 0;
46
- padding: 0;
47
- display: inline-block;
48
- }
49
- .ancestor-nav li a {
50
- display: inline-block;
51
- opacity: 0.66;
52
- transition: all 0.3s;
53
- }
54
- .ancestor-nav li a:hover {
55
- opacity: 1;
56
- transform: scale(1.1, 1.1);
57
- }
58
- .ancestor-nav li:not(.self)::after {
59
- content: '/';
60
- margin: 0 0.36rem;
61
- }
62
- article {
63
- margin-left: 188px;
64
- padding: 1px 2rem 1rem 1rem;
65
- }
66
- h1 {
67
- font-size: 2rem;
68
- }
69
- h2 {
70
- font-size: 1.3rem;
71
- }
72
- h3 {
73
- font-size: 1.1rem;
74
- opacity: 0.9;
75
- }
76
- h1::before,
77
- h2::before,
78
- h3::before {
79
- content: '# ';
80
- opacity: 0.3;
81
- font-size: 1rem;
82
- }
83
- .comment-container {
84
- margin: 1rem 0;
85
- padding: 1rem 1.6rem;
86
- background: rgba(0,0,0,0.2);
87
- font-size: 0.9rem;
88
- border-radius: 4px;
89
- }
90
- .comment-item {
91
- opacity: 0.8;
92
- }
93
- .special-block-container {
94
- background: #141c22;
95
- overflow: auto;
96
- border-radius: 4px;
97
- color: #eee;
98
- font-family: monospace;
99
- white-space: pre;
100
- margin: 1rem 0;
101
- padding: 1rem;
102
- counter-reset: line-index;
103
- }
104
- .special-block-item::before {
105
- counter-increment: line-index;
106
- content: counter(line-index) " | ";
107
- opacity: 0.3;
108
- }
109
- .special-block-item:hover::before {
110
- opacity: 0.8;
111
- }
112
- .special-txt {
113
- background: rgba(27,31,35,0.05);
114
- border-radius: 4px;
115
- font-size: 0.9em;
116
- padding: 2px 4px;
117
- }
118
- .interpage-nav {
119
- margin: 1rem 2rem 2rem 188px;
120
- padding: 0 2rem;
121
- list-style: none;
122
- }
123
- .interpage-nav .prev {
124
- float: left;
125
- }
126
- .interpage-nav .prev::before {
127
- content: '上一篇:';
128
- opacity: 0.6;
129
- }
130
- .interpage-nav .next {
131
- float: right;
132
- }
133
- .interpage-nav .next::before {
134
- content: '下一篇:';
135
- opacity: 0.6;
136
- }
137
- .interpage-nav::after {
138
- content: '';
139
- display: block;
140
- clear: both;
141
- }
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
+ display: block;
32
+ overflow: hidden;
33
+ text-overflow: ellipsis;
34
+ white-space: nowrap;
35
+ }
36
+ .ancestor-nav ul {
37
+ margin: 0;
38
+ padding: 0;
39
+ list-style: none;
40
+ font-size: 0.8rem;
41
+ margin: 1rem 2rem 0 0;
42
+ text-align: right;
43
+ }
44
+ .ancestor-nav li {
45
+ margin: 0;
46
+ padding: 0;
47
+ display: inline-block;
48
+ }
49
+ .ancestor-nav li a {
50
+ display: inline-block;
51
+ opacity: 0.66;
52
+ transition: all 0.3s;
53
+ }
54
+ .ancestor-nav li a:hover {
55
+ opacity: 1;
56
+ transform: scale(1.1, 1.1);
57
+ }
58
+ .ancestor-nav li:not(.self)::after {
59
+ content: '/';
60
+ margin: 0 0.36rem;
61
+ }
62
+ article {
63
+ margin-left: 188px;
64
+ padding: 1px 2rem 1rem 1rem;
65
+ }
66
+ h1 {
67
+ font-size: 2rem;
68
+ }
69
+ h2 {
70
+ font-size: 1.3rem;
71
+ }
72
+ h3 {
73
+ font-size: 1.1rem;
74
+ opacity: 0.9;
75
+ }
76
+ h1::before,
77
+ h2::before,
78
+ h3::before {
79
+ content: '# ';
80
+ opacity: 0.3;
81
+ font-size: 1rem;
82
+ }
83
+ .comment-container {
84
+ margin: 1rem 0;
85
+ padding: 1rem 1.6rem;
86
+ background: rgba(0,0,0,0.2);
87
+ font-size: 0.9rem;
88
+ border-radius: 4px;
89
+ }
90
+ .comment-item {
91
+ opacity: 0.8;
92
+ }
93
+ .special-block-container {
94
+ background: #141c22;
95
+ overflow: auto;
96
+ border-radius: 4px;
97
+ color: #e6e6e6;
98
+ line-height: 1.6;
99
+ position: relative;
100
+ font-family: monospace;
101
+ white-space: pre;
102
+ margin: 1rem 0;
103
+ padding: 1.3rem 3.6rem;
104
+ counter-reset: line-index 1;
105
+ }
106
+ .special-block-container li::before {
107
+ counter-increment: line-index;
108
+ content: '';
109
+ }
110
+ .special-block-container li::marker {
111
+ content: counter(line-index) " | ";
112
+ color: rgba(230,230,230,0.3);
113
+ text-align: right;
114
+ }
115
+ .special-block-container li:hover::marker {
116
+ color: #e6e6e6;
117
+ }
118
+ .special-block-container button.copy {
119
+ position: absolute;
120
+ right: 1rem;
121
+ top: 1rem;
122
+ cursor: pointer;
123
+ background: url("../img/copy20.png");
124
+ width: 20px;
125
+ height: 20px;
126
+ outline: none;
127
+ border: none;
128
+ opacity: 0.5;
129
+ }
130
+ .special-block-container button.copy:hover {
131
+ opacity: 0.8;
132
+ }
133
+ .special-block-container button.copy:active {
134
+ opacity: 1;
135
+ }
136
+ .special-txt {
137
+ background: rgba(27,31,35,0.05);
138
+ border-radius: 4px;
139
+ font-size: 0.9em;
140
+ padding: 2px 4px;
141
+ }
142
+ .interpage-nav {
143
+ margin: 1rem 2rem 2rem 188px;
144
+ padding: 0 2rem;
145
+ list-style: none;
146
+ }
147
+ .interpage-nav .prev {
148
+ float: left;
149
+ }
150
+ .interpage-nav .prev::before {
151
+ content: '上一篇:';
152
+ opacity: 0.6;
153
+ }
154
+ .interpage-nav .next {
155
+ float: right;
156
+ }
157
+ .interpage-nav .next::before {
158
+ content: '下一篇:';
159
+ opacity: 0.6;
160
+ }
161
+ .interpage-nav::after {
162
+ content: '';
163
+ display: block;
164
+ clear: both;
165
+ }
@@ -1,5 +1,10 @@
1
1
  nav-width = 188px
2
2
 
3
+ special-color-r = 230
4
+ special-color-g = 230
5
+ special-color-b = 230
6
+ special-font-color = rgb(special-color-r, special-color-g, special-color-b)
7
+
3
8
  html
4
9
  line-height 1.5
5
10
  body, div, p, aside
@@ -12,7 +17,7 @@ body
12
17
 
13
18
  aside
14
19
  overflow-y auto
15
- padding: 2rem 1rem;
20
+ padding 2rem 1rem;
16
21
 
17
22
  position fixed
18
23
  top 0
@@ -55,7 +60,7 @@ aside
55
60
 
56
61
  article
57
62
  margin-left nav-width
58
- padding: 1px 2rem 1rem 1rem
63
+ padding 1px 2rem 1rem 1rem
59
64
  h1
60
65
  font-size 2rem
61
66
  h2
@@ -83,22 +88,43 @@ h1, h2, h3
83
88
  background #141c22
84
89
  overflow auto
85
90
  border-radius 4px
86
- color #eeeeee
87
-
91
+ color special-font-color
92
+ line-height 1.6
93
+ position relative
94
+
88
95
  font-family monospace
89
96
  white-space pre
90
97
 
91
98
  margin 1rem 0
92
- padding 1rem
93
-
94
- counter-reset line-index
95
- .special-block-item
96
- &::before
97
- counter-increment line-index
98
- content counter(line-index) " | "
99
- opacity 0.3
100
- &:hover::before
101
- opacity 0.8
99
+ padding 1.3rem 3.6rem
100
+ counter-reset line-index 1
101
+ li
102
+ &::before
103
+ counter-increment line-index
104
+ content ''
105
+ &::marker
106
+ content counter(line-index) " | "
107
+ color rgba(special-color-r, special-color-g, special-color-b, 0.3)
108
+ text-align right
109
+
110
+ &:hover::marker
111
+ color special-font-color
112
+ button.copy
113
+ position absolute
114
+ right 1rem
115
+ top 1rem
116
+
117
+ cursor pointer
118
+ background url(../img/copy20.png)
119
+ width 20px
120
+ height 20px
121
+ outline none
122
+ border none
123
+ opacity 0.5
124
+ &:hover
125
+ opacity 0.8
126
+ &:active
127
+ opacity 1
102
128
 
103
129
  .special-txt
104
130
  background rgba(27, 31, 35, 0.05)
data/bin/ppz CHANGED
@@ -1,17 +1,41 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'rubygems'
4
- require 'bundler/setup'
5
-
6
3
  require 'ppz'
7
- require 'fileutils'
8
- require 'pathname'
9
- require_relative './common'
4
+ require_relative './preparation/index'
5
+
6
+ class Main
7
+ attr_accessor :target_in, :target_out, :is_folder
8
+
9
+ def main
10
+ Preparation.new self
11
+
12
+ if @is_folder
13
+ folder
14
+ else
15
+ doc
16
+ end
17
+ end
18
+
19
+ def doc
20
+ # 输出文件路径
21
+ output_html_path = @target_out + 'index.html'
22
+ # 解析文档
23
+ parser = PPZ::FileDocParser.new @target_in
24
+ # 拼接上 css 文件链接
25
+ output_html = %~<link rel="stylesheet" href=".ppz/asset/style/index.css"/>#{
26
+ parser.get_model.to_html
27
+ }<script type="module" src=".ppz/asset/js/index.js"></script>~
28
+ # 输出
29
+ PPZ::Func::write_to_file output_html_path.to_s, output_html
30
+ end
31
+
32
+ def folder
33
+ puts '输入文件夹: ' + @target_in.to_s
34
+ puts '输出文件夹: ' + @target_out.to_s
10
35
 
11
- TARGET_IN, TARGET_OUT, IS_FOLDER = Util.get_in_and_out
36
+ model = PPZ::Folder::FolderModel.new @target_in, 0
37
+ model.compile @target_out
38
+ end
39
+ end
12
40
 
13
- if IS_FOLDER
14
- require_relative './folder.rb'
15
- else
16
- require_relative './doc.rb'
17
- end
41
+ Main.new.main
@@ -0,0 +1,39 @@
1
+ class Preparation
2
+ private def argv main_object
3
+ current_pathname = Pathname File.dirname __FILE__
4
+ a1, a2 = ARGV
5
+
6
+ # 输入文件
7
+ abort '要编译哪那个文件?请告诉我' unless a1 # 检查参数存在
8
+ target_in = Pathname a1
9
+ unless File.exist? target_in # 不存在的话,看看加上 .ppz 后是否存在
10
+ target_name = target_in.basename.to_s + '.ppz'
11
+ target_in += '../' + target_name
12
+ abort target_in[0..-5] + ' 不存在' unless File.exist? target_in # 还不存在的话,就说明是写错了
13
+ end
14
+ main_object.target_in = target_in
15
+ main_object.is_folder = File.directory? target_in
16
+
17
+ # 输出文件
18
+ if target_out
19
+ target_out = Pathname target_out
20
+ else
21
+ # 从输入文件获取文件名
22
+ basename = target_in.basename.to_s
23
+ basename = (/(.*).ppz$/.match basename) ? $1 : basename
24
+ basename += '.pp'
25
+
26
+ target_out = target_in + '../' + basename
27
+ end
28
+ # + 检查上级文件夹是否存在
29
+ upper_dir = target_out + '..'
30
+ abort (upper_dir.to_s) + ' 目录不存在' unless Dir.exist? upper_dir
31
+ # + 检查文件夹:有则检查里面有没有文件;无则创建文件夹
32
+ if Dir.exist? target_out
33
+ abort target_out.to_s + ' 不是一个空文件夹' unless (Dir.children target_out).size == 0
34
+ else
35
+ Dir.mkdir target_out
36
+ end
37
+ main_object.target_out = target_out
38
+ end
39
+ end
@@ -0,0 +1,20 @@
1
+ require 'fileutils'
2
+ require 'pathname'
3
+
4
+ class Preparation
5
+ require_relative './argv'
6
+
7
+ attr_reader :target_in, :target_out, :is_folder
8
+
9
+ def initialize main_object
10
+ argv main_object
11
+ Dir.mkdir @dot_ppz = main_object.target_out + '.ppz'
12
+ asset
13
+ end
14
+
15
+ private
16
+ def asset
17
+ asset_path = (Pathname __FILE__) + '../../../asset'
18
+ FileUtils.cp_r asset_path, @dot_ppz
19
+ end
20
+ end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ppz-bin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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-24 00:00:00.000000000 Z
11
+ date: 2021-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ppz
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 1.0.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 1.0.1
27
27
  description:
28
28
  email: 372301467@qq.com
29
29
  executables:
@@ -31,12 +31,15 @@ executables:
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - asset/style/ppz.css
35
- - asset/style/ppz.styl
36
- - bin/common.rb
37
- - bin/doc.rb
38
- - bin/folder.rb
34
+ - asset/img/copy128.png
35
+ - asset/img/copy20.png
36
+ - asset/img/copy32.png
37
+ - asset/js/index.js
38
+ - asset/style/index.css
39
+ - asset/style/index.styl
39
40
  - bin/ppz
41
+ - bin/preparation/argv.rb
42
+ - bin/preparation/index.rb
40
43
  homepage: https://github.com/daGaiGuanYu/ppz
41
44
  licenses:
42
45
  - MIT
data/bin/common.rb DELETED
@@ -1,38 +0,0 @@
1
- CURRENT_PATH = File.dirname __FILE__
2
- CSS_FILE_PATH = (Pathname CURRENT_PATH) + '../asset/style/ppz.css'
3
-
4
- class Util
5
- class << self
6
- def get_in_and_out
7
- target_in, target_out = ARGV
8
-
9
- # 输入文件
10
- abort '要编译哪那个文件?请告诉我' unless target_in # 检查参数存在
11
- target_in = PPZ::Func.format_path target_in
12
- unless File.exist? target_in # 不存在的话,看看加上 .ppz 后是否存在
13
- target_in += '.ppz'
14
- abort target_in[0..-5] + ' 不存在' unless File.exist? target_in # 还不存在的话,就说明是写错了
15
- end
16
- is_folder = File.directory? target_in
17
-
18
- # 输出文件
19
- unless target_out
20
- # 从输入文件获取文件名
21
- target_out = ((/(.*).ppz$/.match target_in)?$1:target_in) + '.pp'
22
- end
23
- # + 检查上级文件夹是否存在
24
- upper_dir = ((Pathname target_out) + '..').to_s
25
- abort upper_dir + ' 目录不存在' unless Dir.exist? upper_dir
26
- # + 检查文件夹:有则检查里面有没有文件;无则创建文件夹
27
- target_out = target_out.to_s
28
- if Dir.exist? target_out
29
- abort target_out + ' 不是一个空文件夹' unless (Dir.children target_out).size == 0
30
- else
31
- Dir.mkdir target_out
32
- end
33
- target_out = PPZ::Func.format_path target_out
34
-
35
- [target_in, target_out, is_folder]
36
- end
37
- end
38
- end
data/bin/doc.rb DELETED
@@ -1,17 +0,0 @@
1
- target_out = Pathname TARGET_OUT
2
-
3
- # css
4
- # 输出文件路径
5
- output_css_path = target_out + 'index.css'
6
- # 复制
7
- FileUtils.cp CSS_FILE_PATH, output_css_path
8
-
9
- # html
10
- # 输出文件路径
11
- output_html_path = target_out + 'index.html'
12
- # 解析文档
13
- parser = PPZ::FileDocParser.new TARGET_IN
14
- # 拼接上 css 文件链接
15
- output_html = '<link rel="stylesheet" href="./index.css"/>' + parser.get_model.to_html
16
- # 输出
17
- PPZ::Func::write_to_file output_html_path.to_s, output_html
data/bin/folder.rb DELETED
@@ -1,8 +0,0 @@
1
- puts '输入文件夹: ' + TARGET_IN
2
- puts '输出文件夹: ' + TARGET_OUT
3
- puts
4
-
5
- FileUtils.cp CSS_FILE_PATH, ((Pathname TARGET_OUT) + 'style.css').to_s
6
-
7
- model = PPZ::Folder::FolderModel.new TARGET_IN, 0
8
- model.compile TARGET_OUT