middleman-kss 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +12 -0
- data/features/helper.feature +16 -0
- data/features/support/env.rb +5 -0
- data/fixtures/test-app/config.rb +1 -0
- data/fixtures/test-app/source/css/test.css +15 -0
- data/fixtures/test-app/source/styleblocks/_buttons.html.erb +3 -0
- data/fixtures/test-app/source/styleguide.html.md.erb +13 -0
- data/lib/middleman-kss/extension.rb +26 -17
- data/lib/middleman-kss/version.rb +1 -1
- data/middleman-kss.gemspec +3 -3
- metadata +19 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b7bce4a832b29d26b1ad37f71974534425c2d54
|
4
|
+
data.tar.gz: 2faeb01d47817a1ae87cbd73a5e960c808a79425
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a61853655503fba484196d966c36dc084ba809d800db1e6193f5379b89358f2d528a5ec2968bc6fc57fa673037f2320b904ad01084cf9abc59099030dde37a81
|
7
|
+
data.tar.gz: 88a88f44e572fe62732bdb03923ca61dc8d5a0011021bdf25a7f00e5f5342b14735ffff5a1934e5786b2871eead2f9cf30862186fa0dc5f95cf64b3a62477377
|
data/Rakefile
CHANGED
@@ -1 +1,13 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
require 'cucumber/rake/task'
|
4
|
+
|
5
|
+
Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
|
6
|
+
exempt_tags = ""
|
7
|
+
exempt_tags << "--tags ~@nojava " if RUBY_PLATFORM == "java"
|
8
|
+
t.cucumber_opts = "--color --tags ~@wip #{exempt_tags} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'rake/clean'
|
12
|
+
|
13
|
+
task :test => ["cucumber"]
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Feature: Syntax highlighting with the "code" helper method
|
2
|
+
|
3
|
+
Scenario: Renders the styleguide
|
4
|
+
Given the Server is running at "test-app"
|
5
|
+
When I go to "/styleguide.html"
|
6
|
+
Then I should see '<h1>Styleguide</h1>'
|
7
|
+
|
8
|
+
Scenario: Renders plain styleblock
|
9
|
+
Given the Server is running at "test-app"
|
10
|
+
When I go to "/styleguide.html"
|
11
|
+
Then I should see '<button class="btn">Button</button>'
|
12
|
+
|
13
|
+
Scenario: Renders pseudo classes when section is found
|
14
|
+
Given the Server is running at "test-app"
|
15
|
+
When I go to "/styleguide.html"
|
16
|
+
Then I should see '<button class="btn pseudo-class-hover">Button</button>'
|
@@ -0,0 +1 @@
|
|
1
|
+
activate :kss, :kss_dir => 'css'
|
@@ -28,6 +28,8 @@ module Middleman
|
|
28
28
|
end
|
29
29
|
|
30
30
|
module Helpers
|
31
|
+
DEFAULT_STYLEGUIDE_BLOCK_FILE = '_styleguide_block.html.erb'
|
32
|
+
|
31
33
|
# Renders a styleblock with or without styleguide information.
|
32
34
|
#
|
33
35
|
# @param [String] tile
|
@@ -40,29 +42,26 @@ module Middleman
|
|
40
42
|
# @return [String] Generated HTML.
|
41
43
|
#
|
42
44
|
def styleblock(tile, options = {})
|
43
|
-
extension_options = ::Middleman::KSS.options
|
44
|
-
|
45
|
-
# Parse the KSS style guide once per request (because it might change a lot, yo)
|
46
|
-
unless request.has_key?(:styleguide)
|
47
|
-
request[:styleguide] = ::Kss::Parser.new(File.join(self.source_dir, extension_options[:kss_dir]))
|
48
|
-
end
|
49
|
-
|
50
|
-
@styleguide = request[:styleguide]
|
51
|
-
|
52
45
|
tile_file = "_#{tile}.html.erb"
|
53
|
-
# TODO: remove "styleblocks" magic string
|
54
46
|
tile_path = File.join(self.source_dir, "styleblocks", tile_file)
|
55
|
-
|
47
|
+
tile_template = ::Tilt.new(tile_path)
|
48
|
+
|
49
|
+
@block_html = tile_template.render
|
50
|
+
@styleguide = self.get_styleguide
|
56
51
|
|
57
52
|
if options.has_key?(:section)
|
58
53
|
@section = @styleguide.section(options[:section])
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
54
|
+
raise "Section must have a description. Section #{options[:section]} does not have one or section does not exist." if @section.description.blank?
|
55
|
+
end
|
56
|
+
|
57
|
+
if @section
|
58
|
+
# Render the styleguide block
|
59
|
+
styleguide_block_path = File.join(File.dirname(__FILE__), DEFAULT_STYLEGUIDE_BLOCK_FILE)
|
60
|
+
template = ::Tilt.new(styleguide_block_path)
|
61
|
+
return template.render(self)
|
63
62
|
else
|
64
|
-
|
65
|
-
|
63
|
+
# Render just the HTML without the $modifier_class thingies
|
64
|
+
return @block_html.gsub('$modifier_class', '').gsub(' class=""', '').prepend('<div class="styleguide-styleblock">') << '</div>'
|
66
65
|
end
|
67
66
|
end
|
68
67
|
|
@@ -77,6 +76,16 @@ module Middleman
|
|
77
76
|
markdown.render(input)
|
78
77
|
end
|
79
78
|
|
79
|
+
def get_styleguide
|
80
|
+
# Parse the KSS style guide once per request (because it probably changes every request)
|
81
|
+
unless request.has_key?(:styleguide)
|
82
|
+
extension_options = ::Middleman::KSS.options
|
83
|
+
request[:styleguide] = ::Kss::Parser.new(File.join(self.source_dir, extension_options[:kss_dir]))
|
84
|
+
end
|
85
|
+
|
86
|
+
return request[:styleguide]
|
87
|
+
end
|
88
|
+
|
80
89
|
end
|
81
90
|
end
|
82
91
|
end
|
data/middleman-kss.gemspec
CHANGED
@@ -19,11 +19,11 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
|
-
spec.required_ruby_version = '>= 1.
|
22
|
+
spec.required_ruby_version = '>= 1.9.2'
|
23
23
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
24
24
|
spec.add_development_dependency 'rake'
|
25
25
|
|
26
|
-
spec.add_runtime_dependency('middleman-core', '
|
27
|
-
spec.add_runtime_dependency('kss', '~> 0.
|
26
|
+
spec.add_runtime_dependency('middleman-core', '~> 3.0')
|
27
|
+
spec.add_runtime_dependency('kss', '~> 0.5.0')
|
28
28
|
spec.add_runtime_dependency('redcarpet', '~> 2.2.2')
|
29
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-kss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antti-Jussi Kovalainen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,30 +42,30 @@ dependencies:
|
|
42
42
|
name: middleman-core
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.0
|
47
|
+
version: '3.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.0
|
54
|
+
version: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: kss
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.5.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.5.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: redcarpet
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +94,12 @@ files:
|
|
94
94
|
- README.md
|
95
95
|
- Rakefile
|
96
96
|
- TODO.md
|
97
|
+
- features/helper.feature
|
98
|
+
- features/support/env.rb
|
99
|
+
- fixtures/test-app/config.rb
|
100
|
+
- fixtures/test-app/source/css/test.css
|
101
|
+
- fixtures/test-app/source/styleblocks/_buttons.html.erb
|
102
|
+
- fixtures/test-app/source/styleguide.html.md.erb
|
97
103
|
- lib/middleman-kss.rb
|
98
104
|
- lib/middleman-kss/_styleguide_block.html.erb
|
99
105
|
- lib/middleman-kss/extension.rb
|
@@ -112,7 +118,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
118
|
requirements:
|
113
119
|
- - '>='
|
114
120
|
- !ruby/object:Gem::Version
|
115
|
-
version: 1.
|
121
|
+
version: 1.9.2
|
116
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
123
|
requirements:
|
118
124
|
- - '>='
|
@@ -124,4 +130,7 @@ rubygems_version: 2.0.5
|
|
124
130
|
signing_key:
|
125
131
|
specification_version: 4
|
126
132
|
summary: KSS (Knyle Style Sheets) helpers for Middleman
|
127
|
-
test_files:
|
133
|
+
test_files:
|
134
|
+
- features/helper.feature
|
135
|
+
- features/support/env.rb
|
136
|
+
has_rdoc:
|