From b6d901ae75aa1367f06962e9973579b2d022d506 Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Sun, 11 Mar 2012 22:57:53 +0000 Subject: [PATCH] Task for compiling Less --- Rakefile | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index cf975c3c9c..da49711ade 100644 --- a/Rakefile +++ b/Rakefile @@ -2,15 +2,21 @@ require "rubygems" require 'rake' require 'yaml' require 'time' +require 'less' SOURCE = "." +LESS = File.join(SOURCE, "assets", "themes", "twitter") # set theme here CONFIG = { 'version' => "0.2.9", 'themes' => File.join(SOURCE, "_includes", "themes"), 'layouts' => File.join(SOURCE, "_layouts"), 'posts' => File.join(SOURCE, "_posts"), 'post_ext' => "md", - 'theme_package_version' => "0.1.0" + 'theme_package_version' => "0.1.0", + 'less' => File.join(LESS, "less"), + 'css' => File.join(LESS, "css"), + 'input' => "style.less", + 'output' => "style.css" } # Path configuration helper @@ -98,6 +104,23 @@ task :preview do system "jekyll --auto --server" end # task :preview +desc "Compile Less" +task :lessc do + less = CONFIG['less'] + + input = File.join( less, CONFIG['input'] ) + output = File.join( CONFIG['css'], CONFIG['output'] ) + + source = File.open( input, "r" ).read + + parser = Less::Parser.new( :paths => [less] ) + tree = parser.parse( source ) + + File.open( output, "w+" ) do |f| + f.puts tree.to_css( :compress => true ) + end +end # task :lessc + # Public: Alias - Maintains backwards compatability for theme switching. task :switch_theme => "theme:switch"