Glanceway Glanceway
모든 소스

Reddit

소셜 v1.0.0

Hot posts from a subreddit

@codytseng #reddit #social

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

  • SUBREDDIT — Required. Subreddit name without r/ (e.g. programming, javascript) Add each value as a separate list item.
  • SORT — Optional. Sort order for posts

Enter subreddit names without r/, one per list item. Public endpoint availability depends on Reddit’s access rules. The current source supports hot, new, top, and rising sorting.

Example settings

SUBREDDIT (list items):
  programming
  selfhosted
SORT: hot

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.

설정

이름 키 유형 필수 기본값 설명
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
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,
  };
};

관련 소스