weneedfeed 0.16.1 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/Gemfile.lock +17 -17
- data/README.md +19 -10
- data/lib/weneedfeed/command.rb +8 -1
- data/lib/weneedfeed/controllers/show_opml.rb +2 -2
- data/lib/weneedfeed/controllers/show_top_page.rb +2 -3
- data/lib/weneedfeed/item.rb +9 -3
- data/lib/weneedfeed/schema.rb +7 -0
- data/lib/weneedfeed/version.rb +1 -1
- data/lib/weneedfeed/views/show_opml.rb +8 -3
- data/lib/weneedfeed/views/show_top_page.rb +8 -3
- data/templates/show_opml.xml.erb +3 -3
- data/templates/show_top_page.html.erb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe9580666db05c9eaad1dcb58ce31047401f1e96b7c41ac0135cf98b9d094d3e
|
4
|
+
data.tar.gz: 4598e31e6ec68e4c93f071582bb4b1547bfa96f00d0768f59bbaf6e66421c038
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c944a1b21c82145b39c4d7f030e2954a61d63aa96b36666f2c896409b25484f15234bbd414420bafd463934d3bb5f9ab0957d126b434433cd0fc554890fe4c38
|
7
|
+
data.tar.gz: ad51d3ed20a023afb8070092c4570ad48d7dbfdea1e61ff6b9ad5651ecade23b3d570fcbfcb636475be4dd99c555f6bb1d29e4109e5537f4f1948e578312055e
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## Unreleased
|
9
9
|
|
10
|
+
## 0.19.0 - 2022-08-01
|
11
|
+
|
12
|
+
### Added
|
13
|
+
|
14
|
+
- Support %m月%d日配信 date format
|
15
|
+
|
16
|
+
## 0.18.0 - 2022-04-17
|
17
|
+
|
18
|
+
### Added
|
19
|
+
|
20
|
+
- Support configurable feeds title.
|
21
|
+
- Add --port= option to server command.
|
22
|
+
|
23
|
+
## 0.17.0 - 2022-04-15
|
24
|
+
|
25
|
+
### Changed
|
26
|
+
|
27
|
+
- Change outline title on OPML.
|
28
|
+
|
10
29
|
## 0.16.1 - 2022-04-15
|
11
30
|
|
12
31
|
### Fixed
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
weneedfeed (0.
|
4
|
+
weneedfeed (0.19.0)
|
5
5
|
activesupport
|
6
6
|
addressable
|
7
7
|
builder
|
@@ -17,7 +17,7 @@ PATH
|
|
17
17
|
GEM
|
18
18
|
remote: https://rubygems.org/
|
19
19
|
specs:
|
20
|
-
activesupport (7.0.
|
20
|
+
activesupport (7.0.3.1)
|
21
21
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
22
22
|
i18n (>= 1.6, < 2)
|
23
23
|
minitest (>= 5.1)
|
@@ -46,8 +46,8 @@ GEM
|
|
46
46
|
faraday-em_synchrony (1.0.0)
|
47
47
|
faraday-excon (1.1.0)
|
48
48
|
faraday-httpclient (1.0.1)
|
49
|
-
faraday-multipart (1.0.
|
50
|
-
multipart-post (
|
49
|
+
faraday-multipart (1.0.4)
|
50
|
+
multipart-post (~> 2)
|
51
51
|
faraday-net_http (1.0.1)
|
52
52
|
faraday-net_http_persistent (1.2.0)
|
53
53
|
faraday-patron (1.0.0)
|
@@ -55,34 +55,34 @@ GEM
|
|
55
55
|
faraday-retry (1.0.3)
|
56
56
|
faraday_middleware (1.2.0)
|
57
57
|
faraday (~> 1.0)
|
58
|
-
hanami-router (2.0.0.
|
58
|
+
hanami-router (2.0.0.beta1)
|
59
59
|
mustermann (~> 1.0)
|
60
60
|
mustermann-contrib (~> 1.0)
|
61
61
|
rack (~> 2.0)
|
62
|
-
hansi (0.2.
|
62
|
+
hansi (0.2.1)
|
63
63
|
hashdiff (1.0.1)
|
64
64
|
hibana (0.2.0)
|
65
65
|
hanami-router (>= 2.0.0.alpha3)
|
66
66
|
rack
|
67
67
|
tilt
|
68
|
-
i18n (1.
|
68
|
+
i18n (1.12.0)
|
69
69
|
concurrent-ruby (~> 1.0)
|
70
70
|
marcel (1.0.2)
|
71
71
|
mini_portile2 (2.8.0)
|
72
|
-
minitest (5.
|
73
|
-
multipart-post (2.
|
74
|
-
mustermann (1.1.
|
72
|
+
minitest (5.16.2)
|
73
|
+
multipart-post (2.2.3)
|
74
|
+
mustermann (1.1.2)
|
75
75
|
ruby2_keywords (~> 0.0.1)
|
76
|
-
mustermann-contrib (1.1.
|
76
|
+
mustermann-contrib (1.1.2)
|
77
77
|
hansi (~> 0.2.0)
|
78
|
-
mustermann (= 1.1.
|
79
|
-
nokogiri (1.13.
|
78
|
+
mustermann (= 1.1.2)
|
79
|
+
nokogiri (1.13.8)
|
80
80
|
mini_portile2 (~> 2.8.0)
|
81
81
|
racc (~> 1.4)
|
82
82
|
parallel (1.22.1)
|
83
83
|
parser (3.1.2.0)
|
84
84
|
ast (~> 2.4.1)
|
85
|
-
psych (4.0.
|
85
|
+
psych (4.0.4)
|
86
86
|
stringio
|
87
87
|
public_suffix (4.0.7)
|
88
88
|
racc (1.6.0)
|
@@ -125,10 +125,10 @@ GEM
|
|
125
125
|
rubocop (~> 1.19)
|
126
126
|
ruby-progressbar (1.11.0)
|
127
127
|
ruby2_keywords (0.0.5)
|
128
|
-
stringio (3.0.
|
128
|
+
stringio (3.0.2)
|
129
129
|
thor (1.2.1)
|
130
|
-
tilt (2.0.
|
131
|
-
tzinfo (2.0.
|
130
|
+
tilt (2.0.11)
|
131
|
+
tzinfo (2.0.5)
|
132
132
|
concurrent-ruby (~> 1.0)
|
133
133
|
unicode-display_width (2.1.0)
|
134
134
|
webmock (3.14.0)
|
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
|
-
### `
|
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
|
|
@@ -154,6 +161,8 @@ Usage:
|
|
154
161
|
Options:
|
155
162
|
[--schema-path=SCHEMA_PATH] # Path to weneedfeed YAML schema file.
|
156
163
|
# Default: weneedfeed.yml
|
164
|
+
[--port=PORT] # TCP port to bind to.
|
165
|
+
# Default: 8080
|
157
166
|
|
158
167
|
Run HTTP server.
|
159
168
|
```
|
data/lib/weneedfeed/command.rb
CHANGED
@@ -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
|
data/lib/weneedfeed/item.rb
CHANGED
@@ -10,11 +10,17 @@ module Weneedfeed
|
|
10
10
|
# @param [String] string
|
11
11
|
# @return [Time, nil]
|
12
12
|
def parse_time(string)
|
13
|
-
::Time.
|
14
|
-
rescue ArgumentError
|
13
|
+
::Time.strptime(string, '%Y年%m月%d日')
|
14
|
+
rescue ::ArgumentError
|
15
15
|
begin
|
16
|
-
::Time.strptime(string, '%
|
16
|
+
time = ::Time.strptime(string, '%m月%d日')
|
17
|
+
time -= 60 * 60 * 24 * 365 if time > Time.now
|
18
|
+
time
|
17
19
|
rescue ArgumentError
|
20
|
+
begin
|
21
|
+
::Time.parse(string)
|
22
|
+
rescue ArgumentError, RangeError
|
23
|
+
end
|
18
24
|
end
|
19
25
|
end
|
20
26
|
end
|
data/lib/weneedfeed/schema.rb
CHANGED
@@ -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
|
data/lib/weneedfeed/version.rb
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
module Weneedfeed
|
4
4
|
module Views
|
5
5
|
class ShowOpml < Base
|
6
|
-
# @param [
|
7
|
-
def initialize(
|
6
|
+
# @param [Weneedfeed::Schema] schema
|
7
|
+
def initialize(schema:, **argv)
|
8
8
|
super(**argv)
|
9
|
-
@
|
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 [
|
7
|
-
def initialize(
|
6
|
+
# @param [Weneedfeed::Schema] schema
|
7
|
+
def initialize(schema:, **argv)
|
8
8
|
super(**argv)
|
9
|
-
@
|
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
|
data/templates/show_opml.xml.erb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<opml version="1.0">
|
3
3
|
<head>
|
4
|
-
<title
|
4
|
+
<title><%= @schema.title %></title>
|
5
5
|
</head>
|
6
6
|
<body>
|
7
|
-
<outline text="
|
8
|
-
<%
|
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
|
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
|
-
<%
|
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.
|
4
|
+
version: 0.19.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-
|
11
|
+
date: 2022-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -234,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
234
234
|
- !ruby/object:Gem::Version
|
235
235
|
version: '0'
|
236
236
|
requirements: []
|
237
|
-
rubygems_version: 3.
|
237
|
+
rubygems_version: 3.3.7
|
238
238
|
signing_key:
|
239
239
|
specification_version: 4
|
240
240
|
summary: Generate feeds from URL and selectors.
|