jekyll-sass 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/jekyll-sass.gemspec +23 -0
- data/lib/jekyll-sass.rb +62 -0
- data/lib/jekyll-sass/version.rb +5 -0
- data/readme.md +40 -0
- metadata +82 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/jekyll-sass.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "jekyll-sass/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "jekyll-sass"
|
7
|
+
s.version = Jekyll::Sass::VERSION
|
8
|
+
s.authors = ["Jason Kozak"]
|
9
|
+
s.email = ["jay@noctal.com"]
|
10
|
+
s.homepage = "http://github.com/noct/jekyll-sass"
|
11
|
+
s.summary = %q{Sass CSS converter for Jekyll}
|
12
|
+
s.description = %q{Convert Sass SCSS files to standard CSS files as part of your Jekyll build.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "jekyll-sass"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_runtime_dependency('jekyll', [">= 0.10.0"])
|
22
|
+
s.add_runtime_dependency('sass', [">= 3.0.0"])
|
23
|
+
end
|
data/lib/jekyll-sass.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require "jekyll-sass/version"
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Sass
|
5
|
+
require 'sass'
|
6
|
+
class SassCssFile < StaticFile
|
7
|
+
|
8
|
+
# Obtain destination path.
|
9
|
+
# +dest+ is the String path to the destination dir
|
10
|
+
#
|
11
|
+
# Returns destination file path.
|
12
|
+
def destination(dest)
|
13
|
+
File.join(dest, @dir, @name.sub(/scss$/, 'css'))
|
14
|
+
end
|
15
|
+
|
16
|
+
# Convert the scss file into a css file.
|
17
|
+
# +dest+ is the String path to the destination dir
|
18
|
+
#
|
19
|
+
# Returns false if the file was not modified since last time (no-op).
|
20
|
+
def write(dest)
|
21
|
+
dest_path = destination(dest)
|
22
|
+
|
23
|
+
return false if File.exist? dest_path and !modified?
|
24
|
+
@@mtimes[path] = mtime
|
25
|
+
|
26
|
+
FileUtils.mkdir_p(File.dirname(dest_path))
|
27
|
+
begin
|
28
|
+
content = File.read(path)
|
29
|
+
engine = ::Sass::Engine.new( content, :syntax => :scss, :load_paths => ["#{@site.source}#{@dir}"], :style => :compressed )
|
30
|
+
content = engine.render
|
31
|
+
File.open(dest_path, 'w') do |f|
|
32
|
+
f.write(content)
|
33
|
+
end
|
34
|
+
rescue => e
|
35
|
+
STDERR.puts "Sass failed generating '#{dest_path}': #{e.message}"
|
36
|
+
false
|
37
|
+
end
|
38
|
+
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
class SassCssGenerator < Generator
|
45
|
+
safe true
|
46
|
+
|
47
|
+
# Jekyll will have already added the *.scss files as Jekyll::StaticFile
|
48
|
+
# objects to the static_files array. Here we replace those with a
|
49
|
+
# SassCssFile object.
|
50
|
+
def generate(site)
|
51
|
+
site.static_files.clone.each do |sf|
|
52
|
+
if sf.kind_of?(Jekyll::StaticFile) && sf.path =~ /\.scss$/
|
53
|
+
site.static_files.delete(sf)
|
54
|
+
name = File.basename(sf.path)
|
55
|
+
destination = File.dirname(sf.path).sub(site.source, '')
|
56
|
+
site.static_files << SassCssFile.new(site, site.source, destination, name)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/readme.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
Less for Jekyll
|
2
|
+
===============
|
3
|
+
|
4
|
+
This gem provides a [Jekyll](http://github.com/mojombo/jekyll) converter for
|
5
|
+
[Sass](http://http://sass-lang.com//) files.
|
6
|
+
|
7
|
+
Basic Setup
|
8
|
+
-----------
|
9
|
+
Install the gem:
|
10
|
+
|
11
|
+
[sudo] gem install jekyll-sass
|
12
|
+
|
13
|
+
In a plugin file within your Jekyll project's _plugins directory:
|
14
|
+
|
15
|
+
# _plugins/my-plugin.rb
|
16
|
+
require "jekyll-sass"
|
17
|
+
|
18
|
+
Place .scss files anywhere in your Jekyll project's directory. These will be
|
19
|
+
converted to .css files with the same directory path and filename. For example,
|
20
|
+
if you create a Less file at _css/my-stuff/styles.scss, then the corresponding
|
21
|
+
css file would end up at _css/my-stuff/styles.css_.
|
22
|
+
|
23
|
+
Bundler Setup
|
24
|
+
-------------
|
25
|
+
Already using bundler to manage gems for your Jekyll project? Then just add
|
26
|
+
|
27
|
+
gem "jekyll-sass"
|
28
|
+
|
29
|
+
to your gemfile and create the following plugin in your projects _plugins
|
30
|
+
directory. I've called mine bundler.rb. This will automatically require all
|
31
|
+
of the gems specified in your Gemfile.
|
32
|
+
|
33
|
+
# _plugins/bundler.rb
|
34
|
+
require "rubygems"
|
35
|
+
require "bundler/setup"
|
36
|
+
Bundler.require(:default)
|
37
|
+
|
38
|
+
Credit
|
39
|
+
------
|
40
|
+
This gem is based on [Roger López's](https://github.com/zroger) [jekyll-less](https://github.com/zroger/jekyll-less).
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-sass
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jason Kozak
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2012-07-01 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: jekyll
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.10.0
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: sass
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 3.0.0
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id002
|
37
|
+
description: Convert Sass SCSS files to standard CSS files as part of your Jekyll build.
|
38
|
+
email:
|
39
|
+
- jay@noctal.com
|
40
|
+
executables: []
|
41
|
+
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files: []
|
45
|
+
|
46
|
+
files:
|
47
|
+
- .gitignore
|
48
|
+
- Gemfile
|
49
|
+
- Rakefile
|
50
|
+
- jekyll-sass.gemspec
|
51
|
+
- lib/jekyll-sass.rb
|
52
|
+
- lib/jekyll-sass/version.rb
|
53
|
+
- readme.md
|
54
|
+
homepage: http://github.com/noct/jekyll-sass
|
55
|
+
licenses: []
|
56
|
+
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
|
+
requirements: []
|
75
|
+
|
76
|
+
rubyforge_project: jekyll-sass
|
77
|
+
rubygems_version: 1.8.16
|
78
|
+
signing_key:
|
79
|
+
specification_version: 3
|
80
|
+
summary: Sass CSS converter for Jekyll
|
81
|
+
test_files: []
|
82
|
+
|