Skip to content

Commit 71d00c5

Browse files
committed
added showoff github command
1 parent 7cc7c6a commit 71d00c5

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

README.rdoc

+5
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ added where your cursor was. Binding this to a keybinding can allow you to add
276276
[<tt>create</tt>] Create new showoff presentation
277277
[<tt>help</tt>] Shows list of commands or help for one command
278278
[<tt>heroku</tt>] Setup your presentation to serve on Heroku
279+
[<tt>github</tt>] Setup your presentation to serve on GitHub Pages
279280
[<tt>serve</tt>] Serves the showoff presentation in the current directory
280281
[<tt>static</tt>] Generate static version of presentation
281282

@@ -320,6 +321,10 @@ Setup your presentation to serve on Heroku
320321

321322
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.
322323

324+
=== <tt>github</tt>
325+
326+
Generates a static version of your site and puts it in a gh-pages branch for static serving on GitHub.
327+
323328
==== Options
324329
These options are specified *after* the command.
325330

bin/showoff

+8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ command [:create,:init] do |c|
3333
end
3434
end
3535

36+
desc 'Puts your showoff presentation into a gh-pages branch'
37+
long_desc 'Generates a static version of your presentation into your gh-pages branch for publishing to GitHub Pages'
38+
command :github do |c|
39+
c.action do |global_options,options,args|
40+
ShowOffUtils.github
41+
end
42+
end
43+
3644
desc 'Serves the showoff presentation in the current directory'
3745
desc 'Setup your presentation to serve on Heroku'
3846
arg_name 'heroku_name'

lib/showoff_utils.rb

+19
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,25 @@ def self.heroku(name,force,password,use_dot_gems)
9191
end
9292
end
9393

94+
# generate a static version of the site into the gh-pages branch
95+
def self.github
96+
puts "Generating static content"
97+
ShowOff.do_static(nil)
98+
`git add static`
99+
sha = `git write-tree`.chomp
100+
tree_sha = `git rev-parse #{sha}:static`.chomp
101+
`git read-tree HEAD` # reset staging to last-commit
102+
ghp_sha = `git rev-parse gh-pages 2>/dev/null`.chomp
103+
extra = ghp_sha != 'gh-pages' ? "-p #{ghp_sha}" : ''
104+
commit_sha = `echo 'static presentation' | git commit-tree #{tree_sha} #{extra}`.chomp
105+
`git update-ref refs/heads/gh-pages #{commit_sha}`
106+
puts "I've updated your 'gh-pages' branch with the static version of your presentation."
107+
puts "Push it to GitHub to publish it. Probably something like:"
108+
puts
109+
puts " git push origin gh-pages"
110+
puts
111+
end
112+
94113
# Makes a slide as a string.
95114
# [title] title of the slide
96115
# [classes] any "classes" to include, such as 'smaller', 'transition', etc.

showoff.gemspec

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
require 'lib/showoff'
12
Gem::Specification.new do |s|
23
s.name = "showoff"
34
s.version = ShowOff::Version

0 commit comments

Comments
 (0)