jekyll_social_icons 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +98 -0
- data/Rakefile +1 -0
- data/jekyll_social_icons.gemspec +21 -0
- data/lib/jekyll_social_icons.rb +3 -0
- data/lib/jekyll_social_icons/icons.json +10 -0
- data/lib/jekyll_social_icons/option_parser.rb +36 -0
- data/lib/jekyll_social_icons/social_icons.css +69 -0
- data/lib/jekyll_social_icons/social_icons_styles.rb +34 -0
- data/lib/jekyll_social_icons/social_icons_tag.rb +84 -0
- data/lib/jekyll_social_icons/version.rb +3 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6f18f0a984c728f8d55d4d4f74e83210cd610be1
|
4
|
+
data.tar.gz: 40d1a1f13680f65dcf636575d627af62fcc5a35e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aba3100f72c87f849ef6adc8ee7a2de7dfdd16e0e88238b4aa74b7113171afe3c9e2d6101b3415b889f038e4f5856336694a29972ef33b86e81dba849871c45c
|
7
|
+
data.tar.gz: 5cb7ab44fcac2288c609a4a29f21ea1ae2a1028a850547d7b9eab973ea78850a3b3ab590141cc2a4761be73544d544061cd7058d70ea2ebef709533db57e3fd8
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Unai Abrisketa
|
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,98 @@
|
|
1
|
+
# Jekyll Social Icons
|
2
|
+
|
3
|
+
[![Gem](https://img.shields.io/gem/v/jekyll_social_icons.svg)](https://rubygems.org/gems/jekyll_social_icons)
|
4
|
+
|
5
|
+
__Jekyll Social Icons__ plugin allows you rendering your social networks on your [Jekyll](https://jekyllrb.com/) project.
|
6
|
+
|
7
|
+
## 1. Installation
|
8
|
+
|
9
|
+
1. Add the following to your site's `Gemfile`:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'jekyll_social_icons'
|
13
|
+
```
|
14
|
+
|
15
|
+
2. Add the following to your site's `_config.yml`:
|
16
|
+
|
17
|
+
```yaml
|
18
|
+
gems:
|
19
|
+
- jekyll_social_icons
|
20
|
+
```
|
21
|
+
|
22
|
+
3. Run `bundle install` in your command line:
|
23
|
+
|
24
|
+
```bash
|
25
|
+
$ bundle install
|
26
|
+
```
|
27
|
+
|
28
|
+
## 2. Usage
|
29
|
+
|
30
|
+
### 2.1. Configuration
|
31
|
+
|
32
|
+
Add your social networks URLs to the `_config.yml` file:
|
33
|
+
|
34
|
+
```yaml
|
35
|
+
socials:
|
36
|
+
twitter: https://twitter.com/unabris
|
37
|
+
github: https://github.com/unabris
|
38
|
+
```
|
39
|
+
|
40
|
+
Here is a full list of all the __available social networks__: `facebook`, `twitter`, `google-plus`, `instagram`, `linkedin`, `youtube`, `github` and `rss`.
|
41
|
+
|
42
|
+
### 2.2. Rendering
|
43
|
+
|
44
|
+
Use `{% social_icons %}` Jekyll Tag to render all your configured social networks with the default styling. For example, the configuration above will render this html content:
|
45
|
+
|
46
|
+
```html
|
47
|
+
<div class="social-container" id="" style="">
|
48
|
+
<div class="social" style="">
|
49
|
+
<a href="https://twitter.com/unabris" target="_blank">
|
50
|
+
<i class="fa fa-fw fa-twitter" style=""></i>
|
51
|
+
</a>
|
52
|
+
</div>
|
53
|
+
<div class="social" style="">
|
54
|
+
<a href="https://github.com/unabris" target="_blank">
|
55
|
+
<i class="fa fa-fw fa-github" style=""></i>
|
56
|
+
</a>
|
57
|
+
</div>
|
58
|
+
</div>
|
59
|
+
```
|
60
|
+
|
61
|
+
You can also specify the social networks you want to render adding them to the Jekyll Tag this way:
|
62
|
+
|
63
|
+
```html
|
64
|
+
{% social_icons twitter github %}
|
65
|
+
```
|
66
|
+
|
67
|
+
### 2.3. Styling
|
68
|
+
|
69
|
+
There are so many attributes you can use to customize the style of your social networks icons. To use them, just add the attribute and the value you want to the `social_icons` Jekyll Tag this way:
|
70
|
+
|
71
|
+
```html
|
72
|
+
{% social_icons twitter github id="footer-icons" width="30px" height="30px" radius="100%" %}
|
73
|
+
```
|
74
|
+
|
75
|
+
Here is a full list of all the available attributes with their default values:
|
76
|
+
|
77
|
+
| Option | Description | Default |
|
78
|
+
|:--------:|--------------------------------------------------------------------------------------------------------------------------------|:--------:|
|
79
|
+
| `id` | One or more ids separated by a space. This ids are going to be added at the same level than the main `social-container` class. | - |
|
80
|
+
| `class` | One or more classes separated by a space. This classes are going to be added to the main `social-container` class. | - |
|
81
|
+
| `width` | The `width` of the social networks icons. | `50px` |
|
82
|
+
| `height` | The `height` of the social networks icons. | `50px` |
|
83
|
+
| `align` | One of `left`, `center` or `right`. | `center` |
|
84
|
+
| `margin` | The margin between the different social icons you want to render. | `10px` |
|
85
|
+
| `radius` | The border radius of the social icons. Put `100%` if you want circle icons. | `0` |
|
86
|
+
| `size` | The size of the social networks brand image. | `30px` |
|
87
|
+
|
88
|
+
## 3. Contributing
|
89
|
+
|
90
|
+
1. Fork it
|
91
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
92
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
93
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
94
|
+
5. Create a new Pull Request
|
95
|
+
|
96
|
+
## 4. License
|
97
|
+
|
98
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jekyll_social_icons/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'jekyll_social_icons'
|
8
|
+
spec.version = JekyllSocialIcons::VERSION
|
9
|
+
spec.authors = ['Unai Abrisketa']
|
10
|
+
spec.email = ['unai.abrisqueta@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = %q{Jekyll plugin to render your social networks icons}
|
13
|
+
spec.homepage = 'https://github.com/unabris/jekyll_social_icons'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.require_paths = ['lib']
|
18
|
+
|
19
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
20
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
21
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Jekyll
|
2
|
+
class OptionParser
|
3
|
+
icons_json = JSON.parse(IO.readlines(File.expand_path('icons.json', File.dirname(__FILE__))).join)
|
4
|
+
available_socials = icons_json.keys
|
5
|
+
|
6
|
+
OPTIONS_SYNTAX = %r!([^\s]+)\s*=\s*['"]+([^'"]+)['"]+!
|
7
|
+
ALLOWED_SOCIALS = available_socials.freeze
|
8
|
+
ALLOWED_ATTRIBUTES = %w(
|
9
|
+
id
|
10
|
+
class
|
11
|
+
width
|
12
|
+
height
|
13
|
+
align
|
14
|
+
margin
|
15
|
+
radius
|
16
|
+
size
|
17
|
+
).freeze
|
18
|
+
|
19
|
+
class << self
|
20
|
+
def parse(raw_options)
|
21
|
+
options = {
|
22
|
+
attributes: {}
|
23
|
+
}
|
24
|
+
raw_options.scan(OPTIONS_SYNTAX).each do |key, value|
|
25
|
+
if ALLOWED_ATTRIBUTES.include?(key)
|
26
|
+
options[:attributes][key.to_sym] = value
|
27
|
+
end
|
28
|
+
if key.to_sym == :socials
|
29
|
+
options[:socials] = value.split(' ').select { |k, v| ALLOWED_SOCIALS.include?(k) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
options
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
.social-container {
|
2
|
+
display: flex;
|
3
|
+
}
|
4
|
+
.social-container .social {
|
5
|
+
width: 50px;
|
6
|
+
height: 50px;
|
7
|
+
}
|
8
|
+
.social-container .social:last-child {
|
9
|
+
margin-right: 0 !important;
|
10
|
+
}
|
11
|
+
.social-container .social a {
|
12
|
+
width: 100%;
|
13
|
+
height: 100%;
|
14
|
+
display: flex;
|
15
|
+
justify-content: center;
|
16
|
+
align-items: center;
|
17
|
+
cursor: pointer;
|
18
|
+
}
|
19
|
+
.social-container .social a i.fa {
|
20
|
+
color: #fff;
|
21
|
+
}
|
22
|
+
.social-container .social.facebook {
|
23
|
+
background-color: #4460a1;
|
24
|
+
}
|
25
|
+
.social-container .social.twitter {
|
26
|
+
background-color: #01aaed;
|
27
|
+
}
|
28
|
+
.social-container .social.google-plus {
|
29
|
+
background-color: #f9402e;
|
30
|
+
}
|
31
|
+
.social-container .social.instagram {
|
32
|
+
background-color: #275a85;
|
33
|
+
}
|
34
|
+
.social-container .social.linkedin {
|
35
|
+
background-color: #007ebb;
|
36
|
+
}
|
37
|
+
.social-container .social.youtube {
|
38
|
+
background-color: #cf1312;
|
39
|
+
}
|
40
|
+
.social-container .social.github {
|
41
|
+
background-color: #000000;
|
42
|
+
}
|
43
|
+
.social-container .social.rss {
|
44
|
+
background-color: #ff9a00;
|
45
|
+
}
|
46
|
+
.social-container .social.facebook:hover {
|
47
|
+
background-color: #3f5995;
|
48
|
+
}
|
49
|
+
.social-container .social.twitter:hover {
|
50
|
+
background-color: #019edc;
|
51
|
+
}
|
52
|
+
.social-container .social.google-plus:hover {
|
53
|
+
background-color: #dd1906;
|
54
|
+
}
|
55
|
+
.social-container .social.instagram:hover {
|
56
|
+
background-color: #235178;
|
57
|
+
}
|
58
|
+
.social-container .social.linkedin:hover {
|
59
|
+
background-color: #0073aa;
|
60
|
+
}
|
61
|
+
.social-container .social.youtube:hover {
|
62
|
+
background-color: #bf1211;
|
63
|
+
}
|
64
|
+
.social-container .social.github:hover {
|
65
|
+
background-color: #000000;
|
66
|
+
}
|
67
|
+
.social-container .social.rss:hover {
|
68
|
+
background-color: #ee9000;
|
69
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Jekyll
|
2
|
+
class SocialIconsStyles
|
3
|
+
HEAD_END_TAG = %r!</.*head>!
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def add_styles(doc)
|
7
|
+
@config = doc.site.config
|
8
|
+
if doc.output =~ HEAD_END_TAG
|
9
|
+
doc.output.gsub!(HEAD_END_TAG, %(#{header_styles}#{Regexp.last_match}))
|
10
|
+
else
|
11
|
+
doc.output.prepend(header_styles)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def header_styles
|
18
|
+
"""<link rel='stylesheet' href='//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'>
|
19
|
+
<style>
|
20
|
+
#{style_document}
|
21
|
+
</style>"""
|
22
|
+
end
|
23
|
+
|
24
|
+
def style_document
|
25
|
+
style_path = File.join(File.dirname(__FILE__), 'social_icons.css')
|
26
|
+
File.open(style_path).read
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
Jekyll::Hooks.register [:pages, :documents], :post_render do |doc|
|
33
|
+
Jekyll::SocialIconsStyles.add_styles(doc)
|
34
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module Jekyll
|
2
|
+
class SocialIcons < Liquid::Tag
|
3
|
+
DEFAULT_WIDTH = '50px'
|
4
|
+
DEFAULT_HEIGHT = '50px'
|
5
|
+
DEFAULT_MARGIN = '10px'
|
6
|
+
DEFAULT_RADIUS = '0'
|
7
|
+
DEFAULT_FONT_SIZE = '30px'
|
8
|
+
|
9
|
+
def initialize(_, args, _)
|
10
|
+
super
|
11
|
+
@args = OptionParser.parse(args)
|
12
|
+
end
|
13
|
+
|
14
|
+
def render(context)
|
15
|
+
site = context.registers[:site]
|
16
|
+
config_socials = site.config['socials']
|
17
|
+
|
18
|
+
if @args[:socials].nil?
|
19
|
+
socials = config_socials
|
20
|
+
else
|
21
|
+
socials = config_socials.select { |k, v| @args[:socials].include?(k) }
|
22
|
+
end
|
23
|
+
|
24
|
+
icons_json = JSON.parse(IO.readlines(File.expand_path('icons.json', File.dirname(__FILE__))).join)
|
25
|
+
|
26
|
+
data = "<div class='social-container #{attr_class}' id='#{attr_id}' style='#{align}'>"
|
27
|
+
socials.each do |social, url|
|
28
|
+
data += "<div class='social #{social}' style='#{icons_size}#{margin}#{radius}'>
|
29
|
+
<a href='#{url}' target='_blank'>
|
30
|
+
<i class='fa fa-fw fa-#{icons_json[social]}' style='#{font_size}'></i>
|
31
|
+
</a></div>"
|
32
|
+
end
|
33
|
+
data += '</div>'
|
34
|
+
|
35
|
+
data
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def attr_id
|
41
|
+
@args[:attributes][:id]
|
42
|
+
end
|
43
|
+
|
44
|
+
def attr_class
|
45
|
+
@args[:attributes][:class]
|
46
|
+
end
|
47
|
+
|
48
|
+
def align
|
49
|
+
case @args[:attributes][:align]
|
50
|
+
when 'left'
|
51
|
+
'justify-content: flex-start;'
|
52
|
+
when 'center'
|
53
|
+
'justify-content: center;'
|
54
|
+
when 'right'
|
55
|
+
'justify-content: flex-end;'
|
56
|
+
else
|
57
|
+
'justify-content: center;'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def icons_size
|
62
|
+
width = @args[:attributes][:width] || DEFAULT_WIDTH
|
63
|
+
height = @args[:attributes][:height] || DEFAULT_HEIGHT
|
64
|
+
"width:#{width};height:#{height};"
|
65
|
+
end
|
66
|
+
|
67
|
+
def margin
|
68
|
+
margin = @args[:attributes][:margin] || DEFAULT_MARGIN
|
69
|
+
"margin-right:#{margin};"
|
70
|
+
end
|
71
|
+
|
72
|
+
def radius
|
73
|
+
radius = @args[:attributes][:radius] || DEFAULT_RADIUS
|
74
|
+
"border-radius:#{radius};"
|
75
|
+
end
|
76
|
+
|
77
|
+
def size
|
78
|
+
size = @args[:attributes][:size] || DEFAULT_FONT_SIZE
|
79
|
+
"font-size:#{size};"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
Liquid::Template.register_tag('social_icons', Jekyll::SocialIcons)
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll_social_icons
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Unai Abrisketa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- unai.abrisqueta@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- jekyll_social_icons.gemspec
|
54
|
+
- lib/jekyll_social_icons.rb
|
55
|
+
- lib/jekyll_social_icons/icons.json
|
56
|
+
- lib/jekyll_social_icons/option_parser.rb
|
57
|
+
- lib/jekyll_social_icons/social_icons.css
|
58
|
+
- lib/jekyll_social_icons/social_icons_styles.rb
|
59
|
+
- lib/jekyll_social_icons/social_icons_tag.rb
|
60
|
+
- lib/jekyll_social_icons/version.rb
|
61
|
+
homepage: https://github.com/unabris/jekyll_social_icons
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.5.1
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: Jekyll plugin to render your social networks icons
|
85
|
+
test_files: []
|