所有資料來源
Historical events that happened on today's date from Wikipedia
@codytseng #wikipedia #history #today
安裝與設定方式
- 先在 Mac 上安裝並開啟 Glanceway,再使用上方的安裝連結。
- 點選「安裝到 Glanceway」。若瀏覽器無法開啟應用程式,下載 .gwsrc 檔案並在資訊源管理中匯入。
- 填寫以下必填欄位並儲存,設定更新間隔,等待首次成功取得內容。
設定檢查
LANGUAGE— 選填. Wikipedia language edition
沒有顯示內容時如何排查
- 對照目前版本設定表檢查欄位、清單項目與憑證。下方範例不包含可用的真實憑證。
- 檢查網路及上游服務狀態。認證失敗或速率限制可能使更新失敗,請依上游限制調整間隔。
- 空清單也可能代表沒有符合條件的條目。內容與更新時間取決於資料提供方及資訊源實作。
設定項目
| 名稱 | 鍵 | 類型 | 必填 | 預設值 | 描述 |
|---|---|---|---|---|---|
| Language | LANGUAGE | select | 否 | en | Wikipedia language edition enzhjadefres |
原始碼
id: codytseng/wikipedia-on-this-day
version: 1.0.0
name: Wikipedia On This Day
description: Historical events that happened on today's date from Wikipedia
author: codytseng
author_url: https://github.com/codytseng
category: Other
tags:
- wikipedia
- history
- today
config:
- key: LANGUAGE
name: Language
type: select
required: false
default: en
description: Wikipedia language edition
options:
- en
- zh
- ja
- de
- fr
- es id: codytseng/wikipedia-on-this-day
version: 1.0.0
name: Wikipedia On This Day
description: Historical events that happened on today's date from Wikipedia
author: codytseng
author_url: https://github.com/codytseng
category: Other
tags:
- wikipedia
- history
- today
config:
- key: LANGUAGE
name: Language
type: select
required: false
default: en
description: Wikipedia language edition
options:
- en
- zh
- ja
- de
- fr
- es module.exports = async (api) => {
const language = api.config.get("LANGUAGE") || "en";
async function fetchData() {
const now = new Date();
const mm = String(now.getMonth() + 1).padStart(2, "0");
const dd = String(now.getDate()).padStart(2, "0");
const url = `https://api.wikimedia.org/feed/v1/wikipedia/${language}/onthisday/all/${mm}/${dd}`;
const response = await api.fetch(url);
if (!response.ok || !response.json) {
throw new Error(
`Failed to fetch Wikipedia On This Day (HTTP ${response.status})`,
);
}
const events = [
...(response.json.selected || []),
...(response.json.events || []),
];
const seen = new Set();
const items = [];
for (const item of events) {
const page = item.pages?.[0];
const id = `${item.year}-${page?.title || item.text.slice(0, 50)}`;
if (seen.has(id)) continue;
seen.add(id);
items.push({
id,
title: `${item.year} \u2014 ${item.text}`,
subtitle: page?.extract,
url: page?.content_urls?.desktop?.page,
});
if (items.length >= 200) break;
}
api.emit(items);
}
await fetchData();
return {
refresh: fetchData,
};
}; module.exports = async (api) => {
const language = api.config.get("LANGUAGE") || "en";
async function fetchData() {
const now = new Date();
const mm = String(now.getMonth() + 1).padStart(2, "0");
const dd = String(now.getDate()).padStart(2, "0");
const url = `https://api.wikimedia.org/feed/v1/wikipedia/${language}/onthisday/all/${mm}/${dd}`;
const response = await api.fetch(url);
if (!response.ok || !response.json) {
throw new Error(
`Failed to fetch Wikipedia On This Day (HTTP ${response.status})`,
);
}
const events = [
...(response.json.selected || []),
...(response.json.events || []),
];
const seen = new Set();
const items = [];
for (const item of events) {
const page = item.pages?.[0];
const id = `${item.year}-${page?.title || item.text.slice(0, 50)}`;
if (seen.has(id)) continue;
seen.add(id);
items.push({
id,
title: `${item.year} \u2014 ${item.text}`,
subtitle: page?.extract,
url: page?.content_urls?.desktop?.page,
});
if (items.length >= 200) break;
}
api.emit(items);
}
await fetchData();
return {
refresh: fetchData,
};
};