jekyll-codepen 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d059ca871f1d70e30a8cbf478ff8600db5db8f88
4
+ data.tar.gz: c7144bf5a6329b0ae61e5ea9c2e78b3c30172ef4
5
+ SHA512:
6
+ metadata.gz: 7fb02a757d4612fb6f1c2340200a9d4f58405e77e29bf1e5d097104ade498f9079b266b36de29918daceaa574cea644b6fb8bb0b194818a070ce4302281c6550
7
+ data.tar.gz: 63f48e1f8e421a7d8e55e7cf7b09b146113ab4b06d9f87fc6fea580330d8f78890c4914a9fc9899b7835041745f05f82bf95773097d376ccd433ed7589c0ee26
data/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2017 [Rob McFadzean](https://github.com/rmcfadzean).
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # Jekyll::Codepen
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/jekyll-codepen.svg)](http://badge.fury.io/rb/jekyll-codepen)
4
+
5
+ <!-- Tocer[start]: Auto-generated, don't remove. -->
6
+
7
+ # Table of Contents
8
+
9
+ - [Features](#features)
10
+ - [Requirements](#requirements)
11
+ - [Setup](#setup)
12
+ - [Usage](#usage)
13
+ - [Versioning](#versioning)
14
+ - [Code of Conduct](#code-of-conduct)
15
+ - [Contributions](#contributions)
16
+ - [License](#license)
17
+
18
+ <!-- Tocer[finish]: Auto-generated, don't remove. -->
19
+
20
+ # Features
21
+
22
+ Easily embeds codepens into your Jekyll projects.
23
+
24
+ # Requirements
25
+
26
+ * [Ruby 2.x.x](https://www.ruby-lang.org)
27
+ * Jekyll
28
+
29
+ # Setup
30
+
31
+ Add the following to your Gemfile:
32
+
33
+ ```ruby
34
+ gem "jekyll-codepen"
35
+ ```
36
+
37
+ (Optionally) Add the following to `config.yml`
38
+
39
+ ```yaml
40
+ gems:
41
+ - jekyll-codepen
42
+
43
+ codepen:
44
+ theme: 11473
45
+ height: 300
46
+ preview: false
47
+ default_tab: result
48
+ ```
49
+
50
+
51
+ # Usage
52
+
53
+ ```
54
+ {% codepen https://codepen.io/blindingstars/pen/wBexpr %}
55
+ ```
56
+
57
+ or with any of the config options from above
58
+
59
+ ```
60
+ {% codepen https://codepen.io/blindingstars/pen/wBexpr height=800 preview=true %}
61
+ ```
62
+
63
+ # Versioning
64
+
65
+ Read [Semantic Versioning](http://semver.org) for details. Briefly, it means:
66
+
67
+ - Major (X.y.z) - Incremented for any backwards incompatible public API changes.
68
+ - Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
69
+ - Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
70
+
71
+ # Code of Conduct
72
+
73
+ Please note that this project is released with a [CODE OF CONDUCT](CODE_OF_CONDUCT.md). By
74
+ participating in this project you agree to abide by its terms.
75
+
76
+ # Contributions
77
+
78
+ Read [CONTRIBUTING](CONTRIBUTING.md) for details.
79
+
80
+ # License
81
+
82
+ Copyright (c) 2017 [Rob McFadzean](https://github.com/rmcfadzean).
83
+ Read [LICENSE](LICENSE.md) for details.
data/lib/identity.rb ADDED
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Codepen
5
+ # Gem identity information.
6
+ module Identity
7
+ def self.name
8
+ 'jekyll-codepen'
9
+ end
10
+
11
+ def self.label
12
+ 'Jekyll::Codepen'
13
+ end
14
+
15
+ def self.version
16
+ '0.1.0'
17
+ end
18
+
19
+ def self.version_label
20
+ "#{label} #{version}"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'identity'
4
+
5
+ module Jekyll
6
+ class CodePen < Liquid::Tag
7
+ def initialize(tag_name, content, tokens)
8
+ super
9
+
10
+ @defaults = {
11
+ 'class' => 'codepen',
12
+ 'embed_version' => 2,
13
+ 'height' => 300,
14
+ 'preview' => false,
15
+ 'theme_id' => 11_473,
16
+ 'default_tab' => 'result'
17
+ }
18
+
19
+ @args = content.split
20
+
21
+ @url = @args.first
22
+ @slug = @url.match(%r{codepen.io\/\w*\/pen\/(?<slug>\w*)})[:slug]
23
+ @user = @url.match(%r{codepen.io\/(?<user>\w*)\/})[:user]
24
+ end
25
+
26
+ def parse_args(args)
27
+ args[1..-1].map do |arg|
28
+ k, v = arg.split('=')
29
+ { k => v }
30
+ end.flatten.first
31
+ end
32
+
33
+ def attr_map(attrs)
34
+ attrs.map do |key, value|
35
+ key = key.to_s.tr('_', '-')
36
+ "data-#{key}=\"#{value}\" "
37
+ end.join('')
38
+ end
39
+
40
+ def render(context)
41
+ config = context.registers[:site].config['codepen']
42
+ attrs = @defaults.merge(config)
43
+
44
+ args = parse_args(@args)
45
+
46
+ attrs = attrs.merge(args) if args
47
+
48
+ class_name = attrs['class']
49
+ attrs.delete('class')
50
+
51
+ <<-HTML
52
+ <p #{attr_map(attrs)} data-user="#{@user}" data-slug-hash="#{@slug}" class="#{class_name}">
53
+ See the <a href="#{@url}">pen</a> on <a href="//codepen.io">CodePen</a>.
54
+ </p>
55
+ <script async src="https://production-assets.codepen.io/assets/embed/ei.js"></script>
56
+ HTML
57
+ end
58
+ end
59
+ end
60
+
61
+ Liquid::Template.register_tag('codepen', Jekyll::CodePen)
metadata ADDED
@@ -0,0 +1,176 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-codepen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rob McFadzean
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-05-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '12.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '12.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: gemsmith
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '9.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '9.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-state
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.6'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.6'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard-rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '4.7'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '4.7'
111
+ - !ruby/object:Gem::Dependency
112
+ name: reek
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '4.6'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '4.6'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.48'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.48'
139
+ description:
140
+ email:
141
+ - root@sphericalcube.net
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files:
145
+ - README.md
146
+ - LICENSE.md
147
+ files:
148
+ - LICENSE.md
149
+ - README.md
150
+ - lib/identity.rb
151
+ - lib/jekyll-codepen.rb
152
+ homepage: https://github.com/rmcfadzean/jekyll-codepen
153
+ licenses:
154
+ - MIT
155
+ metadata: {}
156
+ post_install_message:
157
+ rdoc_options: []
158
+ require_paths:
159
+ - lib
160
+ required_ruby_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - "~>"
163
+ - !ruby/object:Gem::Version
164
+ version: '2.4'
165
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ requirements: []
171
+ rubyforge_project:
172
+ rubygems_version: 2.6.11
173
+ signing_key:
174
+ specification_version: 4
175
+ summary: ''
176
+ test_files: []