Created
June 25, 2013 17:00
-
-
Save plexus/5860231 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rb-inotify' | |
BUILD='bundle exec mdpress --latex -s plexus presentation.md' | |
class WatchTask | |
def initialize(name, opts = {}) | |
Rake::Task.define_task name do | |
Array(opts[:watch]).each do |pattern| | |
notifier.watch(pattern, :modify, :create) do |event| | |
system(opts[:exec]) | |
puts "OK" | |
end | |
at_exit { | |
notifier.run | |
} | |
end | |
end | |
end | |
def notifier | |
@notifier ||= INotify::Notifier.new | |
end | |
end | |
namespace :mdpress do | |
desc 'watch the presentation and theme for changes and rebuild' | |
WatchTask.new( | |
:watch, | |
:watch => [ | |
'presentation.md', | |
'themes/plexus.css', | |
'themes/plexus.html' | |
], | |
:exec => BUILD | |
) | |
desc 'build the impress.js presentation' | |
task :build do | |
sh BUILD | |
end | |
end | |
desc 'push a preview version to a unique URI' | |
task :preview => 'mdpress:build' do | |
require 'securerandom' | |
secret = SecureRandom.hex(8) | |
sh "scp -r presentation arnebrasseur@arnebrasseur.net:subdomains/www/rulu-#{secret}" | |
url = "http://arnebrasseur.net/rulu-#{secret}/index.html" | |
sh "chromium-browser #{url}" | |
end | |
desc 'Publish the final result after the talk' | |
task :publish => 'mdpress:build' do | |
require 'rainbow' | |
puts '='*80 | |
puts 'Publising slides...'.center(80) | |
sh "scp -r presentation arnebrasseur@arnebrasseur.net:subdomains/www/talks/rulu2013 > /dev/null" | |
puts 'DONE!'.center(80).foreground(:green) | |
puts '='*80 | |
puts | |
[ | |
"Slides are available at".center(80), | |
'http://arnebrasseur.net/talks/rulu2013'.center(80).foreground(:red), | |
"Thank you! <3".center(80).foreground(:green) | |
].each do |str| | |
puts str | |
puts | |
end | |
puts '='*80 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment