weneedfeed 0.17.0 → 0.18.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: c5a85470ed37f8724012951976f2dbe1286d5b82dabace4e9c830e6104051129
4
- data.tar.gz: 980537323111e8ebafd1d0f8496dd45edaf21be74a26aba78aa8f8439e28546d
3
+ metadata.gz: 15fe792e19590e141278496015fefd5f9b7b10c2fa467b2bb2d8f7b6b9206350
4
+ data.tar.gz: c0957471a1a209b3727a04eecec561aae7144c225b9ae469f7dfd66c9e698aa2
5
5
  SHA512:
6
- metadata.gz: 040be9432bb6892d33cae5f8ddc4fd2e228b028fe6e9706fbb86cf58eaf97cef5bb005353a91dda4c972fba17319428b654dab6c6d9bd0ad90b3127cc4583911
7
- data.tar.gz: c386bd0eb5fa38abda0f7e5006f90b6e77c803a9b5b2a6f5becf5ea1aa89c945ed6d07daeb1021187a5dd428eb9fd0b474d1495a34b454c0b616e50378484700
6
+ metadata.gz: 3a52e5daab18cd4f8d5f303e6a065d0018efd23babe7b364c112bb08c488eab67e179efc5fb2037563e5d9706ec71e4992433f83cd70c0b1245ce7b54f50f145
7
+ data.tar.gz: a01540c21b8ddb8737b862530089df9216e6814a084a8e3c132e4b4d30c41dcd571c835c42a1d1a00c41cf39372a093f41449d028ea13282e29a0d084f2eb1ae
data/CHANGELOG.md CHANGED
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## 0.18.0 - 2022-04-17
11
+
12
+ ### Added
13
+
14
+ - Support configurable feeds title.
15
+ - Add --port= option to server command.
16
+
10
17
  ## 0.17.0 - 2022-04-15
11
18
 
12
19
  ### Changed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- weneedfeed (0.17.0)
4
+ weneedfeed (0.18.0)
5
5
  activesupport
6
6
  addressable
7
7
  builder
data/README.md CHANGED
@@ -32,6 +32,8 @@ Weneedfeed requires `weneedfeed.yml` that describes URLs and selectors.
32
32
  ### Example
33
33
 
34
34
  ```yaml
35
+ title: Example RSS feeds
36
+
35
37
  pages:
36
38
  - id: example1
37
39
  title: Example 1
@@ -55,70 +57,75 @@ pages:
55
57
  item_title_selector: .//p[2]
56
58
  ```
57
59
 
58
- ### `id`
60
+ ### `title`
61
+
62
+ - optional (default: `"Weneedfeed"`)
63
+ - Used for feeds title on top page and OPML outline.
64
+
65
+ ### `pages.id`
59
66
 
60
67
  Feed ID.
61
68
 
62
69
  - required
63
70
  - Used for feed URL and `<link>` element in `<channel>` element.
64
71
 
65
- ### `title`
72
+ ### `pages.title`
66
73
 
67
74
  Feed title.
68
75
 
69
76
  - required
70
77
  - Used for RSS `<title>` element in `<channel>` element.
71
78
 
72
- ### `description`
79
+ ### `pages.description`
73
80
 
74
81
  Feed description.
75
82
 
76
83
  - optional
77
84
  - Used for RSS `<description>` element in `<channel>` element.
78
85
 
79
- ### `url`
86
+ ### `pages.url`
80
87
 
81
88
  HTML source URL.
82
89
 
83
90
  - required
84
91
  - Used to fetch HTML page for building feed.
85
92
 
86
- ### `item_selector`
93
+ ### `pages.item_selector`
87
94
 
88
95
  CSS or XPath selector to search each item.
89
96
 
90
97
  - required
91
98
  - Equivalent unit to RSS `<item>` element.
92
99
 
93
- ### `item_link_selector`
100
+ ### `pages.item_link_selector`
94
101
 
95
102
  CSS or XPath selector to find `<a>` element in each item.
96
103
 
97
104
  - required
98
105
  - Used for `<link>` in `<item>`.
99
106
 
100
- ### `item_title_selector`
107
+ ### `pages.item_title_selector`
101
108
 
102
109
  CSS or XPath selector to find element with title information in each item.
103
110
 
104
111
  - required
105
112
  - Used for `<title>` in `<item>`.
106
113
 
107
- ### `item_description_selector`
114
+ ### `pages.item_description_selector`
108
115
 
109
116
  CSS or XPath selector to find element with description information in each item.
110
117
 
111
118
  - optional
112
119
  - Used for `<description>` in `<item>`.
113
120
 
114
- ### `item_image_selector`
121
+ ### `pages.item_image_selector`
115
122
 
116
123
  CSS or XPath selector to find `<img>`element in each item.
117
124
 
118
125
  - optional
119
126
  - Used for `<enclosure>` in `<item>`.
120
127
 
121
- ### `item_time_selector`
128
+ ### `pages.item_time_selector`
122
129
 
123
130
  CSS or XPath selector to find element with datetime information in each item.
124
131
 
@@ -53,9 +53,16 @@ module Weneedfeed
53
53
  type: :string
54
54
  )
55
55
 
56
+ method_option(
57
+ :port,
58
+ default: '8080',
59
+ desc: 'TCP port to bind to.',
60
+ type: :string
61
+ )
62
+
56
63
  def server
57
64
  application = Weneedfeed::Application.new(schema_path: options[:schema_path])
58
- ::Rack::Handler.default.run(application)
65
+ ::Rack::Handler.default.run(application, Port: options[:port])
59
66
  end
60
67
  end
61
68
  end
@@ -7,12 +7,12 @@ module Weneedfeed
7
7
  response.content_type = 'application/xml; charset=utf-8'
8
8
  response.write(
9
9
  ::Weneedfeed::Views::ShowOpml.new(
10
- page_schemata: schema.page_schemata.sort_by(&:title),
11
10
  partial_template_path: ::File.expand_path(
12
11
  'templates/show_opml.xml.erb',
13
12
  "#{__dir__}/../../.."
14
13
  ),
15
- request: request
14
+ request: request,
15
+ schema: schema
16
16
  ).to_s
17
17
  )
18
18
  end
@@ -4,16 +4,15 @@ module Weneedfeed
4
4
  module Controllers
5
5
  class ShowTopPage < ::Weneedfeed::Controllers::Base
6
6
  def call
7
- page_schemata = schema.page_schemata.sort_by(&:title)
8
7
  response.content_type = 'text/html'
9
8
  response.write(
10
9
  ::Weneedfeed::Views::ShowTopPage.new(
11
- page_schemata: page_schemata,
12
10
  partial_template_path: ::File.expand_path(
13
11
  'templates/show_top_page.html.erb',
14
12
  "#{__dir__}/../../.."
15
13
  ),
16
- request: request
14
+ request: request,
15
+ schema: schema
17
16
  ).to_s
18
17
  )
19
18
  end
@@ -4,6 +4,8 @@ require 'yaml'
4
4
 
5
5
  module Weneedfeed
6
6
  class Schema
7
+ DEFAULT_TITLE = 'Weneedfeed'
8
+
7
9
  class << self
8
10
  # @param [String] schema_path
9
11
  # @return [Weneedfeed::Schema]
@@ -48,5 +50,10 @@ module Weneedfeed
48
50
  )
49
51
  end
50
52
  end
53
+
54
+ # @return [String]
55
+ def title
56
+ @raw['title'] || DEFAULT_TITLE
57
+ end
51
58
  end
52
59
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Weneedfeed
4
- VERSION = '0.17.0'
4
+ VERSION = '0.18.0'
5
5
  end
@@ -3,10 +3,10 @@
3
3
  module Weneedfeed
4
4
  module Views
5
5
  class ShowOpml < Base
6
- # @param [Array<Hash>] page_schemata
7
- def initialize(page_schemata:, **argv)
6
+ # @param [Weneedfeed::Schema] schema
7
+ def initialize(schema:, **argv)
8
8
  super(**argv)
9
- @page_schemata = page_schemata
9
+ @schema = schema
10
10
  end
11
11
 
12
12
  private
@@ -21,6 +21,11 @@ module Weneedfeed
21
21
  def feed_path(page_id:)
22
22
  "#{base_path}#{router.path(:feed, page_id: page_id)}"
23
23
  end
24
+
25
+ # @return [Array<String>]
26
+ def page_schemata
27
+ @schema.page_schemata.sort_by(&:title)
28
+ end
24
29
  end
25
30
  end
26
31
  end
@@ -3,10 +3,10 @@
3
3
  module Weneedfeed
4
4
  module Views
5
5
  class ShowTopPage < Base
6
- # @param [Array<Hash>] page_schemata
7
- def initialize(page_schemata:, **argv)
6
+ # @param [Weneedfeed::Schema] schema
7
+ def initialize(schema:, **argv)
8
8
  super(**argv)
9
- @page_schemata = page_schemata
9
+ @schema = schema
10
10
  end
11
11
 
12
12
  private
@@ -27,6 +27,11 @@ module Weneedfeed
27
27
  "#{base_path}#{router.path(:opml)}"
28
28
  end
29
29
 
30
+ # @return [Array<String>]
31
+ def page_schemata
32
+ @schema.page_schemata.sort_by(&:title)
33
+ end
34
+
30
35
  # @return [Hanami::Router]
31
36
  def router
32
37
  ::Weneedfeed::Application.router
@@ -1,11 +1,11 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <opml version="1.0">
3
3
  <head>
4
- <title>Weneedfeed</title>
4
+ <title><%= @schema.title %></title>
5
5
  </head>
6
6
  <body>
7
- <outline text="Weneedfeed" title="Weneedfeed">
8
- <% @page_schemata.each do |page_schema| %>
7
+ <outline text="<%= @schema.title %>" title="<%= @schema.title %>">
8
+ <% page_schemata.each do |page_schema| %>
9
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
10
  <% end %>
11
11
  </outline>
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width">
6
- <title>Weneedfeed</title>
6
+ <title><%= @schema.title %></title>
7
7
  </head>
8
8
  <body>
9
9
  <section>
@@ -11,7 +11,7 @@
11
11
  <h1>Feeds</h1>
12
12
  </header>
13
13
  <ul>
14
- <% @page_schemata.each do |page_schema| %>
14
+ <% page_schemata.each do |page_schema| %>
15
15
  <li>
16
16
  <a href="<%= feed_path(page_id: page_schema.id) %>"><%= page_schema.title %></a>
17
17
  </li>
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.17.0
4
+ version: 0.18.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-15 00:00:00.000000000 Z
11
+ date: 2022-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport