forked from binford2k/showoff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
showoff
executable file
·189 lines (150 loc) · 5.78 KB
/
showoff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#! /usr/bin/env ruby
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require 'showoff'
require 'showoff/version'
require 'rubygems'
require 'gli'
include GLI::App
version SHOWOFF_VERSION
desc 'Create new showoff presentation'
arg_name 'dir_name'
long_desc 'This command helps start a new showoff presentation by setting up the proper directory structure for you. It takes the directory name you would like showoff to create for you.'
command [:create,:init] do |c|
c.desc 'Don''t create sample slides'
c.switch [:n,:nosamples]
c.desc 'sample slide directory name'
c.default_value 'one'
c.flag [:d,:slidedir]
c.action do |global_options,options,args|
raise "dir_name is required" if args.empty?
ShowOffUtils.create(args[0],!options[:n],options[:d])
if !options[:n]
puts "done. run 'showoff serve' in #{options[:d]}/ dir to see slideshow"
else
puts "done. add slides, modify #{ShowOffUtils.presentation_config_file} and then run 'showoff serve' in #{dirname}/ dir to see slideshow"
end
end
end
desc 'Puts your showoff presentation into a gh-pages branch'
long_desc 'Generates a static version of your presentation into your gh-pages branch for publishing to GitHub Pages'
command :github do |c|
c.action do |global_options,options,args|
puts "Generating static content"
ShowOffUtils.github
puts "I've updated your 'gh-pages' branch with the static version of your presentation."
puts "Push it to GitHub to publish it. Probably something like:"
puts
puts " git push origin gh-pages"
puts
end
end
desc 'Serves the showoff presentation in the current directory'
desc 'Setup your presentation to serve on Heroku'
arg_name 'heroku_name'
long_desc 'Creates the Gemfile and config.ru file needed to push a showoff pres to heroku. It will then run ''heroku create'' for you to register the new project on heroku and add the remote for you. Then all you need to do is commit the new created files and run ''git push heroku'' to deploy.'
command :heroku do |c|
c.desc 'add password protection to your heroku site'
c.flag [:p,:password]
c.desc 'force overwrite of existing Gemfile/.gems and config.ru files if they exist'
c.switch [:f,:force]
c.desc 'Use older-style .gems file instead of bundler-style Gemfile'
c.switch [:g,:dotgems]
c.action do |global_options,options,args|
raise "heroku_name is required" if args.empty?
if ShowOffUtils.heroku(args[0],options[:f],options[:p],options[:g])
puts "herokuized. run something like this to launch your heroku presentation:
heroku create #{args[0]}"
if options[:g]
puts " git add .gems config.ru"
else
puts " bundle install"
puts " git add Gemfile Gemfile.lock config.ru"
end
puts " git commit -m 'herokuized'
git push heroku master
"
if options[:p]
puts "CAREFUL: you are commiting your access password - anyone with read access to the repo can access the preso\n\n"
end
end
end
end
desc 'Serves the showoff presentation in the specified (or current) directory'
arg_name "[pres_dir]"
default_value "."
command :serve do |c|
c.desc 'Show verbose messaging'
c.switch :verbose
c.desc 'Port on which to run'
c.default_value "9090"
c.flag [:p,:port]
c.desc 'Host or ip to run on'
c.default_value "localhost"
c.flag [:h,:host]
c.desc 'JSON file used to describe presentation'
c.default_value "showoff.json"
c.flag [:f, :pres_file]
c.action do |global_options,options,args|
url = "http://#{options[:h]}:#{options[:p].to_i}"
puts "
-------------------------
Your ShowOff presentation is now starting up.
To view it plainly, visit [ #{url} ]
To run it from presenter view, go to: [ #{url}/presenter ]
-------------------------
"
ShowOff.run! :host => options[:h], :port => options[:p].to_i, :pres_file => options[:f], :pres_dir => args[0], :verbose => options[:verbose]
end
end
desc 'Add a new slide at the end in a given dir'
arg_name '[title]'
long_desc 'Outputs or creates a new slide. With -d and -n, a new slide is created in the given dir, numbered to appear as the last slide in that dir (use -u to avoid numbering). Without those, outputs the slide markdown to stdout (useful for shelling out from your editor). You may also specify a source file to use for a code slide'
command [:add,:new] do |c|
c.desc 'Don''t number the slide, use the given name verbatim'
c.switch [:u,:nonumber]
c.desc 'Include code from the given file as the slide body'
c.arg_name 'path to file'
c.flag [:s,:source]
c.desc 'Slide Type/Style'
c.arg_name 'valid showoff style/type'
c.default_value 'title'
c.flag [:t,:type,:style]
c.desc 'Slide dir (where to put a new slide file)'
c.arg_name 'dir'
c.flag [:d,:dir]
c.desc 'Slide name (name of the new slide file)'
c.arg_name 'basename'
c.flag [:n,:name]
c.action do |global_options,options,args|
title = args.join(" ")
ShowOffUtils.add_slide(:dir => options[:d],
:name => options[:n],
:title => title,
:number => !options[:u],
:code => options[:s],
:type => options[:t])
end
end
desc 'Generate static version of presentation'
arg_name 'name'
long_desc 'Creates a static, one page version of the presentation as {name}.html'
command [:static] do |c|
c.action do |global_options,options,args|
ShowOff.do_static(args[0])
end
end
pre do |global,command,options,args|
# Pre logic here
# Return true to proceed; false to abourt and not call the
# chosen command
true
end
post do |global,command,options,args|
# Post logic here
end
on_error do |exception|
# Error logic here
# return false to skip default error handling
true
end
exit run(ARGV)