madness 0.8.0 → 0.8.5

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
  SHA256:
3
- metadata.gz: 17e42d618e170958cf8b556c2271ddb7efeeae6e15144c5e5f4252cdb4708808
4
- data.tar.gz: b4fc80231d2cdbc2834dab2a428a501371abbb3b7426984f20833b411314df6e
3
+ metadata.gz: 2ffaa41eacda31f502ff69d9c68189533cff31f293907089288b496e82038304
4
+ data.tar.gz: 44053382dd7dda362a34dd57e9663b7e9d46d510ca5cdecef4f1625468b8c376
5
5
  SHA512:
6
- metadata.gz: 547e6b50b089cac0e4c01bc4938ea14a0cee3985c7dbdcf6bf01a7aa375a4f18f31d720c368918e595c4d03a2ef5f03b6ece929d260c90b523f90d2886b54af5
7
- data.tar.gz: 5c72050811de28e4bf8174b1897f847a770f6eeb12844b741c81ca810ba1c345b353e7aac00194f7ca0c01493d5ba664539ae00bdbedb552b81bffec4c07d4f9
6
+ metadata.gz: 33dc087ef4dec3a0f79019846bd4aadf6b6eab4dd81ed9049d4d619c89bed23235de14879a99296e264dbb14aa87102b841f7a9a1d2f600ab7828d82286a817c
7
+ data.tar.gz: 74c35835a66aa14e44e9885c759445c64b82b8801bc8663c1d088d3d7fa123044d66331068200c649a943545ee8377a75ac038329d6feae4be5f5d92a6f1f1f7
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://travis-ci.com/DannyBen/madness.svg?branch=master)](https://travis-ci.com/DannyBen/madness)
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)
@@ -34,29 +29,31 @@ Table of Contents
34
29
  * [Table of Contents Generation](#table-of-contents-generation)
35
30
  * [Hidden Directories](#hidden-directories)
36
31
  * [Controlling Sort Order](#controlling-sort-order)
32
+ * [Basic Authntication](#basic-authentication)
37
33
  * [Customizing Theme](#customizing-theme)
38
34
  * [Forcing HTTPS Connection](#forcing-https-connection)
39
35
  * [Docker Image](#docker-image)
40
36
 
37
+ ## Install
41
38
 
39
+ **Using Ruby:**
42
40
 
43
- Install
44
- --------------------------------------------------
45
-
46
- $ gem install madness
41
+ ```shell
42
+ $ gem install madness
43
+ ```
47
44
 
45
+ **Using Docker:**
48
46
 
47
+ ```shell
48
+ $ alias madness='docker run --rm -it -v $PWD:/docs -p 3000:3000 dannyben/madness'
49
+ ```
49
50
 
50
- Design Intentions
51
- --------------------------------------------------
51
+ ## Design Intentions
52
52
 
53
53
  Madness was designed in order to provide easy browsing, viewing and
54
54
  searching for local, markdown based documentation directories.
55
55
 
56
-
57
-
58
- Feature Highlights
59
- --------------------------------------------------
56
+ ## Feature Highlights
60
57
 
61
58
  - Easy to use.
62
59
  - Built-in full text search.
@@ -64,30 +61,25 @@ Feature Highlights
64
61
  - Configure with a configuration file or command arguments.
65
62
  - Fully customizable theme.
66
63
  - Automatic generation of navigation sidebar.
67
- - Automatic generation of Table of Contents.
64
+ - Automatic generation of Table of Contents (site-wide and inline).
68
65
 
69
-
70
-
71
- Usage
72
- --------------------------------------------------
66
+ ## Usage
73
67
 
74
68
  Go to any directory that contains markdown files and run:
75
69
 
76
- $ madness
70
+ ```shell
71
+ $ madness
72
+ ```
77
73
 
78
74
  And open <http://localhost:3000> in your browser.
79
75
 
80
76
  For more options, run:
81
77
 
82
- $ madness --help
83
-
84
- If you do not have Ruby installed, you can also
85
- [run madness with docker](#docker-image).
86
-
87
-
78
+ ```shell
79
+ $ madness --help
80
+ ```
88
81
 
89
- Directory Conventions
90
- --------------------------------------------------
82
+ ## Directory Conventions
91
83
 
92
84
  Madness expects to be executed in a documentation directory.
93
85
 
@@ -115,10 +107,7 @@ Example structure:
115
107
  └── File.md
116
108
  ```
117
109
 
118
-
119
-
120
- Configuration File
121
- --------------------------------------------------
110
+ ## Configuration File
122
111
 
123
112
  All the command line arguments can also be configured through a
124
113
  configuration file. Create a file named `.madness.yml` in your
@@ -136,7 +125,8 @@ highlighter: true
136
125
  line_numbers: true
137
126
  copy_code: true
138
127
  index: false
139
- toc: Table of Contents
128
+ search_limit: 100
129
+ dtoc: Table of Contents
140
130
  theme: _theme
141
131
  open: false
142
132
  ```
@@ -147,10 +137,7 @@ For convenience, you can get a template config file by running:
147
137
  $ madness create config
148
138
  ```
149
139
 
150
-
151
-
152
- Search
153
- --------------------------------------------------
140
+ ## Search
154
141
 
155
142
  Madness comes with a full text search page. To activate it, you need to
156
143
  generate a search index by running `madness --index` or
@@ -162,10 +149,7 @@ to your documentation server.
162
149
  You will need to run this command from time to time, as your
163
150
  documents change or new documents are added.
164
151
 
165
-
166
-
167
- Images and Static Files
168
- --------------------------------------------------
152
+ ## Images and Static Files
169
153
 
170
154
  You can put images and other asset files anywhere in your documentation
171
155
  folder.
@@ -184,40 +168,37 @@ this markdown:
184
168
  If you wish to link to images or pages in a different folder, simply specify
185
169
  the path relative to the homepage:
186
170
 
187
- ```
171
+ ```markdown
188
172
  ![alt text](/images/nice-picture.png)
189
173
  ```
190
174
 
191
-
192
-
193
- Automatic H1
194
- --------------------------------------------------
175
+ ## Automatic H1
195
176
 
196
177
  If your markdown document does not start with a level 1 heading, it
197
178
  will be automatically added based on the file name.
198
179
 
180
+ ## Table of Contents Generation
199
181
 
182
+ ### Site-wide
200
183
 
201
- Table of Contents Generation
202
- --------------------------------------------------
203
-
204
- You can use the `madness --toc` command to generate a "Table of Contents"
205
- markdown file.
184
+ To generate a Table of Contents file for the entire site (for the directories
185
+ and files), run `madness --toc FILENAME`
206
186
 
187
+ ### Inline
207
188
 
189
+ If you have long markdown documents, and you wish to add an inline Table of
190
+ Contents for them, simply add an HTML comment `<!-- TOC -->` where you want
191
+ the Table of Contents to be generated. The inserted list will only consider
192
+ H2 and H3 headings.
208
193
 
209
- Hidden Directories
210
- --------------------------------------------------
194
+ ## Hidden Directories
211
195
 
212
196
  Directories that are made only of lowercase letters, underscoes, dash and/or
213
197
  numbers (`/^[a-z_\-0-9]+$/`) will not be displayed in the navigation. In
214
198
  other words, directories must have at least one uppercase letter or a space
215
199
  to be recognized as a documentation directory.
216
200
 
217
-
218
-
219
- Controlling Sort Order
220
- --------------------------------------------------
201
+ ## Controlling Sort Order
221
202
 
222
203
  To control the sort order of the automatically generated navigation elements,
223
204
  simply perfix your files and directories with digits followed by a dot and a
@@ -230,10 +211,17 @@ will be omitted when they are displayed.
230
211
  └── 2. Another file or folder
231
212
  ```
232
213
 
214
+ ## Basic Authentication
215
+
216
+ To add basic authentication, use the `--auth user:password` command line argument or the equivalent `auth` configuration option.
233
217
 
218
+ If you wish to avoid storing the basic authentication credentials in the configuration file, you may use ERB tags to load the credentials from environment variables:
219
+
220
+ ```yaml
221
+ auth: <%= ENV['BASIC_AUTH'] %>
222
+ ```
234
223
 
235
- Customizing Theme
236
- --------------------------------------------------
224
+ ## Customizing Theme
237
225
 
238
226
  There are two ways to change how Madness looks.
239
227
 
@@ -272,20 +260,16 @@ If you are looking to implement a smaller CSS change, follow these steps:
272
260
  Note that this functionality is not guaranteed to stay as is in future
273
261
  versions of madness.
274
262
 
275
-
276
-
277
- Forcing HTTPS Connection
278
- --------------------------------------------------
263
+ ## Forcing HTTPS Connection
279
264
 
280
265
  To have Madness redirect HTTP traffic to HTTPS, set this environment
281
266
  variable:
282
267
 
283
- $ export MADNESS_FORCE_SSL=1
284
-
285
-
268
+ ```shell
269
+ $ export MADNESS_FORCE_SSL=1
270
+ ```
286
271
 
287
- Docker Image
288
- --------------------------------------------------
272
+ ## Docker Image
289
273
 
290
274
  Madness server is also available as a docker image.
291
275
 
@@ -296,6 +280,13 @@ directory as the markdown documentation folder
296
280
  $ docker run --rm -it -v $PWD:/docs -p 3000:3000 dannyben/madness
297
281
  ```
298
282
 
283
+ You may create an alias for convenience:
284
+
285
+ ```shell
286
+ $ alias madness='docker run --rm -it -v $PWD:/docs -p 3000:3000 dannyben/madness'
287
+ $ medness --help
288
+ ```
289
+
299
290
  For more information about the docker image, see:
300
291
 
301
292
  - [Madness image on Docker Hub][dockerhub]
@@ -245,8 +245,9 @@ nav {
245
245
  nav .icon-bar {
246
246
  border-bottom: 1px dotted #ddd; }
247
247
  nav a.document, nav span.document, nav .caption {
248
+ border-bottom: 1px dotted #ddd;
248
249
  display: block;
249
- padding: 3px 20px 3px 30px; }
250
+ padding: 5px 20px 5px 30px; }
250
251
  nav a.icon {
251
252
  display: inline-block;
252
253
  font-size: 1.5em;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "mappings": "AAAA,IAAK;EACH,oBAAoB,EAAE,IAAI;EAC1B,wBAAwB,EAAE,IAAI;EAC9B,KAAK,EAAE,IAAI;EAEX,WAAW,EAAE,mEAAmE;EAChF,SAAS,EAAE,IAAI;EACf,WAAW,EAAE,GAAG;EAChB,SAAS,EAAE,UAAU;;AAGvB,eAAgB;EACd,WAAW,EAAE,MAAM;;AAGrB,sBAAuB;EACrB,UAAU,EAAE,GAAG;EACf,aAAa,EAAE,IAAI;EACnB,WAAW,EAAE,IAAI;EACjB,WAAW,EAAE,GAAG;;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KAAK;EAItB,qBAAkB;IAChB,SAAS,EAAE,KAAK;IAChB,MAAM,EAAE,MAAM",
4
4
  "sources": ["../../styles/_typography.scss","../../styles/_table.scss","../../styles/_anchor.scss","../../styles/_list.scss","../../styles/_code.scss","../../styles/_coderay.scss","../../styles/_image.scss","../../styles/_line.scss","../../styles/_keyboard.scss","../../styles/_search.scss","../../styles/_breadcrumbs.scss","../../styles/_nav.scss","../../styles/_mixins.scss","../../styles/_icons.scss","../../styles/_autocomplete.scss","../../styles/_general.scss","../../styles/main.scss"],
5
5
  "names": [],
6
6
  "file": "main.css"
@@ -20,13 +20,13 @@ nav {
20
20
  }
21
21
 
22
22
  a.document, span.document, .caption {
23
- // border-bottom: 1px dotted #ddd;
23
+ border-bottom: 1px dotted #ddd;
24
24
  // &:hover {
25
25
  // background: #e4e4e4;
26
26
  // }
27
27
 
28
28
  display: block;
29
- padding: 3px 20px 3px 30px;
29
+ padding: 5px 20px 5px 30px;
30
30
  }
31
31
 
32
32
  a.icon {
@@ -1,4 +1,7 @@
1
- require 'byebug' if ENV['BYEBUG']
1
+ if ENV['BYEBUG']
2
+ require 'byebug'
3
+ require 'lp'
4
+ end
2
5
 
3
6
  require 'requires'
4
7
 
@@ -61,10 +61,14 @@ 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 = 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']
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
+ config.auth = args['--auth'] if args['--auth']
70
+ config.auth_realm = args['--auth-realm'] if args['--auth-realm']
71
+
68
72
  config.auto_h1 = false if args['--no-auto-h1']
69
73
  config.auto_nav = false if args['--no-auto-nav']
70
74
  config.sidebar = false if args['--no-sidebar']
@@ -73,6 +77,7 @@ module Madness
73
77
  config.copy_code = false if args['--no-copy-code']
74
78
  config.index = true if args['--index']
75
79
  config.open = true if args['--open']
80
+
76
81
  config.theme = File.expand_path(args['--theme'], config.path) if args['--theme']
77
82
  end
78
83
 
@@ -16,17 +16,17 @@ Subcommands:
16
16
 
17
17
  Parameters:
18
18
  PATH:
19
- Optional path to the markdown directory.
20
- (Config option: path)
19
+ Path to the markdown directory.
20
+ (Config option: path, default: .)
21
21
 
22
22
  Options:
23
23
  -p, --port NUMBER
24
24
  Set server port number.
25
- (Config option: port)
25
+ (Config option: port, default: 3000)
26
26
 
27
27
  -b, --bind ADDRESS
28
28
  Set server listen address.
29
- (Config option: bind)
29
+ (Config option: bind, default: 0.0.0.0)
30
30
 
31
31
  --no-auto-h1
32
32
  By default, if a markdown document does not start with an H1 caption,
@@ -68,6 +68,18 @@ 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
+
75
+ --auth USER:PASS
76
+ Enable basic authentication.
77
+ (Config option: auth)
78
+
79
+ --auth-realm REALM
80
+ The basic authentication realm.
81
+ (Config option: auth_realm, default: Madness)
82
+
71
83
  --open
72
84
  Open the browser pointing at the madness webserver.
73
85
  (Config option: open)
@@ -83,6 +95,7 @@ Examples:
83
95
  madness --no-sidebar --no-auto-nav
84
96
  madness --index --and-quit
85
97
  madness --toc "Table of Contents.md" --index --and-quit
98
+ madness --auth user:secret --port 4000
86
99
  madness --theme _mytheme
87
100
  madness create config
88
101
  madness create theme
@@ -8,36 +8,13 @@ module Madness
8
8
  include ServerHelper
9
9
  using StringRefinements
10
10
 
11
- attr_reader :base, :path
11
+ attr_reader :base, :path, :type, :file, :dir, :title
12
12
 
13
13
  def initialize(path)
14
14
  @path = path
15
15
  @base = path.empty? ? docroot : "#{docroot}/#{path}"
16
16
  @base.chomp! '/'
17
- end
18
-
19
- # Return :readme, :file or :empty
20
- def type
21
- set_base_attributes unless @type
22
- @type
23
- end
24
-
25
- # Return the path to the actual markdown file
26
- def file
27
- set_base_attributes unless @file
28
- @file
29
- end
30
-
31
- # Return the path to the document directory
32
- def dir
33
- set_base_attributes unless @dir
34
- @dir
35
- end
36
-
37
- # Return the path to the document directory
38
- def title
39
- set_base_attributes unless @title
40
- @title
17
+ set_base_attributes
41
18
  end
42
19
 
43
20
  # Return the HTML for that document
@@ -92,22 +69,25 @@ module Madness
92
69
  @markdown ||= File.read file
93
70
  end
94
71
 
72
+ def doc
73
+ @doc ||= CommonMarker.render_doc markdown, :DEFAULT, [:table]
74
+ end
75
+
95
76
  # Convert markdown to HTML, with some additional processing:
96
77
  # 1. Add anchors to headers
97
78
  # 2. Syntax highilghting
98
79
  # 3. Prepend H1 if needed
99
80
  def markdown_to_html
100
- doc = CommonMarker.render_doc markdown, :DEFAULT, [:table]
101
-
102
- add_anchor_ids doc
81
+ replace_toc_marker
82
+ prepend_h1 if config.auto_h1
83
+ add_anchor_ids
103
84
  html = doc.to_html :UNSAFE
104
85
  html = syntax_highlight(html) if config.highlighter
105
- html = prepend_h1(html) if config.auto_h1
106
86
  html
107
87
  end
108
88
 
109
89
  # Add anchors with IDs before all headers
110
- def add_anchor_ids(doc)
90
+ def add_anchor_ids
111
91
  doc.walk do |node|
112
92
  if node.type == :header
113
93
  anchor = CommonMarker::Node.new(:inline_html)
@@ -121,12 +101,39 @@ module Madness
121
101
  end
122
102
  end
123
103
 
124
- # If the document does not start with an H1 tag, add it.
125
- def prepend_h1(html)
126
- unless html[0..3] == "<h1>"
127
- html = "<h1>#{title}</h1>\n#{html}"
104
+ # Replace <!-- TOC --> with a Table of Contents for the page
105
+ def replace_toc_marker
106
+ toc_marker = doc.find do |node|
107
+ node.type == :html and node.string_content.include? "<!-- TOC -->"
128
108
  end
129
- html
109
+
110
+ return unless toc_marker
111
+
112
+ toc_marker.insert_after document_toc
113
+ toc_marker.insert_after CommonMarker.render_doc("## Table of Contents").first_child
114
+ end
115
+
116
+ # Returns a UL object containing the document table of contents
117
+ def document_toc
118
+ toc = []
119
+ doc.walk do |node|
120
+ next unless node.type == :header
121
+ level = node.header_level
122
+ next unless level.between? 2, 3
123
+ text = node.first_child.string_content
124
+ spacer = " " * (level - 1)
125
+ toc << "#{spacer}- [#{text}](##{text.to_slug})"
126
+ end
127
+
128
+ toc = toc.join "\n"
129
+ CommonMarker.render_doc(toc).first_child
130
+ end
131
+
132
+ # If the document does not start with an H1 tag, add it.
133
+ def prepend_h1
134
+ return if doc.first_child.type == :header and doc.first_child.header_level == 1
135
+ h1 = CommonMarker.render_doc("# #{title}").first_child
136
+ doc.first_child.insert_before h1
130
137
  end
131
138
 
132
139
  # Apply syntax highlighting with CodeRay. This will parse for any
@@ -1,3 +1,5 @@
1
+ require 'addressable'
2
+
1
3
  module Madness
2
4
  module StringRefinements
3
5
  refine String do
@@ -6,7 +8,7 @@ module Madness
6
8
  end
7
9
 
8
10
  def to_href
9
- URI.escape self
11
+ Addressable::URI.escape self
10
12
  end
11
13
 
12
14
  def to_slug
@@ -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: 20) do |doc_id, score|
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
@@ -1,9 +1,8 @@
1
- require 'rack/contrib/try_static'
1
+ # require 'sinatra/reloader'
2
2
  require 'rack/ssl'
3
3
  require 'sass'
4
4
  require 'sass/plugin/rack'
5
5
  require 'sinatra/base'
6
- require 'sinatra/reloader'
7
6
  require 'slim'
8
7
 
9
8
  module Madness
@@ -19,11 +18,16 @@ module Madness
19
18
  use Rack::SSL if ENV['MADNESS_FORCE_SSL']
20
19
  set :root, File.expand_path('../../', __dir__)
21
20
  set :server, :puma
21
+ set :environment, ENV['MADNESS_ENV'] || :production
22
22
 
23
- configure :development do
24
- register Sinatra::Reloader
25
- also_reload "#{__dir__}/*.rb"
26
- end
23
+ # TODO: Uncomment when the upstream issue is resolved
24
+ # At this time, we cannot use reloader, since it prints deprecation
25
+ # warnings in Ruby 2.7
26
+ # ref: https://github.com/sinatra/sinatra/issues/1590
27
+ # configure :development do
28
+ # register Sinatra::Reloader
29
+ # also_reload "#{__dir__}/*.rb"
30
+ # end
27
31
 
28
32
  # Since we cannot use any config values in the main body of the class,
29
33
  # since they will be updated later, we need to set anything that relys
@@ -31,10 +35,11 @@ module Madness
31
35
  # The CommandLine class and the test suite should both call
32
36
  # `Server.prepare` before calling Server.run!
33
37
  def self.prepare
34
- use Madness::Static, root: "#{config.path}/", :urls => %w[/]
38
+ use Madness::Static, root: "#{config.path}/", urls: %w[/], cascade: true
35
39
  set :bind, config.bind
36
40
  set :port, config.port
37
41
 
42
+ set_basic_auth if config.auth
38
43
  set_tempalate_locations
39
44
  end
40
45
 
@@ -47,6 +52,12 @@ module Madness
47
52
  Sass::Plugin.options[:css_location] = theme.css_target_path
48
53
  end
49
54
 
55
+ def self.set_basic_auth
56
+ use Rack::Auth::Basic, config.auth_realm do |username, password|
57
+ config.auth.split(':') == [username, password]
58
+ end
59
+ end
60
+
50
61
  def self.config
51
62
  Settings.instance
52
63
  end
@@ -1,4 +1,5 @@
1
1
  require 'singleton'
2
+ require 'extended_yaml'
2
3
 
3
4
  module Madness
4
5
 
@@ -49,12 +50,15 @@ module Madness
49
50
  auto_h1: true,
50
51
  highlighter: true,
51
52
  line_numbers: true,
53
+ search_limit: 100,
52
54
  copy_code: true,
53
55
  index: false,
54
56
  theme: nil,
55
57
  open: false,
56
58
  auto_nav: true,
57
- sidebar: true
59
+ sidebar: true,
60
+ auth: false,
61
+ auth_realm: 'Madness'
58
62
  }
59
63
  end
60
64
 
@@ -63,7 +67,7 @@ module Madness
63
67
  end
64
68
 
65
69
  def file_data
66
- file_exist? ? YAML.load_file(filename).symbolize_keys : {}
70
+ file_exist? ? ExtendedYAML.load(filename).symbolize_keys : {}
67
71
  end
68
72
 
69
73
  end
@@ -1,11 +1,11 @@
1
1
  module Madness
2
2
 
3
3
  # The Madness::Static middleware delegates requests to
4
- # Rack::TryStatic middleware unless the request URI ends with .md
4
+ # Rack::Static middleware unless the request URI ends with .md
5
5
  class Static
6
6
  def initialize(app, options)
7
7
  @app = app
8
- @static = ::Rack::TryStatic.new(app, options)
8
+ @static = Rack::Static.new app, options
9
9
  end
10
10
 
11
11
  def call(env)
@@ -5,7 +5,7 @@ module Madness
5
5
 
6
6
  attr_reader :dir
7
7
 
8
- def initialize(dir=nil)
8
+ def initialize(dir = nil)
9
9
  @dir = dir || docroot
10
10
  end
11
11
 
@@ -20,7 +20,7 @@ module Madness
20
20
 
21
21
  private
22
22
 
23
- def toc!(path=dir, indent=0)
23
+ def toc!(path = dir, indent = 0)
24
24
  list = Directory.new(path).list
25
25
 
26
26
  result = []
@@ -1,9 +1,9 @@
1
1
  # Madness configuration file
2
2
  # Uncomment any of the options below
3
3
 
4
- # path: '.'
5
- # port: '3000'
6
- # bind: '0.0.0.0'
4
+ # path: .
5
+ # port: 3000
6
+ # bind: 0.0.0.0
7
7
  # sidebar: true
8
8
  # auto_h1: true
9
9
  # auto_nav: true
@@ -12,5 +12,8 @@
12
12
  # copy_code: true
13
13
  # index: false
14
14
  # toc: Table of Contents
15
+ # search_limit: 100
15
16
  # theme: _theme
16
17
  # open: false
18
+ # auth: false
19
+ # auth_zone: 'Madness'
@@ -1,3 +1,3 @@
1
1
  module Madness
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.5"
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.8.0
4
+ version: 0.8.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: 2019-12-29 00:00:00.000000000 Z
11
+ date: 2020-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coderay
@@ -128,28 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '4.0'
131
+ version: '5.1'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '4.0'
139
- - !ruby/object:Gem::Dependency
140
- name: rack-contrib
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '2.1'
146
- type: :runtime
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '2.1'
138
+ version: '5.1'
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: rack-ssl
155
141
  requirement: !ruby/object:Gem::Requirement
@@ -213,39 +199,47 @@ dependencies:
213
199
  - !ruby/object:Gem::Version
214
200
  version: 2.0.5
215
201
  - !ruby/object:Gem::Dependency
216
- name: sinatra-contrib
202
+ name: slim
217
203
  requirement: !ruby/object:Gem::Requirement
218
204
  requirements:
219
205
  - - "~>"
220
206
  - !ruby/object:Gem::Version
221
- version: '2.0'
222
- - - ">="
223
- - !ruby/object:Gem::Version
224
- version: 2.0.5
207
+ version: '4.0'
225
208
  type: :runtime
226
209
  prerelease: false
227
210
  version_requirements: !ruby/object:Gem::Requirement
228
211
  requirements:
229
212
  - - "~>"
230
213
  - !ruby/object:Gem::Version
231
- version: '2.0'
232
- - - ">="
214
+ version: '4.0'
215
+ - !ruby/object:Gem::Dependency
216
+ name: extended_yaml
217
+ requirement: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - "~>"
233
220
  - !ruby/object:Gem::Version
234
- version: 2.0.5
221
+ version: '0.2'
222
+ type: :runtime
223
+ prerelease: false
224
+ version_requirements: !ruby/object:Gem::Requirement
225
+ requirements:
226
+ - - "~>"
227
+ - !ruby/object:Gem::Version
228
+ version: '0.2'
235
229
  - !ruby/object:Gem::Dependency
236
- name: slim
230
+ name: addressable
237
231
  requirement: !ruby/object:Gem::Requirement
238
232
  requirements:
239
233
  - - "~>"
240
234
  - !ruby/object:Gem::Version
241
- version: '4.0'
235
+ version: '2.7'
242
236
  type: :runtime
243
237
  prerelease: false
244
238
  version_requirements: !ruby/object:Gem::Requirement
245
239
  requirements:
246
240
  - - "~>"
247
241
  - !ruby/object:Gem::Version
248
- version: '4.0'
242
+ version: '2.7'
249
243
  description: Start a markdown server in any directory
250
244
  email: db@dannyben.com
251
245
  executables:
@@ -333,7 +327,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
333
327
  - !ruby/object:Gem::Version
334
328
  version: '0'
335
329
  requirements: []
336
- rubygems_version: 3.0.3
330
+ rubygems_version: 3.1.4
337
331
  signing_key:
338
332
  specification_version: 4
339
333
  summary: Instant Markdown Server