more cleanup work
This commit is contained in:
parent
c45c5a5a43
commit
f6a0f5ba41
2
Rakefile
2
Rakefile
|
@ -7,7 +7,7 @@ begin
|
||||||
s.email = "john@coswellproductions.com"
|
s.email = "john@coswellproductions.com"
|
||||||
s.homepage = "http://github.com/johnbintz/s6-gen"
|
s.homepage = "http://github.com/johnbintz/s6-gen"
|
||||||
s.description = "Create new S6 presenations using Haml"
|
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.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*"]
|
||||||
s.add_dependency 'haml'
|
s.add_dependency 'haml'
|
||||||
end
|
end
|
||||||
|
|
|
@ -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
|
|
@ -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
|
|
|
@ -1,3 +1,4 @@
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
|
require 's6-gen/generator'
|
||||||
|
|
||||||
Dir[File.join(File.dirname(__FILE__), 'rake/*.rb')].each { |file| require file }
|
Dir[File.join(File.dirname(__FILE__), 'rake/*.rb')].each { |file| require file }
|
||||||
|
|
|
@ -1,50 +1,9 @@
|
||||||
require 's6-gen'
|
|
||||||
require 's6-gen/presentation'
|
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
require 'compass'
|
|
||||||
require 'sass'
|
|
||||||
|
|
||||||
module S6Gen
|
include S6Gen::Generator
|
||||||
module RakeHelper
|
|
||||||
def all!
|
|
||||||
html!
|
|
||||||
css!
|
|
||||||
end
|
|
||||||
|
|
||||||
def html!
|
@source_dir ||= 'src'
|
||||||
raise "No src/index.haml file found!" if !File.exist?('src/index.haml')
|
@target_dir ||= 'public'
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
namespace :s6 do
|
namespace :s6 do
|
||||||
desc "Regenerate presentation index.html file"
|
desc "Regenerate presentation index.html file"
|
||||||
|
@ -64,7 +23,7 @@ namespace :s6 do
|
||||||
task :watch do
|
task :watch do
|
||||||
require 'directory_watcher'
|
require 'directory_watcher'
|
||||||
|
|
||||||
watcher = DirectoryWatcher.new 'src', :pre_load => true
|
watcher = DirectoryWatcher.new @source_dir, :pre_load => true
|
||||||
watcher.interval = 1
|
watcher.interval = 1
|
||||||
watcher.add_observer do |*args|
|
watcher.add_observer do |*args|
|
||||||
args.each { |e| puts e }
|
args.each { |e| puts e }
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
namespace :server do
|
||||||
|
desc "Start Thin"
|
||||||
|
task :thin do
|
||||||
|
system %{thin start}
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,19 +11,21 @@
|
||||||
%script{:src => 'jquery/jquery-ui-1.7.2.effects.min.js', :type => 'text/javascript'}
|
%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.core.js', :type => 'text/javascript'}
|
||||||
%script{:src => 's6/shared/slides.js', :type => 'text/javascript'}
|
%script{:src => 's6/shared/slides.js', :type => 'text/javascript'}
|
||||||
|
|
||||||
:javascript
|
:javascript
|
||||||
$(function() {
|
function updatePermaLink() {
|
||||||
var center;
|
$('#plink').get(0).href = window.location.pathname + '#slide' + snum;
|
||||||
center = function() {
|
|
||||||
setTimeout(function() {
|
var padding = 20;
|
||||||
$('.center').each(function() {
|
|
||||||
$(this).css('left', ($(window).width() - $(this).width()) / 2);
|
var availableWidth = $(window).width() - padding;
|
||||||
});
|
var availableHeight = $('.presentation > .slide:visible').height() - padding;
|
||||||
center();
|
|
||||||
}, 50);
|
$('.center').each(function() {
|
||||||
};
|
$(this).css('left', (availableWidth - $(this).width()) / 2);
|
||||||
center();
|
$(this).css('top', (availableHeight - $(this).height()) / 2);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
%body
|
%body
|
||||||
.layout
|
.layout
|
||||||
.background
|
.background
|
||||||
|
|
Loading…
Reference in New Issue