安装与配置方法
- 先在 Mac 上安装并打开 Glanceway,再使用上方的安装链接。
- 点击“安装到 Glanceway”。如果浏览器无法唤起应用,下载 .gwsrc 文件并在信息源管理中导入。
- 填写下列必填字段并保存,设置刷新间隔,等待首次成功获取。
配置检查
SUBREDDIT— 必填. Subreddit name without r/ (e.g. programming, javascript) 每个值分别作为一条列表项添加。SORT— 可选. Sort order for posts
版块名不带 r/,每个版块作为独立列表项添加。公开端点是否可用取决于 Reddit 的访问规则。当前支持 hot、new、top、rising 排序。
配置示例
SUBREDDIT (list items):
programming
selfhosted
SORT: hot 没有显示内容时如何排查
- 对照当前版本配置表核对字段、列表项和凭据。下方示例不包含可用的真实凭据。
- 检查网络与上游服务状态。认证失败或速率限制可能导致刷新失败,应根据上游限制调整间隔。
- 空列表也可能表示没有符合条件的条目。内容和更新时间取决于数据提供方及信息源实现。
配置项
| 名称 | 键 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|---|
| Subreddit | SUBREDDIT | list | 是 | — | Subreddit name without r/ (e.g. programming, javascript) |
| Sort | SORT | select | 否 | hot | Sort order for posts hotnewtoprising |
源代码
id: codytseng/reddit
version: 1.0.0
name: Reddit
description: Hot posts from a subreddit
author: codytseng
author_url: https://github.com/codytseng
category: Social
tags:
- reddit
- social
config:
- key: SUBREDDIT
name: Subreddit
type: list
required: true
description: Subreddit name without r/ (e.g. programming, javascript)
- key: SORT
name: Sort
type: select
required: false
default: hot
description: Sort order for posts
options:
- hot
- new
- top
- rising id: codytseng/reddit
version: 1.0.0
name: Reddit
description: Hot posts from a subreddit
author: codytseng
author_url: https://github.com/codytseng
category: Social
tags:
- reddit
- social
config:
- key: SUBREDDIT
name: Subreddit
type: list
required: true
description: Subreddit name without r/ (e.g. programming, javascript)
- key: SORT
name: Sort
type: select
required: false
default: hot
description: Sort order for posts
options:
- hot
- new
- top
- rising module.exports = async (api) => {
const subreddits = api.config.get("SUBREDDIT") ?? ["programming"];
const subreddit = subreddits.join("+");
const sort = api.config.get("SORT") || "hot";
async function fetchData() {
const response = await api.fetch(`https://www.reddit.com/r/${subreddit}/${sort}.json?limit=100&raw_json=1`, {
headers: { "User-Agent": "Glanceway/1.0" },
});
if (!response.ok || !response.json) {
throw new Error(`Failed to fetch Reddit posts from r/${subreddit} (HTTP ${response.status})`);
}
api.emit(
response.json.data.children.map((child) => {
const post = child.data;
return {
id: post.id,
title: post.title,
subtitle: post.selftext || `↑ ${post.score} · ${post.num_comments} comments · u/${post.author}`,
url: post.url.startsWith("/")
? `https://www.reddit.com${post.url}`
: post.url,
timestamp: post.created_utc,
};
}),
);
}
await fetchData();
return {
refresh: fetchData,
};
}; module.exports = async (api) => {
const subreddits = api.config.get("SUBREDDIT") ?? ["programming"];
const subreddit = subreddits.join("+");
const sort = api.config.get("SORT") || "hot";
async function fetchData() {
const response = await api.fetch(`https://www.reddit.com/r/${subreddit}/${sort}.json?limit=100&raw_json=1`, {
headers: { "User-Agent": "Glanceway/1.0" },
});
if (!response.ok || !response.json) {
throw new Error(`Failed to fetch Reddit posts from r/${subreddit} (HTTP ${response.status})`);
}
api.emit(
response.json.data.children.map((child) => {
const post = child.data;
return {
id: post.id,
title: post.title,
subtitle: post.selftext || `↑ ${post.score} · ${post.num_comments} comments · u/${post.author}`,
url: post.url.startsWith("/")
? `https://www.reddit.com${post.url}`
: post.url,
timestamp: post.created_utc,
};
}),
);
}
await fetchData();
return {
refresh: fetchData,
};
};