madness 0.9.9 → 1.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +74 -76
- data/app/public/css/main.css +494 -248
- data/app/public/css/main.css.map +30 -24
- data/app/public/font/fontello.eot +0 -0
- data/app/public/font/fontello.svg +16 -0
- data/app/public/font/fontello.ttf +0 -0
- data/app/public/font/fontello.woff +0 -0
- data/app/public/font/fontello.woff2 +0 -0
- data/app/public/js/clipboard.js +2 -2
- data/app/styles/_anchor.scss +5 -3
- data/app/styles/_breadcrumbs.scss +2 -1
- data/app/styles/_code.scss +35 -42
- data/app/styles/{_icons.scss → _fontello.scss} +28 -19
- data/app/styles/_footnotes.scss +5 -0
- data/app/styles/_general.scss +7 -3
- data/app/styles/_image.scss +0 -2
- data/app/styles/_keyboard.scss +8 -7
- data/app/styles/_line.scss +1 -26
- data/app/styles/_manifest.scss +12 -8
- data/app/styles/_nav.scss +5 -15
- data/app/styles/_rouge.scss +213 -0
- data/app/styles/_scrollbar.scss +9 -0
- data/app/styles/_search.scss +5 -6
- data/app/styles/_table.scss +12 -7
- data/app/styles/_typography.scss +9 -5
- data/app/styles/_variables.scss +40 -0
- data/app/styles/main.scss +3 -3
- data/app/views/_index_nav.slim +6 -5
- data/app/views/document.slim +2 -6
- data/bin/madness +6 -2
- data/lib/madness/cli.rb +21 -0
- data/lib/madness/commands/base.rb +11 -0
- data/lib/madness/commands/config.rb +48 -0
- data/lib/madness/commands/server.rb +76 -0
- data/lib/madness/commands/theme.rb +36 -0
- data/lib/madness/document.rb +5 -110
- data/lib/madness/exceptions.rb +6 -0
- data/lib/madness/highlight_renderer.rb +10 -0
- data/lib/madness/markdown_document.rb +103 -0
- data/lib/madness/server_base.rb +1 -1
- data/lib/madness/settings.rb +7 -7
- data/lib/madness/templates/madness.yml +6 -4
- data/lib/madness/version.rb +1 -1
- metadata +53 -50
- data/app/public/fonts/fontello.eot +0 -0
- data/app/public/fonts/fontello.svg +0 -16
- data/app/public/fonts/fontello.ttf +0 -0
- data/app/public/fonts/fontello.woff +0 -0
- data/app/public/fonts/fontello.woff2 +0 -0
- data/app/styles/_coderay.scss +0 -37
- data/lib/madness/command_line.rb +0 -139
- data/lib/madness/docopt.txt +0 -98
@@ -0,0 +1,213 @@
|
|
1
|
+
.highlight table td { padding: 5px; }
|
2
|
+
.highlight table pre { margin: 0; }
|
3
|
+
.highlight .cm {
|
4
|
+
color: #999988;
|
5
|
+
font-style: italic;
|
6
|
+
}
|
7
|
+
.highlight .cp {
|
8
|
+
color: #999999;
|
9
|
+
font-weight: bold;
|
10
|
+
}
|
11
|
+
.highlight .c1 {
|
12
|
+
color: #999988;
|
13
|
+
font-style: italic;
|
14
|
+
}
|
15
|
+
.highlight .cs {
|
16
|
+
color: #999999;
|
17
|
+
font-weight: bold;
|
18
|
+
font-style: italic;
|
19
|
+
}
|
20
|
+
.highlight .c, .highlight .ch, .highlight .cd, .highlight .cpf {
|
21
|
+
color: #999988;
|
22
|
+
font-style: italic;
|
23
|
+
}
|
24
|
+
.highlight .err {
|
25
|
+
color: #a61717;
|
26
|
+
background-color: #e3d2d2;
|
27
|
+
}
|
28
|
+
.highlight .gd {
|
29
|
+
color: #000000;
|
30
|
+
background-color: #ffdddd;
|
31
|
+
}
|
32
|
+
.highlight .ge {
|
33
|
+
color: #000000;
|
34
|
+
font-style: italic;
|
35
|
+
}
|
36
|
+
.highlight .gr {
|
37
|
+
color: #aa0000;
|
38
|
+
}
|
39
|
+
.highlight .gh {
|
40
|
+
color: #999999;
|
41
|
+
}
|
42
|
+
.highlight .gi {
|
43
|
+
color: #000000;
|
44
|
+
background-color: #ddffdd;
|
45
|
+
}
|
46
|
+
.highlight .go {
|
47
|
+
color: #888888;
|
48
|
+
}
|
49
|
+
.highlight .gp {
|
50
|
+
color: #555555;
|
51
|
+
}
|
52
|
+
.highlight .gs {
|
53
|
+
font-weight: bold;
|
54
|
+
}
|
55
|
+
.highlight .gu {
|
56
|
+
color: #aaaaaa;
|
57
|
+
}
|
58
|
+
.highlight .gt {
|
59
|
+
color: #aa0000;
|
60
|
+
}
|
61
|
+
.highlight .kc {
|
62
|
+
color: #000000;
|
63
|
+
font-weight: bold;
|
64
|
+
}
|
65
|
+
.highlight .kd {
|
66
|
+
color: #000000;
|
67
|
+
font-weight: bold;
|
68
|
+
}
|
69
|
+
.highlight .kn {
|
70
|
+
color: #000000;
|
71
|
+
font-weight: bold;
|
72
|
+
}
|
73
|
+
.highlight .kp {
|
74
|
+
color: #000000;
|
75
|
+
font-weight: bold;
|
76
|
+
}
|
77
|
+
.highlight .kr {
|
78
|
+
color: #000000;
|
79
|
+
font-weight: bold;
|
80
|
+
}
|
81
|
+
.highlight .kt {
|
82
|
+
color: #445588;
|
83
|
+
font-weight: bold;
|
84
|
+
}
|
85
|
+
.highlight .k, .highlight .kv {
|
86
|
+
color: #000000;
|
87
|
+
font-weight: bold;
|
88
|
+
}
|
89
|
+
.highlight .mf {
|
90
|
+
color: #009999;
|
91
|
+
}
|
92
|
+
.highlight .mh {
|
93
|
+
color: #009999;
|
94
|
+
}
|
95
|
+
.highlight .il {
|
96
|
+
color: #009999;
|
97
|
+
}
|
98
|
+
.highlight .mi {
|
99
|
+
color: #009999;
|
100
|
+
}
|
101
|
+
.highlight .mo {
|
102
|
+
color: #009999;
|
103
|
+
}
|
104
|
+
.highlight .m, .highlight .mb, .highlight .mx {
|
105
|
+
color: #009999;
|
106
|
+
}
|
107
|
+
.highlight .sa {
|
108
|
+
color: #000000;
|
109
|
+
font-weight: bold;
|
110
|
+
}
|
111
|
+
.highlight .sb {
|
112
|
+
color: #d14;
|
113
|
+
}
|
114
|
+
.highlight .sc {
|
115
|
+
color: #d14;
|
116
|
+
}
|
117
|
+
.highlight .sd {
|
118
|
+
color: #d14;
|
119
|
+
}
|
120
|
+
.highlight .s2 {
|
121
|
+
color: #d14;
|
122
|
+
}
|
123
|
+
.highlight .se {
|
124
|
+
color: #d14;
|
125
|
+
}
|
126
|
+
.highlight .sh {
|
127
|
+
color: #d14;
|
128
|
+
}
|
129
|
+
.highlight .si {
|
130
|
+
color: #d14;
|
131
|
+
}
|
132
|
+
.highlight .sx {
|
133
|
+
color: #d14;
|
134
|
+
}
|
135
|
+
.highlight .sr {
|
136
|
+
color: #009926;
|
137
|
+
}
|
138
|
+
.highlight .s1 {
|
139
|
+
color: #d14;
|
140
|
+
}
|
141
|
+
.highlight .ss {
|
142
|
+
color: #990073;
|
143
|
+
}
|
144
|
+
.highlight .s, .highlight .dl {
|
145
|
+
color: #d14;
|
146
|
+
}
|
147
|
+
.highlight .na {
|
148
|
+
color: #008080;
|
149
|
+
}
|
150
|
+
.highlight .bp {
|
151
|
+
color: #999999;
|
152
|
+
}
|
153
|
+
.highlight .nb {
|
154
|
+
color: #0086B3;
|
155
|
+
}
|
156
|
+
.highlight .nc {
|
157
|
+
color: #445588;
|
158
|
+
font-weight: bold;
|
159
|
+
}
|
160
|
+
.highlight .no {
|
161
|
+
color: #008080;
|
162
|
+
}
|
163
|
+
.highlight .nd {
|
164
|
+
color: #3c5d5d;
|
165
|
+
font-weight: bold;
|
166
|
+
}
|
167
|
+
.highlight .ni {
|
168
|
+
color: #800080;
|
169
|
+
}
|
170
|
+
.highlight .ne {
|
171
|
+
color: #990000;
|
172
|
+
font-weight: bold;
|
173
|
+
}
|
174
|
+
.highlight .nf, .highlight .fm {
|
175
|
+
color: #990000;
|
176
|
+
font-weight: bold;
|
177
|
+
}
|
178
|
+
.highlight .nl {
|
179
|
+
color: #990000;
|
180
|
+
font-weight: bold;
|
181
|
+
}
|
182
|
+
.highlight .nn {
|
183
|
+
color: #555555;
|
184
|
+
}
|
185
|
+
.highlight .nt {
|
186
|
+
color: #000080;
|
187
|
+
}
|
188
|
+
.highlight .vc {
|
189
|
+
color: #008080;
|
190
|
+
}
|
191
|
+
.highlight .vg {
|
192
|
+
color: #008080;
|
193
|
+
}
|
194
|
+
.highlight .vi {
|
195
|
+
color: #008080;
|
196
|
+
}
|
197
|
+
.highlight .nv, .highlight .vm {
|
198
|
+
color: #008080;
|
199
|
+
}
|
200
|
+
.highlight .ow {
|
201
|
+
color: #000000;
|
202
|
+
font-weight: bold;
|
203
|
+
}
|
204
|
+
.highlight .o {
|
205
|
+
color: #000000;
|
206
|
+
font-weight: bold;
|
207
|
+
}
|
208
|
+
.highlight .w {
|
209
|
+
color: #bbbbbb;
|
210
|
+
}
|
211
|
+
.highlight {
|
212
|
+
background-color: #f8f8f8;
|
213
|
+
}
|
data/app/styles/_search.scss
CHANGED
@@ -22,17 +22,16 @@
|
|
22
22
|
}
|
23
23
|
|
24
24
|
.search-field {
|
25
|
+
border: 1px solid var(--search-field-border-color);
|
26
|
+
border-radius: 3px;
|
27
|
+
|
25
28
|
outline: none;
|
26
29
|
padding: 8px 12px;
|
27
30
|
font-size: 1.5em;
|
28
|
-
width: 50%;
|
29
|
-
min-width: 200px;
|
30
31
|
width: 100%;
|
31
|
-
|
32
|
-
border: #ccc 1px solid;
|
33
|
-
border-radius: 3px;
|
32
|
+
min-width: 200px;
|
34
33
|
|
35
34
|
&:focus {
|
36
|
-
border-color:
|
35
|
+
border-color: var(--search-field-focused-border-color);
|
37
36
|
}
|
38
37
|
}
|
data/app/styles/_table.scss
CHANGED
@@ -8,21 +8,26 @@ table {
|
|
8
8
|
word-break: normal;
|
9
9
|
word-break: keep-all;
|
10
10
|
|
11
|
+
th, td {
|
12
|
+
padding: 6px 13px;
|
13
|
+
border: 1px solid var(--table-border-color);
|
14
|
+
}
|
15
|
+
|
16
|
+
td {
|
17
|
+
background-color: var(--table-bg-color);
|
18
|
+
}
|
19
|
+
|
11
20
|
th {
|
12
21
|
font-weight: bold;
|
22
|
+
background-color: var(--table-header-bg-color);
|
13
23
|
}
|
14
24
|
|
15
|
-
th, td {
|
16
|
-
padding: 6px 13px;
|
17
|
-
border: 1px solid #ddd;
|
18
|
-
}
|
19
25
|
|
20
26
|
tr {
|
21
|
-
background-color:
|
22
|
-
border-top: 1px solid #ccc;
|
27
|
+
background-color: var(--table-row-bg-color);
|
23
28
|
}
|
24
29
|
|
25
30
|
tr:nth-child(2n) {
|
26
|
-
background-color:
|
31
|
+
background-color: var(--table-alt-row-bg-color);
|
27
32
|
}
|
28
33
|
}
|
data/app/styles/_typography.scss
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
body {
|
2
2
|
-ms-text-size-adjust: 100%;
|
3
3
|
-webkit-text-size-adjust: 100%;
|
4
|
-
color:
|
4
|
+
color: var(--font-color);
|
5
5
|
// font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
6
6
|
font-family: "Segoe UI", "Helvetica Neue", Helvetica,Arial, freesans, sans-serif;
|
7
7
|
font-size: 16px;
|
@@ -21,39 +21,43 @@ h1, h2, h3, h4, h5, h6 {
|
|
21
21
|
}
|
22
22
|
|
23
23
|
h1 {
|
24
|
+
color: var(--h1-color);
|
25
|
+
border-bottom: 1px solid var(--h1-border-color);
|
24
26
|
margin: 0.67em 0;
|
25
27
|
padding-bottom: 0.3em;
|
26
28
|
font-size: 2.25em;
|
27
29
|
line-height: 1.2;
|
28
|
-
border-bottom: 1px solid #eee;
|
29
30
|
}
|
30
31
|
|
31
32
|
h2 {
|
33
|
+
color: var(--h2-color);
|
34
|
+
border-bottom: 1px solid var(--h2-border-color);
|
32
35
|
padding-bottom: 0.3em;
|
33
36
|
font-size: 1.75em;
|
34
37
|
line-height: 1.225;
|
35
|
-
border-bottom: 1px solid #eee;
|
36
38
|
}
|
37
39
|
|
38
40
|
h3 {
|
41
|
+
color: var(--h3-color);
|
39
42
|
font-size: 1.5em;
|
40
43
|
line-height: 1.43;
|
41
44
|
}
|
42
45
|
|
43
46
|
h4 {
|
47
|
+
color: var(--h4-color);
|
44
48
|
font-size: 1.25em;
|
45
49
|
}
|
46
50
|
|
47
51
|
h5 {
|
52
|
+
color: var(--h5-color);
|
48
53
|
font-size: 1em;
|
49
54
|
}
|
50
55
|
|
51
56
|
h6 {
|
57
|
+
color: var(--h6-color);
|
52
58
|
font-size: 1em;
|
53
|
-
color: #777;
|
54
59
|
}
|
55
60
|
|
56
61
|
code, pre, kbd {
|
57
62
|
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
58
|
-
font-size: 1em;
|
59
63
|
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
:root {
|
2
|
+
|
3
|
+
--background-color: transparent;
|
4
|
+
--blockquote-border-color: #ddd;
|
5
|
+
--blockquote-color: #777;
|
6
|
+
--breadcrumbs-border-color: #ccc;
|
7
|
+
--clipboard-button-bg-color: white;
|
8
|
+
--clipboard-button-border-color: #ccc;
|
9
|
+
--font-color: #333;
|
10
|
+
--footnotes-color: #666;
|
11
|
+
--h1-border-color: #eee;
|
12
|
+
--h1-color: #333;
|
13
|
+
--h2-border-color: #eee;
|
14
|
+
--h2-color: #333;
|
15
|
+
--h3-color: #333;
|
16
|
+
--h4-color: #333;
|
17
|
+
--h5-color: #333;
|
18
|
+
--h6-color: #777;
|
19
|
+
--highlight-color: palegreen;
|
20
|
+
--hr-color: #ddd;
|
21
|
+
--inline-code-bg-color: #eee;
|
22
|
+
--kbd-bg-color: #fcfcfc;
|
23
|
+
--kbd-border-color: #ccc;
|
24
|
+
--kbd-color: #111;
|
25
|
+
--kbd-shadow-color: #bbb;
|
26
|
+
--link-color: #4078c0;
|
27
|
+
--quiet-color: #777;
|
28
|
+
--scrollbar-color: #ccc;
|
29
|
+
--search-field-border-color: #ccc;
|
30
|
+
--search-field-focused-border-color: #4078c0;
|
31
|
+
--sidebar-bg-color: transparent;
|
32
|
+
--sidebar-border-color: #ddd;
|
33
|
+
--sidebar-border-right-color: #ddd;
|
34
|
+
--table-alt-row-bg-color: transparent;
|
35
|
+
--table-bg-color: transparent;
|
36
|
+
--table-border-color: #ddd;
|
37
|
+
--table-header-bg-color: transparent;
|
38
|
+
--table-row-bg-color: transparent;
|
39
|
+
|
40
|
+
}
|
data/app/styles/main.scss
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
@import "manifest";
|
2
2
|
|
3
3
|
body {
|
4
|
-
|
4
|
+
background-color: var(--background-color);
|
5
|
+
max-width: 1400px;
|
5
6
|
margin: 0 auto;
|
6
7
|
}
|
7
8
|
|
@@ -20,7 +21,7 @@ body {
|
|
20
21
|
@include desktop {
|
21
22
|
&.with-sidebar {
|
22
23
|
min-height: 100vh;
|
23
|
-
margin-left:
|
24
|
+
margin-left: 300px;
|
24
25
|
}
|
25
26
|
}
|
26
27
|
|
@@ -29,4 +30,3 @@ body {
|
|
29
30
|
margin: 0 auto;
|
30
31
|
}
|
31
32
|
}
|
32
|
-
|
data/app/views/_index_nav.slim
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
= item.
|
1
|
+
hr
|
2
|
+
ol
|
3
|
+
- nav.links.each do |item|
|
4
|
+
li
|
5
|
+
a href="#{item.href}" class=('strong' if item.type == :dir)
|
6
|
+
= item.label
|
data/app/views/document.slim
CHANGED
data/bin/madness
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
2
|
require 'madness'
|
4
3
|
require 'colsole'
|
5
4
|
include Colsole
|
6
5
|
|
6
|
+
runner = Madness::CLI.runner
|
7
|
+
|
7
8
|
begin
|
8
|
-
|
9
|
+
exit runner.run ARGV
|
10
|
+
rescue Madness::Interrupt
|
11
|
+
say! "\nGoodbye"
|
12
|
+
exit 1
|
9
13
|
rescue => e
|
10
14
|
puts e.backtrace.reverse if ENV['DEBUG']
|
11
15
|
say! "!undred!#{e.class}!txtrst!\n#{e.message}"
|
data/lib/madness/cli.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'mister_bin'
|
2
|
+
|
3
|
+
module Madness
|
4
|
+
# The CLI class is used by the bashly binary and forwards incoming CLI
|
5
|
+
# commands to the relevant Bashly::Commands class
|
6
|
+
class CLI
|
7
|
+
def self.runner
|
8
|
+
runner = MisterBin::Runner.new version: Madness::VERSION,
|
9
|
+
header: 'Markdown Madness - Instant Markdown Server',
|
10
|
+
footer: "Help: !txtpur!madness COMMAND --help!txtrst!\nDocs: !undblu!https://madness.dannyb.co"
|
11
|
+
|
12
|
+
# runner.route 'init', to: Commands::Server
|
13
|
+
runner.route 'server', to: Commands::Server
|
14
|
+
runner.route 'config', to: Commands::Config
|
15
|
+
# runner.route 'toc', to: Commands::TOC
|
16
|
+
runner.route 'theme', to: Commands::Theme
|
17
|
+
|
18
|
+
runner
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Madness
|
2
|
+
module Commands
|
3
|
+
class Config < Base
|
4
|
+
summary 'Manage the madness configuration file'
|
5
|
+
|
6
|
+
usage 'bashly config new'
|
7
|
+
usage 'bashly config show'
|
8
|
+
usage 'bashly config (-h|--help)'
|
9
|
+
|
10
|
+
command 'new', 'Create a new .madness.yml configuration file'
|
11
|
+
command 'show', 'Show all configuration options'
|
12
|
+
|
13
|
+
def new_command
|
14
|
+
raise InitError, "Configuration file #{config.filename} already exists" if File.exist? config.filename
|
15
|
+
|
16
|
+
FileUtils.cp File.expand_path('../templates/madness.yml', __dir__), config.filename
|
17
|
+
say "!txtgrn!Created #{config.filename} config file"
|
18
|
+
end
|
19
|
+
|
20
|
+
def show_command
|
21
|
+
errors_found = false
|
22
|
+
|
23
|
+
config.data.each do |key, value|
|
24
|
+
value_color = config.defaults[key] == value ? '' : '!bldblu!'
|
25
|
+
if config.defaults.has_key?(key)
|
26
|
+
key_color = '!txtgrn!'
|
27
|
+
else
|
28
|
+
key_color = '!txtred!'
|
29
|
+
value_color = '!txtred!'
|
30
|
+
errors_found = true
|
31
|
+
end
|
32
|
+
|
33
|
+
say "#{key_color}#{key.to_s.rjust 20}!txtrst!: #{value_color}#{value || '~'}"
|
34
|
+
end
|
35
|
+
|
36
|
+
say ''
|
37
|
+
|
38
|
+
if config.file_exist?
|
39
|
+
say "Values in !bldblu!blue!txtrst! loaded from !txtgrn!#{config.filename}"
|
40
|
+
end
|
41
|
+
|
42
|
+
return unless errors_found
|
43
|
+
|
44
|
+
say 'Keys in !txtred!red!txtrst! are not recognized'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Madness
|
2
|
+
module Commands
|
3
|
+
class Server < Base
|
4
|
+
summary 'Start the server'
|
5
|
+
|
6
|
+
usage 'madness server [PATH] [options]'
|
7
|
+
usage 'madness init (-h|--help)'
|
8
|
+
|
9
|
+
param 'PATH', 'Path to the markdown directory [default: .]'
|
10
|
+
|
11
|
+
option '-p --port NUMBER', 'Set server port number [default: 3000]'
|
12
|
+
option '-b --bind ADDRESS', 'Set server listen address [default: 0.0.0.0]'
|
13
|
+
option '-o --open', 'Open a web browser after launching'
|
14
|
+
option '--auth USER:PASS', 'Enable basic authentication'
|
15
|
+
option '--auth-zone NAME', 'The basic authentication prompt title [default: Restricted Documentation]'
|
16
|
+
option '--theme FOLDER', 'Use a custom theme (either absolute or relative to the main documentation path)'
|
17
|
+
|
18
|
+
example 'madness server'
|
19
|
+
example 'madness server docs'
|
20
|
+
example 'madness server docs -p 4567'
|
21
|
+
example 'madness server docs --open'
|
22
|
+
example 'madness server --auth user:secret --port 4000'
|
23
|
+
example 'madness server --theme _mytheme'
|
24
|
+
|
25
|
+
def run
|
26
|
+
override_config args
|
27
|
+
build_toc if config.toc
|
28
|
+
open_browser if config.open
|
29
|
+
launch_server
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def launch_server
|
35
|
+
raise ConfigurationError, "Invalid path: #{config.path}" unless File.directory? config.path
|
36
|
+
|
37
|
+
show_status
|
38
|
+
Madness::Server.prepare
|
39
|
+
Madness::Server.run!
|
40
|
+
end
|
41
|
+
|
42
|
+
def build_toc
|
43
|
+
say_status :toc, "generating #{config.toc}"
|
44
|
+
Madness::TableOfContents.new.build(config.toc)
|
45
|
+
end
|
46
|
+
|
47
|
+
def open_browser
|
48
|
+
browser = Browser.new config.bind, config.port
|
49
|
+
browser.open do |error|
|
50
|
+
say "!txtred!#{error}" if error
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def override_config(args)
|
55
|
+
config.path = args['PATH'] if args['PATH']
|
56
|
+
config.port = args['--port'].to_i if args['--port']
|
57
|
+
config.bind = args['--bind'] if args['--bind']
|
58
|
+
config.auth = args['--auth'] if args['--auth']
|
59
|
+
config.auth_zone = args['--auth-zone'] if args['--auth-zone']
|
60
|
+
config.open = true if args['--open']
|
61
|
+
config.theme = File.expand_path(args['--theme'], config.path) if args['--theme']
|
62
|
+
end
|
63
|
+
|
64
|
+
def show_status
|
65
|
+
say_status :start, 'the madness'
|
66
|
+
say_status :env, Madness::Server.environment
|
67
|
+
say_status :listen, "#{config.bind}:#{config.port}"
|
68
|
+
say_status :path, File.realpath(config.path)
|
69
|
+
say_status :config, config.filename if config.file_exist?
|
70
|
+
say_status :theme, config.theme if config.theme
|
71
|
+
|
72
|
+
say '-' * 60
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Madness
|
2
|
+
module Commands
|
3
|
+
class Theme < Base
|
4
|
+
summary 'Create files for theme customization'
|
5
|
+
|
6
|
+
usage 'madness theme full [PATH]'
|
7
|
+
usage 'madness theme css'
|
8
|
+
usage 'madness config (-h|--help)'
|
9
|
+
|
10
|
+
command 'full', 'Create a full theme customization directory in PATH [default: _theme]'
|
11
|
+
command 'css', 'Create a folder with the CSS file for customization'
|
12
|
+
|
13
|
+
def full_command
|
14
|
+
raise InitError, "Directory #{theme_path} already exists" if Dir.exist? theme_path
|
15
|
+
|
16
|
+
FileUtils.cp_r File.expand_path('../../../app', __dir__), theme_path
|
17
|
+
say "!txtgrn!Created #{theme_path} theme folder"
|
18
|
+
end
|
19
|
+
|
20
|
+
def css_command
|
21
|
+
file = 'css/main.css'
|
22
|
+
raise InitError, "File #{file} already exists" if File.exist? file
|
23
|
+
|
24
|
+
FileUtils.mkdir_p 'css'
|
25
|
+
FileUtils.cp_r File.expand_path('../../../app/public/css/main.css', __dir__), 'css/main.css'
|
26
|
+
say '!txtgrn!Created css/main.css'
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def theme_path
|
32
|
+
args['PATH'] || '_theme'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|