middleman-kss 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/CONTRIBUTING.md +1 -0
- data/Gemfile +20 -0
- data/LICENSE +22 -0
- data/README.md +72 -0
- data/Rakefile +1 -0
- data/TODO.md +9 -0
- data/lib/middleman-kss.rb +7 -0
- data/lib/middleman-kss/_styleguide_block.html.erb +29 -0
- data/lib/middleman-kss/extension.rb +82 -0
- data/lib/middleman-kss/middleman_extension.rb +1 -0
- data/lib/middleman-kss/version.rb +5 -0
- data/middleman-kss.gemspec +28 -0
- metadata +123 -0
data/.gitignore
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
CONTRIBUTING.md
|
data/Gemfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'middleman-core'
|
4
|
+
gem 'redcarpet'
|
5
|
+
|
6
|
+
# Specify your gem's dependencies in middleman-kss.gemspec
|
7
|
+
gemspec
|
8
|
+
|
9
|
+
group :development do
|
10
|
+
gem 'rake', '~> 0.9.2'
|
11
|
+
gem 'rdoc', '~> 3.9'
|
12
|
+
gem 'yard', '~> 0.8.0'
|
13
|
+
end
|
14
|
+
|
15
|
+
group :test do
|
16
|
+
gem 'cucumber', '~> 1.2.0'
|
17
|
+
gem 'fivemat'
|
18
|
+
gem 'aruba', '~> 0.4.11'
|
19
|
+
gem 'rspec', '~> 2.7'
|
20
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Antti-Jussi Kovalainen (ajk.fi)
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# middleman-kss
|
2
|
+
|
3
|
+
`middleman-kss` provides [KSS][kss] helpers for
|
4
|
+
[Middleman](http://middlemanapp.com/). With these helpers, you can easily
|
5
|
+
insert KSS styleguide blocks. Great for creating styleguides or design
|
6
|
+
guidelines.
|
7
|
+
|
8
|
+
P.S. This gem was mainly created to be used with my
|
9
|
+
[middleman-styleguide-template][template], which I use for creating styleguides
|
10
|
+
and other documentation.
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your Middleman project Gemfile:
|
15
|
+
|
16
|
+
gem 'middleman-kss'
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Open your `config.rb` and add the required settings:
|
23
|
+
|
24
|
+
set :markdown_engine, :redcarpet
|
25
|
+
activate :kss, :kss_dir => 'stylesheets/external'
|
26
|
+
|
27
|
+
Note: The :kss_dir should be set so all the `url('...')`s in your CSS map correctly.
|
28
|
+
|
29
|
+
Create a `styleblocks`-directory under `source/`
|
30
|
+
|
31
|
+
$ mkdir source/styleblocks
|
32
|
+
|
33
|
+
And read the next chapter for usage instructions.
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
Okay, here's the deal:
|
38
|
+
|
39
|
+
1. Write your CSS/SCSS/LESS in [KSS][kss]
|
40
|
+
2. Insert your CSS/SCSS/LESS into the `kss_dir`
|
41
|
+
3. Write the HTML for individual style blocks into `source/styleblocks`
|
42
|
+
4. Use the helpers to print the style blocks
|
43
|
+
|
44
|
+
See my [middleman-styleguide-template][template] for examples!
|
45
|
+
|
46
|
+
### Helpers
|
47
|
+
|
48
|
+
**styleblock** <%= styleblock 'filename', [section: '1.1'] %>
|
49
|
+
|
50
|
+
Renders the styleblock named `filename`.
|
51
|
+
|
52
|
+
*Optional:* `section` parameter maps the
|
53
|
+
rendered styleblock to a KSS section, which will expand the section into a fully
|
54
|
+
documented KSS styleblock with all the available classes and such.
|
55
|
+
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
Contributions are most welcome! And well-tested and documented contributions are
|
60
|
+
more welcome than others ;)
|
61
|
+
|
62
|
+
1. [Fork the repository][fork]
|
63
|
+
2. [Create a branch][branch] (`git checkout -b my-new-feature`)
|
64
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
65
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
66
|
+
5. [Create a pull request][pr]
|
67
|
+
|
68
|
+
[kss]: https://github.com/kneath/kss
|
69
|
+
[template]: https://github.com/Darep/middleman-styleguide-template
|
70
|
+
[fork]: http://help.github.com/fork-a-repo/
|
71
|
+
[branch]: http://learn.github.com/p/branching.html
|
72
|
+
[pr]: http://help.github.com/send-pull-requests/
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/TODO.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
- Add kss_dir to sprockets' asset path, so Middleman includes it if it's not under stylesheets and Sass/Compass helpers work correctly
|
2
|
+
- Refactor hacky redcarpet implementation, allow use of other engines
|
3
|
+
- Add tests
|
4
|
+
|
5
|
+
-------------------------------------------------------------------------------
|
6
|
+
|
7
|
+
✓ COMPLETED:
|
8
|
+
|
9
|
+
✗ NOPE:
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<div class="styleguide-example">
|
2
|
+
|
3
|
+
<h3><%= @section.section %> <em><%= @section.filename %></em></h3>
|
4
|
+
<div class="styleguide-description markdown-body">
|
5
|
+
<%= kss_markdown kss_h(@section.description) %>
|
6
|
+
<% if @section.modifiers.any? %>
|
7
|
+
<ul class="styleguide-modifier">
|
8
|
+
<% @section.modifiers.each do |modifier| %>
|
9
|
+
<li><strong><%= modifier.name %></strong> - <%= modifier.description %></li>
|
10
|
+
<% end %>
|
11
|
+
</ul>
|
12
|
+
<% end %>
|
13
|
+
</div>
|
14
|
+
<div class="styleguide-element">
|
15
|
+
<%= @block_html.gsub('$modifier_class', '') %>
|
16
|
+
</div>
|
17
|
+
<% @section.modifiers.each do |modifier| %>
|
18
|
+
<div class="styleguide-element styleguide-modifier">
|
19
|
+
<span class="styleguide-modifier-name"><%= modifier.name %></span>
|
20
|
+
<%= @block_html.gsub('$modifier_class', " #{modifier.class_name}") %>
|
21
|
+
</div>
|
22
|
+
<% end %>
|
23
|
+
<div class="styleguide-html">
|
24
|
+
<pre>
|
25
|
+
<code class="language-markup"><%= kss_h @block_html.gsub('$modifier_class', '').gsub(' class=""', '') %></code>
|
26
|
+
</pre>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
</div>
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'kss'
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'redcarpet'
|
5
|
+
rescue LoadError
|
6
|
+
end
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'kramdown'
|
10
|
+
rescue LoadError
|
11
|
+
end
|
12
|
+
|
13
|
+
module Middleman
|
14
|
+
module KSS
|
15
|
+
class << self
|
16
|
+
|
17
|
+
def options
|
18
|
+
@@options
|
19
|
+
end
|
20
|
+
|
21
|
+
def registered(app, options_hash={})
|
22
|
+
@@options = options_hash
|
23
|
+
yield @@options if block_given?
|
24
|
+
|
25
|
+
app.send :include, Helpers
|
26
|
+
end
|
27
|
+
alias :included :registered
|
28
|
+
end
|
29
|
+
|
30
|
+
module Helpers
|
31
|
+
# Renders a styleblock with or without styleguide information.
|
32
|
+
#
|
33
|
+
# @param [String] tile
|
34
|
+
# Name of the style tile file to render.
|
35
|
+
# @param [Hash] options
|
36
|
+
# Options for rendering.
|
37
|
+
# @option options [String] :section
|
38
|
+
# KSS section number (e.g. "1.1") for fetching the styleguide information.
|
39
|
+
#
|
40
|
+
# @return [String] Generated HTML.
|
41
|
+
#
|
42
|
+
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
|
+
tile_file = "_#{tile}.html.erb"
|
53
|
+
# TODO: remove "styleblocks" magic string
|
54
|
+
tile_path = File.join(self.source_dir, "styleblocks", tile_file)
|
55
|
+
@block_html = File.read(tile_path)
|
56
|
+
|
57
|
+
if options.has_key?(:section)
|
58
|
+
@section = @styleguide.section(options[:section])
|
59
|
+
# TODO: remove magic strings: "partials" and "_styleguide_block.html.erb"
|
60
|
+
styleguide_block_path = File.join(File.dirname(__FILE__), '_styleguide_block.html.erb')
|
61
|
+
#styleguide_block_path = File.join(self.source_dir, "partials", "_styleguide_block.html.erb")
|
62
|
+
render_individual_file(styleguide_block_path)
|
63
|
+
else
|
64
|
+
return @block_html.gsub('$modifier_class', '').gsub(' class=""', '')
|
65
|
+
#render_individual_file(@block_html)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Simple HTML escape helper
|
70
|
+
def kss_h(text)
|
71
|
+
Rack::Utils.escape_html(text)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Markdown in KSS
|
75
|
+
def kss_markdown(input)
|
76
|
+
markdown = ::Redcarpet::Markdown.new(::Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true)
|
77
|
+
markdown.render(input)
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'middleman-kss'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'middleman-kss/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'middleman-kss'
|
8
|
+
spec.version = Middleman::KSS::VERSION
|
9
|
+
spec.platform = Gem::Platform::RUBY
|
10
|
+
spec.authors = ['Antti-Jussi Kovalainen']
|
11
|
+
spec.email = ['ajk@ajk.fi']
|
12
|
+
spec.description = %q{KSS (Knyle Style Sheets) helpers for Middleman}
|
13
|
+
spec.summary = spec.description
|
14
|
+
spec.homepage = 'https://github.com/darep/middleman-kss'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.required_ruby_version = '>= 1.8.7'
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
24
|
+
|
25
|
+
spec.add_runtime_dependency('middleman-core', '~> 3.0')
|
26
|
+
spec.add_runtime_dependency('kss', '~> 0.4')
|
27
|
+
spec.add_runtime_dependency('redcarpet', '~> 2.2.2')
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: middleman-kss
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Antti-Jussi Kovalainen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: middleman-core
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '3.0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3.0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: kss
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.4'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.4'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: redcarpet
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.2.2
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.2.2
|
78
|
+
description: KSS (Knyle Style Sheets) helpers for Middleman
|
79
|
+
email:
|
80
|
+
- ajk@ajk.fi
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- .gitignore
|
86
|
+
- CONTRIBUTING.md
|
87
|
+
- Gemfile
|
88
|
+
- LICENSE
|
89
|
+
- README.md
|
90
|
+
- Rakefile
|
91
|
+
- TODO.md
|
92
|
+
- lib/middleman-kss.rb
|
93
|
+
- lib/middleman-kss/_styleguide_block.html.erb
|
94
|
+
- lib/middleman-kss/extension.rb
|
95
|
+
- lib/middleman-kss/middleman_extension.rb
|
96
|
+
- lib/middleman-kss/version.rb
|
97
|
+
- middleman-kss.gemspec
|
98
|
+
homepage: https://github.com/darep/middleman-kss
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.8.7
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ! '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 1.8.25
|
120
|
+
signing_key:
|
121
|
+
specification_version: 3
|
122
|
+
summary: KSS (Knyle Style Sheets) helpers for Middleman
|
123
|
+
test_files: []
|