more cleanup work

This commit is contained in:
John Bintz 2010-07-27 11:09:36 -04:00
parent c45c5a5a43
commit f6a0f5ba41
7 changed files with 74 additions and 76 deletions

View File

@ -7,7 +7,7 @@ begin
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.authors = ["John Bintz"]
s.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*"]
s.add_dependency 'haml'
end

48
lib/s6-gen/generator.rb Normal file
View File

@ -0,0 +1,48 @@
require 'haml'
require 'compass'
require 'sass'
require 'fileutils'
module S6Gen
module Generator
def all!
html!
css!
end
def html!
raise "No #{@source_dir}/index.haml file found!" if !File.exist?("#{@source_dir}/index.haml")
FileUtils.mkdir_p @target_dir
layout = File.exist?("#{@source_dir}/layout.haml") ? "#{@source_dir}/layout.haml" : File.join(S6Gen::ROOT, 'templates/layout.haml')
File.open("#{@target_dir}/index.html", 'w') do |file|
file.puts Haml::Engine.new(File.read(layout)).to_html(self) { render('index.haml') }
end
end
def css!
raise "No #{@source_dir}/style.sass file found!" if !File.exist?("#{@source_dir}/style.sass")
FileUtils.mkdir_p @target_dir
Compass.configuration do |config|
config.project_path = Dir.pwd
config.sass_dir = @source_dir
config.images_dir = File.join(@target_dir, 'graphics')
config.http_path = ""
config.http_images_path = 'graphics'
config.output_style = :compact
end
File.open("#{@target_dir}/style.css", 'w') do |file|
file.puts Sass::Engine.new(File.read("#{@source_dir}/style.sass"), Compass.sass_engine_options).to_css
end
end
def render(file)
Haml::Engine.new(File.read(File.join(@source_dir, file))).to_html(self)
end
end
end

View File

@ -1,18 +0,0 @@
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

View File

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

View File

@ -1,50 +1,9 @@
require 's6-gen'
require 's6-gen/presentation'
require 'fileutils'
require 'compass'
require 'sass'
module S6Gen
module RakeHelper
def all!
html!
css!
end
include S6Gen::Generator
def 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 css!
raise "No src/style.sass file found!" if !File.exist?('src/style.sass')
FileUtils.mkdir_p 'public'
Compass.configuration do |config|
config.project_path = Dir.pwd
config.sass_dir = 'src'
config.images_dir = File.join('public', 'graphics')
config.http_path = ""
config.http_images_path = 'graphics'
config.output_style = :compact
end
File.open('public/style.css', 'w') do |file|
file.puts Sass::Engine.new(File.read('src/style.sass'), Compass.sass_engine_options).to_css
end
end
end
end
include S6Gen::RakeHelper
@source_dir ||= 'src'
@target_dir ||= 'public'
namespace :s6 do
desc "Regenerate presentation index.html file"
@ -64,7 +23,7 @@ namespace :s6 do
task :watch do
require 'directory_watcher'
watcher = DirectoryWatcher.new 'src', :pre_load => true
watcher = DirectoryWatcher.new @source_dir, :pre_load => true
watcher.interval = 1
watcher.add_observer do |*args|
args.each { |e| puts e }

View File

@ -0,0 +1,6 @@
namespace :server do
desc "Start Thin"
task :thin do
system %{thin start}
end
end

View File

@ -11,19 +11,21 @@
%script{:src => 'jquery/jquery-ui-1.7.2.effects.min.js', :type => 'text/javascript'}
%script{:src => 's6/shared/slides.core.js', :type => 'text/javascript'}
%script{:src => 's6/shared/slides.js', :type => 'text/javascript'}
:javascript
$(function() {
var center;
center = function() {
setTimeout(function() {
function updatePermaLink() {
$('#plink').get(0).href = window.location.pathname + '#slide' + snum;
var padding = 20;
var availableWidth = $(window).width() - padding;
var availableHeight = $('.presentation > .slide:visible').height() - padding;
$('.center').each(function() {
$(this).css('left', ($(window).width() - $(this).width()) / 2);
});
center();
}, 50);
};
center();
$(this).css('left', (availableWidth - $(this).width()) / 2);
$(this).css('top', (availableHeight - $(this).height()) / 2);
});
}
%body
.layout
.background