jekyll_icon_list 0.2.1 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 006f071d548e62aa2766ab95210f4f836f0a628c369cce00ca67a8b6671b49c5
4
- data.tar.gz: 25325be68d4b402081270e21c13c777f9737627a4335ae02ca744c00eca29a76
3
+ metadata.gz: e8fa828ed8522d543437eef888c64b66b65f58720b7b81519c0673748e275caa
4
+ data.tar.gz: 6a65cf25a931a0d9e49120dafc7212da582b5e1bf54da962263327d000d2187b
5
5
  SHA512:
6
- metadata.gz: 18185f5ca7028e06767dcb74719fb4176ebf18f09cd499e26b6ce2086a87f59fe44e1468bc30e122175776b5f12333c02c5d26575678636db8d462ff0740e5b8
7
- data.tar.gz: 2cffc1859dc8f86afb47f0ab91c3d5450c73885aa4c849920065020ae2f96dfa40109efebe7ce079a513fa31a4a1e8a684305751f440dcc103ffc2061cd58785
6
+ metadata.gz: 8b0372e48dff779e32b871d396039e8f2c3db85ec1bbb0f3ce1ca0ef95905acb658a2d64d1be6c49cac6cced8136954fa076e22f666c1b260877cbde606bf1da
7
+ data.tar.gz: 21ff8a34efc37fe4082b20d357c4c935c8304d7775eabfc010dc6bac0cb12d52bba361138627fa2976aa4e74560cc930354e7d9083d5bb52f549de9fadb933b6
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Jekyll Icon List
2
2
 
3
- **This plugin works, but I haven't had time to test it very thoroughly. Use with caution, and please
4
- report bugs if you find them.**
3
+ **This plugin, though simple, is not thoroughly tested. Use with caution, and please report bugs if
4
+ you find them.**
5
5
 
6
6
  ## What is it?
7
7
 
@@ -19,11 +19,10 @@ Add some icons, configuration, and a little CSS, get something like this:
19
19
 
20
20
  I use it on [my portfolio](https://robert-buchberger.com/projects.html)
21
21
  ([ github ](https://github.com/rbuchberger/robert-buchberger.com)) if you want to see an example.
22
- (Actually, currently my master branch doesn't use the gem. Yet. Check the other branches.)
23
22
 
24
23
  You could use it to build category lists, or tag lists, or a bunch of other stuff. You can pass
25
24
  element attributes in the tag itself, or set default attributes in the config. It only generates
26
- markup; the styling is up to you.
25
+ markup; the styling is up to you.
27
26
 
28
27
  It integrates with (and requires) [jekyll-svg-inliner](https://github.com/sdumetz/jekyll-inline-svg)
29
28
  to inline your SVGs for you. If you don't use inline SVGs (even though you should), it sets your file
@@ -178,16 +177,16 @@ ul.icon-list li {
178
177
  }
179
178
  ```
180
179
 
181
- ### Using <use> To build an icon system
182
- [CSS tricks on SVG Icon Systems (old article warning)](https://css-tricks.com/svg-sprites-use-better-icon-fonts/)
180
+ ### Using \<use> to build an icon system
181
+ [CSS tricks on SVG Icon Systems](https://css-tricks.com/svg-sprites-use-better-icon-fonts/). It's an
182
+ older article sir, but it checks out.
183
183
 
184
- [Slightly newer article on <use>](https://css-tricks.com/svg-use-with-external-reference-take-2/)
184
+ [Slightly newer CSS tricks article on \<use>](https://css-tricks.com/svg-use-with-external-reference-take-2/)
185
185
 
186
186
  [MDN docs](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/use)
187
187
 
188
- You can do it while using this plugin, but it's not remarkably efficient; build
189
- & inject the reference file on your own, and then write your SVG files like
190
- this:
188
+ You can do it while using this plugin, but you have to do most of it yourself: build & inject the
189
+ reference file on your own, and then write your SVG files like this:
191
190
 
192
191
  ```html
193
192
  <!-- example-name.svg -->
@@ -20,32 +20,10 @@ module JekyllIconList
20
20
  super
21
21
  end
22
22
 
23
- def initialize_attributes
24
- # We will be interpolating strings with these values several times, so
25
- # initializing them with empty strings is convenient.
26
-
27
- {
28
- 'ul' => '',
29
- 'li' => '',
30
- 'img' => '',
31
- 'svg' => '',
32
- 'a' => ''
33
- }
34
- end
35
-
36
- def set_attribute_defaults
37
- @attributes = initialize_attributes
38
-
39
- @attributes.each_key do |k|
40
- if @icon_list_settings['defaults'] && @icon_list_settings['defaults'][k]
41
- @attributes[k] = @icon_list_settings['defaults'][k].dup
42
- end
43
- end
44
- end
45
-
46
23
  def parse_input
47
24
  # raw_input will look something like this:
48
25
  # 'item1 item2 item3 --ul attribute="value" --(...)'
26
+ @attributes = @icon_list_settings['defaults'].dup || {}
49
27
 
50
28
  raw_input_array = @raw_input.split('--').map { |i| i.strip.split(' ') }
51
29
  # [['item1', 'item2', 'item3'], ['ul', 'attribute="value"'], (...) ]
@@ -53,27 +31,30 @@ module JekyllIconList
53
31
  @item_shortnames = raw_input_array.shift
54
32
 
55
33
  raw_input_array.each { |a| @attributes[a.shift] = a.join ' ' }
34
+ @attributes.each_value { |v| v.prepend(' ') }
35
+ @attributes.default = '' # Convenient for concatenation
56
36
  end
57
37
 
58
38
  def build_image_tag(icon_filename)
59
- if icon_filename.split('.').pop.casecmp('svg')
39
+ if icon_filename.split('.').pop.casecmp('svg') == 0
60
40
  Jekyll::Tags::JekyllInlineSvg.send(
61
41
  :new,
62
42
  'svg',
63
- "#{icon_filename} #{@attributes['svg']}",
43
+ icon_filename + @attributes['svg'],
64
44
  @tokens
65
45
  ).render(@context)
66
46
  else
67
- "<img src=\"#{icon_filename}\" #{@attributes['img']}>"
47
+ "<img src=\"#{icon_filename}\"#{@attributes['img']}>"
68
48
  end
69
49
  end
70
50
 
71
51
  def search_path(path, item)
72
- search_results = Dir.glob(Dir.pwd + path + item + '.*')
52
+ # We have to strip the leading slash for Dir to know it's relative:
53
+ search_results = Dir.glob( path[1..-1] + item + '.*')
73
54
  raise "No icon found at #{path + item} .*" unless search_results.any?
74
55
 
75
- # Returns the first matching result. May improve in the future:
76
- search_results.first
56
+ # And put it back so that pages outside of the root directory keep working
57
+ search_results.first.prepend '/'
77
58
  end
78
59
 
79
60
  def find_icon(item_shortname, this_item_data)
@@ -94,9 +75,9 @@ module JekyllIconList
94
75
  end
95
76
 
96
77
  def build_li(this_item_data, icon_location, label)
97
- li = " <li #{@attributes['li']}>"
78
+ li = " <li#{@attributes['li']}>"
98
79
  if this_item_data && this_item_data['url']
99
- li << "<a href=\"#{this_item_data['url']}\" #{@attributes['a']}>"
80
+ li << "<a href=\"#{this_item_data['url']}\"#{@attributes['a']}>"
100
81
  end
101
82
  li << build_image_tag(icon_location)
102
83
  li << label
@@ -105,7 +86,7 @@ module JekyllIconList
105
86
  end
106
87
 
107
88
  def build_html(all_items_data)
108
- list = "<ul #{@attributes['ul']}>\n"
89
+ list = "<ul#{@attributes['ul']}>\n"
109
90
 
110
91
  @item_shortnames.each do |n|
111
92
  this_icon_data = all_items_data[n] || {}
@@ -130,8 +111,6 @@ module JekyllIconList
130
111
 
131
112
  all_items_data = site_settings.data['icon_list'] || {}
132
113
 
133
- set_attribute_defaults
134
-
135
114
  parse_input
136
115
 
137
116
  build_html(all_items_data)
@@ -1,3 +1,3 @@
1
1
  module JekyllIconList
2
- VERSION = '0.2.1'.freeze
2
+ VERSION = '0.2.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_icon_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Buchberger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-24 00:00:00.000000000 Z
11
+ date: 2018-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  version: '0'
104
104
  requirements: []
105
105
  rubyforge_project:
106
- rubygems_version: 2.7.3
106
+ rubygems_version: 2.7.6
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: Builds lists of Icons and labels