madness 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +46 -76
- data/lib/madness/command_line.rb +7 -4
- data/lib/madness/docopt.txt +7 -3
- data/lib/madness/search.rb +5 -1
- data/lib/madness/settings.rb +1 -0
- data/lib/madness/templates/madness.yml +1 -0
- data/lib/madness/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d745803a5a46e353b40e4376b99cc3d1621f04f979c13667d690d786982767a
|
4
|
+
data.tar.gz: 329a470c65598061e69a9dbb0240e2fee6a794a57417d02a51313a3a4f483e24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb774064228bb26a7b116571a96bbb556e5c5b8f553e2610dba70b3b3611597b51f323e730b41dbeed471696ebe41102ee805334beca94f35ed3c25ae578fe2f
|
7
|
+
data.tar.gz: 2ab54a17b5e27471662cb415ae4b1ac99beb6f15dfb9e365fa43b0fde33753b9343aec290d5a6d22f55896aaee262fbdc10a71cf0235111743168d3d39f5f917
|
data/README.md
CHANGED
@@ -1,14 +1,12 @@
|
|
1
|
-
Madness - Instant Markdown Server
|
2
|
-
==================================================
|
1
|
+
# Madness - Instant Markdown Server
|
3
2
|
|
4
3
|
[![Gem Version](https://badge.fury.io/rb/madness.svg)](https://badge.fury.io/rb/madness)
|
5
|
-
[![Build Status](https://
|
4
|
+
[![Build Status](https://github.com/DannyBen/madness/workflows/Test/badge.svg)](https://github.com/DannyBen/madness/actions?query=workflow%3ATest)
|
6
5
|
[![Maintainability](https://api.codeclimate.com/v1/badges/fa440dc4dbf895734d74/maintainability)](https://codeclimate.com/github/DannyBen/madness/maintainability)
|
7
6
|
|
8
7
|
---
|
9
8
|
|
10
|
-
Screenshots (click to zoom)
|
11
|
-
--------------------------------------------------
|
9
|
+
## Screenshots (click to zoom)
|
12
10
|
|
13
11
|
<table><tr>
|
14
12
|
<td><a target='_screenshot' href='assets/screen-main.png'><img src='assets/screen-main.png'/></a></td>
|
@@ -17,10 +15,7 @@ Screenshots (click to zoom)
|
|
17
15
|
<td><a target='_screenshot' href='assets/screen-search.png'><img src='assets/screen-search.png'/></a></td>
|
18
16
|
</tr></table>
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
Table of Contents
|
23
|
-
--------------------------------------------------
|
18
|
+
## Table of Contents
|
24
19
|
|
25
20
|
* [Install](#install)
|
26
21
|
* [Design Intentions](#design-intentions)
|
@@ -38,25 +33,26 @@ Table of Contents
|
|
38
33
|
* [Forcing HTTPS Connection](#forcing-https-connection)
|
39
34
|
* [Docker Image](#docker-image)
|
40
35
|
|
36
|
+
## Install
|
41
37
|
|
38
|
+
**Using Ruby:**
|
42
39
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
$ gem install madness
|
40
|
+
```shell
|
41
|
+
$ gem install madness
|
42
|
+
```
|
47
43
|
|
44
|
+
**Using Docker:**
|
48
45
|
|
46
|
+
```shell
|
47
|
+
$ alias madness='docker run --rm -it -v $PWD:/docs -p 3000:3000 dannyben/madness'
|
48
|
+
```
|
49
49
|
|
50
|
-
Design Intentions
|
51
|
-
--------------------------------------------------
|
50
|
+
## Design Intentions
|
52
51
|
|
53
52
|
Madness was designed in order to provide easy browsing, viewing and
|
54
53
|
searching for local, markdown based documentation directories.
|
55
54
|
|
56
|
-
|
57
|
-
|
58
|
-
Feature Highlights
|
59
|
-
--------------------------------------------------
|
55
|
+
## Feature Highlights
|
60
56
|
|
61
57
|
- Easy to use.
|
62
58
|
- Built-in full text search.
|
@@ -66,28 +62,23 @@ Feature Highlights
|
|
66
62
|
- Automatic generation of navigation sidebar.
|
67
63
|
- Automatic generation of Table of Contents.
|
68
64
|
|
69
|
-
|
70
|
-
|
71
|
-
Usage
|
72
|
-
--------------------------------------------------
|
65
|
+
## Usage
|
73
66
|
|
74
67
|
Go to any directory that contains markdown files and run:
|
75
68
|
|
76
|
-
|
69
|
+
```shell
|
70
|
+
$ madness
|
71
|
+
```
|
77
72
|
|
78
73
|
And open <http://localhost:3000> in your browser.
|
79
74
|
|
80
75
|
For more options, run:
|
81
76
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
[run madness with docker](#docker-image).
|
86
|
-
|
87
|
-
|
77
|
+
```shell
|
78
|
+
$ madness --help
|
79
|
+
```
|
88
80
|
|
89
|
-
Directory Conventions
|
90
|
-
--------------------------------------------------
|
81
|
+
## Directory Conventions
|
91
82
|
|
92
83
|
Madness expects to be executed in a documentation directory.
|
93
84
|
|
@@ -115,10 +106,7 @@ Example structure:
|
|
115
106
|
└── File.md
|
116
107
|
```
|
117
108
|
|
118
|
-
|
119
|
-
|
120
|
-
Configuration File
|
121
|
-
--------------------------------------------------
|
109
|
+
## Configuration File
|
122
110
|
|
123
111
|
All the command line arguments can also be configured through a
|
124
112
|
configuration file. Create a file named `.madness.yml` in your
|
@@ -147,10 +135,7 @@ For convenience, you can get a template config file by running:
|
|
147
135
|
$ madness create config
|
148
136
|
```
|
149
137
|
|
150
|
-
|
151
|
-
|
152
|
-
Search
|
153
|
-
--------------------------------------------------
|
138
|
+
## Search
|
154
139
|
|
155
140
|
Madness comes with a full text search page. To activate it, you need to
|
156
141
|
generate a search index by running `madness --index` or
|
@@ -162,10 +147,7 @@ to your documentation server.
|
|
162
147
|
You will need to run this command from time to time, as your
|
163
148
|
documents change or new documents are added.
|
164
149
|
|
165
|
-
|
166
|
-
|
167
|
-
Images and Static Files
|
168
|
-
--------------------------------------------------
|
150
|
+
## Images and Static Files
|
169
151
|
|
170
152
|
You can put images and other asset files anywhere in your documentation
|
171
153
|
folder.
|
@@ -184,40 +166,28 @@ this markdown:
|
|
184
166
|
If you wish to link to images or pages in a different folder, simply specify
|
185
167
|
the path relative to the homepage:
|
186
168
|
|
187
|
-
```
|
169
|
+
```markdown
|
188
170
|
![alt text](/images/nice-picture.png)
|
189
171
|
```
|
190
172
|
|
191
|
-
|
192
|
-
|
193
|
-
Automatic H1
|
194
|
-
--------------------------------------------------
|
173
|
+
## Automatic H1
|
195
174
|
|
196
175
|
If your markdown document does not start with a level 1 heading, it
|
197
176
|
will be automatically added based on the file name.
|
198
177
|
|
178
|
+
## Table of Contents Generation
|
199
179
|
|
180
|
+
You can use the `madness --toc FILENAME` command to generate a
|
181
|
+
"Table of Contents" markdown file.
|
200
182
|
|
201
|
-
|
202
|
-
--------------------------------------------------
|
203
|
-
|
204
|
-
You can use the `madness --toc` command to generate a "Table of Contents"
|
205
|
-
markdown file.
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
Hidden Directories
|
210
|
-
--------------------------------------------------
|
183
|
+
## Hidden Directories
|
211
184
|
|
212
185
|
Directories that are made only of lowercase letters, underscoes, dash and/or
|
213
186
|
numbers (`/^[a-z_\-0-9]+$/`) will not be displayed in the navigation. In
|
214
187
|
other words, directories must have at least one uppercase letter or a space
|
215
188
|
to be recognized as a documentation directory.
|
216
189
|
|
217
|
-
|
218
|
-
|
219
|
-
Controlling Sort Order
|
220
|
-
--------------------------------------------------
|
190
|
+
## Controlling Sort Order
|
221
191
|
|
222
192
|
To control the sort order of the automatically generated navigation elements,
|
223
193
|
simply perfix your files and directories with digits followed by a dot and a
|
@@ -230,10 +200,7 @@ will be omitted when they are displayed.
|
|
230
200
|
└── 2. Another file or folder
|
231
201
|
```
|
232
202
|
|
233
|
-
|
234
|
-
|
235
|
-
Customizing Theme
|
236
|
-
--------------------------------------------------
|
203
|
+
## Customizing Theme
|
237
204
|
|
238
205
|
There are two ways to change how Madness looks.
|
239
206
|
|
@@ -272,20 +239,16 @@ If you are looking to implement a smaller CSS change, follow these steps:
|
|
272
239
|
Note that this functionality is not guaranteed to stay as is in future
|
273
240
|
versions of madness.
|
274
241
|
|
275
|
-
|
276
|
-
|
277
|
-
Forcing HTTPS Connection
|
278
|
-
--------------------------------------------------
|
242
|
+
## Forcing HTTPS Connection
|
279
243
|
|
280
244
|
To have Madness redirect HTTP traffic to HTTPS, set this environment
|
281
245
|
variable:
|
282
246
|
|
283
|
-
|
284
|
-
|
285
|
-
|
247
|
+
```shell
|
248
|
+
$ export MADNESS_FORCE_SSL=1
|
249
|
+
```
|
286
250
|
|
287
|
-
Docker Image
|
288
|
-
--------------------------------------------------
|
251
|
+
## Docker Image
|
289
252
|
|
290
253
|
Madness server is also available as a docker image.
|
291
254
|
|
@@ -296,6 +259,13 @@ directory as the markdown documentation folder
|
|
296
259
|
$ docker run --rm -it -v $PWD:/docs -p 3000:3000 dannyben/madness
|
297
260
|
```
|
298
261
|
|
262
|
+
You may create an alias for convenience:
|
263
|
+
|
264
|
+
```shell
|
265
|
+
$ alias madness='docker run --rm -it -v $PWD:/docs -p 3000:3000 dannyben/madness'
|
266
|
+
$ medness --help
|
267
|
+
```
|
268
|
+
|
299
269
|
For more information about the docker image, see:
|
300
270
|
|
301
271
|
- [Madness image on Docker Hub][dockerhub]
|
data/lib/madness/command_line.rb
CHANGED
@@ -61,10 +61,12 @@ module Madness
|
|
61
61
|
# Get the arguments as provided by docopt, and set them to our own
|
62
62
|
# config object.
|
63
63
|
def set_config(args)
|
64
|
-
config.path
|
65
|
-
config.port
|
66
|
-
config.bind
|
67
|
-
config.toc
|
64
|
+
config.path = args['PATH'] if args['PATH']
|
65
|
+
config.port = args['--port'].to_i if args['--port']
|
66
|
+
config.bind = args['--bind'] if args['--bind']
|
67
|
+
config.toc = args['--toc'] if args['--toc']
|
68
|
+
config.search_limit = args['--search-limit'].to_i if args['--search-limit']
|
69
|
+
|
68
70
|
config.auto_h1 = false if args['--no-auto-h1']
|
69
71
|
config.auto_nav = false if args['--no-auto-nav']
|
70
72
|
config.sidebar = false if args['--no-sidebar']
|
@@ -73,6 +75,7 @@ module Madness
|
|
73
75
|
config.copy_code = false if args['--no-copy-code']
|
74
76
|
config.index = true if args['--index']
|
75
77
|
config.open = true if args['--open']
|
78
|
+
|
76
79
|
config.theme = File.expand_path(args['--theme'], config.path) if args['--theme']
|
77
80
|
end
|
78
81
|
|
data/lib/madness/docopt.txt
CHANGED
@@ -16,16 +16,16 @@ Subcommands:
|
|
16
16
|
|
17
17
|
Parameters:
|
18
18
|
PATH:
|
19
|
-
|
19
|
+
Path to the markdown directory [default: .].
|
20
20
|
(Config option: path)
|
21
21
|
|
22
22
|
Options:
|
23
23
|
-p, --port NUMBER
|
24
|
-
Set server port number.
|
24
|
+
Set server port number [default: 3000].
|
25
25
|
(Config option: port)
|
26
26
|
|
27
27
|
-b, --bind ADDRESS
|
28
|
-
Set server listen address.
|
28
|
+
Set server listen address [default: 0.0.0.0].
|
29
29
|
(Config option: bind)
|
30
30
|
|
31
31
|
--no-auto-h1
|
@@ -68,6 +68,10 @@ Options:
|
|
68
68
|
Generate a table of contents file.
|
69
69
|
(Config option: toc)
|
70
70
|
|
71
|
+
--search-limit LIMIT
|
72
|
+
Maximum number of results to show on the search page [default: 100].
|
73
|
+
(Config option: search_limit)
|
74
|
+
|
71
75
|
--open
|
72
76
|
Open the browser pointing at the madness webserver.
|
73
77
|
(Config option: open)
|
data/lib/madness/search.rb
CHANGED
@@ -33,7 +33,7 @@ module Madness
|
|
33
33
|
index = Index.new path: index_dir
|
34
34
|
|
35
35
|
results = []
|
36
|
-
index.search_each(query, limit:
|
36
|
+
index.search_each(query, limit: config.search_limit) do |doc_id, score|
|
37
37
|
filename = index[doc_id][:file].sub("#{@path}/", '')[0...-3]
|
38
38
|
highlights = index.highlight "content:(#{query.tr(' ',' OR ')}) ", doc_id, field: :content,
|
39
39
|
pre_tag: "<strong>", post_tag: "</strong>",
|
@@ -91,6 +91,10 @@ module Madness
|
|
91
91
|
.join(' / ')
|
92
92
|
end
|
93
93
|
|
94
|
+
def config
|
95
|
+
@config ||= Settings.instance
|
96
|
+
end
|
97
|
+
|
94
98
|
def file_url(filename)
|
95
99
|
filename.remove(/\/(index|README)$/)
|
96
100
|
end
|
data/lib/madness/settings.rb
CHANGED
data/lib/madness/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: madness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coderay
|