lifer 0.13.0 → 0.14.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 +4 -4
- data/CHANGELOG.md +19 -0
- data/Gemfile.lock +1 -1
- data/lib/lifer/brain.rb +2 -7
- data/lib/lifer/builder/html/from_any.rb +1 -1
- data/lib/lifer/builder/html/from_erb.rb +18 -12
- data/lib/lifer/builder/html.rb +1 -1
- data/lib/lifer/builder/txt.rb +1 -1
- data/lib/lifer/collection.rb +3 -2
- data/lib/lifer/entry.rb +6 -0
- data/lib/lifer/selection.rb +4 -2
- data/lib/lifer/tag.rb +13 -2
- data/lib/lifer/templates/config.yaml +1 -0
- data/lib/lifer/uri_strategy.rb +1 -1
- data/lib/lifer/version.rb +1 -1
- data/lib/lifer.rb +15 -10
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b4416a9edb890d8d98adc06d1baf7e58b695d85da827b48005d7285b6f5a1dbe
|
|
4
|
+
data.tar.gz: 0c45a40304601d473c946315ddea56860041339e029467f8bcecb603ca70a58a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b8aa3c53f350191b59ff5105ac1130c62c4a2f690aca83794877b933e7d7bfa23e501d2c91bd90dfc4954a4db9edf57b5db8ea4c4bf75fe78aa3e3e3e7e20e0c
|
|
7
|
+
data.tar.gz: f9b729936ec8ef025d9bc6dc8b6deab6d4d63c1d281da50e99df5932cd1f245c581c911378a703f1ddb7e6a5167f21fa746a780ac9e9ad72f29721d93bf34215
|
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
## Next
|
|
2
|
+
## v0.14.0
|
|
3
|
+
|
|
4
|
+
This release includes some really nice improvements and bug fixes:
|
|
5
|
+
|
|
6
|
+
- When returning a list of entries belonging to a `Lifer::Collection` or a
|
|
7
|
+
`Lifer::Tag`, the entries are now returned in reverse chronological order
|
|
8
|
+
by default. (But you can pass the argument `order: :oldest` to get them
|
|
9
|
+
in reverse, if you want.)
|
|
10
|
+
- We fixed a bug where entries in `.html.erb` format that attempted to render
|
|
11
|
+
view partials would error out due to the `render` method not having been
|
|
12
|
+
defined with the context of the entry being built yet. This bug was a bit
|
|
13
|
+
unpleasant to reason about, but it resolves a major defect with ERB building.
|
|
14
|
+
- The included Lifer configuration file template now enables the
|
|
15
|
+
JSON Feed builder by default.
|
|
16
|
+
- Every `Lifer::Selection` name is now automatically registered as a setting so
|
|
17
|
+
that you can configure it like you configure any other collection of entries.
|
|
18
|
+
- Lastly, this release removes `Lifer.manifest`. (A collection of absolute
|
|
19
|
+
paths to every entry file ended up not being incredibly useful. We get
|
|
20
|
+
the same-ish functionality from `Lifer.entry_manifest`.)
|
|
2
21
|
|
|
3
22
|
## v0.13.0
|
|
4
23
|
|
data/Gemfile.lock
CHANGED
data/lib/lifer/brain.rb
CHANGED
|
@@ -94,17 +94,12 @@ class Lifer::Brain
|
|
|
94
94
|
# @return [Lifer::Config] The Lifer configuration object.
|
|
95
95
|
def config = (@config ||= Lifer::Config.build file: config_file_location)
|
|
96
96
|
|
|
97
|
-
#
|
|
98
|
-
#
|
|
97
|
+
# Allows for getting the entry manifest or shovelling new entries to the
|
|
98
|
+
# entry manifest.
|
|
99
99
|
#
|
|
100
100
|
# @return [Set<Lifer::Entry>] All entries that currently exist.
|
|
101
101
|
def entry_manifest = (@entry_manifest ||= Set.new)
|
|
102
102
|
|
|
103
|
-
# A manifest of all Lifer project entries.
|
|
104
|
-
#
|
|
105
|
-
# @return [Set<Lifer::Entry>] A set of all entries.
|
|
106
|
-
def manifest = (@manifest ||= Set.new)
|
|
107
|
-
|
|
108
103
|
# Returns the build directory for the Lifer project's build output.
|
|
109
104
|
#
|
|
110
105
|
# @return [String] The Lifer build directory.
|
|
@@ -11,7 +11,7 @@ class Lifer::Builder::HTML
|
|
|
11
11
|
# </head>
|
|
12
12
|
#
|
|
13
13
|
# <body>
|
|
14
|
-
# <%=
|
|
14
|
+
# <%= render "_layouts/header.html.erb" %>
|
|
15
15
|
#
|
|
16
16
|
# <h1><%= my_collection.name %></h1>
|
|
17
17
|
#
|
|
@@ -23,7 +23,7 @@ class Lifer::Builder::HTML
|
|
|
23
23
|
# </section>
|
|
24
24
|
# <% end %>
|
|
25
25
|
#
|
|
26
|
-
# <%=
|
|
26
|
+
# <%= render "_layouts/footer.html.erb" %>
|
|
27
27
|
# </body>
|
|
28
28
|
# </html>
|
|
29
29
|
#
|
|
@@ -101,16 +101,20 @@ class Lifer::Builder::HTML
|
|
|
101
101
|
collections = collection_context_class.new Lifer.collections
|
|
102
102
|
tags = tag_context_class.new Lifer.tags
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
ERB.new(entry.to_html).result(binding)
|
|
104
|
+
current_binding = binding
|
|
105
|
+
current_binding.local_variable_set :collections, collections
|
|
106
|
+
current_binding.local_variable_set :settings, Lifer.settings
|
|
107
|
+
current_binding.local_variable_set :tags, tags
|
|
109
108
|
|
|
110
109
|
define_singleton_method :render,
|
|
111
110
|
-> (relative_path_to_template, locals = {}) {
|
|
112
|
-
partial_render_method relative_path_to_template,
|
|
111
|
+
partial_render_method relative_path_to_template,
|
|
112
|
+
locals,
|
|
113
|
+
current_binding
|
|
113
114
|
}
|
|
115
|
+
|
|
116
|
+
current_binding.local_variable_set :content,
|
|
117
|
+
ERB.new(entry.to_html).result(binding)
|
|
114
118
|
}
|
|
115
119
|
end
|
|
116
120
|
|
|
@@ -130,21 +134,23 @@ class Lifer::Builder::HTML
|
|
|
130
134
|
# available from entry and layout templates.
|
|
131
135
|
#
|
|
132
136
|
# @example Usage
|
|
133
|
-
# <%=
|
|
137
|
+
# <%= render "_layouts/my_partial.html.erb", id: "123" %>
|
|
134
138
|
# @param relative_path_to_template [String] The path, from the Lifer root,
|
|
135
139
|
# to the partial layout file.
|
|
136
140
|
# @param locals [Hash] Additional data that should be passed along for
|
|
137
141
|
# rendering the partial.
|
|
142
|
+
# @param source_binding [Binding] A binding object carrying context
|
|
143
|
+
# required to render the current partial layout.
|
|
138
144
|
# @return [String] The rendered partial document.
|
|
139
|
-
def partial_render_method(relative_path_to_template, locals)
|
|
145
|
+
def partial_render_method(relative_path_to_template, locals, source_binding)
|
|
140
146
|
template_path = File.join(Lifer.root, relative_path_to_template)
|
|
141
147
|
|
|
142
148
|
partial_binding = binding.tap { |binding|
|
|
143
|
-
|
|
149
|
+
source_binding.local_variables.each do |variable|
|
|
144
150
|
next if variable == :content
|
|
145
151
|
|
|
146
152
|
binding.local_variable_set variable,
|
|
147
|
-
|
|
153
|
+
source_binding.local_variable_get(variable)
|
|
148
154
|
end
|
|
149
155
|
|
|
150
156
|
locals.each do |key, value|
|
data/lib/lifer/builder/html.rb
CHANGED
|
@@ -116,7 +116,7 @@ class Lifer::Builder::HTML < Lifer::Builder
|
|
|
116
116
|
# entry cannot be output to HTML. We should not care about this return
|
|
117
117
|
# value.
|
|
118
118
|
def generate_output_file_for(entry)
|
|
119
|
-
return unless entry.
|
|
119
|
+
return unless entry.output_extension == :html
|
|
120
120
|
|
|
121
121
|
relative_path = output_file entry
|
|
122
122
|
absolute_path = File.join(Lifer.output_directory, relative_path)
|
data/lib/lifer/builder/txt.rb
CHANGED
|
@@ -56,7 +56,7 @@ class Lifer::Builder::TXT < Lifer::Builder
|
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
def generate_output_file_for(entry)
|
|
59
|
-
return unless entry.
|
|
59
|
+
return unless entry.output_extension == :txt
|
|
60
60
|
|
|
61
61
|
relative_path = output_file entry
|
|
62
62
|
absolute_path = File.join(Lifer.output_directory, relative_path)
|
data/lib/lifer/collection.rb
CHANGED
|
@@ -32,12 +32,13 @@ class Lifer::Collection
|
|
|
32
32
|
.select { |candidate| Lifer::Entry.supported? candidate }
|
|
33
33
|
|
|
34
34
|
entries = entry_glob.select { |entry|
|
|
35
|
-
|
|
35
|
+
filenames = Lifer.entry_manifest.map(&:file)
|
|
36
|
+
|
|
37
|
+
if filenames.include? entry
|
|
36
38
|
false
|
|
37
39
|
elsif Lifer.ignoreable? entry.gsub("#{directory}/", "")
|
|
38
40
|
false
|
|
39
41
|
else
|
|
40
|
-
Lifer.manifest << entry
|
|
41
42
|
true
|
|
42
43
|
end
|
|
43
44
|
}.map { |entry| Lifer::Entry.generate file: entry, collection: }
|
data/lib/lifer/entry.rb
CHANGED
|
@@ -205,6 +205,12 @@ module Lifer
|
|
|
205
205
|
@full_text ||= File.readlines(file).join if file
|
|
206
206
|
end
|
|
207
207
|
|
|
208
|
+
# The file extension to be used when at the entry's build time. For
|
|
209
|
+
# example, a Markdown file should be built to HTML.
|
|
210
|
+
#
|
|
211
|
+
# @return [String]
|
|
212
|
+
def output_extension = self.class.output_extension
|
|
213
|
+
|
|
208
214
|
# Using the current Lifer configuration, we can calculate the expected
|
|
209
215
|
# permalink for the entry. For example:
|
|
210
216
|
#
|
data/lib/lifer/selection.rb
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# detected Ruby files are dynamically loaded when `Lifer::Brain` is initialized.
|
|
7
7
|
#
|
|
8
8
|
# Implementing a selection is simple. Just implement the `#entries` method and
|
|
9
|
-
#
|
|
9
|
+
# provide a name. The `#entries` method can be used to filter down
|
|
10
10
|
# `Lifer.entry_manifest` in whichever way one needs. To see examples of this,
|
|
11
11
|
# check out the source code of any of the included selections.
|
|
12
12
|
#
|
|
@@ -25,7 +25,9 @@ class Lifer::Selection < Lifer::Collection
|
|
|
25
25
|
#
|
|
26
26
|
# @return [Lifer::Selection]
|
|
27
27
|
def generate
|
|
28
|
-
new(name: name, directory: nil)
|
|
28
|
+
selection = new(name: name, directory: nil)
|
|
29
|
+
Lifer.register_settings name
|
|
30
|
+
selection
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
private
|
data/lib/lifer/tag.rb
CHANGED
|
@@ -43,11 +43,22 @@ module Lifer
|
|
|
43
43
|
|
|
44
44
|
attr_accessor :name
|
|
45
45
|
|
|
46
|
-
attr_reader :entries
|
|
47
|
-
|
|
48
46
|
def initialize(name:, entries:)
|
|
49
47
|
@name = name
|
|
50
48
|
@entries = entries
|
|
51
49
|
end
|
|
50
|
+
|
|
51
|
+
# Returns the tag's associated entries in order.
|
|
52
|
+
#
|
|
53
|
+
# @param order [Symbol] Either :latest (descending) or :oldest (ascending).
|
|
54
|
+
# @return [Array<Lifer::Entry>] The entries for the current tag.
|
|
55
|
+
def entries(order: :latest)
|
|
56
|
+
case order
|
|
57
|
+
when :latest
|
|
58
|
+
@entries.sort_by { |entry| entry.published_at }.reverse
|
|
59
|
+
when :oldest
|
|
60
|
+
@entries.sort_by { |entry| entry.published_at }
|
|
61
|
+
end
|
|
62
|
+
end
|
|
52
63
|
end
|
|
53
64
|
end
|
data/lib/lifer/uri_strategy.rb
CHANGED
data/lib/lifer/version.rb
CHANGED
data/lib/lifer.rb
CHANGED
|
@@ -81,9 +81,21 @@ module Lifer
|
|
|
81
81
|
# @return [Pathname] The path to the current Lifer config file.
|
|
82
82
|
def config_file = brain.config.file
|
|
83
83
|
|
|
84
|
-
#
|
|
85
|
-
#
|
|
86
|
-
# @
|
|
84
|
+
# Uses the entry manifest to return entries in the specified order.
|
|
85
|
+
#
|
|
86
|
+
# @param order [Symbol] Either :latest (descending) or :oldest (ascending).
|
|
87
|
+
# @return [Set] All entries in the specified order.
|
|
88
|
+
def entries(order: :latest)
|
|
89
|
+
case order
|
|
90
|
+
when :latest
|
|
91
|
+
entry_manifest.sort_by { |entry| entry.published_at }.reverse
|
|
92
|
+
when :oldest
|
|
93
|
+
entry_manifest.sort_by { |entry| entry.published_at }
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Allows for getting the entry manifest or shovelling new entries to the
|
|
98
|
+
# entry manifest.
|
|
87
99
|
#
|
|
88
100
|
# @return [Set] All entries.
|
|
89
101
|
def entry_manifest = brain.entry_manifest
|
|
@@ -103,13 +115,6 @@ module Lifer
|
|
|
103
115
|
directory_or_file.match?(/#{IGNORE_PATTERNS.join("|")}/)
|
|
104
116
|
end
|
|
105
117
|
|
|
106
|
-
# A set of all entries currently in the project.
|
|
107
|
-
#
|
|
108
|
-
# @fixme Do we need this as well as `Lifer.manifest`?
|
|
109
|
-
#
|
|
110
|
-
# @return [Set] All entries.
|
|
111
|
-
def manifest = brain.manifest
|
|
112
|
-
|
|
113
118
|
# The build directory for the Lifer project.
|
|
114
119
|
#
|
|
115
120
|
# @return [Pathname] The absolute path to the directory where the Lifer
|
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.
|
|
4
|
+
version: 0.14.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: 2026-
|
|
11
|
+
date: 2026-06-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|
|
@@ -229,8 +229,8 @@ licenses:
|
|
|
229
229
|
- MIT
|
|
230
230
|
metadata:
|
|
231
231
|
allowed_push_host: https://rubygems.org
|
|
232
|
-
homepage_uri: https://github.com/benjaminwil/lifer/blob/v0.
|
|
233
|
-
source_code_uri: https://github.com/benjaminwil/lifer/tree/v0.
|
|
232
|
+
homepage_uri: https://github.com/benjaminwil/lifer/blob/v0.14.0/README.md
|
|
233
|
+
source_code_uri: https://github.com/benjaminwil/lifer/tree/v0.14.0
|
|
234
234
|
changelog_uri: https://github.com/benjaminwil/lifer/blob/main/CHANGELOG.md
|
|
235
235
|
post_install_message:
|
|
236
236
|
rdoc_options: []
|