jekyll-filepath 0.2.0
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 +7 -0
- data/lib/jekyll-filepath.rb +36 -0
- metadata +58 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b2c1f645940f4b2aa75db48acb24f6e2e9fe55cf
|
4
|
+
data.tar.gz: 28dd6429aa7240f3ae936107b4a87327596d35d6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: db1aad2802d615270cfe405fbd6db8529deb90d335265e161aa3e6a1a60056fa1a7cf1e411efb2a886a54c4521eca577803a6ed48ea9ea26ccf9f8f60965d43d
|
7
|
+
data.tar.gz: e5cd861c2788c2e5fc62e60ed99d7d7b3896a370951f62c7ed0b5432f39329f6d5e2a3e8b7618fb91a68074127e3bbd4a9b9629c95ea63496837c991bd95a748
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Jekyll
|
2
|
+
class FilePath < Liquid::Tag
|
3
|
+
@markup = nil
|
4
|
+
|
5
|
+
def initialize(tag_name, markup, tokens)
|
6
|
+
@markup = markup.strip
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def render(context)
|
11
|
+
if @markup.empty?
|
12
|
+
return "Expected syntax {% filepath [filename] %}"
|
13
|
+
end
|
14
|
+
|
15
|
+
rawFilename = Liquid::Template.parse(@markup).render context
|
16
|
+
filename = rawFilename.gsub(/^("|')|("|')$/, '')
|
17
|
+
path = ""
|
18
|
+
page = context.environments.first["page"]
|
19
|
+
|
20
|
+
if page["id"]
|
21
|
+
context.registers[:site].posts.each do |post|
|
22
|
+
if post.id == page["id"]
|
23
|
+
path = "#{post.relative_path}".gsub(/_posts/, '').gsub(/.md/, '')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
else
|
27
|
+
path = page["url"]
|
28
|
+
end
|
29
|
+
|
30
|
+
path = File.dirname(path) if path =~ /\.\w+$/
|
31
|
+
"/files/#{path}/#{filename}".gsub(/\/{2,}/, '/')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
Liquid::Template.register_tag('filepath', Jekyll::FilePath)
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-filepath
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Manuel Gruber
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-30 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: 2.5.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.5.3
|
27
|
+
description: FilePath gem for Jekyll
|
28
|
+
email: g@manuelgruber.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/jekyll-filepath.rb
|
34
|
+
homepage: http://manuelgruber.com
|
35
|
+
licenses:
|
36
|
+
- MIT
|
37
|
+
metadata: {}
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 2.4.8
|
55
|
+
signing_key:
|
56
|
+
specification_version: 4
|
57
|
+
summary: FilePath
|
58
|
+
test_files: []
|