madness 0.5.0 → 0.5.1
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 +4 -4
- data/README.md +25 -9
- data/lib/madness/document.rb +2 -18
- data/lib/madness/navigation.rb +1 -1
- data/lib/madness/server.rb +5 -1
- 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: 4548ff821bb0396f536bc5d7228a03bc44307c9eb60b1282c74aee8519f1dd86
|
4
|
+
data.tar.gz: d438320e3e8a819aa6e90dac8d9a77140444270fceccedf6f5a199c53d685d45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05caa89aa6745f72cc6552ae8b4376db76bace2561196c220fa94958c327a1b9ade31686f0ad38a8c847a13a80a08ab173de2edfddbd689db4848e49060578f5
|
7
|
+
data.tar.gz: 4f8937f11e93d872d1d1a3c1cc5015e5bb326a84d6a34a086fa9fe077db7aa09dbfdba170dcac1f6e0120aef26acbaf71230e32199d05d074ceaa8d4e1db9990
|
data/README.md
CHANGED
@@ -36,7 +36,7 @@ Feature Highlights
|
|
36
36
|
|
37
37
|
- Easy to use
|
38
38
|
- Built in full text search
|
39
|
-
-
|
39
|
+
- Compatible with how markdown files are displayed on GitHub andGitHub pages.
|
40
40
|
- Configure with a configuration file or command arguments
|
41
41
|
|
42
42
|
|
@@ -129,10 +129,7 @@ You can put images and any other asset file anywhere in your documentation
|
|
129
129
|
folder.
|
130
130
|
|
131
131
|
When linking to other pages or images in your documentation folder, simply
|
132
|
-
use the URL relative to the markdown file.
|
133
|
-
relative to the docroot of the generated site.
|
134
|
-
|
135
|
-
This behavior mimics how GitHub is rendering markdown files.
|
132
|
+
use the URL relative to the markdown file.
|
136
133
|
|
137
134
|
For example, if you have a folder named `subfolder` that contains a
|
138
135
|
`README.md` and a `nice-picture.png`, showing it in your `README` is done by
|
@@ -158,18 +155,37 @@ If your markdown document does not start with a level 1 heading, it
|
|
158
155
|
will be automatically added based on the file name.
|
159
156
|
|
160
157
|
|
158
|
+
|
161
159
|
Hidden Directories
|
162
160
|
--------------------------------------------------
|
163
161
|
|
164
|
-
|
165
|
-
|
162
|
+
These directories will not be displayed in the navigation:
|
163
|
+
|
164
|
+
- Directories that begin with an underscore.
|
165
|
+
- Directories that are made only of lowercase letters, underscoew, dash and/or
|
166
|
+
numbers (`/^[a-z_\-0-9]+$/`).
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
Changing Theme
|
171
|
+
--------------------------------------------------
|
172
|
+
|
173
|
+
To change the CSS of your documentation server:
|
174
|
+
|
175
|
+
- Create a directory named `css` in your root documentation directory.
|
176
|
+
- Copy the [main.css][css] file to it.
|
177
|
+
- Update it as you see fit.
|
178
|
+
|
179
|
+
Note that this functionality is not guaranteed to stay as is in future
|
180
|
+
versions of madness, since support for themes is still not yet fully
|
181
|
+
implemented.
|
166
182
|
|
167
183
|
|
168
184
|
|
169
185
|
Docker Image
|
170
186
|
--------------------------------------------------
|
171
187
|
|
172
|
-
|
188
|
+
Madness server is also available as a docker image.
|
173
189
|
|
174
190
|
This command will start the server on localhost:3000, with the current
|
175
191
|
directory as the markdown documentation folder
|
@@ -190,5 +206,5 @@ For more information see:
|
|
190
206
|
[screenshot]: https://raw.githubusercontent.com/DannyBen/madness/master/screenshot.png
|
191
207
|
[dockerhub]: https://hub.docker.com/r/dannyben/madness/
|
192
208
|
[dockerfile]: https://github.com/DannyBen/docker-madness
|
193
|
-
|
209
|
+
[css]: app/public/css/main.css
|
194
210
|
|
data/lib/madness/document.rb
CHANGED
@@ -15,6 +15,7 @@ module Madness
|
|
15
15
|
@path = path
|
16
16
|
|
17
17
|
base = path.empty? ? docroot : "#{docroot}/#{path}"
|
18
|
+
base.chomp! '/'
|
18
19
|
|
19
20
|
if File.directory? base
|
20
21
|
@file = "#{base}/README.md"
|
@@ -48,7 +49,7 @@ module Madness
|
|
48
49
|
|
49
50
|
# Return a reasonable HTML title for the file or directory
|
50
51
|
def title
|
51
|
-
if
|
52
|
+
if type == :readme
|
52
53
|
result = File.basename File.dirname(file)
|
53
54
|
else
|
54
55
|
result = File.basename(file,'.md')
|
@@ -56,10 +57,6 @@ module Madness
|
|
56
57
|
result.tr '-', ' '
|
57
58
|
end
|
58
59
|
|
59
|
-
def relative_dir
|
60
|
-
@relative_dir ||= dir[/#{docroot}\/(.*)/,1]
|
61
|
-
end
|
62
|
-
|
63
60
|
private
|
64
61
|
|
65
62
|
# Convert markdown to HTML, wit hsome additional processing:
|
@@ -67,7 +64,6 @@ module Madness
|
|
67
64
|
# 2. Prepend H1 if needed
|
68
65
|
def markdown_to_html
|
69
66
|
doc = CommonMarker.render_doc(File.read file)
|
70
|
-
fix_relative_links doc if relative_dir
|
71
67
|
html = doc.to_html
|
72
68
|
html = syntax_highlight(html) if config.highlighter
|
73
69
|
html = prepend_h1(html) if config.autoh1
|
@@ -99,18 +95,6 @@ module Madness
|
|
99
95
|
CodeRay.scan(code, lang).html opts
|
100
96
|
end
|
101
97
|
end
|
102
|
-
|
103
|
-
def fix_relative_links(doc)
|
104
|
-
doc.walk do |node|
|
105
|
-
if [:link, :image].include? node.type
|
106
|
-
node.url = "/#{relative_dir}/#{node.url}" if relative? node.url
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def relative?(link)
|
112
|
-
!(link.include? ':' or link[0] == '/')
|
113
|
-
end
|
114
98
|
end
|
115
99
|
end
|
116
100
|
|
data/lib/madness/navigation.rb
CHANGED
data/lib/madness/server.rb
CHANGED
@@ -17,10 +17,14 @@ module Madness
|
|
17
17
|
get '/*' do
|
18
18
|
path = params[:splat].first
|
19
19
|
|
20
|
-
doc
|
20
|
+
doc = Document.new path
|
21
21
|
dir = doc.dir
|
22
22
|
content = doc.content
|
23
23
|
|
24
|
+
if doc.type == :readme and !path.empty? and path[-1] != '/'
|
25
|
+
redirect "#{path}/"
|
26
|
+
end
|
27
|
+
|
24
28
|
nav = Navigation.new(dir)
|
25
29
|
breadcrumbs = Breadcrumbs.new(path).links
|
26
30
|
|
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.5.
|
4
|
+
version: 0.5.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: 2018-05-
|
11
|
+
date: 2018-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sass
|