madness 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 735d6b8d05c5c4ca640fc394f94b6d13dcc728e8
4
- data.tar.gz: ee91a02a64aafb375ff2e410624c281c92096b5b
3
+ metadata.gz: bcdab65af0b9a96400c1d0f7b5dfacb89b51af1a
4
+ data.tar.gz: 988746a41c7cd24248f1c108104fa1f258854285
5
5
  SHA512:
6
- metadata.gz: bc0dc6ca64a6da54e50fb5c60790f4cc71122d8607df9cf8e44cc651a6c4b8042d914cbd00ff038163718d796b5ae9ac4ece3b40e4ff2f836982e803fa556ded
7
- data.tar.gz: 7f054e3b4c1832e91b5bdc5804f90e09745ee08db0e877321973c64002ba05152e8df5f080d40b44e6af77f1f5317072913a5dd88e9d44142af9d49bbcb38d97
6
+ metadata.gz: aeb491dbeb42c2755f985eebc83433bf7e9ad9f40daadff2a77b9a98e53a668c1df1b2895c534fbb895b835ea9f34305abf50c352f8ab2eaf16bf1567b566fa3
7
+ data.tar.gz: ce1cef2c6ca28043ea1cef131849aea3f7fb42acaa88810ec34550aaa987cfd0faee1a234aa3aaf14ddb96c70b3968ae59f3c0d48420cae97ee6ebd015d78c32
data/README.md CHANGED
@@ -8,10 +8,12 @@ Madness - Instant Markdown Server
8
8
 
9
9
  ---
10
10
 
11
+
11
12
  Screenshot
12
13
  --------------------------------------------------
13
14
 
14
- ![Screenshot]
15
+ ![screenshot]
16
+
15
17
 
16
18
 
17
19
  Install
@@ -20,6 +22,7 @@ Install
20
22
  $ gem install madness
21
23
 
22
24
 
25
+
23
26
  Design Intentions
24
27
  --------------------------------------------------
25
28
 
@@ -27,6 +30,17 @@ Madness was designed in order to provide easy browsing, viewing and
27
30
  searching for local, markdown based documentation directories.
28
31
 
29
32
 
33
+
34
+ Feature Highlights
35
+ --------------------------------------------------
36
+
37
+ - Easy to use
38
+ - Built in full text search
39
+ - Built in GraphViz diagram generator
40
+ - Configure with a configuration file or command arguments
41
+
42
+
43
+
30
44
  Usage
31
45
  --------------------------------------------------
32
46
 
@@ -39,6 +53,7 @@ For more options, run:
39
53
  $ madness --help
40
54
 
41
55
 
56
+
42
57
  Directory Conventions
43
58
  --------------------------------------------------
44
59
 
@@ -70,6 +85,8 @@ Example structure:
70
85
  └── Lists.md
71
86
  ```
72
87
 
88
+
89
+
73
90
  Configuration File
74
91
  --------------------------------------------------
75
92
 
@@ -87,9 +104,11 @@ autoh1: true
87
104
  highlighter: true
88
105
  line_numbers: true
89
106
  index: false
107
+ development: false
90
108
  ```
91
109
 
92
110
 
111
+
93
112
  Search
94
113
  --------------------------------------------------
95
114
 
@@ -104,28 +123,93 @@ You will need to run this command from time to time, as your
104
123
  documents change or new documents are added.
105
124
 
106
125
 
107
- Tips
126
+
127
+ Images and Static Files
128
+ --------------------------------------------------
129
+
130
+ Your markdown directory can have a `public` folder. Anything in it
131
+ will be served as is. For example, if you have `public/images/ok.png`
132
+ you can access it from your markdown file by typing:
133
+
134
+ ```markdown
135
+ ![alt text](/images/ok.png)
136
+ ```
137
+
138
+
139
+ Automatic H1
108
140
  --------------------------------------------------
109
141
 
110
- **Automatic H1**
111
142
  If your markdown document does not start with a level 1 heading, it
112
143
  will be automatically added based on the file name.
113
144
 
114
- **Hidden Directories**
145
+
146
+ Hidden Directories
147
+ --------------------------------------------------
148
+
115
149
  Directories that begin with an underscore will not be displayed in the
116
150
  navigation.
117
151
 
118
- **Images and Static Files**
119
- Your markdown directory can have a `public` folder. Anything in it
120
- will be served as is. For example, if you have `public/images/ok.png`
121
- you can access it from your markdown file by typing:
152
+
153
+
154
+ Automatic GraphViz Dot Diagram Generation
155
+ --------------------------------------------------
156
+
157
+ This feature requires that you have GraphViz installed
158
+ (`$ sudo apt install graphviz`).
159
+
160
+ What you place `*.dot` files in the `_dot` folder (or subfolders), they
161
+ can be accessed directly as an image in your Markdown files.
162
+
163
+ In development mode, when such files are accessed, Madness will run the
164
+ graphviz `dot` command and generate a respective image in the `public`
165
+ folder.
166
+
167
+ For example, if you have the following graphviz file:
168
+
169
+ ```
170
+ # _dot/diagrams/my_diagram.dot
171
+ digraph {
172
+ Hello -> World
173
+ }
174
+ ```
175
+
176
+ You can access it from your markdown files like this:
122
177
 
123
178
  ```markdown
124
- ![alt text](/images/ok.png)
179
+ !['alt text'](/diagrams/my_diagram.dot)
125
180
  ```
126
181
 
182
+ This will work in one of two ways:
127
183
 
128
- ---
184
+ 1. If the server is in development mode (`--development`), then it will
185
+ create a `png` image in the public folder, and redirect to it.
186
+ 2. If the server is in production mode, it will redirect to the
187
+ (previously-generated-) `png` image in the public folder, meaning
188
+ `public/diagrams/my_diagram.png`
189
+
190
+
191
+
192
+ Docker Image
193
+ --------------------------------------------------
194
+
195
+ This gem is also available as a docker image.
196
+
197
+ This command will start the server on localhost:3000, with the current
198
+ directory as the markdown documentation folder
129
199
 
130
- [Screenshot]: https://raw.githubusercontent.com/DannyBen/madness/master/screenshot.png
200
+ ```shell
201
+ $ docker run --rm -it -v $PWD:/docs -p 3000:3000 dannyben/madness
202
+ ```
203
+
204
+ For more information see:
205
+
206
+ - [Madness image on Docker Hub][dockerhub]
207
+ - [Madness Dockerfile][dockerfile]
208
+
209
+
210
+
211
+ ---
131
212
 
213
+ [screenshot]: https://raw.githubusercontent.com/DannyBen/madness/master/screenshot.png
214
+ [dockerhub]: https://hub.docker.com/r/dannyben/madness/
215
+ [dockerfile]: https://github.com/DannyBen/docker-madness
@@ -52,12 +52,14 @@ module Madness
52
52
  config.highlighter = false if args['--no-syntax']
53
53
  config.line_numbers = false if args['--no-line-numbers']
54
54
  config.index = true if args['--index']
55
+ config.development = true if args['--development']
55
56
  end
56
57
 
57
58
  # Say hello to everybody when the server starts, showing the known
58
59
  # config.
59
60
  def show_status
60
61
  say_status :start, 'the madness'
62
+ say_status :env, config.development ? 'development' : 'production', :txtblu
61
63
  say_status :listen, "#{config.bind}:#{config.port}", :txtblu
62
64
  say_status :path, File.realpath(config.path), :txtblu
63
65
  say_status :use, config.filename if config.file_exist?
@@ -15,6 +15,11 @@ Options:
15
15
  -b, --bind <address>
16
16
  Set server listen address.
17
17
 
18
+ --development
19
+ Start the server in development mode. In this mode, dot diagrams are
20
+ regenerated on each request, whereas in production mode (default), the
21
+ diagrams are expected to already be generated in the public folder.
22
+
18
23
  --no-auto-h1
19
24
  By default, if a markdown document does not start with an H1 caption,
20
25
  it will be added automatically based on the file name. To disable this
@@ -36,5 +41,6 @@ Examples:
36
41
  madness
37
42
  madness docs
38
43
  madness docs --no-auto-h1 -p 4567
44
+ madness docs --production
39
45
  madness --index --and-quit
40
46
 
@@ -14,6 +14,23 @@ module Madness
14
14
  }
15
15
  end
16
16
 
17
+ get '/*.dot' do
18
+ splat = params[:splat].first
19
+ dot = "_dot/#{splat}.dot"
20
+ png = "public/#{splat}.png"
21
+ out_dir = File.dirname png
22
+
23
+ Dir.chdir docroot do
24
+ if config.development and File.exist? dot
25
+ FileUtils.mkdir_p out_dir unless Dir.exist? out_dir
26
+ system %Q[dot "#{dot}" -Tpng -o "#{png}"]
27
+ redirect to "#{splat}.png"
28
+ else
29
+ redirect to "#{splat}.png"
30
+ end
31
+ end
32
+ end
33
+
17
34
  get '/*' do
18
35
  path = params[:splat].first
19
36
 
@@ -10,7 +10,7 @@ module Madness
10
10
  include Singleton
11
11
 
12
12
  attr_accessor :port, :bind, :path, :autoh1,
13
- :highlighter, :line_numbers, :index
13
+ :highlighter, :line_numbers, :index, :development
14
14
 
15
15
  def initialize
16
16
  reset
@@ -42,6 +42,7 @@ module Madness
42
42
  self.highlighter = true
43
43
  self.line_numbers = true
44
44
  self.index = false
45
+ self.development = false
45
46
  end
46
47
 
47
48
  def load_from_file
@@ -1,3 +1,3 @@
1
1
  module Madness
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
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.2.1
4
+ version: 0.3.0
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: 2017-03-15 00:00:00.000000000 Z
11
+ date: 2017-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '0.8'
159
+ version: '0.9'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: '0.8'
166
+ version: '0.9'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: runfile-tasks
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -198,70 +198,70 @@ dependencies:
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: '3.4'
201
+ version: '3.5'
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: '3.4'
208
+ version: '3.5'
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: rdoc
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
213
  - - "~>"
214
214
  - !ruby/object:Gem::Version
215
- version: '4.2'
215
+ version: '5.1'
216
216
  type: :development
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
- version: '4.2'
222
+ version: '5.1'
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: simplecov
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
227
  - - "~>"
228
228
  - !ruby/object:Gem::Version
229
- version: '0.11'
229
+ version: '0.14'
230
230
  type: :development
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - "~>"
235
235
  - !ruby/object:Gem::Version
236
- version: '0.11'
236
+ version: '0.14'
237
237
  - !ruby/object:Gem::Dependency
238
238
  name: yard
239
239
  requirement: !ruby/object:Gem::Requirement
240
240
  requirements:
241
241
  - - "~>"
242
242
  - !ruby/object:Gem::Version
243
- version: '0.8'
243
+ version: '0.9'
244
244
  type: :development
245
245
  prerelease: false
246
246
  version_requirements: !ruby/object:Gem::Requirement
247
247
  requirements:
248
248
  - - "~>"
249
249
  - !ruby/object:Gem::Version
250
- version: '0.8'
250
+ version: '0.9'
251
251
  - !ruby/object:Gem::Dependency
252
252
  name: rspec-html-matchers
253
253
  requirement: !ruby/object:Gem::Requirement
254
254
  requirements:
255
255
  - - "~>"
256
256
  - !ruby/object:Gem::Version
257
- version: '0.7'
257
+ version: '0.9'
258
258
  type: :development
259
259
  prerelease: false
260
260
  version_requirements: !ruby/object:Gem::Requirement
261
261
  requirements:
262
262
  - - "~>"
263
263
  - !ruby/object:Gem::Version
264
- version: '0.7'
264
+ version: '0.9'
265
265
  description: Start a markdown server in any directory
266
266
  email: db@dannyben.com
267
267
  executables:
@@ -328,7 +328,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
328
328
  version: '0'
329
329
  requirements: []
330
330
  rubyforge_project:
331
- rubygems_version: 2.6.6
331
+ rubygems_version: 2.5.1
332
332
  signing_key:
333
333
  specification_version: 4
334
334
  summary: Instant Markdown Server