Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add Links to Atom & RSS Feeds #407

Merged
merged 1 commit into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/components/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Button, Card, Icon, List, Modal } from 'semantic-ui-react'
import Credits from './Credits'
import DescriptionItem from './DescriptionItem'
import { DescriptionTypes, Ticker } from '../lib/types'
import { getAtomFeedUrl, getRssFeedUrl } from '../lib/api'

interface Props {
ticker: Ticker
Expand Down Expand Up @@ -49,6 +50,13 @@ const About: FC<Props> = props => {
type={DescriptionTypes.Telegram}
/>
)}
<List.Item>
<List.Icon name="feed" />
<List.Content>
<a href={getAtomFeedUrl()}>Atom</a> |{' '}
<a href={getRssFeedUrl()}>RSS</a>
</List.Content>
</List.Item>
</List>
)

Expand Down
18 changes: 13 additions & 5 deletions src/lib/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Message, Settings, Ticker } from './types'

const apiUrl = process.env.REACT_APP_API_URL
export const ApiUrl = process.env.REACT_APP_API_URL

type InitResponseData = {
settings: Settings
Expand Down Expand Up @@ -32,7 +32,7 @@ async function get<T>(path: string): Promise<T> {
}

export async function getInit(): Promise<InitResponse> {
return get(`${apiUrl}/init`)
return get(`${ApiUrl}/init`)
}

export type TimelineOpts = {
Expand All @@ -44,12 +44,20 @@ export async function getTimeline(
opts: TimelineOpts
): Promise<TimelineResponse> {
if (opts.after != null) {
return get(`${apiUrl}/timeline?after=${opts.after}`)
return get(`${ApiUrl}/timeline?after=${opts.after}`)
}

if (opts.before != null) {
return get(`${apiUrl}/timeline?before=${opts.before}`)
return get(`${ApiUrl}/timeline?before=${opts.before}`)
}

return get(`${apiUrl}/timeline`)
return get(`${ApiUrl}/timeline`)
}

export function getAtomFeedUrl(): string {
return `${ApiUrl}/feed?origin=${window.location.hostname}&format=atom`
}

export function getRssFeedUrl(): string {
return `${ApiUrl}/feed?origin=${window.location.hostname}&format=rss`
}