commit 9446e9e7bdf5a90bc583c3b48478f0c84ca2cad5 Author: John Bintz Date: Thu May 20 11:40:16 2010 -0400 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6eb137d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.loadpath +.project + diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..4c66117 --- /dev/null +++ b/Rakefile @@ -0,0 +1,16 @@ +begin + require 'jeweler' + Jeweler::Tasks.new do |s| + s.name = "s6-gen" + s.executables = "new-s6-presentation" + s.summary = "Create new S6 presenations using Haml" + s.email = "john@coswellproductions.com" + s.homepage = "http://github.com/johnbintz/s6-gen" + s.description = "Create new S6 presenations using Haml" + s.authors = ["JJohn Bintz"] + s.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*"] + s.add_dependency 'haml' + end +rescue LoadError + puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com" +end diff --git a/lib/s6-gen.rb b/lib/s6-gen.rb new file mode 100644 index 0000000..de8c070 --- /dev/null +++ b/lib/s6-gen.rb @@ -0,0 +1,3 @@ +module S6Gen + ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) +end diff --git a/lib/s6-gen/presentation.rb b/lib/s6-gen/presentation.rb new file mode 100644 index 0000000..4c21116 --- /dev/null +++ b/lib/s6-gen/presentation.rb @@ -0,0 +1,18 @@ +require 'haml' + +module S6Gen + class Presentation + def self.render(file, root) + presentation = self.new(root) + presentation.render(file) + end + + def initialize(root) + @root = root + end + + def render(file) + Haml::Engine.new(File.read(File.join(@root, file))).to_html(self) + end + end +end diff --git a/lib/s6-gen/rake.rb b/lib/s6-gen/rake.rb new file mode 100644 index 0000000..d991a58 --- /dev/null +++ b/lib/s6-gen/rake.rb @@ -0,0 +1,3 @@ +require 'rubygems' + +Dir[File.join(File.dirname(__FILE__), 'rake/*.rb')].each { |file| require file } diff --git a/lib/s6-gen/rake/generate.rb b/lib/s6-gen/rake/generate.rb new file mode 100644 index 0000000..921908b --- /dev/null +++ b/lib/s6-gen/rake/generate.rb @@ -0,0 +1,68 @@ +require 's6-gen' +require 's6-gen/presentation' +require 'fileutils' +require 'sass' + +module S6Gen + class RakeHelper + def self.all! + self.html! + self.css! + end + + def self.html! + raise "No src/index.haml file found!" if !File.exist?('src/index.haml') + + FileUtils.mkdir_p 'public' + + layout = File.exist?('src/layout.haml') ? 'src/layout.haml' : File.join(S6Gen::ROOT, 'templates/layout.haml') + File.open('public/index.html', 'w') do |file| + file.puts Haml::Engine.new(File.read(layout)).to_html(self) { S6Gen::Presentation.render('index.haml', 'src') } + end + end + + def self.css! + raise "No src/style.sass file found!" if !File.exist?('src/style.sass') + + FileUtils.mkdir_p 'public' + + File.open('public/style.css', 'w') do |file| + file.puts Sass::Engine.new(File.read('src/style.sass')).to_css + end + end + end +end + +namespace :s6 do + desc "Regenerate presentation index.html file" + task :regenerate_html do + S6Gen::RakeHelper.html! + end + + desc "Regenerate style.css" + task :regenerate_css do + S6Gen::RakeHelper.css! + end + + desc "Regenerate everything" + task :regenerate => [ :regenerate_html, :regenerate_css ] + + desc "Watch for changes and regenerate when needed" + task :watch do + require 'directory_watcher' + + watcher = DirectoryWatcher.new 'src', :pre_load => true + watcher.interval = 1 + watcher.add_observer do |*args| + args.each { |e| puts e } + + S6Gen::RakeHelper.all! + end + + puts ">> S6-Gen is watching for changes, press Enter to quit" + watcher.start + $stdin.gets + puts ">> Shutting down" + watcher.stop + end +end diff --git a/lib/s6-gen/rake/install_s6.rb b/lib/s6-gen/rake/install_s6.rb new file mode 100644 index 0000000..b20a759 --- /dev/null +++ b/lib/s6-gen/rake/install_s6.rb @@ -0,0 +1,10 @@ +require 's6-gen' +require 'fileutils' + +namespace :s6 do + desc "Install S6 into the public directory of this presentation" + task :install do + FileUtils.mkdir_p 'public' + FileUtils.cp_r File.join(S6Gen::ROOT, 's6'), 'public' + end +end diff --git a/s6 b/s6 new file mode 160000 index 0000000..8291d72 --- /dev/null +++ b/s6 @@ -0,0 +1 @@ +Subproject commit 8291d72c6f003612b4005f016787106e26c6666d diff --git a/templates/layout.haml b/templates/layout.haml new file mode 100644 index 0000000..e279dab --- /dev/null +++ b/templates/layout.haml @@ -0,0 +1,11 @@ +%html + %head + %title= @title + %meta{:name => :author, :content => @author} + %link{:rel => :stylesheet, :href => 'style.css', :type => 'text/css', :media => :screen} + %link{:rel => :stylesheet, :href => 's6/shared/outline.css', :type => 'text/css', :media => :screen} + %link{:rel => :stylesheet, :href => 's6/shared/print.css', :type => 'text/css', :media => :print} + %body + whoa + + = yield