Browse files

added showoff github command

  • Loading branch information...
1 parent 7cc7c6a commit 71d00c5578183558d26c6913cd9bf072d03fb4ed @schacon schacon committed Dec 29, 2010
Showing with 33 additions and 0 deletions.
  1. +5 −0 README.rdoc
  2. +8 −0 bin/showoff
  3. +19 −0 lib/showoff_utils.rb
  4. +1 −0 showoff.gemspec
@@ -276,6 +276,7 @@ added where your cursor was. Binding this to a keybinding can allow you to add
[<tt>create</tt>] Create new showoff presentation
[<tt>help</tt>] Shows list of commands or help for one command
[<tt>heroku</tt>] Setup your presentation to serve on Heroku
+[<tt>github</tt>] Setup your presentation to serve on GitHub Pages
[<tt>serve</tt>] Serves the showoff presentation in the current directory
[<tt>static</tt>] Generate static version of presentation
@@ -320,6 +321,10 @@ Setup your presentation to serve on Heroku
Creates the Gemfile and 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.
+=== <tt>github</tt>
+Generates a static version of your site and puts it in a gh-pages branch for static serving on GitHub.
==== Options
These options are specified *after* the command.
@@ -33,6 +33,14 @@ command [:create,:init] do |c|
+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|
+ ShowOffUtils.github
+ end
desc 'Serves the showoff presentation in the current directory'
desc 'Setup your presentation to serve on Heroku'
arg_name 'heroku_name'
@@ -91,6 +91,25 @@ def self.heroku(name,force,password,use_dot_gems)
+ # generate a static version of the site into the gh-pages branch
+ def self.github
+ puts "Generating static content"
+ ShowOff.do_static(nil)
+ `git add static`
+ sha = `git write-tree`.chomp
+ tree_sha = `git rev-parse #{sha}:static`.chomp
+ `git read-tree HEAD` # reset staging to last-commit
+ ghp_sha = `git rev-parse gh-pages 2>/dev/null`.chomp
+ extra = ghp_sha != 'gh-pages' ? "-p #{ghp_sha}" : ''
+ commit_sha = `echo 'static presentation' | git commit-tree #{tree_sha} #{extra}`.chomp
+ `git update-ref refs/heads/gh-pages #{commit_sha}`
+ 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
# Makes a slide as a string.
# [title] title of the slide
# [classes] any "classes" to include, such as 'smaller', 'transition', etc.
@@ -1,3 +1,4 @@
+require 'lib/showoff' do |s| = "showoff"
s.version = ShowOff::Version

0 comments on commit 71d00c5

Please sign in to comment.