diff --git a/doc-src/Gemfile b/doc-src/Gemfile index b2d5adb9..bdcf01b0 100644 --- a/doc-src/Gemfile +++ b/doc-src/Gemfile @@ -1,3 +1,5 @@ +gem 'fssm' gem 'nanoc3', :require_as => false gem 'rdiscount' -gem 'thor' \ No newline at end of file +gem 'serve' +gem 'thor' diff --git a/doc-src/Rakefile b/doc-src/Rakefile index 5571a53f..80a47f7a 100644 --- a/doc-src/Rakefile +++ b/doc-src/Rakefile @@ -1 +1,62 @@ +require File.join(File.dirname(__FILE__), 'vendor/gems/environment') require 'nanoc3/tasks' +$: << "lib" + +desc "watch for changes and recompile" +task :watch do + require 'fssm' + require 'nanoc3' + require 'nanoc3/cli' + Dir['lib/commands/*.rb'].map{|d| d[4..-1]}.sort.each { |f| require f } + Dir['lib/data_sources/*.rb'].map{|d| d[4..-1]}.sort.each { |f| require f } + Nanoc3::NotificationCenter.on(:compilation_started) do |rep| + puts "Compiling: #{rep.path}" + end + + rebuild_site = lambda do |base, relative| + if relative + puts ">>> Change Detected to #{relative} <<<" + else + puts ">>> Compiling <<<" + end + start = Time.now + # Nanoc3::CLI::Base.new.run(["co"]) + site = Nanoc3::Site.new('.') + site.load_data + begin + site.compiler.run + puts ">>> Done in #{((Time.now - start)*10000).round.to_f / 10}ms <<<" + `growlnotify -m "Compilation Complete" --image misc/success-icon.png; exit 0` + rescue Exception => e + puts ">>> ERROR: #{e.message} <<<" + `growlnotify -m "Compilation Error!" --image misc/error-icon.png; exit 0` + end + end + rebuild_site.call(nil,nil) + + puts ">>> Watching for Changes <<<" + puts "Run: ./bin/serve .." + monitor = FSSM::Monitor.new + monitor.path("#{File.dirname(__FILE__)}/content", '**/*') do + update(&rebuild_site) + delete(&rebuild_site) + create(&rebuild_site) + end + monitor.path("#{File.dirname(__FILE__)}/lib", '**/*') do + update(&rebuild_site) + delete(&rebuild_site) + create(&rebuild_site) + end + monitor.path("#{File.dirname(__FILE__)}/layouts", '**/*') do + update(&rebuild_site) + delete(&rebuild_site) + create(&rebuild_site) + end + monitor.path("#{File.dirname(__FILE__)}/assets", '**/*') do + update(&rebuild_site) + delete(&rebuild_site) + create(&rebuild_site) + end + monitor.run +end + diff --git a/doc-src/misc/error-icon.png b/doc-src/misc/error-icon.png new file mode 100644 index 00000000..0ca9f671 Binary files /dev/null and b/doc-src/misc/error-icon.png differ diff --git a/doc-src/misc/success-icon.png b/doc-src/misc/success-icon.png new file mode 100644 index 00000000..584de4ac Binary files /dev/null and b/doc-src/misc/success-icon.png differ