lifer 0.10.2 → 0.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0628d28de38f509eb51cc2d2dd65cb794fe3e4e46239bbf11c82decfd28f1d5d'
4
- data.tar.gz: dcb12aba6fa318f57c3224fed97a6a28233b847ca7399f321c855a739a44543b
3
+ metadata.gz: a63fea0c89c87889fa7aab9fc17e53385a562d2bf5bbca5aa552076acc31ed10
4
+ data.tar.gz: d158cad653234c27d4f17291f2a4511e3896684e148e5aa12206ffdef4403603
5
5
  SHA512:
6
- metadata.gz: 0d74bf3c194492fec78a17ca70045dd107a40ddf33cf154243b33bb0a9d13876b1b0bdc4ea6bbf40c15984bf6a2a86dc898ed55939c9e222cf86d4cadd73b8d3
7
- data.tar.gz: af6d75bd7b875807c8fc74c69b04c5849d0d5e787a4ae6516f8af5189eb22e668d249660f741802b90209d9c2697909ae69400f364fc80a7dfe703a69490bb78
6
+ metadata.gz: 59974cefd0e30b280ff61b6e2d624aea02ddeb099afc97eff50796f208f09f1a8327a91004441b87f5e7b5ea1d66908f8ebd56c467d1e2bdddf7f4ed8d1faafe
7
+ data.tar.gz: b4b288d0a7dd6e1766bdd8dc6ea72b7851aabaaaf16eb6eaf3a1c11f6d14ef2a3d2f4f859c38f6c4ed6127afedb1655cf9b5f705ade2d22683eb3f27224f8589
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  ## Next
2
2
 
3
+ ## v0.11.0
4
+
5
+ This release adds new functionality to our URI strategies, adding
6
+ `URIStrategy#permalink`, to make support for pretty URI strategies (i.e. where
7
+ entries all end in `/index.ext`) better and more compatible with web servers
8
+ where `foo` is the "same thing" as `foo/index.html`.
9
+
10
+ Example output filename:
11
+
12
+ /my/filename/index.html
13
+
14
+ Expected permalink for this file using a pretty URI strategy:
15
+
16
+ /my/filename
17
+
3
18
  ## v0.10.2
4
19
 
5
20
  This release resolves another bug in `Entry#summary` causing entries without
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lifer (0.10.2)
4
+ lifer (0.11.0)
5
5
  i18n (< 2)
6
6
  kramdown (~> 2.4)
7
7
  liquid (~> 5.6, < 6)
data/lib/lifer/entry.rb CHANGED
@@ -194,9 +194,10 @@ module Lifer
194
194
  cached_permalink_variable,
195
195
  File.join(
196
196
  host,
197
- Lifer::URIStrategy.find(collection.setting :uri_strategy)
197
+ Lifer::URIStrategy
198
+ .find(collection.setting :uri_strategy)
198
199
  .new(root: Lifer.root)
199
- .output_file(self)
200
+ .permalink(self)
200
201
  )
201
202
  )
202
203
  end
@@ -14,8 +14,15 @@ class Lifer::URIStrategy::Pretty < Lifer::URIStrategy
14
14
  basename = File.basename entry.file,
15
15
  Lifer::Utilities.file_extension(entry.file)
16
16
 
17
- Pathname entry.file.to_s
17
+ entry.file.to_s
18
18
  .gsub(/#{root}[\/]{0,1}/, "")
19
- .gsub(/#{basename}(\..+)/, "#{basename}/index.#{file_extension(entry)}")
19
+ .gsub(/#{basename}(\..+)/, "#{basename}#{pretty_part entry}")
20
20
  end
21
+
22
+ # @see Lifer::UriStrategy#permalink
23
+ def permalink(entry) = output_file(entry).gsub pretty_part(entry), ""
24
+
25
+ private
26
+
27
+ def pretty_part(entry) = "/index.#{file_extension(entry)}"
21
28
  end
@@ -11,14 +11,28 @@ class Lifer::URIStrategy
11
11
 
12
12
  # @see Lifer::URIStrategy#output_file
13
13
  def output_file(entry)
14
- basename = File.basename entry.file,
15
- Lifer::Utilities.file_extension(entry.file)
14
+ if basename(entry) == "index"
15
+ "index.html"
16
+ else
17
+ "#{basename entry}#{pretty_part entry}"
18
+ end
19
+ end
16
20
 
17
- if basename == "index"
18
- Pathname "index.html"
21
+ # @see Lifer::UriStrategy#permalink
22
+ def permalink(entry)
23
+ if basename(entry) == "index"
24
+ "/"
19
25
  else
20
- Pathname "#{basename}/index.#{file_extension(entry)}"
26
+ output_file(entry).gsub pretty_part(entry), ""
21
27
  end
22
28
  end
29
+
30
+ private
31
+
32
+ def basename(entry)
33
+ File.basename entry.file, Lifer::Utilities.file_extension(entry.file)
34
+ end
35
+
36
+ def pretty_part(entry) = "/index.#{file_extension(entry)}"
23
37
  end
24
38
  end
@@ -24,9 +24,16 @@
24
24
  basename = File.basename entry.file,
25
25
  Lifer::Utilities.file_extension(entry.file)
26
26
 
27
- Pathname entry.file.to_s
27
+ entry.file.to_s
28
28
  .gsub(/#{root}[\/]{0,1}/, "")
29
- .gsub(/#{basename}(\..+)/, "#{basename}/index.#{file_extension(entry)}")
29
+ .gsub(/#{basename}(\..+)/, "#{basename}#{pretty_part entry}")
30
30
  .gsub(DATE_REGEXP, "")
31
31
  end
32
+
33
+ # @see Lifer::UriStrategy#permalink
34
+ def permalink(entry) = output_file(entry).gsub pretty_part(entry), ""
35
+
36
+ private
37
+
38
+ def pretty_part(entry) = "/index.#{file_extension(entry)}"
32
39
  end
@@ -11,7 +11,10 @@ class Lifer::URIStrategy
11
11
  basename = File.basename entry.file,
12
12
  Lifer::Utilities.file_extension(entry.file)
13
13
 
14
- Pathname "#{basename}.#{file_extension(entry)}"
14
+ "#{basename}.#{file_extension(entry)}"
15
15
  end
16
+
17
+ # @see Lifer::UriStrategy#permalink
18
+ def permalink(entry) = output_file(entry)
16
19
  end
17
20
  end
@@ -10,8 +10,11 @@ class Lifer::URIStrategy::Simple < Lifer::URIStrategy
10
10
  basename = File.basename entry.file,
11
11
  Lifer::Utilities.file_extension(entry.file)
12
12
 
13
- Pathname entry.file.to_s
13
+ entry.file.to_s
14
14
  .gsub(/#{root}[\/]{0,1}/, "")
15
15
  .gsub(/#{basename}(\..+)/, "#{basename}.#{file_extension(entry)}")
16
16
  end
17
+
18
+ # @see Lifer::UriStrategy#permalink
19
+ def permalink(entry) = output_file(entry)
17
20
  end
@@ -39,6 +39,24 @@ class Lifer::URIStrategy
39
39
  raise NotImplementedError, I18n.t("shared.not_implemented_method")
40
40
  end
41
41
 
42
+ # This method should sometimes return the path to the file in the format
43
+ # specified by the current URI strategy. Of course, this depends on what the URI
44
+ # stategy is. For "pretty" strategies, the permalink may differ from the output
45
+ # filename. For example, the output file may point to
46
+ #
47
+ # entry-name/index.html
48
+ #
49
+ # While the permalink like points to:
50
+ #
51
+ # entry-name
52
+ #
53
+ # @raise [NotImplementedError] This method must be implemented on each
54
+ # subclass.
55
+ # @return [String] The permalink to the built output file.
56
+ def permalink(entry)
57
+ raise NotImplementedError, I18n.t("shared.not_implemented_error")
58
+ end
59
+
42
60
  private
43
61
 
44
62
  def file_extension(entry) = entry.class.output_extension
data/lib/lifer/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lifer
2
- VERSION = "0.10.2"
2
+ VERSION = "0.11.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lifer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - benjamin wil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-10 00:00:00.000000000 Z
11
+ date: 2025-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -210,8 +210,8 @@ licenses:
210
210
  - MIT
211
211
  metadata:
212
212
  allowed_push_host: https://rubygems.org
213
- homepage_uri: https://github.com/benjaminwil/lifer/blob/v0.10.2/README.md
214
- source_code_uri: https://github.com/benjaminwil/lifer/tree/v0.10.2
213
+ homepage_uri: https://github.com/benjaminwil/lifer/blob/v0.11.0/README.md
214
+ source_code_uri: https://github.com/benjaminwil/lifer/tree/v0.11.0
215
215
  changelog_uri: https://github.com/benjaminwil/lifer/blob/main/CHANGELOG.md
216
216
  post_install_message:
217
217
  rdoc_options: []