Skip to content

Commit d3d5bed

Browse files
authored
Merge pull request #1762 from coderdojo-japan/claude/register-prtimes-rss-feed-for-news-section
CoderDojo Japan の PR TIMES RSS フィードを News セクションに登録
2 parents 0bc1c3f + 01bbf86 commit d3d5bed

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

db/news.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,43 @@
22
- id: 14
33
url: https://news.coderdojo.jp/2025/11/02/dojoletter-vol-90-2025%e5%b9%b409%e6%9c%88%e5%8f%b7/
44
title: DojoLetter Vol.90 2025年09月号
5-
published_at: Sun, 02 Nov 2025 13:10:18 +0000
5+
published_at: '2025-11-02T13:10:18+00:00'
66
- id: 13
77
url: https://news.coderdojo.jp/2025/10/04/dojoletter-vol-89-2025%e5%b9%b408%e6%9c%88%e5%8f%b7/
88
title: DojoLetter Vol.89 2025年08月号
9-
published_at: Sat, 04 Oct 2025 13:20:16 +0000
9+
published_at: '2025-10-04T13:20:16+00:00'
1010
- id: 12
1111
url: https://news.coderdojo.jp/2025/09/10/dojoletter-vol-88-2025%e5%b9%b407%e6%9c%88%e5%8f%b7/
1212
title: DojoLetter Vol.88 2025年07月号
13-
published_at: Wed, 10 Sep 2025 03:45:56 +0000
13+
published_at: '2025-09-10T03:45:56+00:00'
1414
- id: 11
1515
url: https://news.coderdojo.jp/2025/08/12/dojoletter-vol-87-2025%e5%b9%b406%e6%9c%88%e5%8f%b7/
1616
title: DojoLetter Vol.87 2025年06月号
17-
published_at: Tue, 12 Aug 2025 04:00:02 +0000
17+
published_at: '2025-08-12T04:00:02+00:00'
1818
- id: 10
1919
url: https://news.coderdojo.jp/2025/07/14/233-laptops-to-coderdojo/
2020
title: 米国系 IT 企業から CoderDojo へ、233 台のノート PC 寄贈
21-
published_at: Mon, 14 Jul 2025 05:50:31 +0000
21+
published_at: '2025-07-14T05:50:31+00:00'
2222
- id: 9
2323
url: https://news.coderdojo.jp/2025/07/10/dojoletter-vol-86-2025%e5%b9%b405%e6%9c%88%e5%8f%b7/
2424
title: DojoLetter Vol.86 2025年05月号
25-
published_at: Thu, 10 Jul 2025 04:00:07 +0000
25+
published_at: '2025-07-10T04:00:07+00:00'
2626
- id: 8
2727
url: https://news.coderdojo.jp/2025/06/10/dojoletter-vol-85-2025%e5%b9%b404%e6%9c%88%e5%8f%b7/
2828
title: DojoLetter Vol.85 2025年04月号
29-
published_at: Tue, 10 Jun 2025 03:30:18 +0000
29+
published_at: '2025-06-10T03:30:18+00:00'
3030
- id: 7
3131
url: https://news.coderdojo.jp/2025/05/12/dojoletter-vol-84-2025%e5%b9%b403%e6%9c%88%e5%8f%b7/
3232
title: DojoLetter Vol.84 2025年03月号
33-
published_at: Mon, 12 May 2025 04:00:33 +0000
33+
published_at: '2025-05-12T04:00:33+00:00'
3434
- id: 6
3535
url: https://news.coderdojo.jp/2025/04/10/dojoletter-vol-83-2025%e5%b9%b402%e6%9c%88%e5%8f%b7/
3636
title: DojoLetter Vol.83 2025年02月号
37-
published_at: Thu, 10 Apr 2025 03:45:27 +0000
37+
published_at: '2025-04-10T03:45:27+00:00'
3838
- id: 5
3939
url: https://news.coderdojo.jp/2025/04/04/55-laptops-to-coderdojo/
4040
title: 米国系 IT 企業から CoderDojo へ、55 台のノート PC 寄贈
41-
published_at: Fri, 04 Apr 2025 10:00:32 +0000
41+
published_at: '2025-04-04T10:00:32+00:00'
4242
- id: 4
4343
url: https://news.coderdojo.jp/2025/03/10/dojoletter-vol-82-2025%e5%b9%b401%e6%9c%88%e5%8f%b7/
4444
title: DojoLetter Vol.82 2025年01月号

lib/tasks/news.rake

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,32 @@ namespace :news do
1515

1616
# 本番/開発環境では実フィード、それ以外(テスト環境など)ではテスト用フィード
1717
DOJO_NEWS_FEED = 'https://news.coderdojo.jp/feed/'
18+
PR_TIMES_FEED = 'https://prtimes.jp/companyrdf.php?company_id=38935'
1819
TEST_NEWS_FEED = Rails.root.join('spec', 'fixtures', 'sample_news.rss')
1920
RSS_FEED_LIST = (Rails.env.test? || Rails.env.staging?) ?
2021
[TEST_NEWS_FEED] :
21-
[DOJO_NEWS_FEED]
22+
[DOJO_NEWS_FEED, PR_TIMES_FEED]
2223

2324
# RSS のデータ構造を、News のデータ構造に変換
2425
fetched_items = RSS_FEED_LIST.flat_map do |feed|
2526
feed = RSS::Parser.parse(feed, false)
2627
feed.items.map { |item|
28+
# RSS 1.0 (RDF) と RSS 2.0 の両方に対応
29+
# RSS 2.0: pubDate, RSS 1.0 (RDF): dc:date
30+
# - PR TIMES: RSS 1.0 (RDF) 形式 - <rdf:RDF> タグ、dc:date フィールドを使用
31+
# - CoderDojo News: RSS 2.0 形式 - <rss version="2.0"> タグ、pubDate フィールドを使用
32+
published_at = if item.respond_to?(:pubDate) && item.pubDate
33+
item.pubDate
34+
elsif item.respond_to?(:dc_date) && item.dc_date
35+
item.dc_date
36+
else
37+
raise "Unexpected RSS format: neither pubDate nor dc:date found for item: #{item.link}"
38+
end
39+
2740
{
2841
'url' => item.link,
2942
'title' => item.title,
30-
'published_at' => item.pubDate.to_s
43+
'published_at' => published_at.iso8601 # ISO 8601 形式に統一
3144
}
3245
}
3346
end

0 commit comments

Comments
 (0)