Skip to content

Commit

Permalink
added showoff github command
Browse files Browse the repository at this point in the history
  • Loading branch information
schacon committed Dec 29, 2010
1 parent 7cc7c6a commit 71d00c5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -320,6 +321,10 @@ Setup your presentation to serve on Heroku

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.

=== <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.

Expand Down
8 changes: 8 additions & 0 deletions bin/showoff
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ command [:create,:init] do |c|
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|
ShowOffUtils.github
end
end

desc 'Serves the showoff presentation in the current directory'
desc 'Setup your presentation to serve on Heroku'
arg_name 'heroku_name'
Expand Down
19 changes: 19 additions & 0 deletions lib/showoff_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,25 @@ def self.heroku(name,force,password,use_dot_gems)
end
end

# 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.
Expand Down
1 change: 1 addition & 0 deletions showoff.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'lib/showoff'
Gem::Specification.new do |s|
s.name = "showoff"
s.version = ShowOff::Version
Expand Down

0 comments on commit 71d00c5

Please sign in to comment.