madness 1.0.0.rc1 → 1.0.0

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.
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.0.0.rc1
4
+ version: 1.0.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: 2023-01-18 00:00:00.000000000 Z
11
+ date: 2023-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -28,44 +28,50 @@ dependencies:
28
28
  name: colsole
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.8.1
34
+ - - "<"
32
35
  - !ruby/object:Gem::Version
33
- version: '0.5'
36
+ version: '2'
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.8.1
44
+ - - "<"
39
45
  - !ruby/object:Gem::Version
40
- version: '0.5'
46
+ version: '2'
41
47
  - !ruby/object:Gem::Dependency
42
- name: docopt
48
+ name: extended_yaml
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '0.6'
53
+ version: '0.2'
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: '0.6'
60
+ version: '0.2'
55
61
  - !ruby/object:Gem::Dependency
56
- name: extended_yaml
62
+ name: mister_bin
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '0.2'
67
+ version: '0.7'
62
68
  type: :runtime
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
72
  - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: '0.2'
74
+ version: '0.7'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: naturally
71
77
  requirement: !ruby/object:Gem::Requirement
@@ -101,6 +107,9 @@ dependencies:
101
107
  - - ">="
102
108
  - !ruby/object:Gem::Version
103
109
  version: '5.1'
110
+ - - "<"
111
+ - !ruby/object:Gem::Version
112
+ version: '7'
104
113
  type: :runtime
105
114
  prerelease: false
106
115
  version_requirements: !ruby/object:Gem::Requirement
@@ -108,6 +117,9 @@ dependencies:
108
117
  - - ">="
109
118
  - !ruby/object:Gem::Version
110
119
  version: '5.1'
120
+ - - "<"
121
+ - !ruby/object:Gem::Version
122
+ version: '7'
111
123
  - !ruby/object:Gem::Dependency
112
124
  name: redcarpet
113
125
  requirement: !ruby/object:Gem::Requirement
@@ -168,16 +180,22 @@ dependencies:
168
180
  name: slim
169
181
  requirement: !ruby/object:Gem::Requirement
170
182
  requirements:
171
- - - "~>"
183
+ - - ">="
172
184
  - !ruby/object:Gem::Version
173
185
  version: '4.0'
186
+ - - "<"
187
+ - !ruby/object:Gem::Version
188
+ version: '6'
174
189
  type: :runtime
175
190
  prerelease: false
176
191
  version_requirements: !ruby/object:Gem::Requirement
177
192
  requirements:
178
- - - "~>"
193
+ - - ">="
179
194
  - !ruby/object:Gem::Version
180
195
  version: '4.0'
196
+ - - "<"
197
+ - !ruby/object:Gem::Version
198
+ version: '6'
181
199
  description: Start a markdown server in any directory
182
200
  email: db@dannyben.com
183
201
  executables:
@@ -215,6 +233,7 @@ files:
215
233
  - app/styles/_search.scss
216
234
  - app/styles/_table.scss
217
235
  - app/styles/_typography.scss
236
+ - app/styles/_variables.scss
218
237
  - app/styles/main.scss
219
238
  - app/views/_breadcrumbs.slim
220
239
  - app/views/_index_nav.slim
@@ -227,10 +246,14 @@ files:
227
246
  - lib/madness.rb
228
247
  - lib/madness/breadcrumbs.rb
229
248
  - lib/madness/browser.rb
230
- - lib/madness/command_line.rb
249
+ - lib/madness/cli.rb
250
+ - lib/madness/commands/base.rb
251
+ - lib/madness/commands/config.rb
252
+ - lib/madness/commands/server.rb
253
+ - lib/madness/commands/theme.rb
231
254
  - lib/madness/directory.rb
232
- - lib/madness/docopt.txt
233
255
  - lib/madness/document.rb
256
+ - lib/madness/exceptions.rb
234
257
  - lib/madness/highlight_renderer.rb
235
258
  - lib/madness/item.rb
236
259
  - lib/madness/markdown_document.rb
@@ -268,11 +291,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
268
291
  version: '2.7'
269
292
  required_rubygems_version: !ruby/object:Gem::Requirement
270
293
  requirements:
271
- - - ">"
294
+ - - ">="
272
295
  - !ruby/object:Gem::Version
273
- version: 1.3.1
296
+ version: '0'
274
297
  requirements: []
275
- rubygems_version: 3.4.3
298
+ rubygems_version: 3.4.7
276
299
  signing_key:
277
300
  specification_version: 4
278
301
  summary: Instant Markdown Server
@@ -1,130 +0,0 @@
1
- require 'fileutils'
2
- require 'singleton'
3
- require 'colsole'
4
- require 'docopt'
5
-
6
- module Madness
7
- # Handle command line execution. Used by bin/madness.
8
- class CommandLine
9
- include Singleton
10
- include Colsole
11
-
12
- # Process ARGV by putting it through docopt
13
- def execute(argv = [])
14
- doc = File.read File.expand_path('docopt.txt', __dir__)
15
-
16
- begin
17
- args = Docopt.docopt(doc, argv: argv, version: VERSION)
18
- handle args
19
- rescue Docopt::Exit => e
20
- puts e.message
21
- end
22
- end
23
-
24
- private
25
-
26
- # Separate between the two main modes: Create something, or launch
27
- # the server.
28
- def handle(args)
29
- if args['create']
30
- create_config if args['config']
31
- create_theme(args['FOLDER']) if args['theme']
32
- else
33
- launch_server_with_options args
34
- end
35
- end
36
-
37
- # Execute some pre-server-launch operations if needed, execute the
38
- # server, and launch the browser if requested.
39
- def launch_server_with_options(args)
40
- set_config args
41
- generate_stuff
42
- open_browser if config.open
43
- launch_server unless args['--and-quit']
44
- end
45
-
46
- # Launch the server, but not before doing some checks and making sure
47
- # we ask it to "prepare". This will set the server options such as port
48
- # and static files folder.
49
- def launch_server
50
- unless File.directory? config.path
51
- $stderr.puts "Invalid path (#{config.path})"
52
- return
53
- end
54
-
55
- show_status
56
- Server.prepare
57
- Server.run!
58
- end
59
-
60
- # Get the arguments as provided by docopt, and set them to our own
61
- # config object.
62
- def set_config(args)
63
- config.path = args['PATH'] if args['PATH']
64
- config.port = args['--port'].to_i if args['--port']
65
- config.bind = args['--bind'] if args['--bind']
66
- config.toc = args['--toc'] if args['--toc']
67
- config.auth = args['--auth'] if args['--auth']
68
- config.auth_realm = args['--auth-realm'] if args['--auth-realm']
69
- config.open = true if args['--open']
70
- config.theme = File.expand_path(args['--theme'], config.path) if args['--theme']
71
- end
72
-
73
- # Generate index and toc, if requested by the user.
74
- def generate_stuff
75
- build_toc if config.toc
76
- end
77
-
78
- # Create config
79
- def create_config
80
- if File.exist? config.filename
81
- say "!txtred!Abort: config file #{config.filename} already exists"
82
- else
83
- FileUtils.cp File.expand_path('templates/madness.yml', __dir__), config.filename
84
- say "!txtgrn!Created #{config.filename} config file"
85
- end
86
- end
87
-
88
- # Create theme
89
- def create_theme(path)
90
- if Dir.exist? path
91
- say "!txtred!Abort: folder #{path} already exists"
92
- else
93
- FileUtils.cp_r File.expand_path('../../app', __dir__), path
94
- say "!txtgrn!Created #{path} theme folder"
95
- end
96
- end
97
-
98
- # Say hello to everybody when the server starts, showing the known
99
- # config.
100
- def show_status
101
- say_status :start, 'the madness'
102
- say_status :env, Server.environment, :txtblu
103
- say_status :listen, "#{config.bind}:#{config.port}", :txtblu
104
- say_status :path, File.realpath(config.path), :txtblu
105
- say_status :use, config.filename if config.file_exist?
106
- say_status :theme, config.theme, :txtblu if config.theme
107
-
108
- say '-' * 60
109
- end
110
-
111
- # Generate the table of contents file
112
- def build_toc
113
- say_status :toc, "generating #{config.toc}"
114
- TableOfContents.new.build(config.toc)
115
- end
116
-
117
- def config
118
- @config ||= Settings.instance
119
- end
120
-
121
- # Open a web browser if the server is running. This is done in a
122
- # non-blocking manner, so it can be executed before starting the server.
123
- def open_browser
124
- browser = Browser.new config.bind, config.port
125
- browser.open do |error|
126
- say "!txtred!#{error}" if error
127
- end
128
- end
129
- end
130
- end
@@ -1,64 +0,0 @@
1
- Madness
2
-
3
- Usage:
4
- madness [PATH] [options]
5
- madness create config
6
- madness create theme FOLDER
7
- madness (-h|--help|--version)
8
-
9
- Subcommands:
10
- create config
11
- Initialize a new default .madness.yml config file.
12
-
13
- create theme
14
- Initialize a new theme folder, based on the default theme. You can then
15
- customize it to your needs and use it with --theme.
16
-
17
- Parameters:
18
- PATH:
19
- Path to the markdown directory.
20
- (Config option: path, default: .)
21
-
22
- Options:
23
- -p, --port NUMBER
24
- Set server port number.
25
- (Config option: port, default: 3000)
26
-
27
- -b, --bind ADDRESS
28
- Set server listen address.
29
- (Config option: bind, default: 0.0.0.0)
30
-
31
- --theme FOLDER
32
- Use a custom theme. FOLDER is either absolute or relative to the main
33
- documentation path.
34
- (Config option: theme)
35
-
36
- --toc FILE
37
- Generate a table of contents file.
38
- (Config option: toc)
39
-
40
- --auth USER:PASS
41
- Enable basic authentication.
42
- (Config option: auth)
43
-
44
- --auth-realm REALM
45
- The basic authentication realm.
46
- (Config option: auth_realm, default: Madness)
47
-
48
- --open
49
- Open the browser pointing at the madness webserver.
50
- (Config option: open)
51
-
52
- --and-quit
53
- Quit instead of running the server. Useful with --toc.
54
-
55
- Examples:
56
- madness
57
- madness docs
58
- madness docs -p 4567
59
- madness docs --open
60
- madness --toc "Table of Contents.md" --and-quit
61
- madness --auth user:secret --port 4000
62
- madness --theme _mytheme
63
- madness create config
64
- madness create theme