lifer 0.6.1 → 0.8.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 +38 -0
- data/Gemfile.lock +1 -1
- data/lib/lifer/brain.rb +15 -9
- data/lib/lifer/builder/html/from_erb.rb +24 -5
- data/lib/lifer/builder/html/from_liquid/drops/collection_drop.rb +3 -3
- data/lib/lifer/builder/html/from_liquid/drops/collections_drop.rb +4 -3
- data/lib/lifer/builder/html/from_liquid/drops/entry_drop.rb +3 -3
- data/lib/lifer/builder/html/from_liquid/drops/frontmatter_drop.rb +2 -3
- data/lib/lifer/builder/html/from_liquid/drops/settings_drop.rb +2 -1
- data/lib/lifer/builder/html/from_liquid/drops/tag_drop.rb +42 -0
- data/lib/lifer/builder/html/from_liquid/drops/tags_drop.rb +43 -0
- data/lib/lifer/builder/html/from_liquid/drops.rb +2 -0
- data/lib/lifer/builder/html/from_liquid/filters.rb +3 -5
- data/lib/lifer/builder/html/from_liquid/layout_tag.rb +1 -2
- data/lib/lifer/builder/html/from_liquid.rb +4 -2
- data/lib/lifer/builder/html.rb +1 -1
- data/lib/lifer/builder/rss.rb +62 -8
- data/lib/lifer/builder.rb +2 -1
- data/lib/lifer/config.rb +1 -1
- data/lib/lifer/dev/response.rb +2 -3
- data/lib/lifer/dev/server.rb +2 -3
- data/lib/lifer/entry/html.rb +10 -13
- data/lib/lifer/entry/markdown.rb +22 -90
- data/lib/lifer/entry/txt.rb +11 -14
- data/lib/lifer/entry.rb +252 -129
- data/lib/lifer/selection.rb +4 -4
- data/lib/lifer/shared/finder_methods.rb +1 -2
- data/lib/lifer/tag.rb +53 -0
- data/lib/lifer/templates/config.yaml +7 -0
- data/lib/lifer/utilities.rb +7 -8
- data/lib/lifer/version.rb +1 -1
- data/lib/lifer.rb +15 -4
- data/lifer.gemspec +2 -2
- data/locales/en.yml +2 -3
- metadata +7 -4
data/lib/lifer/selection.rb
CHANGED
@@ -48,13 +48,13 @@ class Lifer::Selection < Lifer::Collection
|
|
48
48
|
raise NotImplementedError, I18n.t("selection.entries_not_implemented")
|
49
49
|
end
|
50
50
|
|
51
|
-
# FIXME:
|
52
|
-
# Getting selection settings may actually need to be different than getting
|
53
|
-
# collection settings. But for now let's just inherit the superclass method.
|
54
|
-
#
|
55
51
|
# A getter for selection settings. See `Lifer::Collection#setting` for more
|
56
52
|
# information.
|
57
53
|
#
|
54
|
+
# @fixme Getting selection settings may actually need to be different than
|
55
|
+
# getting collection settings. But for now let's just inherit the
|
56
|
+
# superclass method.
|
57
|
+
#
|
58
58
|
# @return [String, Symbol, NilClass] The setting for the collection (or a
|
59
59
|
# fallback setting, or a default setting).
|
60
60
|
def setting(...)
|
data/lib/lifer/tag.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
module Lifer
|
2
|
+
# A tag is a way to categorize entries. You've likely encountered tags in
|
3
|
+
# other software before. In Lifer, tags are sort of the inverse of
|
4
|
+
# collections. It's a nice way to associate entries across many collections.
|
5
|
+
#
|
6
|
+
# Because tags are used to link entries, we definitely do not want duplicate
|
7
|
+
# tags. So the only way to build or retrieve tags is via the
|
8
|
+
# `.build_or_update` class method, which helps us responsibly manage the
|
9
|
+
# global tag manifest.
|
10
|
+
#
|
11
|
+
class Tag
|
12
|
+
class << self
|
13
|
+
# Builds or updates a Lifer tag. On update, its list of entries gets
|
14
|
+
# freshened.
|
15
|
+
#
|
16
|
+
# @param name [String] The name of the tag.
|
17
|
+
# @param entries [Array<Lifer::Entry>] A list of entries that should be
|
18
|
+
# associated with the tag. This parameter is not a true writer, in that
|
19
|
+
# if the tag already exists, old entry associations won't be removed--
|
20
|
+
# only appended to.
|
21
|
+
# @return [Lifer:Tag] The new or updated tag.
|
22
|
+
def build_or_update(name:, entries: [])
|
23
|
+
update(name:, entries:) || build(name:, entries:)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def build(name:, entries:)
|
29
|
+
if (new_tag = new(name:, entries:))
|
30
|
+
Lifer.tag_manifest << new_tag
|
31
|
+
end
|
32
|
+
new_tag || false
|
33
|
+
end
|
34
|
+
|
35
|
+
def update(name:, entries:)
|
36
|
+
if (tag = Lifer.tags.detect { _1.name == name })
|
37
|
+
tag.instance_variable_set :@entries,
|
38
|
+
(tag.instance_variable_get(:@entries) | entries)
|
39
|
+
end
|
40
|
+
tag || false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
attr_accessor :name
|
45
|
+
|
46
|
+
attr_reader :entries
|
47
|
+
|
48
|
+
def initialize(name:, entries:)
|
49
|
+
@name = name
|
50
|
+
@entries = entries
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -32,6 +32,13 @@ uri_strategy: simple
|
|
32
32
|
### uri_strategy: pretty
|
33
33
|
###
|
34
34
|
### layout_file: path/to/my_other_layout.html.erb
|
35
|
+
###
|
36
|
+
### my_with_fine_grained_rss_settings:
|
37
|
+
### rss
|
38
|
+
### count: 99
|
39
|
+
### format: rss
|
40
|
+
### managing_editor: editor@example.com (Managing Editor)
|
41
|
+
### url: custom.xml
|
35
42
|
|
36
43
|
# Selections
|
37
44
|
#
|
data/lib/lifer/utilities.rb
CHANGED
@@ -14,16 +14,15 @@ module Lifer::Utilities
|
|
14
14
|
end
|
15
15
|
|
16
16
|
# Given a string path, classify it into a namespaced Ruby constant. If the
|
17
|
-
# constant does not exist, we raise a helpful error.
|
17
|
+
# constant does not exist, we raise a helpful error.
|
18
18
|
#
|
19
|
-
#
|
20
|
-
#
|
19
|
+
# @example Result
|
20
|
+
# classify("my/class_name/that_exists") #=> My::ClassName::ThatExists
|
21
21
|
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
# (`u_r_i_strategy`).
|
22
|
+
# @fixme Note that this method is currently a bit naive. It cannot politely
|
23
|
+
# transform classes with many caps in them (i.e. `URIStrategy`) without
|
24
|
+
# being given an exact match (`URIStrategy`) or a broken-looking one
|
25
|
+
# (`u_r_i_strategy`).
|
27
26
|
#
|
28
27
|
# @param string_constant [String] A string that maps to a Ruby constant.
|
29
28
|
# @return [Class, Module]
|
data/lib/lifer/version.rb
CHANGED
data/lib/lifer.rb
CHANGED
@@ -63,7 +63,7 @@ module Lifer
|
|
63
63
|
|
64
64
|
# A set of all entries currently in the project.
|
65
65
|
#
|
66
|
-
#
|
66
|
+
# @fixme Do we need this as well as `Lifer.manifest`?
|
67
67
|
#
|
68
68
|
# @return [Set] All entries.
|
69
69
|
def entry_manifest = brain.entry_manifest
|
@@ -85,7 +85,7 @@ module Lifer
|
|
85
85
|
|
86
86
|
# A set of all entries currently in the project.
|
87
87
|
#
|
88
|
-
#
|
88
|
+
# @fixme Do we need this as well as `Lifer.manifest`?
|
89
89
|
#
|
90
90
|
# @return [Set] All entries.
|
91
91
|
def manifest = brain.manifest
|
@@ -99,8 +99,7 @@ module Lifer
|
|
99
99
|
# Register new settings so that they are "safe" and can be read from a Lifer
|
100
100
|
# configuration file. Unregistered settings are ignored.
|
101
101
|
#
|
102
|
-
#
|
103
|
-
#
|
102
|
+
# @example Usage
|
104
103
|
# register_settings(
|
105
104
|
# :hidden,
|
106
105
|
# :birthday,
|
@@ -142,6 +141,17 @@ module Lifer
|
|
142
141
|
#
|
143
142
|
# @return [Hash] The `Lifer::Config#settings`.
|
144
143
|
def settings = brain.config.settings
|
144
|
+
|
145
|
+
# All of the tags represented in Lifer entries for the current project.
|
146
|
+
#
|
147
|
+
# @return [Array<Lifer::Tag>] The complete list of tags.
|
148
|
+
def tags = brain.tags
|
149
|
+
|
150
|
+
# A set of all tags added to the project. Prefer using the `#tags` method
|
151
|
+
# for tag queries.
|
152
|
+
#
|
153
|
+
# @return [Set<Lifer::Tag>] The complete set of tags.
|
154
|
+
def tag_manifest = brain.tag_manifest
|
145
155
|
end
|
146
156
|
end
|
147
157
|
|
@@ -159,4 +169,5 @@ require_relative "lifer/builder"
|
|
159
169
|
require_relative "lifer/collection"
|
160
170
|
require_relative "lifer/entry"
|
161
171
|
require_relative "lifer/message"
|
172
|
+
require_relative "lifer/tag"
|
162
173
|
require_relative "lifer/uri_strategy"
|
data/lifer.gemspec
CHANGED
@@ -17,9 +17,9 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
18
18
|
|
19
19
|
spec.metadata["homepage_uri"] =
|
20
|
-
"%s/blob/%s/README.md" % [spec.homepage, Lifer::VERSION]
|
20
|
+
"%s/blob/%s/README.md" % [spec.homepage, "v#{Lifer::VERSION}"]
|
21
21
|
spec.metadata["source_code_uri"] =
|
22
|
-
"%s/tree/%s" % [spec.homepage, Lifer::VERSION]
|
22
|
+
"%s/tree/%s" % [spec.homepage, "v#{Lifer::VERSION}"]
|
23
23
|
spec.metadata["changelog_uri"] = "%s/blob/main/CHANGELOG.md" % spec.homepage
|
24
24
|
|
25
25
|
# Specify which files should be added to the gem when it is released. The
|
data/locales/en.yml
CHANGED
@@ -30,11 +30,10 @@ en:
|
|
30
30
|
content_type_not_implemented: no content type defined for files like %{path} yet
|
31
31
|
four_oh_four: 404 Not Found
|
32
32
|
entry:
|
33
|
+
date_error: "[%{filename}]: %{error}"
|
33
34
|
feedable_error: >
|
34
35
|
please set `%{entry_class}.include_in_feeds` to true or false
|
35
|
-
|
36
|
-
date_error: "[%{filename}]: %{error}"
|
37
|
-
no_date_metadata: "[%{filename}]: no date metadata"
|
36
|
+
no_date_metadata: "[%{filename}]: no date metadata"
|
38
37
|
not_found: >
|
39
38
|
file "%{file}" does not exist
|
40
39
|
config:
|
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.8.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-03-
|
11
|
+
date: 2025-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -167,6 +167,8 @@ files:
|
|
167
167
|
- lib/lifer/builder/html/from_liquid/drops/entry_drop.rb
|
168
168
|
- lib/lifer/builder/html/from_liquid/drops/frontmatter_drop.rb
|
169
169
|
- lib/lifer/builder/html/from_liquid/drops/settings_drop.rb
|
170
|
+
- lib/lifer/builder/html/from_liquid/drops/tag_drop.rb
|
171
|
+
- lib/lifer/builder/html/from_liquid/drops/tags_drop.rb
|
170
172
|
- lib/lifer/builder/html/from_liquid/filters.rb
|
171
173
|
- lib/lifer/builder/html/from_liquid/layout_tag.rb
|
172
174
|
- lib/lifer/builder/html/from_liquid/liquid_env.rb
|
@@ -188,6 +190,7 @@ files:
|
|
188
190
|
- lib/lifer/selection/included_in_feeds.rb
|
189
191
|
- lib/lifer/shared.rb
|
190
192
|
- lib/lifer/shared/finder_methods.rb
|
193
|
+
- lib/lifer/tag.rb
|
191
194
|
- lib/lifer/templates/cli.txt.erb
|
192
195
|
- lib/lifer/templates/config.yaml
|
193
196
|
- lib/lifer/templates/its-a-living.png
|
@@ -207,8 +210,8 @@ licenses:
|
|
207
210
|
- MIT
|
208
211
|
metadata:
|
209
212
|
allowed_push_host: https://rubygems.org
|
210
|
-
homepage_uri: https://github.com/benjaminwil/lifer/blob/
|
211
|
-
source_code_uri: https://github.com/benjaminwil/lifer/tree/
|
213
|
+
homepage_uri: https://github.com/benjaminwil/lifer/blob/v0.8.0/README.md
|
214
|
+
source_code_uri: https://github.com/benjaminwil/lifer/tree/v0.8.0
|
212
215
|
changelog_uri: https://github.com/benjaminwil/lifer/blob/main/CHANGELOG.md
|
213
216
|
post_install_message:
|
214
217
|
rdoc_options: []
|