PortalJS连接CKAN

本条目介绍 PortalJS连接CKAN 的公开用途。DeepSkill 当前公开目录说明:“将一个脚手架的 PortalJS 门户连接到 CKAN 后端,通过其 API 进行通信。生成一个轻量级的服务器端获取客户端(无运行时依赖),并从 CKAN 获取 /search 目录和 /@namespace/slug 展示页面,而不是使用 datasets.json。适用于将现有门户连接到实时 CKAN 实例,而非静态清单的场景。” 适用场景包括应用接入与集成、写代码与代码审查。本页根据公开目录资料和固定版本的上游仓库整理,建议使用前核对该版本的环境、工具、权限及数据处理要求。Skillπ 提供站方用途介绍与原站链接;原始 SKILL.md 和附件仅在对应许可允许时开放。

仓库
jeremylongshore/tons-of-skills-marketplace

安装方式

先用 Prompt 核对来源,也可切换到安装命令或下载可用的安装包。

安装方式

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "portaljs-connect-ckan":https://skillpi.com/zh/skills/deepskill-a649b3482535d99a9192ce275d031c2f834a71043fd3f1d627c1845bd9d6231c。安装前核对上游来源和版本:https://github.com/jeremylongshore/tons-of-skills-marketplace/blob/6ea46b08dce892944db7c16f28d0b5308d402402/plugins/community/portaljs/skills/portaljs-connect-ckan/SKILL.md。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

此命令从 GitHub 来源仓库获取指定技能。运行前请先查看源文件。

运行工具
npx skills add https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/6ea46b08dce892944db7c16f28d0b5308d402402/plugins/community/portaljs/skills/portaljs-connect-ckan --skill portaljs-connect-ckan
许可协议: —

来源与配置

查看 GitHub 源码

jeremylongshore/tons-of-skills-marketplace固定提交 6ea46b08dce892944db7c16f28d0b5308d402402

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

本条目介绍 PortalJS连接CKAN 的公开用途。DeepSkill 当前公开目录说明:“将一个脚手架的 PortalJS 门户连接到 CKAN 后端,通过其 API 进行通信。生成一个轻量级的服务器端获取客户端(无运行时依赖),并从 CKAN 获取 /search 目录和 /@namespace/slug 展示页面,而不是使用 datasets.json。适用于将现有门户连接到实时 CKAN 实例,而非静态清单的场景。” 适用场景包括应用接入与集成、写代码与代码审查。本页根据公开目录资料和固定版本的上游仓库整理,建议使用前核对该版本的环境、工具、权限及数据处理要求。Skillπ 提供站方用途介绍与原站链接;原始 SKILL.md 和附件仅在对应许可允许时开放。

↓ 0 下载 ↗ 0 分享点击

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
---
name: portaljs-connect-ckan
description: Wire a scaffolded PortalJS portal to a CKAN backend over its API. Generates a tiny server-side fetch client (no runtime dependency) and feeds the /search catalog and /@namespace/slug showcases from CKAN instead of datasets.json. Use when connecting an existing portal to a live CKAN instance instead of a static manifest.
allowed-tools: Read, Write, Edit, Bash(npm:*), Bash(npx:*), WebFetch
version: 1.0.0
author: Datopian <hello@datopian.com>
license: MIT
compatibility: Claude Code with PortalJS portals (Next.js 14, React 18, Node 18+). Runs from any project via the plugin, a personal ~/.claude/commands install, or a portaljs clone.
tags:
  - portaljs
  - data-portal
  - ckan
  - backend
  - api
  - catalog
---

# PortalJS — Connect CKAN

## Overview

Connect an existing `portaljs-catalog` portal to a live CKAN backend for the "decoupled /
any backend" path. The portal stops reading the static `datasets.json` manifest (and files
in `/public/data/`) and instead feeds its two data surfaces — the **`/search` catalog** and
the **`/@namespace/slug` showcases** — straight from a CKAN instance's REST API
(`package_search` / `package_show`) through a generated fetch client. Output is plain,
editable Next.js code with **no runtime dependency** — never `@portaljs/ckan`, whose bundle
wires React UI components to React 18 internals and crashes at import under the template's
React 19. Pages fetch CKAN server-side in `getStaticProps`/`getStaticPaths`, so the catalog
is pre-rendered at build time and the site can still be statically deployed. Run this right
after `portaljs-new-portal` to swap a freshly scaffolded portal's sample data over to CKAN.

## Prerequisites

- A scaffolded PortalJS portal (see `portaljs-new-portal`) with `package.json`, `pages/`,
  `datasets.json`, `pages/search.tsx`, and `pages/[owner]/[slug].tsx` present.
- A CKAN base URL that is publicly reachable, e.g. `https://demo.dev.datopian.com`.
- Node 18+ and npm available in the portal directory (no new packages are installed).

## Instructions

The canonical, full step-by-step workflow is
[`.claude/commands/portaljs-connect-ckan.md`](https://github.com/datopian/portaljs/blob/main/.claude/commands/portaljs-connect-ckan.md) —
the single source of truth. Read and follow it when executing. Summary:

1. Gather input from `$ARGUMENTS` — CKAN base URL (required), org filter (optional), group
   filter (optional), portal directory (default `.`). If the URL is missing, interview the
   user; never dead-end with a missing-input error.
2. Validate the target directory is a `portaljs-catalog` portal; if not, suggest
   `portaljs-new-portal` instead of failing silently.
3. Verify the CKAN backend is reachable via `package_search?rows=1`, and validate each org
   filter via `organization_show`; on failure, explain and re-prompt rather than dead-ending.
4. Generate `lib/ckan.ts` — a self-contained server-side fetch client wrapping
   `package_search` and `package_show`, with `DMS`, `ORG_FILTER`, `GROUP_FILTER`, and
   `MAX_DATASETS` as editable constants.
5. Rewire `pages/search.tsx` to list datasets from `package_search`, linking each to
   `/@namespace/slug` via `datasetHref`; leave `pages/index.tsx` untouched.
6. Overwrite `pages/[owner]/[slug].tsx` to pre-render one page per dataset via
   `getStaticPaths` and fetch details with `package_show`, previewing tabular resources
   through the existing `Table` component.
7. Verify the build with `npx next build`; fix any error before reporting success.
8. Report what changed: client, catalog, showcase, filters, and static page count.

## Output

- **Created:** `lib/ckan.ts` (fetch wrapper client — no dependency added to `package.json`).
- **Modified:** `pages/search.tsx` (catalog reads `package_search`); `pages/[owner]/[slug].tsx`
  (showcase reads `package_show`, overwritten to drop the `datasets.json` source).
- **Unchanged:** `pages/index.tsx` (still the static search-first landing page).
- **Verified:** `npx next build` succeeds and prints the static page count.
- **Result:** `/search` and `/@namespace/slug` are served from the CKAN backend; the
  `DMS` env var can override the base URL at deploy time without editing code.

## Error Handling

| Symptom | Cause | Fix |
| --- | --- | --- |
| Missing CKAN URL | User invoked the skill with no `$ARGUMENTS` | Ask for the base URL (and optional org/group filter); never error out. |
| `package_search` request fails or times out | URL isn't a reachable CKAN root | Tell the user, ask them to confirm the URL, and retry. |
| Org filter not found | `organization_show` returns `success: false` | List valid orgs from `organization_list` and ask which one was meant. |
| Catalog renders empty after connecting | Wrong org/group filter name in `lib/ckan.ts` | Clear or correct the filter constants and rebuild. |
| `next build` fails | Typo in substituted `CKAN_URL` or bad TypeScript edit | Print the log, fix the first error, and re-run before reporting success. |
| `<Table>` fails to load a resource | CKAN resource host blocks CORS | Note that the Download link still works; prefer datastore-backed resources. |

## Examples

### Example 1 — Public CKAN demo, no filters

```
/portaljs-connect-ckan url=https://demo.dev.datopian.com
```

### Example 2 — Restrict the catalog to one organization

```
/portaljs-connect-ckan url=https://demo.dev.datopian.com org=my-org
```

### Example 3 — Filter by group and target a specific portal directory

```
/portaljs-connect-ckan url=https://data.example.gov group=education dir=./my-portal
```

## Resources

- Full workflow: [`.claude/commands/portaljs-connect-ckan.md`](https://github.com/datopian/portaljs/blob/main/.claude/commands/portaljs-connect-ckan.md)
- Client, filters, and troubleshooting reference: [`references/reference.md`](references/reference.md)
- Related skills: `portaljs-new-portal`, `portaljs-add-dataset`, `portaljs-deploy`
- CKAN Action API documentation: <https://docs.ckan.org/en/latest/api/>

当前收录版本

1.0.0

核对来源版本 ↗

质量评测

满分 100。前四项来自 DeepSkill 收录的质量报告。

场景价值78/100
评分依据

解决 PortalJS 门户连接实时 CKAN 后端的实际需求,替代静态清单

触发精准72/100
评分依据

skill_body 内部提供了清晰的功能说明和使用场景

结构规范92/100
评分依据

文档结构完整,包含 Overview、Prerequisites、Instructions、Output、Error Handling、Examples 等必要章节

执行可靠88/100
评分依据

工具来源明确,基于 PortalJS 和 CKAN API 的标准实现

证据可验 (前四项均值)83/100
计算方式

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

  • 安装或获取外部依赖

    使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。

    主文档提及 · 第 4, 61, 70 行
文档引用的域名或地址

这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。

  • data.example.gov
  • demo.dev.datopian.com
  • docs.ckan.org
  • github.com

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

risk · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。

来源与使用声明 SkillPi 的部分技能资料来自公开来源或创作者提交。第三方内容的权利归各自权利人所有。安装或运行前,请查看原站的许可、权限要求和使用风险。

来源与使用

请按详情页的作者、原始来源和许可证核对使用条件,运行前检查技能需要的权限。目录收录不等于已验证安装或安全性。