Created
August 7, 2014 18:04
-
-
Save endymion/17a8c16453e21334abcf to your computer and use it in GitHub Desktop.
Building a static site with gollum-lib, for deployment to Amazon S3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fileutils' | |
require 'yaml' | |
require 'haml' | |
require 'sass' | |
require 'gollum-lib' | |
desc 'Build a static web site from the Gollum wiki.' | |
task :build do |t, args| | |
puts "Generating static web site from the wiki, in _site..." | |
mkdir_p('_site') | |
wiki = Gollum::Wiki.new(Dir.pwd) | |
sidebar = wiki.page('_Sidebar').formatted_data | |
wiki.pages.each do |page| | |
@page = page | |
puts "Converting #{page.name}..." | |
File.open('_site/' + @page.name + '.html', 'w') do |file| | |
file.write Haml::Engine.new(File.read('static/layout.haml')).render( | |
Object.new, { page: page, sidebar: sidebar }) | |
end | |
end | |
puts "Copying images..." | |
cp_r 'images/', '_site/images/' | |
puts "Generating styles..." | |
File.open('_site/styles.css', 'w') do |file| | |
file.write Sass::Engine.new(File.read('static/styles.scss'), { :syntax => :scss }).render | |
end | |
puts "Done! The static site is in _site, and you can deploy it to S3 with 'rake deploy:s3'" | |
end | |
namespace :deploy do | |
desc 'Deploy the static site to Amazon S3. Requires config/aws.yml' | |
task :s3, [:version] do |t, args| | |
puts "Deploying _site folder to Amazon S3..." | |
properties = YAML.load_file('config/aws.yml') | |
puts "Bucket: #{database = properties['bucket']}" | |
system("s3cmd sync _site/* s3://#{properties['bucket']}/ --acl-public") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment