jekyll-itafroma-archive 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll/itafroma/archive_substitution.rb +63 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1dab8e51289bc538a25cdb15e08daa1f2338042
|
4
|
+
data.tar.gz: 5462c9971508af959219de8e568957f34d6ca106
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fd0371278fedaea1ac0805a9904c1d25622b6ef52a3f12c5ceee3c2dfde44c471ba71d71f07146146641d2f7e4b541e5f994a508155cd43c3d9273928d73b35
|
7
|
+
data.tar.gz: 47bf01e963daf234211b3207a1d64c4447f9269c99d3bcc87a8c725504783d0dbf2f3616702d04388bd37d962024c96356e5bb716dc45568b5a35662aea8bde3
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#
|
2
|
+
# Substitution for strings used in Jekyll Archive Generator.
|
3
|
+
#
|
4
|
+
# Author:: Mark Trapp
|
5
|
+
# Copyright: Copyright (c) 2015 Mark Trapp
|
6
|
+
# License:: MIT
|
7
|
+
# Acknowledgements:: Inspired by the work done by nlindley and ilkka on Github:
|
8
|
+
# https://gist.github.com/nlindley/6409459
|
9
|
+
# https://gist.github.com/nlindley/6409441
|
10
|
+
# https://gist.github.com/ilkka/707020
|
11
|
+
# https://gist.github.com/ilkka/707909
|
12
|
+
|
13
|
+
module Jekyll
|
14
|
+
module Itafroma
|
15
|
+
class ArchiveSubstitution
|
16
|
+
|
17
|
+
# Initialize a new ArchiveSubstitution.
|
18
|
+
#
|
19
|
+
# post - The post to generate a URL for.
|
20
|
+
#
|
21
|
+
# Returns nothing.
|
22
|
+
def initialize(post)
|
23
|
+
@post = post
|
24
|
+
end
|
25
|
+
|
26
|
+
# Substitute placeholders within a string with data from the post.
|
27
|
+
#
|
28
|
+
# Adapted from Jekyll::URL::generate_url.
|
29
|
+
#
|
30
|
+
# Returns a string containing the substituted post data.
|
31
|
+
def translate(template)
|
32
|
+
placeholders.inject(template) do |result, token|
|
33
|
+
break result if result.index(':').nil?
|
34
|
+
result.gsub(/:#{token.first}/, token.last)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Returns a Jekyll URL object for the given template.
|
39
|
+
def url(template)
|
40
|
+
URL.new({
|
41
|
+
:template => template,
|
42
|
+
:placeholders => placeholders
|
43
|
+
})
|
44
|
+
end
|
45
|
+
|
46
|
+
# Returns a hash of placeholder names (as symbols) mapping to the desired
|
47
|
+
# placeholder replacements.
|
48
|
+
def placeholders
|
49
|
+
{
|
50
|
+
:year => @post.date.strftime('%Y'),
|
51
|
+
:short_year => @post.date.strftime('%y'),
|
52
|
+
:month => @post.date.strftime('%m'),
|
53
|
+
:i_month => @post.date.strftime('%-m'),
|
54
|
+
:short_month => @post.date.strftime('%b'),
|
55
|
+
:long_month => @post.date.strftime('%B'),
|
56
|
+
:day => @post.date.strftime('%d'),
|
57
|
+
:i_day => @post.date.strftime('%-d'),
|
58
|
+
:y_day => @post.date.strftime('%j')
|
59
|
+
}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-itafroma-archive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Trapp
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- lib/jekyll/itafroma/archive_generator.rb
|
45
45
|
- lib/jekyll/itafroma/archive_page.rb
|
46
46
|
- lib/jekyll/itafroma/archive_pager.rb
|
47
|
+
- lib/jekyll/itafroma/archive_substitution.rb
|
47
48
|
homepage: http://marktrapp.com/projects/jekyll-archive
|
48
49
|
licenses:
|
49
50
|
- MIT
|