weneedfeed 0.14.0 → 0.16.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa3500ddeba8701a3cc8c7f729fbfef3c61f95050572bc34327c489842c5744d
4
- data.tar.gz: dd89a38ec4ceed97813e9fc5b73b5df1f1c7568ae0dd6b3ab2e0e6a52d0f7bec
3
+ metadata.gz: ac235ec3ef110856c49b2f1232ffef3318c95d401fda62f0d03a8ecbbe634e87
4
+ data.tar.gz: b0638cf42a0c679ef01e00551735bc71ea11325053a4695485e533e6640adbb0
5
5
  SHA512:
6
- metadata.gz: 8e74fb89776dde8f1c7dfb068ddea721a9a9ce6da67d31aa496673e53efcd0993f3deee7452685d643ab73e56ac56fdf42be59aa11413593ee1de326bd219a2c
7
- data.tar.gz: d9036bccf6f43b8480eb36d7ea3db5dc348e879705e93b92290ea953b04302898caa5cf4a3aea8fda71704291ab0bf1841e3c761873798f72172191f17c57c88
6
+ metadata.gz: 3cf511ebf7e37879f4a39bc564d8a0fe6ac18de6a88d91f5ae46f1c5a54e26d064bfac375cb8e6ed708ff75bada7a0e63ef749ed38c2ba6f7ad9de1bbe838eb7
7
+ data.tar.gz: 79770b221efdd171712d1e5bacb56ca3d971763dbc9ce4dbf1700e480a411eb3238455f10e28919fbd97781677cabd5d0c6418ff3687fef36e7f049456bdcea4
data/CHANGELOG.md CHANGED
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## 0.16.1 - 2022-04-15
11
+
12
+ ### Fixed
13
+
14
+ - Fix bug that opml.xml is not built.
15
+
16
+ ## 0.16.0 - 2022-04-15
17
+
18
+ ### Added
19
+
20
+ - Add OPML page.
21
+
22
+ ## 0.15.0 - 2022-04-14
23
+
24
+ ### Changed
25
+
26
+ - Use hashed title and content as guid fallback.
27
+
10
28
  ## 0.14.0 - 2022-04-14
11
29
 
12
30
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- weneedfeed (0.14.0)
4
+ weneedfeed (0.16.1)
5
5
  activesupport
6
6
  addressable
7
7
  builder
@@ -7,6 +7,7 @@ module Weneedfeed
7
7
  route do
8
8
  get '/', to: ::Weneedfeed::Controllers::ShowTopPage, as: :top_page
9
9
  get '/feeds/:page_id.xml', to: ::Weneedfeed::Controllers::ShowFeed, as: :feed
10
+ get '/opml.xml', to: ::Weneedfeed::Controllers::ShowOpml, as: :opml
10
11
  end
11
12
 
12
13
  # @param [String] schema_path
@@ -23,7 +24,10 @@ module Weneedfeed
23
24
 
24
25
  # @return [Array<String>]
25
26
  def paths
26
- ['/'] + @schema.page_ids.map do |page_id|
27
+ %w[
28
+ /
29
+ /opml.xml
30
+ ] + @schema.page_ids.map do |page_id|
27
31
  "/feeds/#{page_id}.xml"
28
32
  end
29
33
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Weneedfeed
4
+ module Controllers
5
+ class ShowOpml < ::Weneedfeed::Controllers::Base
6
+ def call
7
+ response.content_type = 'application/xml; charset=utf-8'
8
+ response.write(
9
+ ::Weneedfeed::Views::ShowOpml.new(
10
+ page_schemata: schema.page_schemata.sort_by(&:title),
11
+ partial_template_path: ::File.expand_path(
12
+ 'templates/show_opml.xml.erb',
13
+ "#{__dir__}/../../.."
14
+ ),
15
+ request: request
16
+ ).to_s
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
@@ -4,6 +4,7 @@ module Weneedfeed
4
4
  module Controllers
5
5
  autoload :Base, 'weneedfeed/controllers/base'
6
6
  autoload :ShowFeed, 'weneedfeed/controllers/show_feed'
7
+ autoload :ShowOpml, 'weneedfeed/controllers/show_opml'
7
8
  autoload :ShowTopPage, 'weneedfeed/controllers/show_top_page'
8
9
  end
9
10
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'addressable'
4
+ require 'digest/sha1'
4
5
  require 'marcel'
5
6
 
6
7
  module Weneedfeed
@@ -50,6 +51,11 @@ module Weneedfeed
50
51
  @node.at(@description_selector)&.inner_html
51
52
  end
52
53
 
54
+ # @return [String]
55
+ def guid
56
+ link || hashed_title_and_description
57
+ end
58
+
53
59
  # @return [String, nil]
54
60
  def image_mime_type
55
61
  return unless image_url
@@ -80,7 +86,7 @@ module Weneedfeed
80
86
  ).normalize.to_s
81
87
  end
82
88
 
83
- # @return [String]
89
+ # @return [String, nil]
84
90
  def link
85
91
  return unless link_path_or_url
86
92
 
@@ -120,6 +126,13 @@ module Weneedfeed
120
126
 
121
127
  private
122
128
 
129
+ # @return [String]
130
+ def hashed_title_and_description
131
+ source = [title, description].join(':')
132
+ sha1 = ::Digest::SHA1.hexdigest(source)
133
+ "urn:sha1:#{sha1}"
134
+ end
135
+
123
136
  # @return [Nokogiri::Node, nil]
124
137
  def time_node
125
138
  @node.at(@time_selector)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Weneedfeed
4
- VERSION = '0.14.0'
4
+ VERSION = '0.16.1'
5
5
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Weneedfeed
4
+ module Views
5
+ class Base < ::Hibana::View
6
+ private
7
+
8
+ # @return [Hanami::Router]
9
+ def router
10
+ ::Weneedfeed::Application.router
11
+ end
12
+ end
13
+ end
14
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Weneedfeed
4
4
  module Views
5
- class ShowFeed < ::Hibana::View
5
+ class ShowFeed < Base
6
6
  include ::Weneedfeed::Helpers::Parameters
7
7
 
8
8
  # @param [Weneedfeed::Page] page
@@ -29,11 +29,6 @@ module Weneedfeed
29
29
  def page_id
30
30
  path_parameters[:page_id]
31
31
  end
32
-
33
- # @return [Hanami::Router]
34
- def router
35
- ::Weneedfeed::Application.router
36
- end
37
32
  end
38
33
  end
39
34
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Weneedfeed
4
+ module Views
5
+ class ShowOpml < Base
6
+ # @param [Array<Hash>] page_schemata
7
+ def initialize(page_schemata:, **argv)
8
+ super(**argv)
9
+ @page_schemata = page_schemata
10
+ end
11
+
12
+ private
13
+
14
+ # @return [String]
15
+ def base_path
16
+ request.path.delete_suffix(router.path(:opml))
17
+ end
18
+
19
+ # @param [String] page_id
20
+ # @return [String]
21
+ def feed_path(page_id:)
22
+ "#{base_path}#{router.path(:feed, page_id: page_id)}"
23
+ end
24
+ end
25
+ end
26
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Weneedfeed
4
4
  module Views
5
- class ShowTopPage < ::Hibana::View
5
+ class ShowTopPage < Base
6
6
  # @param [Array<Hash>] page_schemata
7
7
  def initialize(page_schemata:, **argv)
8
8
  super(**argv)
@@ -22,6 +22,11 @@ module Weneedfeed
22
22
  "#{base_path}#{router.path(:feed, page_id: page_id)}"
23
23
  end
24
24
 
25
+ # @return [String]
26
+ def opml_path
27
+ "#{base_path}#{router.path(:opml)}"
28
+ end
29
+
25
30
  # @return [Hanami::Router]
26
31
  def router
27
32
  ::Weneedfeed::Application.router
@@ -2,7 +2,9 @@
2
2
 
3
3
  module Weneedfeed
4
4
  module Views
5
+ autoload :Base, 'weneedfeed/views/base'
5
6
  autoload :ShowFeed, 'weneedfeed/views/show_feed'
7
+ autoload :ShowOpml, 'weneedfeed/views/show_opml'
6
8
  autoload :ShowTopPage, 'weneedfeed/views/show_top_page'
7
9
  end
8
10
  end
@@ -17,7 +17,7 @@
17
17
  <% end %>
18
18
  <description><![CDATA[<%= item.description %>]]></description>
19
19
  <content:encoded><![CDATA[<%= item.description %>]]></content:encoded>
20
- <guid isPermaLink="true"><%= item.link %></guid>
20
+ <guid isPermaLink="true"><%= item.guid %></guid>
21
21
  <% if item.image_url %>
22
22
  <enclosure url=<%= item.image_url.encode(xml: :attr) %> length="0" type="<%= item.image_mime_type %>"/>
23
23
  <% end %>
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <opml version="1.0">
3
+ <head>
4
+ <title>Feeds from Weneedfeed</title>
5
+ </head>
6
+ <body>
7
+ <outline text="Feeds" title="Feeds">
8
+ <% @page_schemata.each do |page_schema| %>
9
+ <outline type="rss" text="<%= page_schema.title %>" title="<%= page_schema.title %>" xmlUrl="<%= "#{request.base_url}#{feed_path(page_id: page_schema.id)}" %>" htmlUrl="<%= page_schema.url %>"/>
10
+ <% end %>
11
+ </outline>
12
+ </body>
13
+ </opml>
@@ -6,12 +6,25 @@
6
6
  <title>Weneedfeed</title>
7
7
  </head>
8
8
  <body>
9
- <ul>
10
- <% @page_schemata.each do |page_schema| %>
11
- <li>
12
- <a href="<%= feed_path(page_id: page_schema.id) %>"><%= page_schema.title %></a>
13
- </li>
14
- <% end %>
15
- </ul>
9
+ <section>
10
+ <header>
11
+ <h1>Feeds</h1>
12
+ </header>
13
+ <ul>
14
+ <% @page_schemata.each do |page_schema| %>
15
+ <li>
16
+ <a href="<%= feed_path(page_id: page_schema.id) %>"><%= page_schema.title %></a>
17
+ </li>
18
+ <% end %>
19
+ </ul>
20
+ </section>
21
+ <section>
22
+ <header>
23
+ <h1>Others</h1>
24
+ </header>
25
+ <ul>
26
+ <li><a href="<%= opml_path %>">OPML</a></li>
27
+ </ul>
28
+ </section>
16
29
  </body>
17
30
  </html>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weneedfeed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-14 00:00:00.000000000 Z
11
+ date: 2022-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -192,6 +192,7 @@ files:
192
192
  - lib/weneedfeed/controllers.rb
193
193
  - lib/weneedfeed/controllers/base.rb
194
194
  - lib/weneedfeed/controllers/show_feed.rb
195
+ - lib/weneedfeed/controllers/show_opml.rb
195
196
  - lib/weneedfeed/controllers/show_top_page.rb
196
197
  - lib/weneedfeed/faraday_response_middleware.rb
197
198
  - lib/weneedfeed/helpers.rb
@@ -203,9 +204,12 @@ files:
203
204
  - lib/weneedfeed/scraping.rb
204
205
  - lib/weneedfeed/version.rb
205
206
  - lib/weneedfeed/views.rb
207
+ - lib/weneedfeed/views/base.rb
206
208
  - lib/weneedfeed/views/show_feed.rb
209
+ - lib/weneedfeed/views/show_opml.rb
207
210
  - lib/weneedfeed/views/show_top_page.rb
208
211
  - templates/show_feed.xml.erb
212
+ - templates/show_opml.xml.erb
209
213
  - templates/show_top_page.html.erb
210
214
  - weneedfeed.gemspec
211
215
  homepage: https://github.com/r7kamura/weneedfeed