diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/config/defaults.ts | 1 | ||||
| -rw-r--r-- | src/config/types.ts | 1 | ||||
| -rw-r--r-- | src/modules/sidebar/modules/headlines.tsx | 12 | ||||
| -rw-r--r-- | src/services/news.ts | 4 |
4 files changed, 13 insertions, 5 deletions
diff --git a/src/config/defaults.ts b/src/config/defaults.ts index cc52a5e..9b4bf1c 100644 --- a/src/config/defaults.ts +++ b/src/config/defaults.ts @@ -175,6 +175,7 @@ export default { categories: ["business", "top", "technology", "world"], // A list of news categories to filter by languages: ["en"], // A list of languages codes to filter by domains: [] as string[], // A list of news domains to pull from, see https://newsdata.io/news-sources for available domains + excludeDomains: ["news.google.com"], // A list of news domains to exclude, e.g. bbc.co.uk timezone: "", // A timezone to filter by, e.g. "America/New_York", see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones pages: 3, // Number of pages to pull (each page is 10 articles) }, diff --git a/src/config/types.ts b/src/config/types.ts index 66e0cfe..6127e6f 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -86,6 +86,7 @@ export default { "news.categories": ARR(NEWS_CATEGORIES), "news.languages": ARR(NEWS_LANGUAGES), "news.domains": ARR(STR), + "news.excludeDomains": ARR(STR), "news.timezone": STR, "news.pages": NUM, } as { [k: string]: string | string[] | number[] }; diff --git a/src/modules/sidebar/modules/headlines.tsx b/src/modules/sidebar/modules/headlines.tsx index 9515b28..462e2ee 100644 --- a/src/modules/sidebar/modules/headlines.tsx +++ b/src/modules/sidebar/modules/headlines.tsx @@ -2,7 +2,6 @@ import type { Monitor } from "@/services/monitors"; import News, { type IArticle } from "@/services/news"; import Palette, { type IPalette } from "@/services/palette"; import { capitalize } from "@/utils/strings"; -import { setupCustomTooltip } from "@/utils/widgets"; import { bind, execAsync, Variable } from "astal"; import { Gtk } from "astal/gtk3"; import { sidebar } from "config"; @@ -56,7 +55,7 @@ const Article = ({ title, description, creator, pubDate, source_name, link }: IA <button className="wrapper" cursor="pointer" onClicked={() => expanded.set(!expanded.get())}> <box hexpand className="header"> <box vertical> - <label truncate xalign={0} label={title} setup={self => setupCustomTooltip(self, title)} /> + <label truncate xalign={0} label={title} /> <label truncate xalign={0} @@ -73,6 +72,7 @@ const Article = ({ title, description, creator, pubDate, source_name, link }: IA > <button onClicked={() => execAsync(`app2unit -O -- ${link}`)}> <box vertical className="article-body"> + <label wrap className="title" xalign={0} label={title} /> <label wrap xalign={0} label={`Published on ${new Date(pubDate).toLocaleString()}`} /> <label wrap @@ -119,9 +119,11 @@ const Category = ({ title, articles }: { title: string; articles: IArticle[] }) transitionDuration={200} > <box vertical className="body"> - {articles.map(a => ( - <Article {...a} /> - ))} + {articles + .sort((a, b) => a.source_priority - b.source_priority) + .map(a => ( + <Article {...a} /> + ))} </box> </revealer> </box> diff --git a/src/services/news.ts b/src/services/news.ts index 8db280a..e5f605d 100644 --- a/src/services/news.ts +++ b/src/services/news.ts @@ -10,6 +10,7 @@ export interface IArticle { description: string | null; pubDate: string; source_name: string; + source_priority: number; category: string[]; } @@ -68,6 +69,7 @@ export default class News extends GObject.Object { const categories = config.categories.get().join(","); const languages = config.languages.get().join(","); const domains = config.domains.get().join(","); + const excludeDomains = config.excludeDomains.get().join(","); const timezone = config.timezone.get(); if (countries.includes("current")) { @@ -80,6 +82,7 @@ export default class News extends GObject.Object { if (categories) args += `&category=${categories}`; if (languages) args += `&language=${languages}`; if (domains) args += `&domain=${domains}`; + if (excludeDomains) args += `&excludedomain=${excludeDomains}`; if (timezone) args += `&timezone=${timezone}`; const url = `https://newsdata.io/api/1/latest?apikey=${config.apiKey.get()}&${args}`; @@ -141,6 +144,7 @@ export default class News extends GObject.Object { config.categories.subscribe(() => this.getNews().catch(console.error)); config.languages.subscribe(() => this.getNews().catch(console.error)); config.domains.subscribe(() => this.getNews().catch(console.error)); + config.excludeDomains.subscribe(() => this.getNews().catch(console.error)); config.timezone.subscribe(() => this.getNews().catch(console.error)); config.pages.subscribe(() => this.getNews().catch(console.error)); } |