madness 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -3
- data/lib/madness/directory.rb +21 -7
- data/lib/madness/document.rb +22 -4
- data/lib/madness/navigation.rb +10 -1
- data/lib/madness/refinements/array_refinements.rb +2 -2
- data/lib/madness/server_base.rb +1 -1
- data/lib/madness/settings.rb +2 -1
- data/lib/madness/templates/madness.yml +5 -0
- data/lib/madness/version.rb +1 -1
- data/lib/madness.rb +2 -5
- metadata +6 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76896d82203c749d37aa6bb4a321deee5e544f9763ff9ab9544bd28ae90c613d
|
4
|
+
data.tar.gz: a1a8c4093bc5dbef67489096658f057860945125c6de6e5376f362287b207be2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a0e267fcdd6e0568f348e03d2b67b99e3bbc7ca6cbc7eefef3d8f00f1661b5193c281800520fa7b4ad266083eb174dc62d65314d1a6883e91d986e5e6719203
|
7
|
+
data.tar.gz: 55db2eb7681263246b3fbae1881c811e62c5d39974439ad7279ecf6ba48c43c6e69d18866c09e9d110aa3e26674ec127e251343f88ccdc8d9da3a5926359b182
|
data/README.md
CHANGED
@@ -78,9 +78,6 @@ Madness expects to be executed in a documentation directory.
|
|
78
78
|
A documentation directory contains only markdown files (`*.md`) and sub
|
79
79
|
directories that contain more markdown files.
|
80
80
|
|
81
|
-
The server will consider the file `index.md` or `README.md` in any directory as
|
82
|
-
the main file describing this directory, where `index.md` has priority.
|
83
|
-
|
84
81
|
The navigation sidebar will show all the sub directories and files in the same
|
85
82
|
directory as the viewed file.
|
86
83
|
|
@@ -129,6 +126,11 @@ bind: 0.0.0.0
|
|
129
126
|
# base_uri: /docs
|
130
127
|
base_uri: ~
|
131
128
|
|
129
|
+
# choose navigation sort order:
|
130
|
+
# sort_order: dirs_first # alphabetic directories then alphabetic files
|
131
|
+
# sort_order: mixed # alphabetic regardless of type
|
132
|
+
sort_order: dirs_first
|
133
|
+
|
132
134
|
# enable sidebar
|
133
135
|
sidebar: true
|
134
136
|
|
@@ -195,6 +197,23 @@ exclude: ['^[a-z_\-0-9]+$']
|
|
195
197
|
|
196
198
|
## Features
|
197
199
|
|
200
|
+
### Cover Pages
|
201
|
+
|
202
|
+
Cover pages are specially named markdown files that serve as the introduction
|
203
|
+
to the contents of a specific directory.
|
204
|
+
|
205
|
+
The server will consider any of the following files as cover pages (prioritized):
|
206
|
+
|
207
|
+
- A markdown file with the same name as the directory (adjacent to it).
|
208
|
+
- `index.md`
|
209
|
+
- `README.md`
|
210
|
+
|
211
|
+
For example, for a directory named "API Documentation":
|
212
|
+
|
213
|
+
- `/API Documentation.md`
|
214
|
+
- `/API Documentation/index.md`
|
215
|
+
- `/API Documentation/README.md`
|
216
|
+
|
198
217
|
### Search
|
199
218
|
|
200
219
|
Madness comes with a full text search page.
|
@@ -286,6 +305,9 @@ will be omitted when they are displayed.
|
|
286
305
|
└── 2. Another file or folder
|
287
306
|
```
|
288
307
|
|
308
|
+
Note that by default, directories will appear above files. If you wish to
|
309
|
+
change this, set `sort_order: mixed` in your configuration file.
|
310
|
+
|
289
311
|
### Displaying Additional File Types
|
290
312
|
|
291
313
|
If you wish the navigation and search features to also show other documents
|
data/lib/madness/directory.rb
CHANGED
@@ -3,6 +3,7 @@ module Madness
|
|
3
3
|
class Directory
|
4
4
|
include ServerHelper
|
5
5
|
using ArrayRefinements
|
6
|
+
using StringRefinements
|
6
7
|
|
7
8
|
attr_reader :dir
|
8
9
|
|
@@ -17,17 +18,22 @@ module Madness
|
|
17
18
|
private
|
18
19
|
|
19
20
|
def files
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
@files ||= begin
|
22
|
+
result = Dir["#{dir}/#{config.dir_glob}"]
|
23
|
+
result.reject! do |f|
|
24
|
+
['README.md', 'index.md'].include? File.basename(f)
|
25
|
+
end
|
26
|
+
result.reject! { |f| is_cover_page? f }
|
27
|
+
result.nat_sort.map { |path| Item.new path, :file }
|
23
28
|
end
|
24
|
-
result.nat_sort.map { |path| Item.new path, :file }
|
25
29
|
end
|
26
30
|
|
27
31
|
def dirs
|
28
|
-
|
29
|
-
|
30
|
-
|
32
|
+
@dirs ||= begin
|
33
|
+
result = Dir["#{dir}/*"].select { |f| File.directory? f }
|
34
|
+
result.reject! { |f| exclude? f }
|
35
|
+
result.nat_sort.map { |path| Item.new path, :dir }
|
36
|
+
end
|
31
37
|
end
|
32
38
|
|
33
39
|
def exclude?(path)
|
@@ -40,6 +46,14 @@ module Madness
|
|
40
46
|
false
|
41
47
|
end
|
42
48
|
|
49
|
+
def is_cover_page?(path)
|
50
|
+
dir_paths.include? path.remove(/\.md$/)
|
51
|
+
end
|
52
|
+
|
53
|
+
def dir_paths
|
54
|
+
@dir_paths ||= dirs.map(&:path)
|
55
|
+
end
|
56
|
+
|
43
57
|
def config
|
44
58
|
@config ||= Settings.instance
|
45
59
|
end
|
data/lib/madness/document.rb
CHANGED
@@ -55,10 +55,8 @@ module Madness
|
|
55
55
|
@dir = base
|
56
56
|
@type = :readme
|
57
57
|
|
58
|
-
if
|
59
|
-
@file =
|
60
|
-
elsif File.exist? "#{base}/README.md"
|
61
|
-
@file = "#{base}/README.md"
|
58
|
+
if cover_page
|
59
|
+
@file = cover_page
|
62
60
|
else
|
63
61
|
@type = :empty
|
64
62
|
end
|
@@ -79,5 +77,25 @@ module Madness
|
|
79
77
|
def md_filename
|
80
78
|
File.extname(base) == '.md' ? base : "#{base}.md"
|
81
79
|
end
|
80
|
+
|
81
|
+
def cover_page
|
82
|
+
@cover_page ||= cover_page!
|
83
|
+
end
|
84
|
+
|
85
|
+
def cover_page!
|
86
|
+
cover_page_candidates.each do |candidate|
|
87
|
+
return candidate if File.exist? candidate
|
88
|
+
end
|
89
|
+
|
90
|
+
nil
|
91
|
+
end
|
92
|
+
|
93
|
+
def cover_page_candidates
|
94
|
+
@cover_page_candidates ||= [
|
95
|
+
File.expand_path("../#{File.basename(base)}.md", base),
|
96
|
+
File.expand_path('index.md', base),
|
97
|
+
File.expand_path('README.md', base),
|
98
|
+
]
|
99
|
+
end
|
82
100
|
end
|
83
101
|
end
|
data/lib/madness/navigation.rb
CHANGED
@@ -2,6 +2,7 @@ module Madness
|
|
2
2
|
# Handle the navigation links for a given directory
|
3
3
|
class Navigation
|
4
4
|
include ServerHelper
|
5
|
+
using ArrayRefinements
|
5
6
|
using StringRefinements
|
6
7
|
|
7
8
|
attr_reader :dir
|
@@ -11,7 +12,11 @@ module Madness
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def links
|
14
|
-
@links ||=
|
15
|
+
@links ||= if config.sort_order == 'mixed'
|
16
|
+
directory.list.nat_sort(by: :href)
|
17
|
+
else
|
18
|
+
directory.list
|
19
|
+
end
|
15
20
|
end
|
16
21
|
|
17
22
|
def caption
|
@@ -27,5 +32,9 @@ module Madness
|
|
27
32
|
def directory
|
28
33
|
@directory ||= Directory.new(dir)
|
29
34
|
end
|
35
|
+
|
36
|
+
def config
|
37
|
+
Settings.instance
|
38
|
+
end
|
30
39
|
end
|
31
40
|
end
|
data/lib/madness/server_base.rb
CHANGED
@@ -16,7 +16,7 @@ module Madness
|
|
16
16
|
set :static, false
|
17
17
|
|
18
18
|
# Since we cannot use any config values in the main body of the class,
|
19
|
-
# since they will be updated later, we need to set anything that
|
19
|
+
# since they will be updated later, we need to set anything that relies
|
20
20
|
# on the config values just before running the server.
|
21
21
|
# The CommandLine class and the test suite should both call
|
22
22
|
# `Server.prepare` before calling Server.run!
|
data/lib/madness/settings.rb
CHANGED
@@ -15,7 +15,7 @@ module Madness
|
|
15
15
|
reset
|
16
16
|
end
|
17
17
|
|
18
|
-
def method_missing(name, *args, &
|
18
|
+
def method_missing(name, *args, &_block)
|
19
19
|
name_string = name.to_s
|
20
20
|
|
21
21
|
if name_string.end_with? '='
|
@@ -57,6 +57,7 @@ module Madness
|
|
57
57
|
port: 3000,
|
58
58
|
bind: '0.0.0.0',
|
59
59
|
base_uri: nil,
|
60
|
+
sort_order: 'dirs_first',
|
60
61
|
sidebar: true,
|
61
62
|
auto_h1: true,
|
62
63
|
auto_nav: true,
|
@@ -15,6 +15,11 @@ bind: 0.0.0.0
|
|
15
15
|
# base_uri: /docs
|
16
16
|
base_uri: ~
|
17
17
|
|
18
|
+
# choose navigation sort order:
|
19
|
+
# sort_order: dirs_first # alphabetic directories then alphabetic files
|
20
|
+
# sort_order: mixed # alphabetic regardless of type
|
21
|
+
sort_order: dirs_first
|
22
|
+
|
18
23
|
# enable sidebar
|
19
24
|
sidebar: true
|
20
25
|
|
data/lib/madness/version.rb
CHANGED
data/lib/madness.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: 1.1.
|
4
|
+
version: 1.1.5
|
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: 2024-
|
11
|
+
date: 2024-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -28,22 +28,16 @@ dependencies:
|
|
28
28
|
name: colsole
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.8.1
|
34
|
-
- - "<"
|
31
|
+
- - "~>"
|
35
32
|
- !ruby/object:Gem::Version
|
36
|
-
version: '
|
33
|
+
version: '1.0'
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
|
-
- - "
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: 0.8.1
|
44
|
-
- - "<"
|
38
|
+
- - "~>"
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
40
|
+
version: '1.0'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: extended_yaml
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|