madness 1.0.0.rc1 → 1.0.0.rc2

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.
@@ -1,29 +1,4 @@
1
1
  hr {
2
- box-sizing: content-box;
3
- // height: 0;
4
- overflow: visible;
5
- height: 0;
6
- // margin: 15px 0;
7
- overflow: hidden;
8
- // background: transparent;
9
2
  border: 0;
10
- border-bottom: 1px solid #ddd;
11
-
12
- height: 4px;
13
- padding: 0;
14
- margin: 16px 0;
15
- background-color: #e7e7e7;
16
- // border: 0 none;
17
-
18
- border-bottom-color: #eee;
19
-
20
- &::before {
21
- display: table;
22
- content: "";
23
- }
24
- &::after {
25
- display: table;
26
- clear: both;
27
- content: "";
28
- }
3
+ border-top: 2px solid var(--hr-color);
29
4
  }
@@ -1,3 +1,5 @@
1
+ @import "variables";
2
+
1
3
  @import "mixins";
2
4
 
3
5
  @import "anchor";
data/app/styles/_nav.scss CHANGED
@@ -7,8 +7,8 @@ nav {
7
7
  display: none;
8
8
  }
9
9
 
10
- // background: #eee;
11
- // border-right: 1px solid #ccc;
10
+ background: var(--sidebar-bg-color);
11
+ border-right: 1px solid var(--sidebar-border-right-color);
12
12
 
13
13
  height: 100vh;
14
14
  width: 300px;
@@ -16,11 +16,11 @@ nav {
16
16
  position: fixed;
17
17
 
18
18
  .icon-bar {
19
- border-bottom: 1px dotted #ddd;
19
+ border-bottom: 1px dotted var(--sidebar-border-color);
20
20
  }
21
21
 
22
22
  a.document, span.document, .caption {
23
- border-bottom: 1px dotted #ddd;
23
+ border-bottom: 1px dotted var(--sidebar-border-color);
24
24
  // &:hover {
25
25
  // background: #e4e4e4;
26
26
  // }
@@ -4,6 +4,6 @@
4
4
  height: 6px;
5
5
  }
6
6
  ::-webkit-scrollbar-thumb {
7
- background: #ccc;
7
+ background: var(--scrollbar-color);
8
8
  -webkit-border-radius: 3px;
9
9
  }
@@ -22,17 +22,16 @@
22
22
  }
23
23
 
24
24
  .search-field {
25
+ border: 1px solid var(--search-field-border-color);
26
+ border-radius: 3px;
27
+
25
28
  outline: none;
26
29
  padding: 8px 12px;
27
30
  font-size: 1.5em;
28
- width: 50%;
29
- min-width: 200px;
30
31
  width: 100%;
31
-
32
- border: #ccc 1px solid;
33
- border-radius: 3px;
32
+ min-width: 200px;
34
33
 
35
34
  &:focus {
36
- border-color: #4078c0;
35
+ border-color: var(--search-field-focused-border-color);
37
36
  }
38
37
  }
@@ -8,21 +8,26 @@ table {
8
8
  word-break: normal;
9
9
  word-break: keep-all;
10
10
 
11
+ th, td {
12
+ padding: 6px 13px;
13
+ border: 1px solid var(--table-border-color);
14
+ }
15
+
16
+ td {
17
+ background-color: var(--table-bg-color);
18
+ }
19
+
11
20
  th {
12
21
  font-weight: bold;
22
+ background-color: var(--table-header-bg-color);
13
23
  }
14
24
 
15
- th, td {
16
- padding: 6px 13px;
17
- border: 1px solid #ddd;
18
- }
19
25
 
20
26
  tr {
21
- background-color: #fff;
22
- border-top: 1px solid #ccc;
27
+ background-color: var(--table-row-bg-color);
23
28
  }
24
29
 
25
30
  tr:nth-child(2n) {
26
- background-color: #f8f8f8;
31
+ background-color: var(--table-alt-row-bg-color);
27
32
  }
28
33
  }
@@ -1,7 +1,7 @@
1
1
  body {
2
2
  -ms-text-size-adjust: 100%;
3
3
  -webkit-text-size-adjust: 100%;
4
- color: #333;
4
+ color: var(--font-color);
5
5
  // font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
6
6
  font-family: "Segoe UI", "Helvetica Neue", Helvetica,Arial, freesans, sans-serif;
7
7
  font-size: 16px;
@@ -21,39 +21,43 @@ h1, h2, h3, h4, h5, h6 {
21
21
  }
22
22
 
23
23
  h1 {
24
+ color: var(--h1-color);
25
+ border-bottom: 1px solid var(--h1-border-color);
24
26
  margin: 0.67em 0;
25
27
  padding-bottom: 0.3em;
26
28
  font-size: 2.25em;
27
29
  line-height: 1.2;
28
- border-bottom: 1px solid #eee;
29
30
  }
30
31
 
31
32
  h2 {
33
+ color: var(--h2-color);
34
+ border-bottom: 1px solid var(--h2-border-color);
32
35
  padding-bottom: 0.3em;
33
36
  font-size: 1.75em;
34
37
  line-height: 1.225;
35
- border-bottom: 1px solid #eee;
36
38
  }
37
39
 
38
40
  h3 {
41
+ color: var(--h3-color);
39
42
  font-size: 1.5em;
40
43
  line-height: 1.43;
41
44
  }
42
45
 
43
46
  h4 {
47
+ color: var(--h4-color);
44
48
  font-size: 1.25em;
45
49
  }
46
50
 
47
51
  h5 {
52
+ color: var(--h5-color);
48
53
  font-size: 1em;
49
54
  }
50
55
 
51
56
  h6 {
57
+ color: var(--h6-color);
52
58
  font-size: 1em;
53
- color: #777;
54
59
  }
55
60
 
56
61
  code, pre, kbd {
57
62
  font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
58
- font-size: 1em;
59
63
  }
@@ -0,0 +1,40 @@
1
+ :root {
2
+
3
+ --background-color: transparent;
4
+ --blockquote-border-color: #ddd;
5
+ --blockquote-color: #777;
6
+ --breadcrumbs-border-color: #ccc;
7
+ --clipboard-button-bg-color: white;
8
+ --clipboard-button-border-color: #ccc;
9
+ --font-color: #333;
10
+ --footnotes-color: #666;
11
+ --h1-border-color: #eee;
12
+ --h1-color: #333;
13
+ --h2-border-color: #eee;
14
+ --h2-color: #333;
15
+ --h3-color: #333;
16
+ --h4-color: #333;
17
+ --h5-color: #333;
18
+ --h6-color: #777;
19
+ --highlight-color: palegreen;
20
+ --hr-color: #ddd;
21
+ --inline-code-bg-color: #eee;
22
+ --kbd-bg-color: #fcfcfc;
23
+ --kbd-border-color: #ccc;
24
+ --kbd-color: #111;
25
+ --kbd-shadow-color: #bbb;
26
+ --link-color: #4078c0;
27
+ --quiet-color: #777;
28
+ --scrollbar-color: #ccc;
29
+ --search-field-border-color: #ccc;
30
+ --search-field-focused-border-color: #4078c0;
31
+ --sidebar-bg-color: transparent;
32
+ --sidebar-border-color: #ddd;
33
+ --sidebar-border-right-color: #ddd;
34
+ --table-alt-row-bg-color: transparent;
35
+ --table-bg-color: transparent;
36
+ --table-border-color: #ddd;
37
+ --table-header-bg-color: transparent;
38
+ --table-row-bg-color: transparent;
39
+
40
+ }
data/app/styles/main.scss CHANGED
@@ -1,6 +1,7 @@
1
1
  @import "manifest";
2
2
 
3
3
  body {
4
+ background-color: var(--background-color);
4
5
  max-width: 1400px;
5
6
  margin: 0 auto;
6
7
  }
@@ -29,4 +30,3 @@ body {
29
30
  margin: 0 auto;
30
31
  }
31
32
  }
32
-
@@ -1,5 +1,6 @@
1
- ol
2
- - nav.links.each do |item|
3
- li
4
- a href="#{item.href}" class=('strong' if item.type == :dir)
5
- = item.label
1
+ hr
2
+ ol
3
+ - nav.links.each do |item|
4
+ li
5
+ a href="#{item.href}" class=('strong' if item.type == :dir)
6
+ = item.label
@@ -6,9 +6,5 @@
6
6
  == content
7
7
 
8
8
  - if type != :file and config.auto_nav
9
- - unless type == :empty
10
- hr
11
- == slim :_index_nav, locals: { nav: nav }
12
-
13
-
14
-
9
+ - if nav.links.any?
10
+ == slim :_index_nav, locals: { nav: nav }
data/bin/madness CHANGED
@@ -1,11 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  require 'madness'
4
3
  require 'colsole'
5
4
  include Colsole
6
5
 
6
+ runner = Madness::CLI.runner
7
+
7
8
  begin
8
- Madness::CommandLine.instance.execute ARGV
9
+ exit runner.run ARGV
10
+ rescue Madness::Interrupt
11
+ say! "\nGoodbye"
12
+ exit 1
9
13
  rescue => e
10
14
  puts e.backtrace.reverse if ENV['DEBUG']
11
15
  say! "!undred!#{e.class}!txtrst!\n#{e.message}"
@@ -0,0 +1,21 @@
1
+ require 'mister_bin'
2
+
3
+ module Madness
4
+ # The CLI class is used by the bashly binary and forwards incoming CLI
5
+ # commands to the relevant Bashly::Commands class
6
+ class CLI
7
+ def self.runner
8
+ runner = MisterBin::Runner.new version: Madness::VERSION,
9
+ header: 'Markdown Madness - Instant Markdown Server',
10
+ footer: "Help: !txtpur!madness COMMAND --help!txtrst!\nDocs: !undblu!https://madness.dannyb.co"
11
+
12
+ # runner.route 'init', to: Commands::Server
13
+ runner.route 'server', to: Commands::Server
14
+ runner.route 'config', to: Commands::Config
15
+ # runner.route 'toc', to: Commands::TOC
16
+ runner.route 'theme', to: Commands::Theme
17
+
18
+ runner
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ require 'mister_bin'
2
+
3
+ module Madness
4
+ module Commands
5
+ class Base < MisterBin::Command
6
+ def config
7
+ @config ||= Settings.instance
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,48 @@
1
+ module Madness
2
+ module Commands
3
+ class Config < Base
4
+ summary 'Manage the madness configuration file'
5
+
6
+ usage 'bashly config new'
7
+ usage 'bashly config show'
8
+ usage 'bashly config (-h|--help)'
9
+
10
+ command 'new', 'Create a new .madness.yml configuration file'
11
+ command 'show', 'Show all configuration options'
12
+
13
+ def new_command
14
+ raise InitError, "Configuration file #{config.filename} already exists" if File.exist? config.filename
15
+
16
+ FileUtils.cp File.expand_path('../templates/madness.yml', __dir__), config.filename
17
+ say "!txtgrn!Created #{config.filename} config file"
18
+ end
19
+
20
+ def show_command
21
+ errors_found = false
22
+
23
+ config.data.each do |key, value|
24
+ value_color = config.defaults[key] == value ? '' : '!bldblu!'
25
+ if config.defaults.has_key?(key)
26
+ key_color = '!txtgrn!'
27
+ else
28
+ key_color = '!txtred!'
29
+ value_color = '!txtred!'
30
+ errors_found = true
31
+ end
32
+
33
+ say "#{key_color}#{key.to_s.rjust 20}!txtrst!: #{value_color}#{value || '~'}"
34
+ end
35
+
36
+ say ''
37
+
38
+ if config.file_exist?
39
+ say "Values in !bldblu!blue!txtrst! loaded from !txtgrn!#{config.filename}"
40
+ end
41
+
42
+ return unless errors_found
43
+
44
+ say 'Keys in !txtred!red!txtrst! are not recognized'
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,76 @@
1
+ module Madness
2
+ module Commands
3
+ class Server < Base
4
+ summary 'Start the server'
5
+
6
+ usage 'madness server [PATH] [options]'
7
+ usage 'madness init (-h|--help)'
8
+
9
+ param 'PATH', 'Path to the markdown directory [default: .]'
10
+
11
+ option '-p --port NUMBER', 'Set server port number [default: 3000]'
12
+ option '-b --bind ADDRESS', 'Set server listen address [default: 0.0.0.0]'
13
+ option '-o --open', 'Open a web browser after launching'
14
+ option '--auth USER:PASS', 'Enable basic authentication'
15
+ option '--auth-zone NAME', 'The basic authentication prompt title [default: Restricted Documentation]'
16
+ option '--theme FOLDER', 'Use a custom theme (either absolute or relative to the main documentation path)'
17
+
18
+ example 'madness server'
19
+ example 'madness server docs'
20
+ example 'madness server docs -p 4567'
21
+ example 'madness server docs --open'
22
+ example 'madness server --auth user:secret --port 4000'
23
+ example 'madness server --theme _mytheme'
24
+
25
+ def run
26
+ override_config args
27
+ build_toc if config.toc
28
+ open_browser if config.open
29
+ launch_server
30
+ end
31
+
32
+ private
33
+
34
+ def launch_server
35
+ raise ConfigurationError, "Invalid path: #{config.path}" unless File.directory? config.path
36
+
37
+ show_status
38
+ Madness::Server.prepare
39
+ Madness::Server.run!
40
+ end
41
+
42
+ def build_toc
43
+ say_status :toc, "generating #{config.toc}"
44
+ Madness::TableOfContents.new.build(config.toc)
45
+ end
46
+
47
+ def open_browser
48
+ browser = Browser.new config.bind, config.port
49
+ browser.open do |error|
50
+ say "!txtred!#{error}" if error
51
+ end
52
+ end
53
+
54
+ def override_config(args)
55
+ config.path = args['PATH'] if args['PATH']
56
+ config.port = args['--port'].to_i if args['--port']
57
+ config.bind = args['--bind'] if args['--bind']
58
+ config.auth = args['--auth'] if args['--auth']
59
+ config.auth_zone = args['--auth-zone'] if args['--auth-zone']
60
+ config.open = true if args['--open']
61
+ config.theme = File.expand_path(args['--theme'], config.path) if args['--theme']
62
+ end
63
+
64
+ def show_status
65
+ say_status :start, 'the madness'
66
+ say_status :env, Madness::Server.environment
67
+ say_status :listen, "#{config.bind}:#{config.port}"
68
+ say_status :path, File.realpath(config.path)
69
+ say_status :config, config.filename if config.file_exist?
70
+ say_status :theme, config.theme if config.theme
71
+
72
+ say '-' * 60
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,36 @@
1
+ module Madness
2
+ module Commands
3
+ class Theme < Base
4
+ summary 'Create files for theme customization'
5
+
6
+ usage 'madness theme full [PATH]'
7
+ usage 'madness theme css'
8
+ usage 'madness config (-h|--help)'
9
+
10
+ command 'full', 'Create a full theme customization directory in PATH [default: _theme]'
11
+ command 'css', 'Create a folder with the CSS file for customization'
12
+
13
+ def full_command
14
+ raise InitError, "Directory #{theme_path} already exists" if Dir.exist? theme_path
15
+
16
+ FileUtils.cp_r File.expand_path('../../../app', __dir__), theme_path
17
+ say "!txtgrn!Created #{theme_path} theme folder"
18
+ end
19
+
20
+ def css_command
21
+ file = 'css/main.css'
22
+ raise InitError, "File #{file} already exists" if File.exist? file
23
+
24
+ FileUtils.mkdir_p 'css'
25
+ FileUtils.cp_r File.expand_path('../../../app/public/css/main.css', __dir__), 'css/main.css'
26
+ say '!txtgrn!Created css/main.css'
27
+ end
28
+
29
+ private
30
+
31
+ def theme_path
32
+ args['PATH'] || '_theme'
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,6 @@
1
+ module Madness
2
+ class Interrupt < Interrupt; end
3
+ class Error < StandardError; end
4
+ class InitError < Error; end
5
+ class ConfigurationError < Error; end
6
+ end
@@ -36,7 +36,7 @@ module Madness
36
36
  end
37
37
 
38
38
  def self.set_basic_auth
39
- use Rack::Auth::Basic, config.auth_realm do |username, password|
39
+ use Rack::Auth::Basic, config.auth_zone do |username, password|
40
40
  config.auth.split(':') == [username, password]
41
41
  end
42
42
  end
@@ -47,7 +47,9 @@ module Madness
47
47
  data[:expose_extensions] ? "*.{md,#{data[:expose_extensions].delete(' ')}}" : '*.md'
48
48
  end
49
49
 
50
- private
50
+ def data
51
+ @data ||= defaults.merge(file_data)
52
+ end
51
53
 
52
54
  def defaults
53
55
  {
@@ -65,15 +67,13 @@ module Madness
65
67
  theme: nil,
66
68
  open: false,
67
69
  auth: false,
68
- auth_realm: 'Madness',
70
+ auth_zone: 'Restricted Documentation',
69
71
  expose_extensions: nil,
70
- exclude: [/^[a-z_\-0-9]+$/],
72
+ exclude: ['^[a-z_\-0-9]+$'],
71
73
  }
72
74
  end
73
75
 
74
- def data
75
- @data ||= defaults.merge(file_data)
76
- end
76
+ private
77
77
 
78
78
  def file_data
79
79
  result = if file_exist?
@@ -50,7 +50,7 @@ open: false
50
50
  auth: false
51
51
 
52
52
  # if auth is enabled, specify auth realm name
53
- auth_zone: Madness
53
+ auth_zone: Restricted Documentation
54
54
 
55
55
  # show files with these extensions in the navigation and search, for example:
56
56
  # expose_extensions: pdf,docx,xlsx,txt
@@ -1,3 +1,3 @@
1
1
  module Madness
2
- VERSION = '1.0.0.rc1'
2
+ VERSION = '1.0.0.rc2'
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: 1.0.0.rc1
4
+ version: 1.0.0.rc2
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-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -39,33 +39,33 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.5'
41
41
  - !ruby/object:Gem::Dependency
42
- name: docopt
42
+ name: extended_yaml
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.6'
47
+ version: '0.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.6'
54
+ version: '0.2'
55
55
  - !ruby/object:Gem::Dependency
56
- name: extended_yaml
56
+ name: mister_bin
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.2'
61
+ version: '0.7'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.2'
68
+ version: '0.7'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: naturally
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -215,6 +215,7 @@ files:
215
215
  - app/styles/_search.scss
216
216
  - app/styles/_table.scss
217
217
  - app/styles/_typography.scss
218
+ - app/styles/_variables.scss
218
219
  - app/styles/main.scss
219
220
  - app/views/_breadcrumbs.slim
220
221
  - app/views/_index_nav.slim
@@ -227,10 +228,14 @@ files:
227
228
  - lib/madness.rb
228
229
  - lib/madness/breadcrumbs.rb
229
230
  - lib/madness/browser.rb
230
- - lib/madness/command_line.rb
231
+ - lib/madness/cli.rb
232
+ - lib/madness/commands/base.rb
233
+ - lib/madness/commands/config.rb
234
+ - lib/madness/commands/server.rb
235
+ - lib/madness/commands/theme.rb
231
236
  - lib/madness/directory.rb
232
- - lib/madness/docopt.txt
233
237
  - lib/madness/document.rb
238
+ - lib/madness/exceptions.rb
234
239
  - lib/madness/highlight_renderer.rb
235
240
  - lib/madness/item.rb
236
241
  - lib/madness/markdown_document.rb