madness 1.0.0.rc1 → 1.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -14
- data/app/public/css/main.css +90 -62
- data/app/public/css/main.css.map +18 -16
- data/app/styles/_anchor.scss +1 -3
- data/app/styles/_breadcrumbs.scss +2 -1
- data/app/styles/_code.scss +3 -3
- data/app/styles/_footnotes.scss +1 -2
- data/app/styles/_general.scss +4 -4
- data/app/styles/_image.scss +0 -2
- data/app/styles/_keyboard.scss +8 -7
- data/app/styles/_line.scss +1 -26
- data/app/styles/_manifest.scss +2 -0
- data/app/styles/_nav.scss +4 -4
- data/app/styles/_scrollbar.scss +1 -1
- data/app/styles/_search.scss +5 -6
- data/app/styles/_table.scss +12 -7
- data/app/styles/_typography.scss +9 -5
- data/app/styles/_variables.scss +40 -0
- data/app/styles/main.scss +1 -1
- data/app/views/_index_nav.slim +6 -5
- data/app/views/document.slim +2 -6
- data/bin/madness +6 -2
- data/lib/madness/cli.rb +21 -0
- data/lib/madness/commands/base.rb +11 -0
- data/lib/madness/commands/config.rb +48 -0
- data/lib/madness/commands/server.rb +76 -0
- data/lib/madness/commands/theme.rb +36 -0
- data/lib/madness/exceptions.rb +6 -0
- data/lib/madness/server_base.rb +1 -1
- data/lib/madness/settings.rb +6 -6
- data/lib/madness/templates/madness.yml +1 -1
- data/lib/madness/version.rb +1 -1
- metadata +15 -10
- data/lib/madness/command_line.rb +0 -130
- data/lib/madness/docopt.txt +0 -64
data/lib/madness/command_line.rb
DELETED
@@ -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
|
data/lib/madness/docopt.txt
DELETED
@@ -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
|