jekyll-crypticons 1.0.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: f681366f1e33f0c67b1b90a028bc821a92135b8c
4
+ data.tar.gz: dfa4afdc38bb68e4392dc0e921c52158f62d5094
5
+ SHA512:
6
+ metadata.gz: 2327ec63dd4a9f5c3adf4c041b66de2eaa6090902f104a82f4bdfe42eb60b2ff68aaffffa22c9f2354793d07232302f6683f2a8f5a97128ebafd2654c09c2aee
7
+ data.tar.gz: 6e1f443fe0cf2d84e4d18a3838a5287cb065930e82f1e958f994f95b6cefed354c5f6c6c10ada3057b3aaeeee798d9634b5381693edfce5c09be67eb9c5d120d
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Mitchell Cash
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Crypticons jekyll tag
2
+
3
+ [![Gem version](https://img.shields.io/gem/v/jekyll-crypticons.svg)](https://rubygems.org/gems/jekyll-crypticons)
4
+ [![Build Status](https://travis-ci.org/mitchellcash/crypticons.svg?branch=master)](https://travis-ci.org/mitchellcash/crypticons)
5
+
6
+ > A liquid jekyll tag that injects Crypticon svg into the page
7
+
8
+ This jekyll liquid tag, is a plugin that will let you easily include svg crypticons in your jekyll sites.
9
+
10
+ ## Install
11
+
12
+ 1. Add this to your `Gemfile`
13
+
14
+ ```rb
15
+ gem 'jekyll-crypticons'
16
+ ```
17
+
18
+ 2. Add this to your jekyll `_config.yml`
19
+
20
+ ```yml
21
+ gems:
22
+ - jekyll-crypticons
23
+ ```
24
+
25
+ 3. Use this tag in your jekyll templates
26
+
27
+ ```
28
+ {% crypticon bitcoin height:32 class:"right left" aria-label:hi %}
29
+ ```
30
+
31
+ We recommend including the CSS in the [crypticons_node](../crypticons_node/) module. You can also npm install that package and include `build/build.css` in your styles.
32
+
33
+ ## Documentation
34
+
35
+ For a full list of options available, see the [crypticons_gem documentation](../crypticons_gem/#documentation)
36
+
37
+ ## License
38
+
39
+ (c) Mitchell Cash
40
+
41
+ [MIT](./LICENSE)
42
+
43
+ [crypticons]: https://github.com/mitchellcash/crypticons
@@ -0,0 +1,73 @@
1
+ # rubocop:disable Naming/FileName
2
+ require "crypticons"
3
+ require "jekyll-crypticons/version"
4
+ require "liquid"
5
+ require "jekyll/liquid_extensions"
6
+
7
+ module Jekyll
8
+ class Crypticons < Liquid::Tag
9
+ include Jekyll::LiquidExtensions
10
+
11
+ # Syntax for the crypticon symbol
12
+ Syntax = /\A(#{Liquid::VariableSignature}+)/
13
+
14
+ # For interpoaltion, look for liquid variables
15
+ Variable = /\{\{\s*([\w]+\.?[\w]*)\s*\}\}/i
16
+
17
+ # Copied from Liquid::TagAttributes to allow dashes in tag names:
18
+ #
19
+ # {% crypticon alert area-label:"Hello World!" %}
20
+ #
21
+ TagAttributes = /([\w-]+)\s*\:\s*(#{Liquid::QuotedFragment})/o
22
+
23
+ def initialize(tag_name, markup, options)
24
+ super
25
+ @markup = markup
26
+
27
+ # If there's interpoaltion going on, we need to do this in render
28
+ prepare(markup) unless match = markup.match(Variable)
29
+ end
30
+
31
+ def render(context)
32
+ prepare(interpolate(@markup, context)) if match = @markup.match(Variable)
33
+
34
+ return nil if @symbol.nil?
35
+ ::Crypticons::Crypticon.new(@symbol, @options).to_svg
36
+ end
37
+
38
+ private
39
+
40
+ def interpolate(markup, context)
41
+ markup.scan Variable do |variable|
42
+ markup = markup.gsub(Variable, lookup_variable(context, variable.first))
43
+ end
44
+ markup
45
+ end
46
+
47
+ def prepare(markup)
48
+ @symbol = symbol(markup)
49
+ @options = string_to_hash(markup)
50
+ end
51
+
52
+ def symbol(markup)
53
+ if match = markup.match(Syntax)
54
+ match[1]
55
+ end
56
+ end
57
+
58
+ # Create a ruby hash from a string passed by the jekyll tag
59
+ def string_to_hash(markup)
60
+ options = {}
61
+
62
+ if match = markup.match(Syntax)
63
+ markup.scan(TagAttributes) do |key, value|
64
+ options[key.to_sym] = value.gsub(/\A"|"\z/, "")
65
+ end
66
+ end
67
+
68
+ options
69
+ end
70
+ end
71
+ end
72
+
73
+ Liquid::Template.register_tag("crypticon", Jekyll::Crypticons)
@@ -0,0 +1,8 @@
1
+ # Prevent bundler errors
2
+ module Liquid; class Tag; end; end
3
+
4
+ module Jekyll
5
+ class Crypticons < Liquid::Tag
6
+ VERSION = "1.0.0".freeze
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-crypticons
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Mitchell Cash
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-01-28 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'
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'
27
+ - !ruby/object:Gem::Dependency
28
+ name: crypticons
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.0
41
+ description: A jekyll liquid plugin that makes including svg Crypticons simple.
42
+ email:
43
+ - mitchell@mitchellcash.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - LICENSE
49
+ - README.md
50
+ - lib/jekyll-crypticons.rb
51
+ - lib/jekyll-crypticons/version.rb
52
+ homepage: https://github.com/mitchellcash/crypticons
53
+ licenses:
54
+ - MIT
55
+ metadata: {}
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 2.6.13
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: Crypticons jekyll liquid tag
76
+ test_files: []