Glanceway Glanceway
Все источники

Wikipedia On This Day

Другое v1.0.0

Historical events that happened on today's date from Wikipedia

@codytseng #wikipedia #history #today

Install and configure this source

  1. Install Glanceway and open it on your Mac before using the install link above.
  2. Choose Install in Glanceway. If the browser cannot open the app, download the .gwsrc file and import it through source management.
  3. Complete the required fields below, save, and choose a refresh interval. Check the source after its first successful fetch.

Configuration checklist

  • LANGUAGE — Optional. Wikipedia language edition

If items are missing

  • Verify the field names, list entries, and credentials against the current version’s configuration table. Sample values below are examples, not active credentials.
  • Check network access and upstream service availability. Authentication failures and rate limits can prevent a refresh; use a slower interval when the provider limits requests.
  • An empty result can also mean there are no matching items. Fetched content and update timing depend on the provider and source implementation.

Настройки

Название Ключ Тип Обязательно По умолчанию Описание
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
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,
  };
};