Skip to content

Commit

Permalink
Update tidyread---streamline-your-daily-reading extension (raycast#10568
Browse files Browse the repository at this point in the history
)

* Update tidyread---streamline-your-daily-reading extension

- Merge branch \'contributions/merge-1707060463863168000\'
- Pull contributions
- fix: fix RSS pull 406 error code

* Update tidyread---streamline-your-daily-reading extension

- change default
- chore: change prompt to remove ads
- chore: improve feedback and digest content
- feat: digest can be categorized by tags
- feat: add defaultSearchText context for search rss page
- chore: change desc
- feat: export digest as markdown
- fix: feed with only summary cause empty content

* Update tidyread---streamline-your-daily-reading extension

- change title
- chore: change title

* chore: improve speed of parse RSS and fix abort on RSS pull failed

* chore: add tips

* fix lint

---------

Co-authored-by: jaredliu <jaredliu233@gmail.com>
  • Loading branch information
DophinL and jaredliu233 authored Feb 7, 2024
1 parent 1e9358c commit bde81ef
Show file tree
Hide file tree
Showing 18 changed files with 320 additions and 106 deletions.
12 changes: 12 additions & 0 deletions extensions/tidyread---streamline-your-daily-reading/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# TidyRead - Streamline Your Daily Reading Changelog

## [Support Categorized Digest And Fix Some Edge Case Bugs] - 2024-01-30
- feat: digest can be categorized by tags
- feat: export digest as markdown file
- feat: add defaultSearchText context for search rss page
- chore: moonshot default to 8k
- chore: improve feedback and digest content
- chore: change prompt to remove ads
- chore: improve speed of parse RSS
- fix: abort on RSS pull failed
- fix: RSS pull 406 error code
- fix: feed with only summary cause empty content

## [Add Search RSS Page] - 2024-01-30
- add search rss page
- add generate digest in background
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,4 @@ For more information, visit [Tidyread](https://tidyread.info).

> If you have any questions or would like to discuss further, feel free to [DM me on x](https://x.com/jaredliu_bravo).
## Other Links

- [Buy me a coffee](https://www.buymeacoffee.com/jaredliu)
<a href="https://www.buymeacoffee.com/jaredliu" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>
11 changes: 10 additions & 1 deletion extensions/tidyread---streamline-your-daily-reading/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
},
{
"name": "preferredLanguage",
"description": "If you configure the AI, it will automatically translate the article titles in the digest into your preferred language. You can also use the {{lang}} variable in the Summarize Prompt field.",
"description": "Summarize the content within 50-200 characters, directly output. Focusing strictly on its core insights. Exclude promotional content, including podcast listening options, subscription offers, access instructions, and any form of contact details for additional services. Most important, respond in {{lang}}.",
"type": "textfield",
"title": "Preferred Language",
"required": false
Expand Down Expand Up @@ -323,6 +323,15 @@
"title": "WriteFreely Password",
"required": false
},
{
"name": "splitByTags",
"description": "Whether digest content is categorized by label",
"type": "checkbox",
"title": "Enable Digest Split By Tags",
"label": "Enable",
"default": false,
"required": false
},
{
"name": "enableItemLinkProxy",
"description": "The article links in digest will be redirected to the official website of tidyread by default, for the purpose of usage statistics and the possible addition of structured reading features in the future. If you think this affects your normal use, you can disable it.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { LaunchProps } from "@raycast/api";
import RSSSearch from "./components/RSSSearch";
import RedirectRoute from "./components/RedirectRoute";

export default function CreateSourceForm() {
export default function CreateSourceForm(props: LaunchProps<{ launchContext: { defaultSearchText: string } }>) {
const defaultSearchText = props?.launchContext?.defaultSearchText ?? "";
return (
<RedirectRoute>
<RSSSearch />
<RSSSearch defaultSearchText={defaultSearchText} />
</RedirectRoute>
);
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,46 @@
import { Action, Detail } from "@raycast/api";
import { Action, Detail, Icon, Toast, showToast } from "@raycast/api";
import { Digest } from "../types";
import CustomActionPanel from "./CustomActionPanel";
import SharableLinkAction from "./SharableLinkAction";
import { saveFileAs } from "../utils/file";
import { useEffect } from "react";
import { addDigestGenerationCount } from "../store";
import { usePromise } from "@raycast/utils";
import { getFeedbackContent } from "../utils/biz";
// import dayjs from "dayjs";

export default function DigestDetail({ digest }: { digest: Digest }) {
const prefix = "";
// const prefix = `# ${digest.title} \`at ${dayjs(digest.createAt).format('HH:mm')}\`\n\n`;
const md = `${prefix}${digest.content}`;
const { data: feedbackContent = "" } = usePromise(getFeedbackContent);

useEffect(() => {
setTimeout(() => {
addDigestGenerationCount();
}, 300);
}, []);

return (
<Detail
navigationTitle={digest.title}
actions={
<CustomActionPanel>
<Action
title="Export As Markdown File"
icon={Icon.Download}
onAction={async () => {
try {
const flag = await saveFileAs(md, `${digest.title.replaceAll(/\s/g, "-")}.md`);
if (flag) {
showToast(Toast.Style.Success, "File saved");
}
} catch (err: any) {
showToast(Toast.Style.Failure, "Failed to save file", err.message);
console.error("Failed to save file", err);
}
}}
/>
<Action.CopyToClipboard title="Copy Content" content={md} />
<SharableLinkAction
actionTitle="Share This Digest"
Expand All @@ -22,7 +49,7 @@ export default function DigestDetail({ digest }: { digest: Digest }) {
/>
</CustomActionPanel>
}
markdown={md}
markdown={feedbackContent + md}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ export default function GenTodaysDigestPanel({
setTotal(stage.data);
console.log("pullitems stage.data", stage.data);
} else if (status === "failed") {
setPullItemsStatus("failed");
// 无需关注错误情况,会在简报中生成相应的错误提示
// setPullItemsStatus("failed");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function RSSListItem(props: {
}, [selected]);

const keywords = useMemo(() => {
return [item.description, silent(() => extractDomain(item.url!))].filter(Boolean) as string[];
return [item.description, item.url, silent(() => extractDomain(item.url!))].filter(Boolean) as string[];
}, [item]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import SourceForm from "./SourceForm";
export default function RSSPlainListView(props: {
searchBarAccessory?: List.Props["searchBarAccessory"];
filterByTag?: string;
defaultSearchText?: string;
}) {
const { searchBarAccessory } = props;
const { searchBarAccessory, filterByTag, defaultSearchText } = props;
const [selectId, setSelectId] = useState<string>("");
const { data, isLoading } = useCachedPromise(async () => {
const resp = (await requestWithFallback(
Expand All @@ -25,7 +26,7 @@ export default function RSSPlainListView(props: {
return resp
.filter((item) => item.available ?? true)
.filter((item) => {
return props.filterByTag ? (item.tags || []).includes(props.filterByTag) : true;
return filterByTag ? (item.tags || []).includes(filterByTag) : true;
})
.sort((a, b) => (b.weight ?? 1) - (a.weight ?? 1));
})) as Partial<ExternalSource>[];
Expand Down Expand Up @@ -53,6 +54,7 @@ export default function RSSPlainListView(props: {
isLoading={isLoading}
searchBarPlaceholder="Search source, or press `⌘ + Enter` to manually add"
isShowingDetail
searchText={defaultSearchText}
searchBarAccessory={searchBarAccessory}
// selectedItemId={selectId}
onSelectionChange={(id) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ function Dropdown(props: { defaultValue: string; onChange: (newValue: string) =>
);
}

export default function RSSSearch() {
export default function RSSSearch(props: { defaultSearchText?: string }) {
const { defaultSearchText } = props;
const [view, setView] = useState<"all" | "tag">("all");

if (view === "tag") {
Expand All @@ -44,6 +45,7 @@ export default function RSSSearch() {

return (
<RSSPlainListView
defaultSearchText={defaultSearchText}
searchBarAccessory={<Dropdown defaultValue="all" onChange={(val) => setView(val as "all" | "tag")} />}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const CATEGORIES = [
{ value: "AI", emoji: "✨", weight: 100 },
{ value: "Arts", emoji: "🎨" },
{ value: "Automotive", emoji: "🚗" },
{ value: "BlockChain", emoji: "🔗" },
{ value: "Blog", emoji: "📝" },
{ value: "Business", emoji: "💼", weight: 70 },
{ value: "Culture", emoji: "🌍" },
Expand All @@ -19,7 +20,7 @@ export const CATEGORIES = [
{ value: "Language", emoji: "🔤" },
{ value: "Legal", emoji: "🧑‍⚖️" },
{ value: "Lifestyle", emoji: "🛋️" },
{ value: "Other", emoji: "💭" },
{ value: "Others", emoji: "💭" },
{ value: "Personal Development", emoji: "🚀", weight: 85 },
{ value: "Philosophy", emoji: "🤔" },
{ value: "Politics", emoji: "🏛", weight: 80 },
Expand All @@ -34,6 +35,7 @@ export const CATEGORIES = [
{ value: "Startup", emoji: "🚀", weight: 90 },
{ value: "Technology", emoji: "🤖", weight: 90 },
{ value: "Travel", emoji: "🛫" },
{ value: "Web3", emoji: "🌐" },
];

export const CATEGORIES_EMOJI_MAP = CATEGORIES.reduce(
Expand Down
Loading

0 comments on commit bde81ef

Please sign in to comment.