initial commit

This commit is contained in:
John Bintz 2010-05-20 11:40:16 -04:00
commit 9446e9e7bd
9 changed files with 133 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.loadpath
.project

16
Rakefile Normal file
View File

@ -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

3
lib/s6-gen.rb Normal file
View File

@ -0,0 +1,3 @@
module S6Gen
ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
end

View File

@ -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

3
lib/s6-gen/rake.rb Normal file
View File

@ -0,0 +1,3 @@
require 'rubygems'
Dir[File.join(File.dirname(__FILE__), 'rake/*.rb')].each { |file| require file }

View File

@ -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

View File

@ -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

1
s6 Submodule

@ -0,0 +1 @@
Subproject commit 8291d72c6f003612b4005f016787106e26c6666d

11
templates/layout.haml Normal file
View File

@ -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