mirror of
https://github.com/Athou/commafeed.git
synced 2026-11-20 02:33:33 +00:00
use 120 max line length for both server and client code (was 100 and 140)
This commit is contained in:
@@ -15,7 +15,9 @@ describe("Content component", () => {
|
||||
})
|
||||
|
||||
it("renders iframe tag when included in content", () => {
|
||||
const { container } = render(<Content content='<iframe src="https://example.com"></iframe>' />, { wrapper: MantineProvider })
|
||||
const { container } = render(<Content content='<iframe src="https://example.com"></iframe>' />, {
|
||||
wrapper: MantineProvider,
|
||||
})
|
||||
expect(container.querySelector("iframe")).toHaveAttribute("src", "https://example.com")
|
||||
})
|
||||
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
import { Box, Mark } from "@mantine/core"
|
||||
import escapeStringRegexp from "escape-string-regexp"
|
||||
import { ALLOWED_TAG_LIST, type ChildrenNode, Interweave, Matcher, type MatchResponse, type Node, type TransformCallback } from "interweave"
|
||||
import {
|
||||
ALLOWED_TAG_LIST,
|
||||
type ChildrenNode,
|
||||
Interweave,
|
||||
Matcher,
|
||||
type MatchResponse,
|
||||
type Node,
|
||||
type TransformCallback,
|
||||
} from "interweave"
|
||||
import React from "react"
|
||||
import styleToObject from "style-to-object"
|
||||
import { Constants } from "@/app/constants"
|
||||
|
||||
@@ -300,7 +300,9 @@ export function FeedEntries() {
|
||||
entry={entry}
|
||||
expanded={!!entry.expanded || viewMode === "expanded"}
|
||||
selected={entry.id === selectedEntryId}
|
||||
showSelectionIndicator={entry.id === selectedEntryId && (!entry.expanded || viewMode === "expanded")}
|
||||
showSelectionIndicator={
|
||||
entry.id === selectedEntryId && (!entry.expanded || viewMode === "expanded")
|
||||
}
|
||||
maxWidth={sidebarVisible ? Constants.layout.entryMaxWidth : undefined}
|
||||
onHeaderClick={event => headerClicked(entry, event)}
|
||||
onHeaderRightClick={event => headerRightClicked(entry, event)}
|
||||
|
||||
@@ -34,67 +34,80 @@ const useStyles = tss
|
||||
maxWidth?: number
|
||||
fontSizePercentage: number
|
||||
}>()
|
||||
.create(({ theme, colorScheme, read, expanded, viewMode, rtl, showSelectionIndicator, maxWidth, fontSizePercentage }) => {
|
||||
let backgroundColor: string
|
||||
if (colorScheme === "dark") {
|
||||
backgroundColor = read ? "inherit" : theme.colors.dark[5]
|
||||
} else {
|
||||
backgroundColor = read && !expanded ? theme.colors.gray[0] : "inherit"
|
||||
}
|
||||
.create(
|
||||
({
|
||||
theme,
|
||||
colorScheme,
|
||||
read,
|
||||
expanded,
|
||||
viewMode,
|
||||
rtl,
|
||||
showSelectionIndicator,
|
||||
maxWidth,
|
||||
fontSizePercentage,
|
||||
}) => {
|
||||
let backgroundColor: string
|
||||
if (colorScheme === "dark") {
|
||||
backgroundColor = read ? "inherit" : theme.colors.dark[5]
|
||||
} else {
|
||||
backgroundColor = read && !expanded ? theme.colors.gray[0] : "inherit"
|
||||
}
|
||||
|
||||
let marginY = 10
|
||||
if (viewMode === "title") {
|
||||
marginY = 2
|
||||
} else if (viewMode === "cozy") {
|
||||
marginY = 6
|
||||
}
|
||||
let marginY = 10
|
||||
if (viewMode === "title") {
|
||||
marginY = 2
|
||||
} else if (viewMode === "cozy") {
|
||||
marginY = 6
|
||||
}
|
||||
|
||||
let mobileMarginY = 6
|
||||
if (viewMode === "title") {
|
||||
mobileMarginY = 2
|
||||
} else if (viewMode === "cozy") {
|
||||
mobileMarginY = 4
|
||||
}
|
||||
let mobileMarginY = 6
|
||||
if (viewMode === "title") {
|
||||
mobileMarginY = 2
|
||||
} else if (viewMode === "cozy") {
|
||||
mobileMarginY = 4
|
||||
}
|
||||
|
||||
let backgroundHoverColor = backgroundColor
|
||||
if (!expanded && !read) {
|
||||
backgroundHoverColor = colorScheme === "dark" ? theme.colors.dark[6] : theme.colors.gray[1]
|
||||
}
|
||||
let backgroundHoverColor = backgroundColor
|
||||
if (!expanded && !read) {
|
||||
backgroundHoverColor = colorScheme === "dark" ? theme.colors.dark[6] : theme.colors.gray[1]
|
||||
}
|
||||
|
||||
let paperBorderLeftColor = ""
|
||||
if (showSelectionIndicator) {
|
||||
const borderLeftColor = colorScheme === "dark" ? theme.colors[theme.primaryColor][4] : theme.colors[theme.primaryColor][6]
|
||||
paperBorderLeftColor = `${borderLeftColor} !important`
|
||||
}
|
||||
let paperBorderLeftColor = ""
|
||||
if (showSelectionIndicator) {
|
||||
const borderLeftColor =
|
||||
colorScheme === "dark" ? theme.colors[theme.primaryColor][4] : theme.colors[theme.primaryColor][6]
|
||||
paperBorderLeftColor = `${borderLeftColor} !important`
|
||||
}
|
||||
|
||||
return {
|
||||
paper: {
|
||||
backgroundColor,
|
||||
borderLeftColor: paperBorderLeftColor,
|
||||
marginTop: marginY,
|
||||
marginBottom: marginY,
|
||||
[`@media (max-width: ${Constants.layout.mobileBreakpoint}px)`]: {
|
||||
marginTop: mobileMarginY,
|
||||
marginBottom: mobileMarginY,
|
||||
},
|
||||
"@media (hover: hover)": {
|
||||
"&:hover": {
|
||||
backgroundColor: backgroundHoverColor,
|
||||
return {
|
||||
paper: {
|
||||
backgroundColor,
|
||||
borderLeftColor: paperBorderLeftColor,
|
||||
marginTop: marginY,
|
||||
marginBottom: marginY,
|
||||
[`@media (max-width: ${Constants.layout.mobileBreakpoint}px)`]: {
|
||||
marginTop: mobileMarginY,
|
||||
marginBottom: mobileMarginY,
|
||||
},
|
||||
"@media (hover: hover)": {
|
||||
"&:hover": {
|
||||
backgroundColor: backgroundHoverColor,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
headerLink: {
|
||||
fontSize: `${fontSizePercentage}%`,
|
||||
color: "inherit",
|
||||
textDecoration: "none",
|
||||
},
|
||||
body: {
|
||||
fontSize: `${fontSizePercentage}%`,
|
||||
direction: rtl ? "rtl" : "ltr",
|
||||
maxWidth: maxWidth ?? "100%",
|
||||
},
|
||||
headerLink: {
|
||||
fontSize: `${fontSizePercentage}%`,
|
||||
color: "inherit",
|
||||
textDecoration: "none",
|
||||
},
|
||||
body: {
|
||||
fontSize: `${fontSizePercentage}%`,
|
||||
direction: rtl ? "rtl" : "ltr",
|
||||
maxWidth: maxWidth ?? "100%",
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
export function FeedEntry(props: Readonly<FeedEntryProps>) {
|
||||
const viewMode = useAppSelector(state => state.user.localSettings.viewMode)
|
||||
@@ -116,7 +129,9 @@ export function FeedEntry(props: Readonly<FeedEntryProps>) {
|
||||
const showExternalLinkIcon =
|
||||
externalLinkDisplayMode && ["always", mobile ? "on_mobile" : "on_desktop"].includes(externalLinkDisplayMode)
|
||||
const showStarIcon =
|
||||
props.entry.markable && starIconDisplayMode && ["always", mobile ? "on_mobile" : "on_desktop"].includes(starIconDisplayMode)
|
||||
props.entry.markable &&
|
||||
starIconDisplayMode &&
|
||||
["always", mobile ? "on_mobile" : "on_desktop"].includes(starIconDisplayMode)
|
||||
|
||||
const swipeHandlers = useSwipeable({
|
||||
onSwipedLeft: props.onSwipedLeft,
|
||||
|
||||
@@ -35,7 +35,12 @@ export function FeedEntryContextMenu(props: Readonly<FeedEntryContextMenuProps>)
|
||||
const { openLinkInBackgroundTab } = useBrowserExtension()
|
||||
|
||||
return (
|
||||
<Menu id={Constants.dom.entryContextMenuId(props.entry)} theme={colorScheme} animation={false} className={classes.menu}>
|
||||
<Menu
|
||||
id={Constants.dom.entryContextMenuId(props.entry)}
|
||||
theme={colorScheme}
|
||||
animation={false}
|
||||
className={classes.menu}
|
||||
>
|
||||
<Item
|
||||
onClick={() => {
|
||||
window.open(props.entry.url, "_blank", "noreferrer")
|
||||
@@ -63,13 +68,19 @@ export function FeedEntryContextMenu(props: Readonly<FeedEntryContextMenuProps>)
|
||||
|
||||
{props.entry.markable && (
|
||||
<>
|
||||
<Item onClick={async () => await dispatch(starEntry({ entry: props.entry, starred: !props.entry.starred }))}>
|
||||
<Item
|
||||
onClick={async () =>
|
||||
await dispatch(starEntry({ entry: props.entry, starred: !props.entry.starred }))
|
||||
}
|
||||
>
|
||||
<Group>
|
||||
{props.entry.starred ? <TbStarOff size={iconSize} /> : <TbStar size={iconSize} />}
|
||||
{props.entry.starred ? <Trans>Unstar</Trans> : <Trans>Star</Trans>}
|
||||
</Group>
|
||||
</Item>
|
||||
<Item onClick={async () => await dispatch(markEntry({ entry: props.entry, read: !props.entry.read }))}>
|
||||
<Item
|
||||
onClick={async () => await dispatch(markEntry({ entry: props.entry, read: !props.entry.read }))}
|
||||
>
|
||||
<Group>
|
||||
{props.entry.read ? <TbMail size={iconSize} /> : <TbMailOpened size={iconSize} />}
|
||||
{props.entry.read ? <Trans>Keep unread</Trans> : <Trans>Mark as read</Trans>}
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
import { msg } from "@lingui/core/macro"
|
||||
import { useLingui } from "@lingui/react"
|
||||
import { Group, Indicator, Popover, TagsInput } from "@mantine/core"
|
||||
import { TbArrowBarToDown, TbExternalLink, TbMail, TbMailOpened, TbShare, TbStar, TbStarOff, TbTag } from "react-icons/tb"
|
||||
import {
|
||||
TbArrowBarToDown,
|
||||
TbExternalLink,
|
||||
TbMail,
|
||||
TbMailOpened,
|
||||
TbShare,
|
||||
TbStar,
|
||||
TbStarOff,
|
||||
TbTag,
|
||||
} from "react-icons/tb"
|
||||
import { markEntriesUpToEntry, markEntry, starEntry, tagEntry } from "@/app/entries/thunks"
|
||||
import { useAppDispatch, useAppSelector } from "@/app/store"
|
||||
import type { Entry } from "@/app/types"
|
||||
@@ -71,7 +80,12 @@ export function FeedEntryFooter(props: Readonly<FeedEntryFooterProps>) {
|
||||
{tags && (
|
||||
<Popover withArrow shadow="md" closeOnClickOutside={!mobile}>
|
||||
<Popover.Target>
|
||||
<Indicator label={props.entry.tags.length} disabled={props.entry.tags.length === 0} inline size={16}>
|
||||
<Indicator
|
||||
label={props.entry.tags.length}
|
||||
disabled={props.entry.tags.length === 0}
|
||||
inline
|
||||
size={16}
|
||||
>
|
||||
<ActionButton icon={<TbTag size={18} />} label={msg`Tags`} />
|
||||
</Indicator>
|
||||
</Popover.Target>
|
||||
|
||||
@@ -104,7 +104,9 @@ export function ShareButtons(
|
||||
}>
|
||||
) {
|
||||
const sharingSettings = useAppSelector(state => state.user.settings?.sharingSettings)
|
||||
const enabledSharingSites = (Object.keys(Constants.sharing) as Array<keyof SharingSettings>).filter(site => sharingSettings?.[site])
|
||||
const enabledSharingSites = (Object.keys(Constants.sharing) as Array<keyof SharingSettings>).filter(
|
||||
site => sharingSettings?.[site]
|
||||
)
|
||||
const url = encodeURIComponent(props.url)
|
||||
const desc = encodeURIComponent(props.description)
|
||||
const clipboardAvailable = typeof navigator.clipboard !== "undefined"
|
||||
@@ -119,7 +121,9 @@ export function ShareButtons(
|
||||
{showNativeSection && (
|
||||
<SimpleGrid cols={4}>
|
||||
{clipboardAvailable && <CopyUrlButton url={props.url} />}
|
||||
{nativeSharingAvailable && <BrowserNativeShareButton url={props.url} description={props.description} />}
|
||||
{nativeSharingAvailable && (
|
||||
<BrowserNativeShareButton url={props.url} description={props.description} />
|
||||
)}
|
||||
</SimpleGrid>
|
||||
)}
|
||||
|
||||
|
||||
@@ -36,7 +36,12 @@ export function AddCategory() {
|
||||
|
||||
<form onSubmit={form.onSubmit(addCategory.execute)}>
|
||||
<Stack>
|
||||
<TextInput label={<Trans>Category</Trans>} placeholder={_(msg`Category`)} {...form.getInputProps("name")} required />
|
||||
<TextInput
|
||||
label={<Trans>Category</Trans>}
|
||||
placeholder={_(msg`Category`)}
|
||||
{...form.getInputProps("name")}
|
||||
required
|
||||
/>
|
||||
<CategorySelect label={<Trans>Parent</Trans>} {...form.getInputProps("parentId")} clearable />
|
||||
<Group justify="center">
|
||||
<Button variant="default" onClick={async () => await dispatch(redirectToSelectedSource())}>
|
||||
|
||||
@@ -44,8 +44,8 @@ export function ImportOpml() {
|
||||
placeholder={_(msg`OPML file`)}
|
||||
description={
|
||||
<Trans>
|
||||
An opml file is an XML file containing feed URLs and categories. You can get an OPML file by exporting your
|
||||
data from other feed reading services.
|
||||
An opml file is an XML file containing feed URLs and categories. You can get an OPML
|
||||
file by exporting your data from other feed reading services.
|
||||
</Trans>
|
||||
}
|
||||
{...form.getInputProps("file")}
|
||||
|
||||
@@ -85,8 +85,8 @@ export function Subscribe() {
|
||||
placeholder="https://www.mysite.com/rss"
|
||||
description={
|
||||
<Trans>
|
||||
The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed
|
||||
will try to find the feed in the page.
|
||||
The URL for the feed you want to subscribe to. You can also use the website's url
|
||||
directly and CommaFeed will try to find the feed in the page.
|
||||
</Trans>
|
||||
}
|
||||
required
|
||||
@@ -101,8 +101,17 @@ export function Subscribe() {
|
||||
>
|
||||
<Stack>
|
||||
<TextInput label={<Trans>Feed URL</Trans>} {...step1Form.getInputProps("url")} disabled />
|
||||
<TextInput label={<Trans>Feed name</Trans>} {...step1Form.getInputProps("title")} required autoFocus />
|
||||
<CategorySelect label={<Trans>Category</Trans>} {...step1Form.getInputProps("categoryId")} clearable />
|
||||
<TextInput
|
||||
label={<Trans>Feed name</Trans>}
|
||||
{...step1Form.getInputProps("title")}
|
||||
required
|
||||
autoFocus
|
||||
/>
|
||||
<CategorySelect
|
||||
label={<Trans>Category</Trans>}
|
||||
{...step1Form.getInputProps("categoryId")}
|
||||
clearable
|
||||
/>
|
||||
</Stack>
|
||||
</Stepper.Step>
|
||||
</Stepper>
|
||||
@@ -117,7 +126,11 @@ export function Subscribe() {
|
||||
</Button>
|
||||
)}
|
||||
{activeStep === 1 && (
|
||||
<Button type="submit" leftSection={<TbRss size={16} />} loading={fetchFeed.loading || subscribe.loading}>
|
||||
<Button
|
||||
type="submit"
|
||||
leftSection={<TbRss size={16} />}
|
||||
loading={fetchFeed.loading || subscribe.loading}
|
||||
>
|
||||
<Trans>Subscribe</Trans>
|
||||
</Button>
|
||||
)}
|
||||
|
||||
@@ -26,7 +26,16 @@ const fields: Field[] = [
|
||||
{ name: "categoriesLower", label: "Categories (lower case)" },
|
||||
]
|
||||
|
||||
const textOperators = new Set(["=", "!=", "contains", "beginsWith", "endsWith", "doesNotContain", "doesNotBeginWith", "doesNotEndWith"])
|
||||
const textOperators = new Set([
|
||||
"=",
|
||||
"!=",
|
||||
"contains",
|
||||
"beginsWith",
|
||||
"endsWith",
|
||||
"doesNotContain",
|
||||
"doesNotBeginWith",
|
||||
"doesNotEndWith",
|
||||
])
|
||||
|
||||
function toCelString(query: RuleGroupType): string {
|
||||
if (query.rules.length === 0) {
|
||||
|
||||
@@ -24,7 +24,10 @@ export function Star(
|
||||
}
|
||||
|
||||
return (
|
||||
<Tooltip label={props.entry.starred ? <Trans>Unstar</Trans> : <Trans>Star</Trans>} openDelay={Constants.tooltip.delay}>
|
||||
<Tooltip
|
||||
label={props.entry.starred ? <Trans>Unstar</Trans> : <Trans>Star</Trans>}
|
||||
openDelay={Constants.tooltip.delay}
|
||||
>
|
||||
<ActionIcon variant="transparent" onClick={onClick}>
|
||||
{props.entry.starred ? <TbStarFilled size={18} /> : <TbStar size={18} />}
|
||||
</ActionIcon>
|
||||
|
||||
Reference in New Issue
Block a user