nanoc-feeds 0.1.0 → 0.1.2
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/README.md +30 -10
- data/lib/nanoc/feeds/helpers/feeds.rb +6 -2
- data/lib/nanoc/feeds/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f40b9f32b3ed641d3930ef1a5a6dc1020a8cda66c66176cea5497a47058a369c
|
4
|
+
data.tar.gz: 13bdb8b0b8497e288639650857a2f8f0df7a17e3053497ee153ff88a1c1c2424
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb5f63cb408efe141e29af0b478ad02b387457e476372b9bf7ff51af3fb7b4aac2cd88f2ae732d82102dda2df0499d1b610a8381b05955389642e08f3789276e
|
7
|
+
data.tar.gz: 98b33920ee6695e209f2bcd4aa4df775a662d5bc2944aa55bbf3eee5b6fe0873505334a4e9d3ad7c3fc492d046711bf2da334856751b99daaa91ed44a558d14a
|
data/README.md
CHANGED
@@ -1,28 +1,48 @@
|
|
1
1
|
# Nanoc::Feeds
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/nanoc/feeds`. To experiment with that code, run `bin/console` for an interactive prompt.
|
3
|
+
A set of helpers for generating additional feeds in nanoc. Currently JSON and Atom feeds are supported.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
Install the gem and add to the application's Gemfile by executing:
|
7
|
+
Install the gem and add to your nanoc project Gemfile by executing:
|
12
8
|
|
13
9
|
```bash
|
14
|
-
bundle add
|
10
|
+
bundle add nanoc-feeds
|
15
11
|
```
|
16
12
|
|
17
13
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
18
14
|
|
19
15
|
```bash
|
20
|
-
gem install
|
16
|
+
gem install nanoc-feeds
|
21
17
|
```
|
22
18
|
|
23
19
|
## Usage
|
24
20
|
|
25
|
-
|
21
|
+
To generate JSON and Atom feeds add this gem to your `Gemfile` and then include the module in your `lib/helpers.rb` file:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
use_helper Nanoc::Feeds::Helpers::Feeds
|
25
|
+
```
|
26
|
+
|
27
|
+
Now create a `feed.erb` in your content folder using the helper provided:
|
28
|
+
```erb
|
29
|
+
<%= feed articles: sorted_articles %>
|
30
|
+
```
|
31
|
+
|
32
|
+
Finally add the following to your `Rules` file:
|
33
|
+
```ruby
|
34
|
+
compile "/feed.erb" do
|
35
|
+
filter :erb
|
36
|
+
write "/feed.xml"
|
37
|
+
end
|
38
|
+
|
39
|
+
compile "/feed.erb", rep: :json do
|
40
|
+
filter :erb
|
41
|
+
write "/feed.json"
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
This will render a JSON (`feed.json`) and Atom (`feed.xml`) feed for your articles.
|
26
46
|
|
27
47
|
## Development
|
28
48
|
|
@@ -32,7 +52,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
52
|
|
33
53
|
## Contributing
|
34
54
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
55
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/michaelem/nanoc-feeds.
|
36
56
|
|
37
57
|
## License
|
38
58
|
|
@@ -14,13 +14,17 @@ module Nanoc::Feeds::Helpers::Feeds
|
|
14
14
|
|
15
15
|
def json_feed(params = {})
|
16
16
|
articles = params[:articles]
|
17
|
+
articles = articles.first(params[:limit]) if params[:limit]
|
17
18
|
title = params[:title] || @config[:title]
|
19
|
+
|
20
|
+
items = articles.map { |article| build_for_article(article, title) }
|
21
|
+
|
18
22
|
{
|
19
23
|
version: "https://jsonfeed.org/version/1.1",
|
20
24
|
title: title,
|
21
25
|
home_page_url: "#{config[:base_url]}",
|
22
|
-
feed_url:
|
23
|
-
items:
|
26
|
+
feed_url: feed_url,
|
27
|
+
items: items
|
24
28
|
}.to_json
|
25
29
|
end
|
26
30
|
|
data/lib/nanoc/feeds/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc-feeds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Emhofer
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-01-
|
10
|
+
date: 2025-01-20 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: zeitwerk
|