lib/simple_site.rb in simple_site-0.0.1 vs lib/simple_site.rb in simple_site-0.0.2
- old
+ new
@@ -1,18 +1,34 @@
require 'aws/s3'
require 'uglifier'
+require 'simple_site/tasks'
+require 'simple_site/haml_context'
+require 'haml'
class SimpleSite
+ attr_reader :options
+
def initialize(options = {})
- @options = options
+ @options = {}
+ @options[:buckets] ||= [options.delete(:bucket)].compact
+ options[:buckets].each {|bucket| @options[:buckets] << bucket } unless options[:buckets].nil?
+ @options.merge!(options)
@options[:js_files] ||= Dir['_js/*.js']
- @options[:buckets] ||= []
end
+ def js_files=(files)
+ @options[:js_files] = files
+ end
+
+ def buckets=(buckets)
+ @options[:buckets] = buckets
+ end
+
def generate_html
- system "haml -r simple_site/haml_helper.rb _src/index.haml public/index.html"
+ engine = Haml::Engine.new(File.read('_src/index.haml'))
+ File.open('public/index.html', 'w') {|f| f.write(engine.render(SimpleSite::HamlContext.new)) }
puts "Regenerated site!"
end
def generate_css
system "sass _sass/style.sass public/css/style.css"
@@ -47,11 +63,11 @@
private
def deploy(file)
age = 7*24*60*60
options = {
:access => :public_read,
- :cache_control => "max-age=#{age}",
- :expires => age.from_now.httpdate
+ :cache_control => "max-age=#{age}"
+ # :expires => age.from_now.httpdate
}
puts " --> #{file}"
@options[:buckets].each do |bucket|
AWS::S3::S3Object.store(file, open(file), bucket, options)
end
\ No newline at end of file