jekyll-file-protocol 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e418656e1f83e82a737545da93852ef808324a35
4
- data.tar.gz: d344d91df65bfe4aca4dd06d365d540658d9e51c
3
+ metadata.gz: 0556055def8a3132be2a980da5e5eca1bd2b82fa
4
+ data.tar.gz: e08f69269cf12a3f023ff001cf27e5094c811788
5
5
  SHA512:
6
- metadata.gz: 91ef34632a1f22eb06ab6ab3837ed1d790e730ab50502d391155bec1ed06974c5c1643ab38bb0314f3f40d4a167c359d05b15064238338a5345cc48be72a74c1
7
- data.tar.gz: e8e4c45719a32436ec80cfc633d3f275ab0e508374dbd0a1e4e61bdf85d37ea5225b9a31d4f07a1bd17b3d6c13c279ab4c74318eafe4ad649ab3276f561ad9d7
6
+ metadata.gz: 42c3fc214640418af2f91a0c1b665c31e6c1fd104ae41ebe744933e78f8b2d5dcaf55b1abd7bbcfb3fec1529c78c0bdfb2d8472b062c1ef0de7a355c6c7a8bce
7
+ data.tar.gz: e411b1a2f5d7b646366318adad202917d4d4e2a5289f42653adc4baf3b20896b3ad1dcb823951da0d5eca30442a626e4fa72b008510e5f60b4bbea8fe206c0c8
data/README.md CHANGED
@@ -10,7 +10,7 @@ This gem is born to help me creating relative paths for filters of the gem [jeky
10
10
 
11
11
  Add this line to your application's Gemfile:
12
12
 
13
- gem 'jekyll-file-protocol', '~> 0.3.0'
13
+ gem 'jekyll-file-protocol', '~> 0.4.1'
14
14
 
15
15
  And then execute:
16
16
 
@@ -68,7 +68,18 @@ The other filter is `relative_tag` which can be used with `stylesheet`,
68
68
 
69
69
  And the output is the same as before.
70
70
  There are also some useful helpers (tags) to get url filename with and without
71
- extension: `url_filename` and `url_filename_with_ext`.
71
+ extension and directory of url filename:
72
+ `url_filename`, `url_filename_with_ext` and `url_directoryname`.
73
+
74
+ Examples
75
+
76
+ ```
77
+ # /this/is/my/test.html
78
+
79
+ {% url_filename %} # => test
80
+ {% url_filename_with_ext %} # => test.html
81
+ {% url_directoryname %} # => my
82
+ ```
72
83
 
73
84
  ## TODO
74
85
 
@@ -21,7 +21,7 @@ module JekyllFileProtocol
21
21
  tags = nil
22
22
 
23
23
  # Stylesheet
24
- if tags = node.css('link').to_a
24
+ if (tags = node.css('link').to_a).size < 1
25
25
  return tags.map do |tag|
26
26
  tag['href'] = ::JekyllFileProtocol::RelativePathRenderer.new(@context, tag['href']).render
27
27
  tag
@@ -29,7 +29,7 @@ module JekyllFileProtocol
29
29
  end
30
30
 
31
31
  # Javascript
32
- if tags = node.css('script').to_a
32
+ if (tags = node.css('script').to_a).size < 1
33
33
  return tags.map do |tag|
34
34
  tag['src'] = ::JekyllFileProtocol::RelativePathRenderer.new(@context, tag['src']).render
35
35
  tag
@@ -37,7 +37,7 @@ module JekyllFileProtocol
37
37
  end
38
38
 
39
39
  # Image
40
- if tags = node.css('img').to_a
40
+ if (tags = node.css('img').to_a).size < 1
41
41
  return tags.map do |tag|
42
42
  tag['src'] = ::JekyllFileProtocol::RelativePathRenderer.new(@context, tag['src']).render
43
43
  tag
@@ -0,0 +1,27 @@
1
+ require 'uri'
2
+ require 'liquid'
3
+
4
+ module JekyllFileProtocol
5
+
6
+ module Jekyll
7
+
8
+ class UrlDirectorynameTag < Liquid::Tag
9
+
10
+ def initialize(tag_name, param, tokens)
11
+ super
12
+ end
13
+
14
+ def render(context)
15
+ uri = URI.parse(context.registers[:page]['url'])
16
+
17
+ File.basename(File.dirname(uri.path))
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+
26
+
27
+ Liquid::Template.register_tag 'url_directoryname', JekyllFileProtocol::Jekyll::UrlDirectorynameTag
@@ -1,3 +1,3 @@
1
1
  module JekyllFileProtocol
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -3,6 +3,7 @@ require 'jekyll-file-protocol/relative_path_renderer'
3
3
  require 'jekyll-file-protocol/jekyll/filters/relative_path'
4
4
  require 'jekyll-file-protocol/jekyll/tags/url_filename'
5
5
  require 'jekyll-file-protocol/jekyll/tags/url_filename_with_ext'
6
+ require 'jekyll-file-protocol/jekyll/tags/url_directoryname'
6
7
 
7
8
 
8
9
  module JekyllFileProtocol
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-file-protocol
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fire-Dragon-DoL
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-28 00:00:00.000000000 Z
11
+ date: 2013-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -96,6 +96,7 @@ files:
96
96
  - jekyll-file-protocol.gemspec
97
97
  - lib/jekyll-file-protocol.rb
98
98
  - lib/jekyll-file-protocol/jekyll/filters/relative_path.rb
99
+ - lib/jekyll-file-protocol/jekyll/tags/url_directoryname.rb
99
100
  - lib/jekyll-file-protocol/jekyll/tags/url_filename.rb
100
101
  - lib/jekyll-file-protocol/jekyll/tags/url_filename_with_ext.rb
101
102
  - lib/jekyll-file-protocol/relative_path_renderer.rb