all repos — h3rald @ cc50c9eee3f6eb9771d49973b6bbe0db9ef6a6ec

The sources of https://h3rald.com

tasks/site.rake

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
require 'rubygems'
require 'extlib'
require 'pathname'
require 'fileutils'


namespace :site do

	task :clear_output do
		output = Pathname.new(Dir.pwd)/'output'
		puts "Deleting all files in output dir..."
		output.rmtree
	end

	task :update => [:copy_files] do
		system "nanoc co"
	end

	task :run => [:copy_files] do
		system "nanoc aco"
	end

	task :rebuild => [:clear_output, :copy_files, :update] do
	end

	task :copy_files do
		pwd = Pathname.new Dir.pwd
		file_dirs = [Pathname.new(pwd/'files/images'), 
			Pathname.new(pwd/'files/js'),
			Pathname.new(pwd/'files/css')]
		file_dirs.each do |d|
			d.find do |src|
				if src.file? then
					rel_path = src.relative_path_from(pwd/'files').to_s
					dst = Pathname.new(pwd/"output/#{rel_path}")
					if !dst.exist? || dst.exist? && !FileUtils.cmp(dst.to_s, src.to_s) then
						dst.parent.mkpath
						FileUtils.cp src.to_s, dst.to_s
						puts "Copied '#{src}'."
					end
				end
			end
		end
	end

end