madness 0.9.9 → 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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +74 -76
  3. data/app/public/css/main.css +494 -248
  4. data/app/public/css/main.css.map +30 -24
  5. data/app/public/font/fontello.eot +0 -0
  6. data/app/public/font/fontello.svg +16 -0
  7. data/app/public/font/fontello.ttf +0 -0
  8. data/app/public/font/fontello.woff +0 -0
  9. data/app/public/font/fontello.woff2 +0 -0
  10. data/app/public/js/clipboard.js +2 -2
  11. data/app/styles/_anchor.scss +5 -3
  12. data/app/styles/_breadcrumbs.scss +2 -1
  13. data/app/styles/_code.scss +35 -42
  14. data/app/styles/{_icons.scss → _fontello.scss} +28 -19
  15. data/app/styles/_footnotes.scss +5 -0
  16. data/app/styles/_general.scss +7 -3
  17. data/app/styles/_image.scss +0 -2
  18. data/app/styles/_keyboard.scss +8 -7
  19. data/app/styles/_line.scss +1 -26
  20. data/app/styles/_manifest.scss +12 -8
  21. data/app/styles/_nav.scss +5 -15
  22. data/app/styles/_rouge.scss +213 -0
  23. data/app/styles/_scrollbar.scss +9 -0
  24. data/app/styles/_search.scss +5 -6
  25. data/app/styles/_table.scss +12 -7
  26. data/app/styles/_typography.scss +9 -5
  27. data/app/styles/_variables.scss +40 -0
  28. data/app/styles/main.scss +3 -3
  29. data/app/views/_index_nav.slim +6 -5
  30. data/app/views/document.slim +2 -6
  31. data/bin/madness +6 -2
  32. data/lib/madness/cli.rb +21 -0
  33. data/lib/madness/commands/base.rb +11 -0
  34. data/lib/madness/commands/config.rb +48 -0
  35. data/lib/madness/commands/server.rb +76 -0
  36. data/lib/madness/commands/theme.rb +36 -0
  37. data/lib/madness/document.rb +5 -110
  38. data/lib/madness/exceptions.rb +6 -0
  39. data/lib/madness/highlight_renderer.rb +10 -0
  40. data/lib/madness/markdown_document.rb +103 -0
  41. data/lib/madness/server_base.rb +1 -1
  42. data/lib/madness/settings.rb +7 -7
  43. data/lib/madness/templates/madness.yml +6 -4
  44. data/lib/madness/version.rb +1 -1
  45. metadata +53 -50
  46. data/app/public/fonts/fontello.eot +0 -0
  47. data/app/public/fonts/fontello.svg +0 -16
  48. data/app/public/fonts/fontello.ttf +0 -0
  49. data/app/public/fonts/fontello.woff +0 -0
  50. data/app/public/fonts/fontello.woff2 +0 -0
  51. data/app/styles/_coderay.scss +0 -37
  52. data/lib/madness/command_line.rb +0 -139
  53. data/lib/madness/docopt.txt +0 -98
@@ -1,139 +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
-
70
- config.auto_h1 = false if args['--no-auto-h1']
71
- config.auto_nav = false if args['--no-auto-nav']
72
- config.sidebar = false if args['--no-sidebar']
73
- config.highlighter = false if args['--no-syntax']
74
- config.line_numbers = false if args['--no-line-numbers']
75
- config.copy_code = false if args['--no-copy-code']
76
- config.shortlinks = true if args['--shortlinks']
77
- config.open = true if args['--open']
78
-
79
- config.theme = File.expand_path(args['--theme'], config.path) if args['--theme']
80
- end
81
-
82
- # Generate index and toc, if requested by the user.
83
- def generate_stuff
84
- build_toc if config.toc
85
- end
86
-
87
- # Create config
88
- def create_config
89
- if File.exist? config.filename
90
- say "!txtred!Abort: config file #{config.filename} already exists"
91
- else
92
- FileUtils.cp File.expand_path('templates/madness.yml', __dir__), config.filename
93
- say "!txtgrn!Created #{config.filename} config file"
94
- end
95
- end
96
-
97
- # Create theme
98
- def create_theme(path)
99
- if Dir.exist? path
100
- say "!txtred!Abort: folder #{path} already exists"
101
- else
102
- FileUtils.cp_r File.expand_path('../../app', __dir__), path
103
- say "!txtgrn!Created #{path} theme folder"
104
- end
105
- end
106
-
107
- # Say hello to everybody when the server starts, showing the known
108
- # config.
109
- def show_status
110
- say_status :start, 'the madness'
111
- say_status :env, Server.environment, :txtblu
112
- say_status :listen, "#{config.bind}:#{config.port}", :txtblu
113
- say_status :path, File.realpath(config.path), :txtblu
114
- say_status :use, config.filename if config.file_exist?
115
- say_status :theme, config.theme, :txtblu if config.theme
116
-
117
- say '-' * 60
118
- end
119
-
120
- # Generate the table of contents file
121
- def build_toc
122
- say_status :toc, "generating #{config.toc}"
123
- TableOfContents.new.build(config.toc)
124
- end
125
-
126
- def config
127
- @config ||= Settings.instance
128
- end
129
-
130
- # Open a web browser if the server is running. This is done in a
131
- # non-blocking manner, so it can be executed before starting the server.
132
- def open_browser
133
- browser = Browser.new config.bind, config.port
134
- browser.open do |error|
135
- say "!txtred!#{error}" if error
136
- end
137
- end
138
- end
139
- end
@@ -1,98 +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
- --no-auto-h1
32
- By default, if a markdown document does not start with an H1 caption,
33
- it will be added automatically based on the file name. To disable this
34
- behavior, use --no-auto-h1.
35
- (Config option: auto_h1)
36
-
37
- --no-syntax
38
- Disable code syntax highlighting.
39
- (Config option: highlighter)
40
-
41
- --no-line-numbers
42
- Disable line numbering for syntax highlighter.
43
- (Config option: line_numbers)
44
-
45
- --no-copy-code
46
- Disable copy to cliboard icon for code snippets.
47
- (Config option: copy_code)
48
-
49
- --no-sidebar
50
- Disable sidebar navigation.
51
- (Config option: sidebar)
52
-
53
- --no-auto-nav
54
- Disable automatic generation of footer navigation for folder README
55
- files.
56
- (Config option: auto_nav)
57
-
58
- --shortlinks
59
- Enable support for [[Short Links]].
60
- (Config option: shortlinks)
61
-
62
- --theme FOLDER
63
- Use a custom theme. FOLDER is either absolute or relative to the main
64
- documentation path.
65
- (Config option: theme)
66
-
67
- --toc FILE
68
- Generate a table of contents file.
69
- (Config option: toc)
70
-
71
- --auth USER:PASS
72
- Enable basic authentication.
73
- (Config option: auth)
74
-
75
- --auth-realm REALM
76
- The basic authentication realm.
77
- (Config option: auth_realm, default: Madness)
78
-
79
- --open
80
- Open the browser pointing at the madness webserver.
81
- (Config option: open)
82
-
83
- --and-quit
84
- Quit instead of running the server. Useful with --toc.
85
-
86
- Examples:
87
- madness
88
- madness docs
89
- madness docs --no-auto-h1 -p 4567
90
- madness docs --open
91
- madness --no-sidebar --no-auto-nav
92
- madness --toc "Table of Contents.md" --and-quit
93
- madness --auth user:secret --port 4000
94
- madness --theme _mytheme
95
- madness create config
96
- madness create theme
97
-
98
-