jekyll-itafroma-archive 0.4.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: 80c55e7cff0aca89064cc7d9da5c9c43deb346bb
4
- data.tar.gz: 58160aa10a21f01d43611d5768c651999d1829f3
3
+ metadata.gz: f1dab8e51289bc538a25cdb15e08daa1f2338042
4
+ data.tar.gz: 5462c9971508af959219de8e568957f34d6ca106
5
5
  SHA512:
6
- metadata.gz: cf02a340506e699b16f41034b6a00d7a3dad51c762bd97df86abaa0754c79e8314b3c3e59815c0fa1346b0a91b6e8a8adf5edba84b00006bff0d8fff5adf38c6
7
- data.tar.gz: 683a3360166b583128226564d92b1055d80812579fa10201158843e59d011e7e5d096308fef15ff25beaab14ae4fef1a8765ccb077d8b89c74fc294ea928dabe
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.0
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