Skip to content

Commit

Permalink
add support for atom feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
dethos committed Feb 10, 2024
1 parent b6cb960 commit 09a017b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 31 deletions.
15 changes: 10 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,17 @@ async function handleRequest(request) {
response = new Response(content, {
headers: {
'content-type': 'application/rss+xml',
'Cache-Control': 'max-age=3600',
'Cache-Control': `max-age=${cacheMaxAge}`,
},
})
} else if (path === '/atom') {
let content = await WORKER_PLANET_STORE.get('atom')
response = new Response(content, {
headers: {
'content-type': 'application/atom+xml',
'Cache-Control': `max-age=${cacheMaxAge}`,
},
})
// } else if (path === '/atom') {
// let content = await WORKER_PLANET_STORE.get('atom')
// response = new Response(content)
} else {
return new Response('', { status: 404 })
}
Expand Down Expand Up @@ -118,7 +123,7 @@ async function handleScheduled() {
let html = createHTML(content, sources)
// Store
await WORKER_PLANET_STORE.put('rss', feed.rss2())
//await WORKER_PLANET_STORE.put('atom', feed.atom1())
await WORKER_PLANET_STORE.put('atom', feed.atom1())
await WORKER_PLANET_STORE.put('html', html)
}

Expand Down
1 change: 1 addition & 0 deletions templates/default.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<meta property="og:description" content="{{page_description}}" />
<meta http-equiv="Content-Security-Policy" content="script-src https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js; style-src https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css 'sha256-G3Hryz5a3r//doprn3mQdVn71SMV/Wb1C6hMehrBGnk=';" />
<link rel="alternate" type="application/rss+xml" title="Planet RSS feed" href="/rss" />
<link rel="alternate" type="application/atom+xml" title="Planet Atom feed" href="/atom" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css"
Expand Down
26 changes: 13 additions & 13 deletions templates/default.precompiled.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions templates/headlines.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<meta property="og:description" content="{{page_description}}" />
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-hashes' 'sha256-2drSom6Fplo+OFvNUVKnb+wZyrq6v1lOEkVaexi/Fw4=' 'sha256-JeTyInHTbNelTT9AfPH8MBCkB4sU4yMQjoaIQNeLIZ8='; style-src https://cdn.jsdelivr.net/npm/@picocss/pico@1/css/pico.min.css;" />
<link rel="alternate" type="application/rss+xml" title="Planet RSS feed" href="/rss" />
<link rel="alternate" type="application/atom+xml" title="Planet Atom feed" href="/atom" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@1/css/pico.min.css">
</head>
<body>
Expand Down
Loading

0 comments on commit 09a017b

Please sign in to comment.