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.
@@ -8,10 +8,10 @@ p {
8
8
  }
9
9
 
10
10
  blockquote {
11
+ color: var(--blockquote-color);
12
+ border-left: 4px solid var(--blockquote-border-color);
11
13
  margin: 0;
12
14
  padding: 0 15px;
13
- color: #777;
14
- border-left: 4px solid #ddd;
15
15
 
16
16
  &>:first-child {
17
17
  margin-top: 0;
@@ -28,9 +28,9 @@ p, blockquote, ul, ol, dl, table, pre {
28
28
  }
29
29
 
30
30
  mark {
31
- background-color: palegreen;
31
+ background-color: var(--highlight-color);
32
32
  }
33
33
 
34
34
  .quiet {
35
- color: #777;
35
+ color: var(--quiet-color);
36
36
  }
@@ -1,7 +1,5 @@
1
1
  img {
2
2
  border-style: none;
3
-
4
3
  max-width: 100%;
5
4
  box-sizing: content-box;
6
- background-color: #fff;
7
5
  }
@@ -1,14 +1,15 @@
1
1
  kbd {
2
+ color: var(--kbd-color);
3
+ background-color: var(--kbd-bg-color);
4
+ border: solid 1px var(--kbd-border-color);
5
+ border-bottom-color: var(--kbd-shadow-color);
6
+ box-shadow: inset 0 -1px 0 var(--kbd-shadow-color);
7
+
2
8
  display: inline-block;
3
- padding: 3px 5px;
4
- font-size: 11px;
9
+ padding: 6px 8px;
10
+ font-size: 85%;
5
11
  line-height: 10px;
6
- color: #555;
7
12
  vertical-align: middle;
8
- background-color: #fcfcfc;
9
- border: solid 1px #ccc;
10
- border-bottom-color: #bbb;
11
13
  border-radius: 3px;
12
- box-shadow: inset 0 -1px 0 #bbb;
13
14
  }
14
15
 
@@ -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,15 @@ nav {
16
16
  position: fixed;
17
17
 
18
18
  .icon-bar {
19
- border-bottom: 1px dotted #ddd;
19
+ background: var(--sidebar-bg-color);
20
+ border-bottom: 1px dotted var(--sidebar-border-color);
21
+ position: sticky;
22
+ top: 0;
23
+ z-index: 1;
20
24
  }
21
25
 
22
26
  a.document, span.document, .caption {
23
- border-bottom: 1px dotted #ddd;
27
+ border-bottom: 1px dotted var(--sidebar-border-color);
24
28
  // &:hover {
25
29
  // background: #e4e4e4;
26
30
  // }
@@ -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: #fff;
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: #fff;
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 }
@@ -1,11 +1,16 @@
1
1
  doctype html
2
2
 
3
+ ruby:
4
+ custom_css = Dir["css/*.css"].reject { |f| File.basename(f) == 'main.css' }
5
+
3
6
  html
4
7
  head
5
8
  title = locals[:title]
6
9
  meta name="HandheldFriendly" content="true"
7
10
  meta name="viewport" content="width=device-width, initial-scale=1"
8
11
  link href='/css/main.css' rel='stylesheet' type='text/css'
12
+ - custom_css.each do |file|
13
+ link href="/#{file}" rel='stylesheet' type='text/css'
9
14
 
10
15
  - if config.copy_code
11
16
  script src="/js/vendor/jquery.min.js"
data/bin/madness CHANGED
@@ -1,13 +1,17 @@
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
- say! "!undred!#{e.class}!txtrst!\n#{e.message}"
15
+ say! "rib` #{e.class} `\n #{e.message}"
12
16
  exit 1
13
17
  end
@@ -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: m`madness COMMAND --help`\nDocs: bu`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 "Created g`#{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 ? 'n' : 'bb'
25
+ if config.defaults.has_key?(key)
26
+ key_color = 'g'
27
+ else
28
+ key_color = 'r'
29
+ value_color = 'r'
30
+ errors_found = true
31
+ end
32
+
33
+ say "#{key_color}`#{key.to_s.rjust 20}`: #{value_color}`#{value || '~'}`"
34
+ end
35
+
36
+ say ''
37
+
38
+ if config.file_exist?
39
+ say "Values in bb`blue` loaded from g`#{config.filename}`"
40
+ end
41
+
42
+ return unless errors_found
43
+
44
+ say 'Keys in r`red` are not recognized'
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,75 @@
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 "g`▌` 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 "r`#{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 'g`▌` starting server'
66
+ say "g`▌ env` : #{Madness::Server.environment}"
67
+ say "g`▌ listen` : #{config.bind}:#{config.port}"
68
+ say "g`▌ path` : #{File.realpath(config.path)}"
69
+ say "g`▌ config` : #{config.filename}" if config.file_exist?
70
+ say "g`▌ theme` : #{config.theme}" if config.theme
71
+ say ''
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,45 @@
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 theme colors'
9
+ usage 'madness config (-h|--help)'
10
+
11
+ command 'full', 'Create a full theme customization directory in PATH [default: _theme]'
12
+ command 'css', 'Create a folder with the entire CSS file for customization'
13
+ command 'colors', 'Create a folder with CSS for overriding colors only'
14
+
15
+ def full_command
16
+ raise InitError, "Directory #{theme_path} already exists" if Dir.exist? theme_path
17
+
18
+ FileUtils.cp_r File.expand_path('../../../app', __dir__), theme_path
19
+ say "Created g`#{theme_path}` theme folder"
20
+ end
21
+
22
+ def css_command
23
+ copy_file 'app/public/css/main.css', 'css/main.css'
24
+ end
25
+
26
+ def colors_command
27
+ copy_file 'app/styles/_variables.scss', 'css/colors.css'
28
+ end
29
+
30
+ private
31
+
32
+ def copy_file(source, target)
33
+ raise InitError, "File #{target} already exists" if File.exist? target
34
+
35
+ FileUtils.mkdir_p File.dirname(target)
36
+ FileUtils.cp_r File.expand_path("../../../#{source}", __dir__), target
37
+ say "Created g`#{target}`"
38
+ end
39
+
40
+ def theme_path
41
+ args['PATH'] || '_theme'
42
+ end
43
+ end
44
+ end
45
+ 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
@@ -12,7 +12,7 @@ module Madness
12
12
  end
13
13
 
14
14
  def to_slug
15
- downcase.strip.tr(' ', '-').remove(/[^\w-]/)
15
+ downcase.strip.gsub(/[^\w]/, '-').squeeze('-').remove(/(^-|-$)/)
16
16
  end
17
17
 
18
18
  # This is here so we can have one place that defines how to convert
@@ -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'
3
3
  end