weneedfeed 0.15.0 → 0.16.0

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: 819bba3695f6ec96a66d4a2eca1521ffd70362061267ae43278bc9e2a50263f7
4
- data.tar.gz: bfe94358ddedce6a9d2fc029c1cef72b7672e6dd29c1a0de7c7ad9535f9b4d74
3
+ metadata.gz: baf60aaaa90d968a375a3bff27c32700721d6fc0376854d7dfc20e8892dc59e3
4
+ data.tar.gz: 7fc14522a11c58837223ebf2be78b7aca9caa2dd1f2d707b3e8f63a5b25e5d46
5
5
  SHA512:
6
- metadata.gz: f6cf9a9347388458458b433b0397f942b1a1db30712d5cc35155b90ef5ccda42e23eb2dcf5e264b8440fb2cec1b74ba14886718da840824da012f043a5f899fe
7
- data.tar.gz: 978321586272751213ac40ad55fb4907c868e9e893985b3464be7d8d6e0f8af28242d341f35af9b4bba50708208a0fdc20904c4e00821ab10ad045b8735525f9
6
+ metadata.gz: b21d52a7ceb2dd9370e356981e294031ce1eee8a28c08aa0941ef59de9f2551948f4d5b95bd929fb6bbf7aca38fb32b6e65ce6c2c2fbad9b734ddae1374da143
7
+ data.tar.gz: 361b1a2e06859701dc962898fe1ef93fd246298f1d320b1d597caa89186bd3ed1144b74e6b1c28e380e3cb0a7036767b1e8e6c3bc343c9656a2e9bf6b4cbf66a
data/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## 0.16.0 - 2022-04-15
11
+
12
+ ### Added
13
+
14
+ - Add OPML page.
15
+
10
16
  ## 0.15.0 - 2022-04-14
11
17
 
12
18
  ### Changed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- weneedfeed (0.15.0)
4
+ weneedfeed (0.16.0)
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
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,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Weneedfeed
4
- VERSION = '0.15.0'
4
+ VERSION = '0.16.0'
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
@@ -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.15.0
4
+ version: 0.16.0
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