madness 0.9.7 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/madness +1 -1
- data/lib/madness/breadcrumbs.rb +9 -8
- data/lib/madness/browser.rb +3 -2
- data/lib/madness/command_line.rb +7 -8
- data/lib/madness/directory.rb +5 -6
- data/lib/madness/document.rb +12 -10
- data/lib/madness/item.rb +2 -2
- data/lib/madness/navigation.rb +2 -2
- data/lib/madness/refinements/hash_refinements.rb +1 -1
- data/lib/madness/refinements/string_refinements.rb +2 -2
- data/lib/madness/search.rb +8 -6
- data/lib/madness/server.rb +12 -13
- data/lib/madness/server_base.rb +1 -3
- data/lib/madness/server_helper.rb +6 -7
- data/lib/madness/settings.rb +23 -21
- data/lib/madness/static.rb +2 -3
- data/lib/madness/table_of_contents.rb +6 -5
- data/lib/madness/theme.rb +1 -2
- data/lib/madness/version.rb +1 -1
- data/lib/madness.rb +3 -2
- metadata +41 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e5aec00c5e1b2645ddd8df0791c72f1f9b1dac802bf9f8ebbec7ee82adf9af3
|
4
|
+
data.tar.gz: b4813953be6a17acc191e98b000470351849703d33def5c6b1783d8670b3bebf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ea3389d117c99fae165537c8bd6f9b6702faded54d20ca3100bb543b5f137d3643573baa1186a62cc65acc772513824a1de88a73610eef3c6817675f7cff462
|
7
|
+
data.tar.gz: acf4925d81080002ff39c295ec0dcb78dcdd8ee8e3b306893be27ca1be4858481552bdb09756b89b6e76c6fca91bcf5512a9c9c75d59d25662400d3ead725587
|
data/bin/madness
CHANGED
data/lib/madness/breadcrumbs.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
module Madness
|
2
|
-
|
3
2
|
# Handle breadcumbs generation by converting a path to an array
|
4
3
|
# of links
|
5
4
|
class Breadcrumbs
|
6
5
|
using StringRefinements
|
7
|
-
|
6
|
+
|
8
7
|
attr_reader :path
|
9
8
|
|
10
9
|
def initialize(path)
|
@@ -12,13 +11,13 @@ module Madness
|
|
12
11
|
end
|
13
12
|
|
14
13
|
def links
|
15
|
-
path ==
|
14
|
+
path == '' ? [] : breadcrumbs
|
16
15
|
end
|
17
16
|
|
18
17
|
private
|
19
18
|
|
20
|
-
def
|
21
|
-
home = OpenStruct.new({ label:
|
19
|
+
def breadcrumbs
|
20
|
+
home = OpenStruct.new({ label: 'Home', href: '/' })
|
22
21
|
result = breadcrumbs_maker(path).reverse.unshift home
|
23
22
|
result.last.last = true
|
24
23
|
result
|
@@ -26,9 +25,11 @@ module Madness
|
|
26
25
|
|
27
26
|
def breadcrumbs_maker(partial_path)
|
28
27
|
parent, basename = File.split partial_path
|
29
|
-
item = OpenStruct.new(
|
30
|
-
|
31
|
-
|
28
|
+
item = OpenStruct.new(
|
29
|
+
{
|
30
|
+
label: basename.to_label,
|
31
|
+
href: "/#{partial_path}",
|
32
|
+
}
|
32
33
|
)
|
33
34
|
result = [item]
|
34
35
|
result += breadcrumbs_maker parent unless parent == '.'
|
data/lib/madness/browser.rb
CHANGED
@@ -7,7 +7,8 @@ module Madness
|
|
7
7
|
attr_reader :host, :port
|
8
8
|
|
9
9
|
def initialize(host, port)
|
10
|
-
@host
|
10
|
+
@host = host
|
11
|
+
@port = port
|
11
12
|
end
|
12
13
|
|
13
14
|
# Returns a URL based on host, port and MADNESS_FORCE_SSL.
|
@@ -51,7 +52,7 @@ module Madness
|
|
51
52
|
|
52
53
|
# Runs the appropriate command (based on OS) to open a browser.
|
53
54
|
def open!
|
54
|
-
system
|
55
|
+
system(*open_command, err: File::NULL, in: File::NULL, out: File::NULL)
|
55
56
|
end
|
56
57
|
|
57
58
|
# Returns the appropriate command (based on OS) to open a browser.
|
data/lib/madness/command_line.rb
CHANGED
@@ -4,16 +4,15 @@ require 'colsole'
|
|
4
4
|
require 'docopt'
|
5
5
|
|
6
6
|
module Madness
|
7
|
-
|
8
7
|
# Handle command line execution. Used by bin/madness.
|
9
8
|
class CommandLine
|
10
9
|
include Singleton
|
11
10
|
include Colsole
|
12
11
|
|
13
12
|
# Process ARGV by putting it through docopt
|
14
|
-
def execute(argv=[])
|
13
|
+
def execute(argv = [])
|
15
14
|
doc = File.read File.expand_path('docopt.txt', __dir__)
|
16
|
-
|
15
|
+
|
17
16
|
begin
|
18
17
|
args = Docopt.docopt(doc, argv: argv, version: VERSION)
|
19
18
|
handle args
|
@@ -49,7 +48,7 @@ module Madness
|
|
49
48
|
# and static files folder.
|
50
49
|
def launch_server
|
51
50
|
unless File.directory? config.path
|
52
|
-
|
51
|
+
$stderr.puts "Invalid path (#{config.path})"
|
53
52
|
return
|
54
53
|
end
|
55
54
|
|
@@ -61,7 +60,7 @@ module Madness
|
|
61
60
|
# Get the arguments as provided by docopt, and set them to our own
|
62
61
|
# config object.
|
63
62
|
def set_config(args)
|
64
|
-
config.path = args['PATH']
|
63
|
+
config.path = args['PATH'] if args['PATH']
|
65
64
|
config.port = args['--port'].to_i if args['--port']
|
66
65
|
config.bind = args['--bind'] if args['--bind']
|
67
66
|
config.toc = args['--toc'] if args['--toc']
|
@@ -76,7 +75,7 @@ module Madness
|
|
76
75
|
config.copy_code = false if args['--no-copy-code']
|
77
76
|
config.shortlinks = true if args['--shortlinks']
|
78
77
|
config.open = true if args['--open']
|
79
|
-
|
78
|
+
|
80
79
|
config.theme = File.expand_path(args['--theme'], config.path) if args['--theme']
|
81
80
|
end
|
82
81
|
|
@@ -105,7 +104,7 @@ module Madness
|
|
105
104
|
end
|
106
105
|
end
|
107
106
|
|
108
|
-
# Say hello to everybody when the server starts, showing the known
|
107
|
+
# Say hello to everybody when the server starts, showing the known
|
109
108
|
# config.
|
110
109
|
def show_status
|
111
110
|
say_status :start, 'the madness'
|
@@ -115,7 +114,7 @@ module Madness
|
|
115
114
|
say_status :use, config.filename if config.file_exist?
|
116
115
|
say_status :theme, config.theme, :txtblu if config.theme
|
117
116
|
|
118
|
-
say
|
117
|
+
say '-' * 60
|
119
118
|
end
|
120
119
|
|
121
120
|
# Generate the table of contents file
|
data/lib/madness/directory.rb
CHANGED
@@ -9,7 +9,7 @@ module Madness
|
|
9
9
|
def initialize(dir)
|
10
10
|
@dir = dir
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def list
|
14
14
|
@list ||= (dirs + files)
|
15
15
|
end
|
@@ -18,9 +18,8 @@ module Madness
|
|
18
18
|
|
19
19
|
def files
|
20
20
|
result = Dir["#{dir}/#{config.dir_glob}"]
|
21
|
-
result.reject! do |f|
|
22
|
-
|
23
|
-
basename == 'README.md' or basename == 'index.md'
|
21
|
+
result.reject! do |f|
|
22
|
+
['README.md', 'index.md'].include? File.basename(f)
|
24
23
|
end
|
25
24
|
result.nat_sort.map { |path| Item.new path, :file }
|
26
25
|
end
|
@@ -33,9 +32,10 @@ module Madness
|
|
33
32
|
|
34
33
|
def exclude?(path)
|
35
34
|
return false unless config.exclude.is_a? Array
|
35
|
+
|
36
36
|
basename = File.basename path
|
37
37
|
config.exclude.each do |pattern|
|
38
|
-
return true if basename
|
38
|
+
return true if basename&.match?(Regexp.new(pattern))
|
39
39
|
end
|
40
40
|
false
|
41
41
|
end
|
@@ -43,6 +43,5 @@ module Madness
|
|
43
43
|
def config
|
44
44
|
@config ||= Settings.instance
|
45
45
|
end
|
46
|
-
|
47
46
|
end
|
48
47
|
end
|
data/lib/madness/document.rb
CHANGED
@@ -2,7 +2,6 @@ require 'commonmarker'
|
|
2
2
|
require 'coderay'
|
3
3
|
|
4
4
|
module Madness
|
5
|
-
|
6
5
|
# Handle a single markdown document.
|
7
6
|
class Document
|
8
7
|
include ServerHelper
|
@@ -24,7 +23,7 @@ module Madness
|
|
24
23
|
|
25
24
|
# Return the HTML for that document, force re-read.
|
26
25
|
def content!
|
27
|
-
[
|
26
|
+
%i[empty missing].include?(type) ? "<h1>#{title}</h1>" : markdown_to_html
|
28
27
|
end
|
29
28
|
|
30
29
|
private
|
@@ -99,7 +98,7 @@ module Madness
|
|
99
98
|
anchor = CommonMarker::Node.new(:inline_html)
|
100
99
|
|
101
100
|
next unless node.first_child.type == :text
|
102
|
-
|
101
|
+
|
103
102
|
anchor_id = node.first_child.string_content.to_slug
|
104
103
|
anchor.string_content = "<a id='#{anchor_id}'></a>"
|
105
104
|
node.prepend_child anchor
|
@@ -110,13 +109,13 @@ module Madness
|
|
110
109
|
# Replace <!-- TOC --> with a Table of Contents for the page
|
111
110
|
def replace_toc_marker
|
112
111
|
toc_marker = doc.find do |node|
|
113
|
-
node.type == :html and node.string_content.include?
|
112
|
+
node.type == :html and node.string_content.include? '<!-- TOC -->'
|
114
113
|
end
|
115
114
|
|
116
115
|
return unless toc_marker
|
117
116
|
|
118
117
|
toc_marker.insert_after document_toc
|
119
|
-
toc_marker.insert_after CommonMarker.render_doc(
|
118
|
+
toc_marker.insert_after CommonMarker.render_doc('## Table of Contents').first_child
|
120
119
|
end
|
121
120
|
|
122
121
|
# Replace [[link]] with [link](link)
|
@@ -129,10 +128,12 @@ module Madness
|
|
129
128
|
toc = []
|
130
129
|
doc.walk do |node|
|
131
130
|
next unless node.type == :header
|
131
|
+
|
132
132
|
level = node.header_level
|
133
133
|
next unless level.between? 2, 3
|
134
|
+
|
134
135
|
text = node.first_child.string_content
|
135
|
-
spacer =
|
136
|
+
spacer = ' ' * (level - 1)
|
136
137
|
toc << "#{spacer}- [#{text}](##{text.to_slug})"
|
137
138
|
end
|
138
139
|
|
@@ -143,7 +144,8 @@ module Madness
|
|
143
144
|
# If the document does not start with an H1 tag, add it.
|
144
145
|
def prepend_h1
|
145
146
|
return unless doc.first_child
|
146
|
-
return if doc.first_child.type == :header
|
147
|
+
return if (doc.first_child.type == :header) && (doc.first_child.header_level == 1)
|
148
|
+
|
147
149
|
h1 = CommonMarker.render_doc("# #{title}").first_child
|
148
150
|
doc.first_child.insert_before h1
|
149
151
|
end
|
@@ -159,8 +161,9 @@ module Madness
|
|
159
161
|
def syntax_highlight(html)
|
160
162
|
line_numbers = config.line_numbers ? :table : nil
|
161
163
|
opts = { css: :style, wrap: nil, line_numbers: line_numbers }
|
162
|
-
html.gsub(
|
163
|
-
lang
|
164
|
+
html.gsub(%r{<code class="language-(.+?)">(.+?)</code>}m) do
|
165
|
+
lang = $1
|
166
|
+
code = $2
|
164
167
|
code = CGI.unescapeHTML code
|
165
168
|
CodeRay.scan(code, lang).html opts
|
166
169
|
end
|
@@ -175,4 +178,3 @@ module Madness
|
|
175
178
|
end
|
176
179
|
end
|
177
180
|
end
|
178
|
-
|
data/lib/madness/item.rb
CHANGED
data/lib/madness/navigation.rb
CHANGED
@@ -15,7 +15,7 @@ module Madness
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def caption
|
18
|
-
@caption ||= (dir == docroot ?
|
18
|
+
@caption ||= (dir == docroot ? 'Index' : File.basename(dir).to_label)
|
19
19
|
end
|
20
20
|
|
21
21
|
def with_search?
|
@@ -28,4 +28,4 @@ module Madness
|
|
28
28
|
@directory ||= Directory.new(dir)
|
29
29
|
end
|
30
30
|
end
|
31
|
-
end
|
31
|
+
end
|
@@ -12,14 +12,14 @@ module Madness
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def to_slug
|
15
|
-
downcase.strip.
|
15
|
+
downcase.strip.tr(' ', '-').remove(/[^\w-]/)
|
16
16
|
end
|
17
17
|
|
18
18
|
# This is here so we can have one place that defines how to convert
|
19
19
|
# a string (usually a filename without .md extension, or a folder name)
|
20
20
|
# to a label.
|
21
21
|
# It is used by different navigation elements in madness, and ucrrently
|
22
|
-
# just removes any numbers followed by a dot at the beginning of the
|
22
|
+
# just removes any numbers followed by a dot at the beginning of the
|
23
23
|
# string, in order to allow "The Invisible Sorting Hand".
|
24
24
|
def to_label
|
25
25
|
remove(/^\d+\.\s+/).remove(/\.md$/)
|
data/lib/madness/search.rb
CHANGED
@@ -5,7 +5,7 @@ module Madness
|
|
5
5
|
include ServerHelper
|
6
6
|
using StringRefinements
|
7
7
|
|
8
|
-
def initialize(path=nil)
|
8
|
+
def initialize(path = nil)
|
9
9
|
@path = path || docroot
|
10
10
|
end
|
11
11
|
|
@@ -27,7 +27,8 @@ module Madness
|
|
27
27
|
found = 0
|
28
28
|
words.each { |word| found += 1 if content.include? word }
|
29
29
|
next unless found == word_count
|
30
|
-
|
30
|
+
|
31
|
+
result[label] = url
|
31
32
|
end
|
32
33
|
|
33
34
|
result
|
@@ -40,6 +41,7 @@ module Madness
|
|
40
41
|
|
41
42
|
Dir["#{@path}/**/#{config.dir_glob}"].sort.each do |file|
|
42
43
|
next if skip_index? file
|
44
|
+
|
43
45
|
filename = file_url(file.sub("#{@path}/", '')).downcase
|
44
46
|
index_content = File.extname(file) == '.md'
|
45
47
|
content = index_content ? File.read(file).downcase : ''
|
@@ -49,7 +51,7 @@ module Madness
|
|
49
51
|
end
|
50
52
|
|
51
53
|
# We are going to avoid indexing of README.md when there is also an
|
52
|
-
# index.md in the same directory, to keep behavior consistent with the
|
54
|
+
# index.md in the same directory, to keep behavior consistent with the
|
53
55
|
# display logic
|
54
56
|
def skip_index?(file)
|
55
57
|
if file.end_with? 'README.md'
|
@@ -62,9 +64,9 @@ module Madness
|
|
62
64
|
|
63
65
|
def file_label(filename)
|
64
66
|
filename
|
65
|
-
.remove(
|
67
|
+
.remove(%r{/(index|README)$})
|
66
68
|
.split('/')
|
67
|
-
.map
|
69
|
+
.map(&:to_label)
|
68
70
|
.join(' / ')
|
69
71
|
end
|
70
72
|
|
@@ -73,7 +75,7 @@ module Madness
|
|
73
75
|
end
|
74
76
|
|
75
77
|
def file_url(filename)
|
76
|
-
filename.remove(
|
78
|
+
filename.remove(%r{/(index|README)$})
|
77
79
|
end
|
78
80
|
end
|
79
81
|
end
|
data/lib/madness/server.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'madness/server_base'
|
2
2
|
|
3
3
|
module Madness
|
4
|
-
|
5
4
|
# The Sinatra server
|
6
5
|
class Server < ServerBase
|
7
6
|
using StringRefinements
|
@@ -11,8 +10,8 @@ module Madness
|
|
11
10
|
results = query ? Search.new.search(query) : false
|
12
11
|
nav = Navigation.new docroot
|
13
12
|
slim :search, locals: {
|
14
|
-
nav:
|
15
|
-
results: results
|
13
|
+
nav: nav,
|
14
|
+
results: results,
|
16
15
|
}
|
17
16
|
end
|
18
17
|
|
@@ -23,27 +22,27 @@ module Madness
|
|
23
22
|
dir = doc.dir
|
24
23
|
content = doc.content
|
25
24
|
|
26
|
-
if doc.type == :readme
|
25
|
+
if (doc.type == :readme) && !path.empty? && (path[-1] != '/')
|
27
26
|
redirect "#{path.to_href}/"
|
28
27
|
end
|
29
28
|
|
30
29
|
nav = Navigation.new dir
|
31
30
|
breadcrumbs = Breadcrumbs.new(path).links
|
32
31
|
|
33
|
-
if nav.links.count == 1
|
32
|
+
if (nav.links.count == 1) && (doc.type == :empty)
|
34
33
|
redirect to(nav.links.first.href)
|
35
34
|
end
|
36
35
|
|
37
36
|
status 404 if doc.type == :missing
|
38
37
|
|
39
|
-
slim :document, locals: {
|
40
|
-
content:
|
41
|
-
type:
|
42
|
-
title:
|
43
|
-
file:
|
44
|
-
nav:
|
45
|
-
breadcrumbs: breadcrumbs
|
38
|
+
slim :document, locals: {
|
39
|
+
content: content,
|
40
|
+
type: doc.type,
|
41
|
+
title: doc.title,
|
42
|
+
file: doc.file,
|
43
|
+
nav: nav,
|
44
|
+
breadcrumbs: breadcrumbs,
|
46
45
|
}
|
47
46
|
end
|
48
47
|
end
|
49
|
-
end
|
48
|
+
end
|
data/lib/madness/server_base.rb
CHANGED
@@ -3,7 +3,6 @@ require 'sinatra/base'
|
|
3
3
|
require 'slim'
|
4
4
|
|
5
5
|
module Madness
|
6
|
-
|
7
6
|
# The base class for the sinatra server.
|
8
7
|
# Initialize what we can here, but since there are values that will
|
9
8
|
# become known only later, the #prepare method is provided.
|
@@ -31,7 +30,7 @@ module Madness
|
|
31
30
|
|
32
31
|
def self.set_tempalate_locations
|
33
32
|
theme = Theme.new config.theme
|
34
|
-
|
33
|
+
|
35
34
|
set :views, theme.views_path
|
36
35
|
set :public_folder, theme.public_path
|
37
36
|
end
|
@@ -46,5 +45,4 @@ module Madness
|
|
46
45
|
Settings.instance
|
47
46
|
end
|
48
47
|
end
|
49
|
-
|
50
48
|
end
|
@@ -1,9 +1,8 @@
|
|
1
1
|
module Madness
|
2
|
-
|
3
2
|
# All the methods that we may need inside of any server route.
|
4
3
|
# The module can also be included manually anywhere else.
|
5
4
|
module ServerHelper
|
6
|
-
def config
|
5
|
+
def config
|
7
6
|
@config ||= Settings.instance
|
8
7
|
end
|
9
8
|
|
@@ -12,11 +11,11 @@ module Madness
|
|
12
11
|
end
|
13
12
|
|
14
13
|
def log(obj)
|
15
|
-
|
16
|
-
open('madness.log', 'a')
|
14
|
+
# :nocov:
|
15
|
+
open('madness.log', 'a') do |f|
|
17
16
|
f.puts obj.inspect
|
18
|
-
|
19
|
-
|
17
|
+
end
|
18
|
+
# :nocov:
|
20
19
|
end
|
21
20
|
end
|
22
|
-
end
|
21
|
+
end
|
data/lib/madness/settings.rb
CHANGED
@@ -2,7 +2,6 @@ require 'singleton'
|
|
2
2
|
require 'extended_yaml'
|
3
3
|
|
4
4
|
module Madness
|
5
|
-
|
6
5
|
# Handle the configuration options
|
7
6
|
# Each configuration option has three sources
|
8
7
|
# 1. The default value
|
@@ -18,7 +17,7 @@ module Madness
|
|
18
17
|
|
19
18
|
def method_missing(name, *args, &_blk)
|
20
19
|
name_string = name.to_s
|
21
|
-
|
20
|
+
|
22
21
|
if name_string.end_with? '='
|
23
22
|
data[name_string.chop.to_sym] = args.first
|
24
23
|
else
|
@@ -26,7 +25,11 @@ module Madness
|
|
26
25
|
end
|
27
26
|
end
|
28
27
|
|
29
|
-
|
28
|
+
def respond_to_missing?(*_args)
|
29
|
+
true
|
30
|
+
end
|
31
|
+
|
32
|
+
# Force reload of the config file, set defaults, and then read from
|
30
33
|
# file.
|
31
34
|
def reset
|
32
35
|
@data = nil
|
@@ -41,30 +44,30 @@ module Madness
|
|
41
44
|
end
|
42
45
|
|
43
46
|
def dir_glob
|
44
|
-
data[:expose_extensions] ? "*.{md,#{data[:expose_extensions].delete(' ')}}" :
|
47
|
+
data[:expose_extensions] ? "*.{md,#{data[:expose_extensions].delete(' ')}}" : '*.md'
|
45
48
|
end
|
46
49
|
|
47
50
|
private
|
48
51
|
|
49
52
|
def defaults
|
50
53
|
{
|
51
|
-
path:
|
52
|
-
port:
|
53
|
-
bind:
|
54
|
-
sidebar:
|
55
|
-
auto_h1:
|
56
|
-
auto_nav:
|
57
|
-
highlighter:
|
58
|
-
line_numbers:
|
59
|
-
copy_code:
|
60
|
-
shortlinks:
|
61
|
-
toc:
|
62
|
-
theme:
|
63
|
-
open:
|
64
|
-
auth:
|
65
|
-
auth_realm:
|
54
|
+
path: '.',
|
55
|
+
port: 3000,
|
56
|
+
bind: '0.0.0.0',
|
57
|
+
sidebar: true,
|
58
|
+
auto_h1: true,
|
59
|
+
auto_nav: true,
|
60
|
+
highlighter: true,
|
61
|
+
line_numbers: true,
|
62
|
+
copy_code: true,
|
63
|
+
shortlinks: false,
|
64
|
+
toc: nil,
|
65
|
+
theme: nil,
|
66
|
+
open: false,
|
67
|
+
auth: false,
|
68
|
+
auth_realm: 'Madness',
|
66
69
|
expose_extensions: nil,
|
67
|
-
exclude:
|
70
|
+
exclude: [/^[a-z_\-0-9]+$/],
|
68
71
|
}
|
69
72
|
end
|
70
73
|
|
@@ -81,6 +84,5 @@ module Madness
|
|
81
84
|
|
82
85
|
result || {}
|
83
86
|
end
|
84
|
-
|
85
87
|
end
|
86
88
|
end
|
data/lib/madness/static.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module Madness
|
2
|
-
|
3
|
-
# The Madness::Static middleware delegates requests to
|
2
|
+
# The Madness::Static middleware delegates requests to
|
4
3
|
# Rack::Static middleware unless the request URI ends with .md
|
5
4
|
class Static
|
6
5
|
def initialize(app, options)
|
@@ -9,7 +8,7 @@ module Madness
|
|
9
8
|
end
|
10
9
|
|
11
10
|
def call(env)
|
12
|
-
if env['PATH_INFO'].end_with?
|
11
|
+
if env['PATH_INFO'].end_with? '.md'
|
13
12
|
@app.call env
|
14
13
|
else
|
15
14
|
@static.call env
|
@@ -10,7 +10,7 @@ module Madness
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def build(file)
|
13
|
-
file +=
|
13
|
+
file += '.md' unless file.end_with? '.md'
|
14
14
|
File.write "#{dir}/#{file}", toc
|
15
15
|
end
|
16
16
|
|
@@ -25,10 +25,11 @@ module Madness
|
|
25
25
|
|
26
26
|
result = []
|
27
27
|
list.each do |item|
|
28
|
-
|
28
|
+
case item.type
|
29
|
+
when :dir
|
29
30
|
result.push "#{' ' * indent}1. #{make_link item}"
|
30
|
-
result += toc! item.path, indent+4
|
31
|
-
|
31
|
+
result += toc! item.path, indent + 4
|
32
|
+
when :file
|
32
33
|
result.push "#{' ' * indent}1. #{make_link item}"
|
33
34
|
end
|
34
35
|
end
|
@@ -39,4 +40,4 @@ module Madness
|
|
39
40
|
"[#{item.label}](#{item.href})"
|
40
41
|
end
|
41
42
|
end
|
42
|
-
end
|
43
|
+
end
|
data/lib/madness/theme.rb
CHANGED
data/lib/madness/version.rb
CHANGED
data/lib/madness.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: madness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.9
|
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: 2023-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: addressable
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.7'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: coderay
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -30,14 +44,14 @@ dependencies:
|
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
47
|
+
version: 0.7.2
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
54
|
+
version: 0.7.2
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: commonmarker
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,6 +86,20 @@ dependencies:
|
|
72
86
|
- - "~>"
|
73
87
|
- !ruby/object:Gem::Version
|
74
88
|
version: '0.6'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: extended_yaml
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 0.2.3
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 0.2.3
|
75
103
|
- !ruby/object:Gem::Dependency
|
76
104
|
name: naturally
|
77
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,14 +132,14 @@ dependencies:
|
|
104
132
|
name: puma
|
105
133
|
requirement: !ruby/object:Gem::Requirement
|
106
134
|
requirements:
|
107
|
-
- - "
|
135
|
+
- - ">="
|
108
136
|
- !ruby/object:Gem::Version
|
109
137
|
version: '5.1'
|
110
138
|
type: :runtime
|
111
139
|
prerelease: false
|
112
140
|
version_requirements: !ruby/object:Gem::Requirement
|
113
141
|
requirements:
|
114
|
-
- - "
|
142
|
+
- - ">="
|
115
143
|
- !ruby/object:Gem::Version
|
116
144
|
version: '5.1'
|
117
145
|
- !ruby/object:Gem::Dependency
|
@@ -120,34 +148,28 @@ dependencies:
|
|
120
148
|
requirements:
|
121
149
|
- - "~>"
|
122
150
|
- !ruby/object:Gem::Version
|
123
|
-
version: '0
|
151
|
+
version: '1.0'
|
124
152
|
type: :runtime
|
125
153
|
prerelease: false
|
126
154
|
version_requirements: !ruby/object:Gem::Requirement
|
127
155
|
requirements:
|
128
156
|
- - "~>"
|
129
157
|
- !ruby/object:Gem::Version
|
130
|
-
version: '0
|
158
|
+
version: '1.0'
|
131
159
|
- !ruby/object:Gem::Dependency
|
132
160
|
name: sinatra
|
133
161
|
requirement: !ruby/object:Gem::Requirement
|
134
162
|
requirements:
|
135
163
|
- - "~>"
|
136
164
|
- !ruby/object:Gem::Version
|
137
|
-
version: '
|
138
|
-
- - ">="
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
version: 2.0.5
|
165
|
+
version: '3.0'
|
141
166
|
type: :runtime
|
142
167
|
prerelease: false
|
143
168
|
version_requirements: !ruby/object:Gem::Requirement
|
144
169
|
requirements:
|
145
170
|
- - "~>"
|
146
171
|
- !ruby/object:Gem::Version
|
147
|
-
version: '
|
148
|
-
- - ">="
|
149
|
-
- !ruby/object:Gem::Version
|
150
|
-
version: 2.0.5
|
172
|
+
version: '3.0'
|
151
173
|
- !ruby/object:Gem::Dependency
|
152
174
|
name: slim
|
153
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,34 +184,6 @@ dependencies:
|
|
162
184
|
- - "~>"
|
163
185
|
- !ruby/object:Gem::Version
|
164
186
|
version: '4.0'
|
165
|
-
- !ruby/object:Gem::Dependency
|
166
|
-
name: extended_yaml
|
167
|
-
requirement: !ruby/object:Gem::Requirement
|
168
|
-
requirements:
|
169
|
-
- - "~>"
|
170
|
-
- !ruby/object:Gem::Version
|
171
|
-
version: '0.2'
|
172
|
-
type: :runtime
|
173
|
-
prerelease: false
|
174
|
-
version_requirements: !ruby/object:Gem::Requirement
|
175
|
-
requirements:
|
176
|
-
- - "~>"
|
177
|
-
- !ruby/object:Gem::Version
|
178
|
-
version: '0.2'
|
179
|
-
- !ruby/object:Gem::Dependency
|
180
|
-
name: addressable
|
181
|
-
requirement: !ruby/object:Gem::Requirement
|
182
|
-
requirements:
|
183
|
-
- - "~>"
|
184
|
-
- !ruby/object:Gem::Version
|
185
|
-
version: '2.7'
|
186
|
-
type: :runtime
|
187
|
-
prerelease: false
|
188
|
-
version_requirements: !ruby/object:Gem::Requirement
|
189
|
-
requirements:
|
190
|
-
- - "~>"
|
191
|
-
- !ruby/object:Gem::Version
|
192
|
-
version: '2.7'
|
193
187
|
description: Start a markdown server in any directory
|
194
188
|
email: db@dannyben.com
|
195
189
|
executables:
|
@@ -264,6 +258,7 @@ metadata:
|
|
264
258
|
changelog_uri: https://github.com/DannyBen/madness/blob/master/CHANGELOG.md
|
265
259
|
homepage_uri: https://madness.dannyb.co/
|
266
260
|
source_code_uri: https://github.com/DannyBen/madness
|
261
|
+
rubygems_mfa_required: 'true'
|
267
262
|
post_install_message:
|
268
263
|
rdoc_options: []
|
269
264
|
require_paths:
|
@@ -272,14 +267,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
272
267
|
requirements:
|
273
268
|
- - ">="
|
274
269
|
- !ruby/object:Gem::Version
|
275
|
-
version: 2.
|
270
|
+
version: '2.7'
|
276
271
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
277
272
|
requirements:
|
278
273
|
- - ">="
|
279
274
|
- !ruby/object:Gem::Version
|
280
275
|
version: '0'
|
281
276
|
requirements: []
|
282
|
-
rubygems_version: 3.3
|
277
|
+
rubygems_version: 3.4.3
|
283
278
|
signing_key:
|
284
279
|
specification_version: 4
|
285
280
|
summary: Instant Markdown Server
|