jekyll-components 0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7a14e0263cadc7b385c8fe3c0ddf649939d33483
4
+ data.tar.gz: '0128cc1f9b026ab32d5c43fa926d8b06b03a4eae'
5
+ SHA512:
6
+ metadata.gz: 7bd917e02476d4c7806aeaa424e90ffe3881a7b8fb508746f1b9b568f60ca4a7d2be37a3bd8b44b7ccb5ecdb6e63f4f177f9cacada592debf90b7dbeff1f04fb
7
+ data.tar.gz: 7a4ce03b483d9ceb13772ac9cc4d47d502baadee68f34dbe2aa6ec685a8eb2584c5068ee631686a8d2808589b574588b8a51d50ae24f6ffceebdd8f9098c4e6a
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ .DS_Store
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.13.7
6
+
7
+ install:
8
+ - bundle install
9
+
10
+ script:
11
+ - bundle exec rake test
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Help Scout
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # jekyll-components 🌟
2
+
3
+ A Jekyll library for building component-based UI
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'jekyll-components'
11
+ ```
12
+
13
+ And then execute:
14
+ ```
15
+ bundle
16
+ ```
17
+
18
+ Or install it yourself as:
19
+ ```
20
+ gem install jekyll-components
21
+ ```
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rubygems'
3
+ require 'rake'
4
+ require 'rdoc'
5
+ require 'date'
6
+ require 'yaml'
7
+ require 'rake/testtask'
8
+
9
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), *%w[lib]))
10
+ require 'jekyll/version'
11
+
12
+ Rake::TestTask.new(:test) do |test|
13
+ test.libs << 'lib' << 'test'
14
+ test.pattern = 'test/**/test_*.rb'
15
+ test.verbose = true
16
+ end
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jekyll/components/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jekyll-components"
8
+ spec.version = Jekyll::Components::VERSION
9
+ spec.authors = ["ItsJonQ"]
10
+ spec.email = ["itsjonq@gmail.com"]
11
+
12
+ spec.summary = "A Jekyll library for building component-based UI"
13
+ spec.homepage = "https://github.com/helpscout/jekyll-components"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_runtime_dependency("jekyll", ">= 3.1.2")
24
+ spec.add_runtime_dependency("htmlcompressor", "~> 0.3.1")
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.13"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "minitest-reporters"
29
+ spec.add_development_dependency "minitest-profile"
30
+ spec.add_development_dependency "minitest", "~> 5.8"
31
+ spec.add_development_dependency "nokogiri", "~> 1.7.1"
32
+ spec.add_development_dependency "rspec-mocks"
33
+ spec.add_development_dependency "shoulda"
34
+ spec.add_development_dependency "kramdown"
35
+ end
@@ -0,0 +1 @@
1
+ require "jekyll/components"
@@ -0,0 +1,4 @@
1
+ require "jekyll"
2
+ require "jekyll/components/version"
3
+ require "jekyll/components/block"
4
+ require "jekyll/components/tag"
@@ -0,0 +1,134 @@
1
+ require "htmlcompressor"
2
+ require "jekyll"
3
+ require "liquid"
4
+
5
+ module Jekyll
6
+ module ComponentBase
7
+ include Liquid::StandardFilters
8
+
9
+ @@compressor = HtmlCompressor::Compressor.new({
10
+ :remove_comments => true
11
+ }).freeze
12
+
13
+ def initialize(tag_name, markup, tokens)
14
+ super
15
+
16
+ @attributes = {}
17
+ @context = false
18
+ @context_name = self.name.to_s.gsub("::", "_").downcase
19
+ @content = ''
20
+ @default_selector_attr = []
21
+ @props = Hash.new
22
+ @site = false
23
+
24
+ if markup =~ /(#{Liquid::QuotedFragment}+)?/
25
+ # Parse parameters
26
+ # Source: https://gist.github.com/jgatjens/8925165
27
+ markup.scan(Liquid::TagAttributes) do |key, value|
28
+ @attributes[key] = Liquid::Expression.parse(value)
29
+ end
30
+ else
31
+ raise SyntaxError.new(options[:locale].t("errors.syntax.include".freeze))
32
+ end
33
+ end
34
+
35
+ # blank?
36
+ # Description: Override's Liquid's default blank checker. This allows
37
+ # for templates to be used without passing inner content.
38
+ def blank?
39
+ false
40
+ end
41
+
42
+ def selector_default_props(attr = @default_selector_attr)
43
+ template = ""
44
+ attr.each { |prop|
45
+ if @props.key?(prop)
46
+ template += "#{prop}='#{@props[prop]}' "
47
+ end
48
+ }
49
+
50
+ template
51
+ end
52
+
53
+ def selector_data_props(attr = @attributes)
54
+ template = ""
55
+ attr.keys.each { |key|
56
+ if key.include? "data"
57
+ template += "#{key.gsub("_", "-")}='#{@props[key]}' "
58
+ end
59
+ }
60
+
61
+ template
62
+ end
63
+
64
+ def selector_props(attr = @default_selector_attr)
65
+ template = ""
66
+ template += selector_data_props
67
+ template += selector_default_props(attr)
68
+
69
+ template
70
+ end
71
+
72
+ def set_props(props = Hash.new)
73
+ @context[@context_name] = @props = @props.merge(props)
74
+ end
75
+
76
+ def serialize_data
77
+ data = Hash.new
78
+ @attributes["content"] = @content
79
+ if @attributes.length
80
+ @attributes.each do |key, value|
81
+ val = @context.evaluate(value)
82
+ data[key] = val
83
+ end
84
+ end
85
+
86
+ return set_props(data)
87
+ end
88
+
89
+ def unindent(content)
90
+ # Remove initial whitespace
91
+ content.gsub!(/\A^\s*\n/, "")
92
+ # Remove indentations
93
+ if content =~ %r!^\s*!m
94
+ indentation = Regexp.last_match(0).length
95
+ content.gsub!(/^\ {#{indentation}}/, "")
96
+ end
97
+
98
+ return content
99
+ end
100
+
101
+ def markdown_file?()
102
+ file = @context["page"]["name"]
103
+ if file
104
+ file.include?(".md") || file.include?(".markdown")
105
+ else
106
+ false
107
+ end
108
+ end
109
+
110
+ def render(context)
111
+ @context = context
112
+ @site = @context.registers[:site]
113
+ @content = super
114
+ serialize_data
115
+ output = template(context)
116
+
117
+ # if (markdown_file?)
118
+ # output = "{::nomarkdown type='html'}#{output}{:/nomarkdown}"
119
+ # end
120
+
121
+ if (output.instance_of?(String))
122
+ output = Liquid::Template.parse(output).render()
123
+ output = @@compressor.compress(unindent(output))
124
+ else
125
+ output
126
+ end
127
+ end
128
+
129
+ def template(context = @context)
130
+ context
131
+ end
132
+
133
+ end
134
+ end
@@ -0,0 +1,8 @@
1
+ require "jekyll"
2
+ require_relative "./base"
3
+
4
+ module Jekyll
5
+ class ComponentBlock < Liquid::Block
6
+ include Jekyll::ComponentBase
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require "jekyll"
2
+ require_relative "./base"
3
+
4
+ module Jekyll
5
+ class ComponentTag < Liquid::Tag
6
+ include Jekyll::ComponentBase
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module Components
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,211 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-components
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - ItsJonQ
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-05-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.1.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.1.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: htmlcompressor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.3.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.3.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.13'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.13'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest-reporters
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest-profile
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '5.8'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '5.8'
111
+ - !ruby/object:Gem::Dependency
112
+ name: nokogiri
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 1.7.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 1.7.1
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec-mocks
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: shoulda
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: kramdown
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ description:
168
+ email:
169
+ - itsjonq@gmail.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - ".gitignore"
175
+ - ".travis.yml"
176
+ - Gemfile
177
+ - LICENSE.txt
178
+ - README.md
179
+ - Rakefile
180
+ - jekyll-components.gemspec
181
+ - lib/jekyll-components.rb
182
+ - lib/jekyll/components.rb
183
+ - lib/jekyll/components/base.rb
184
+ - lib/jekyll/components/block.rb
185
+ - lib/jekyll/components/tag.rb
186
+ - lib/jekyll/components/version.rb
187
+ homepage: https://github.com/helpscout/jekyll-components
188
+ licenses:
189
+ - MIT
190
+ metadata: {}
191
+ post_install_message:
192
+ rdoc_options: []
193
+ require_paths:
194
+ - lib
195
+ required_ruby_version: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
200
+ required_rubygems_version: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ version: '0'
205
+ requirements: []
206
+ rubyforge_project:
207
+ rubygems_version: 2.5.2
208
+ signing_key:
209
+ specification_version: 4
210
+ summary: A Jekyll library for building component-based UI
211
+ test_files: []