Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

feat(plugins): add author url link to plugin metadata

Gabe Kangasf992e0a7265c
diff --git a/pluginhost/registry.go b/pluginhost/registry.go
index 038e96cb05..a1668fac3f 100644
--- a/pluginhost/registry.go
+++ b/pluginhost/registry.go
@@ -161,6 +161,19 @@ func (p *Host) handleRegistryInstall(w http.ResponseWriter, r *http.Request) {
writeJSONResponse(w, http.StatusBadRequest, map[string]string{jsonErrorKey: "plugin cannot be installed: " + err.Error()})
return
}
+
+ // Record the registry's homepage link for the plugin so the
+ // installed-plugins list can show it. Best-effort: the install
+ // itself already succeeded, so a bad or missing link just means no
+ // homepage renders.
+ if detail.Homepage != "" {
+ if err := p.manager.SetPluginHomepage(entry.Slug, detail.Homepage); err != nil {
+ log.Warnf("plugin %q: could not record registry homepage: %v", entry.Slug, err)
+ } else {
+ entry.Homepage = detail.Homepage
+ }
+ }
+
log.Infof("plugin %q [%s] v%s installed from registry by admin", entry.DisplayName, entry.Slug, entry.Version)
writeJSONResponse(w, http.StatusOK, entry)
}
@@ -174,7 +187,11 @@ type registryVersion struct {
}
type registryDetail struct {
- Slug string `json:"slug"`
+ Slug string `json:"slug"`
+ // Homepage is the plugin's external link from the registry listing
+ // (docs, source repo, tip jar). Persisted host-side at install time
+ // so the installed-plugins list can render it.
+ Homepage string `json:"homepage"`
Versions []registryVersion `json:"versions"`
}
diff --git a/pluginhost/registry_test.go b/pluginhost/registry_test.go
index 5d27a6954e..ce027a1bac 100644
--- a/pluginhost/registry_test.go
+++ b/pluginhost/registry_test.go
@@ -367,6 +367,10 @@ func TestHandleRegistryRoute_DispatchesActions(t *testing.T) {
// --- test helpers ---
+// stubRegistryHomepage is the homepage link the stub registry's detail
+// payload advertises. Successful installs persist it host-side.
+const stubRegistryHomepage = "https://example.com/docs"
+
// newRegistryStub returns an httptest server that emulates the
// directory's /plugins/<slug> detail endpoint plus a download URL
// the install handler will GET to retrieve the .ocpkg bytes. The
@@ -386,7 +390,8 @@ func newRegistryStub(t *testing.T, slug, version string, pkg []byte, sha string)
downloadURL := fmt.Sprintf("http://%s/ocpkg/%s", r.Host, slug)
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(map[string]any{
- "slug": slug,
+ "slug": slug,
+ "homepage": stubRegistryHomepage,
"versions": []map[string]any{
{
"version": version,
@@ -404,3 +409,89 @@ func newRegistryStub(t *testing.T, slug, version string, pkg []byte, sha string)
t.Cleanup(srv.Close)
return srv
}
+
+// buildJSPackageBytes assembles an in-memory .ocpkg whose code entry is
+// author JavaScript run on the embedded shared engine, so install-path
+// tests don't depend on the SDK example wasm being built.
+func buildJSPackageBytes(t *testing.T, manifest []byte) []byte {
+ t.Helper()
+ var buf bytes.Buffer
+ zw := zip.NewWriter(&buf)
+ mw, err := zw.Create("plugin.manifest.json")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err := mw.Write(manifest); err != nil {
+ t.Fatal(err)
+ }
+ jw, err := zw.Create("plugin.js")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err := jw.Write([]byte(`const { definePlugin } = require("@owncast/plugin-sdk"); module.exports = definePlugin({});`)); err != nil {
+ t.Fatal(err)
+ }
+ if err := zw.Close(); err != nil {
+ t.Fatal(err)
+ }
+ return buf.Bytes()
+}
+
+// TestHandleRegistryInstall_PersistsHomepageSidecar covers the registry
+// metadata flow: the registry's detail payload carries a homepage link,
+// the install handler persists it via SetPluginHomepage (as a
+// <base>.registry.json sidecar next to the installed .ocpkg), and the
+// install response's entry JSON reflects it.
+func TestHandleRegistryInstall_PersistsHomepageSidecar(t *testing.T) {
+ pkg := buildJSPackageBytes(t, []byte(`{
+ "api": "1",
+ "name": "Hello World",
+ "slug": "hello-world",
+ "version": "0.1.0",
+ "description": "registry homepage test",
+ "permissions": []
+ }`))
+ sum := sha256.Sum256(pkg)
+ sha := hex.EncodeToString(sum[:])
+
+ upstream := newRegistryStub(t, "hello-world", "0.1.0", pkg, sha)
+ withRegistryEnv(t, upstream.URL)
+ host := newTestHost(t)
+
+ rec := httptest.NewRecorder()
+ req := httptest.NewRequest(http.MethodPost, "/api/admin/plugin-registry/install",
+ strings.NewReader(`{"slug":"hello-world","version":"0.1.0"}`))
+ host.handleRegistryInstall(rec, req)
+
+ if rec.Code != http.StatusOK {
+ t.Fatalf("status = %d, want 200 (body=%s)", rec.Code, rec.Body.String())
+ }
+ var entry plugins.DiscoveredEntry
+ if err := json.Unmarshal(rec.Body.Bytes(), &entry); err != nil {
+ t.Fatalf("decode install response: %v", err)
+ }
+ if entry.Homepage != stubRegistryHomepage {
+ t.Errorf("install response homepage = %q, want %q", entry.Homepage, stubRegistryHomepage)
+ }
+
+ // The homepage is persisted as a sidecar next to the installed
+ // package so it survives host restarts.
+ entries := host.manager.List()
+ if len(entries) != 1 {
+ t.Fatalf("manager has %d entries, want 1", len(entries))
+ }
+ sidecar := strings.TrimSuffix(entries[0].Path, filepath.Ext(entries[0].Path)) + ".registry.json"
+ raw, err := os.ReadFile(sidecar)
+ if err != nil {
+ t.Fatalf("read homepage sidecar: %v", err)
+ }
+ var meta struct {
+ Homepage string `json:"homepage"`
+ }
+ if err := json.Unmarshal(raw, &meta); err != nil {
+ t.Fatalf("decode sidecar %s: %v", raw, err)
+ }
+ if meta.Homepage != stubRegistryHomepage {
+ t.Errorf("sidecar homepage = %q, want %q", meta.Homepage, stubRegistryHomepage)
+ }
+}
diff --git a/services/plugins/manager.go b/services/plugins/manager.go
index 97963cbd0f..cb7977af9f 100644
--- a/services/plugins/manager.go
+++ b/services/plugins/manager.go
@@ -8,6 +8,7 @@ import (
"fmt"
"io"
"io/fs"
+ "net/url"
"os"
"path/filepath"
"sort"
@@ -369,15 +370,21 @@ func (m *Manager) notifyUnload(l *Loaded) {
// identity for plugins that post to chat. Empty means "use
// DisplayName" (resolved at chat-send time, not here).
type DiscoveredEntry struct {
- Slug string `json:"slug"`
- DisplayName string `json:"name"`
- BotDisplayName string `json:"botDisplayName,omitempty"`
- Version string `json:"version,omitempty"`
- Description string `json:"description,omitempty"`
- Permissions []string `json:"permissions,omitempty"`
- Path string `json:"path"`
- Enabled bool `json:"enabled"`
- Loaded bool `json:"loaded"`
+ Slug string `json:"slug"`
+ DisplayName string `json:"name"`
+ BotDisplayName string `json:"botDisplayName,omitempty"`
+ Version string `json:"version,omitempty"`
+ Description string `json:"description,omitempty"`
+ // Homepage is an optional external link for the plugin (docs, help
+ // page, source repo, tip jar). Recorded from the registry's
+ // metadata when the plugin is installed from the registry (kept in
+ // a "<base>.registry.json" sidecar next to the plugin file);
+ // manually-uploaded plugins have none.
+ Homepage string `json:"homepage,omitempty"`
+ Permissions []string `json:"permissions,omitempty"`
+ Path string `json:"path"`
+ Enabled bool `json:"enabled"`
+ Loaded bool `json:"loaded"`
// AutoDisabled is set when the dispatcher's strike system stopped
// invoking the plugin (too many consecutive filter failures).
// Enabled stays true so the admin can see what they originally chose,
@@ -838,6 +845,52 @@ func (m *Manager) Install(ctx context.Context, packageBytes []byte) (*Discovered
return &snapshot, nil
}
+// SetPluginHomepage records an external link for an installed plugin,
+// persisted as a "<base>.registry.json" sidecar next to the plugin file
+// so it survives restarts, and mirrored into the discovered entry so
+// the next List() shows it without waiting for a scan. Called by the
+// registry install flow with the registry's listing metadata. Only
+// absolute http(s) URLs are accepted since the admin UI renders the
+// value as a clickable link; an empty URL removes the sidecar.
+func (m *Manager) SetPluginHomepage(slug, homepage string) error {
+ m.mu.RLock()
+ entry, ok := m.discovered[slug]
+ var path string
+ if ok {
+ path = entry.Path
+ }
+ m.mu.RUnlock()
+ if !ok {
+ return fmt.Errorf("plugin %q not discovered", slug)
+ }
+
+ metaPath := registryMetaPathFor(path)
+ if homepage == "" {
+ if err := os.Remove(metaPath); err != nil && !os.IsNotExist(err) {
+ return err
+ }
+ } else {
+ u, err := url.Parse(homepage)
+ if err != nil || (u.Scheme != "http" && u.Scheme != "https") || u.Host == "" {
+ return fmt.Errorf("homepage %q must be an absolute http(s) URL", homepage)
+ }
+ b, err := json.Marshal(registryMeta{Homepage: homepage})
+ if err != nil {
+ return err
+ }
+ if err := os.WriteFile(metaPath, b, 0o600); err != nil {
+ return fmt.Errorf("write registry metadata: %w", err)
+ }
+ }
+
+ m.mu.Lock()
+ if entry, ok := m.discovered[slug]; ok {
+ entry.Homepage = homepage
+ }
+ m.mu.Unlock()
+ return nil
+}
+
// Disable unloads a plugin and persists the choice. No-op if already disabled.
func (m *Manager) Disable(ctx context.Context, name string) error {
m.mu.Lock()
@@ -912,6 +965,7 @@ func removePluginFiles(path string) error {
if err := os.Remove(path); err != nil && !os.IsNotExist(err) {
return err
}
+ _ = os.Remove(registryMetaPathFor(path))
if strings.HasSuffix(path, ".wasm") {
base := strings.TrimSuffix(path, ".wasm")
_ = os.Remove(base + ".manifest.json")
@@ -1065,6 +1119,7 @@ func (m *Manager) scan(ctx context.Context) error {
hasIcon := hasPluginIcon(path)
hasInstructions := hasPluginInstructions(path)
+ homepage := readPluginHomepage(path)
m.mu.Lock()
if existing, ok := m.discovered[manifest.Slug]; ok {
@@ -1081,6 +1136,7 @@ func (m *Manager) scan(ctx context.Context) error {
existing.PendingPermissions = pendingPermissions(manifest.Permissions, m.approvedSet[manifest.Slug])
existing.AllowedHosts = manifest.Network.AllowedHosts
existing.Config = manifest.Config
+ existing.Homepage = homepage
} else {
m.discovered[manifest.Slug] = &DiscoveredEntry{
Slug: manifest.Slug,
@@ -1097,6 +1153,7 @@ func (m *Manager) scan(ctx context.Context) error {
HasInstructions: hasInstructions,
PendingPermissions: pendingPermissions(manifest.Permissions, m.approvedSet[manifest.Slug]),
Config: manifest.Config,
+ Homepage: homepage,
}
}
m.mu.Unlock()
@@ -1575,6 +1632,40 @@ func requireChatFilterPermission(manifest *Manifest, subs Subscriptions) error {
return nil
}
+// registryMetaSuffix names the sidecar file the host writes next to a
+// plugin installed from the registry ("<base>.registry.json"), carrying
+// registry-sourced metadata that has no home in the plugin's own
+// manifest. The scan loop ignores it (only .wasm/.ocpkg are discovered)
+// and Uninstall removes it with the plugin.
+const registryMetaSuffix = ".registry.json"
+
+// registryMeta is the sidecar's JSON shape.
+type registryMeta struct {
+ Homepage string `json:"homepage,omitempty"`
+}
+
+// registryMetaPathFor returns the registry-metadata sidecar path for a
+// plugin file: "<dir>/<base>.registry.json" for both the x.ocpkg and
+// x.wasm layouts.
+func registryMetaPathFor(pluginPath string) string {
+ return strings.TrimSuffix(pluginPath, filepath.Ext(pluginPath)) + registryMetaSuffix
+}
+
+// readPluginHomepage reads the homepage from a plugin's registry
+// sidecar, or "" when there is no sidecar (manual upload) or it doesn't
+// parse. Called per scan, so it's a single small read.
+func readPluginHomepage(pluginPath string) string {
+ b, err := os.ReadFile(registryMetaPathFor(pluginPath))
+ if err != nil {
+ return ""
+ }
+ var meta registryMeta
+ if err := json.Unmarshal(b, &meta); err != nil {
+ return ""
+ }
+ return meta.Homepage
+}
+
// PluginIconFilename is the conventional filename a plugin uses to ship
// an icon. For .ocpkg plugins it lives at the root of the zip; for loose
// .wasm files it sits next to the wasm as "<base>.icon.png" so multiple
diff --git a/services/plugins/manager_test.go b/services/plugins/manager_test.go
index 204748af47..9ebe530ce4 100644
--- a/services/plugins/manager_test.go
+++ b/services/plugins/manager_test.go
@@ -676,3 +676,165 @@ func TestManager_Install_UpdatesExistingPlugin(t *testing.T) {
t.Errorf("update should not duplicate the entry, got %d", len(mgr.List()))
}
}
+
+// --- registry homepage sidecar ---
+
+const testHomepage = "https://example.com/docs"
+
+// sidecarPath returns the registry-metadata sidecar path the manager
+// writes next to a loose-files plugin in dir.
+func sidecarPath(dir, name string) string {
+ return filepath.Join(dir, name+".registry.json")
+}
+
+// readSidecarHomepage decodes the homepage recorded in a registry
+// sidecar file. The literal filename and JSON key are the on-disk
+// persistence contract the registry install flow depends on.
+func readSidecarHomepage(t *testing.T, path string) string {
+ t.Helper()
+ raw, err := os.ReadFile(path)
+ if err != nil {
+ t.Fatalf("read sidecar: %v", err)
+ }
+ var meta struct {
+ Homepage string `json:"homepage"`
+ }
+ if err := json.Unmarshal(raw, &meta); err != nil {
+ t.Fatalf("decode sidecar %s: %v", raw, err)
+ }
+ return meta.Homepage
+}
+
+// Discovery only parses the manifest sidecar (never instantiates the
+// wasm), so the homepage tests use junk wasm bytes and run without the
+// SDK example being built.
+func TestManager_SetPluginHomepage_WritesSidecarAndSurvivesRestart(t *testing.T) {
+ dir := t.TempDir()
+ makePluginFiles(t, dir, "hello-world", []byte{0x00})
+
+ ctx := context.Background()
+ mgr := NewManager(dir, &HostEnv{})
+ if err := mgr.Start(ctx); err != nil {
+ t.Fatalf("start: %v", err)
+ }
+
+ if err := mgr.SetPluginHomepage("hello-world", testHomepage); err != nil {
+ t.Fatalf("set homepage: %v", err)
+ }
+ if got := readSidecarHomepage(t, sidecarPath(dir, "hello-world")); got != testHomepage {
+ t.Errorf("sidecar homepage = %q, want %q", got, testHomepage)
+ }
+ entries := mgr.List()
+ if len(entries) != 1 {
+ t.Fatalf("expected 1 discovered, got %d", len(entries))
+ }
+ if entries[0].Homepage != testHomepage {
+ t.Errorf("List should show the homepage immediately, got %q", entries[0].Homepage)
+ }
+
+ // Restart survival: a fresh manager over the same dir rediscovers
+ // the plugin with the homepage populated from the sidecar.
+ mgr.Stop(ctx)
+ mgr2 := NewManager(dir, &HostEnv{})
+ if err := mgr2.Start(ctx); err != nil {
+ t.Fatalf("restart: %v", err)
+ }
+ defer mgr2.Stop(ctx)
+ entries = mgr2.List()
+ if len(entries) != 1 {
+ t.Fatalf("expected 1 discovered after restart, got %d", len(entries))
+ }
+ if entries[0].Homepage != testHomepage {
+ t.Errorf("homepage should survive a restart via the sidecar, got %q", entries[0].Homepage)
+ }
+}
+
+func TestManager_SetPluginHomepage_RejectsNonHTTPURLs(t *testing.T) {
+ dir := t.TempDir()
+ makePluginFiles(t, dir, "hello-world", []byte{0x00})
+
+ mgr := NewManager(dir, &HostEnv{})
+ if err := mgr.Start(context.Background()); err != nil {
+ t.Fatalf("start: %v", err)
+ }
+ defer mgr.Stop(context.Background())
+
+ // The admin UI renders the homepage as a clickable link, so only
+ // absolute http(s) URLs may be recorded.
+ for _, bad := range []string{"javascript:alert(1)", "/relative", "example.com/no-scheme"} {
+ if err := mgr.SetPluginHomepage("hello-world", bad); err == nil {
+ t.Errorf("SetPluginHomepage(%q) should be rejected", bad)
+ }
+ }
+ if _, err := os.Stat(sidecarPath(dir, "hello-world")); !os.IsNotExist(err) {
+ t.Errorf("rejected homepage must not leave a sidecar, stat err = %v", err)
+ }
+ entries := mgr.List()
+ if len(entries) != 1 {
+ t.Fatalf("expected 1 discovered, got %d", len(entries))
+ }
+ if entries[0].Homepage != "" {
+ t.Errorf("rejected homepage must not show in List, got %q", entries[0].Homepage)
+ }
+}
+
+func TestManager_SetPluginHomepage_UnknownSlugErrors(t *testing.T) {
+ mgr := NewManager(t.TempDir(), &HostEnv{})
+ if err := mgr.Start(context.Background()); err != nil {
+ t.Fatalf("start: %v", err)
+ }
+ defer mgr.Stop(context.Background())
+ if err := mgr.SetPluginHomepage("nothing-here", testHomepage); err == nil {
+ t.Fatal("expected error setting homepage for unknown plugin")
+ }
+}
+
+func TestManager_SetPluginHomepage_EmptyRemovesSidecar(t *testing.T) {
+ dir := t.TempDir()
+ makePluginFiles(t, dir, "hello-world", []byte{0x00})
+
+ mgr := NewManager(dir, &HostEnv{})
+ if err := mgr.Start(context.Background()); err != nil {
+ t.Fatalf("start: %v", err)
+ }
+ defer mgr.Stop(context.Background())
+
+ if err := mgr.SetPluginHomepage("hello-world", testHomepage); err != nil {
+ t.Fatalf("set homepage: %v", err)
+ }
+ if err := mgr.SetPluginHomepage("hello-world", ""); err != nil {
+ t.Fatalf("clear homepage: %v", err)
+ }
+ if _, err := os.Stat(sidecarPath(dir, "hello-world")); !os.IsNotExist(err) {
+ t.Errorf("clearing the homepage should remove the sidecar, stat err = %v", err)
+ }
+ entries := mgr.List()
+ if len(entries) != 1 {
+ t.Fatalf("expected 1 discovered, got %d", len(entries))
+ }
+ if entries[0].Homepage != "" {
+ t.Errorf("cleared homepage should vanish from List, got %q", entries[0].Homepage)
+ }
+}
+
+func TestManager_Uninstall_RemovesRegistrySidecar(t *testing.T) {
+ dir := t.TempDir()
+ makePluginFiles(t, dir, "hello-world", []byte{0x00})
+
+ ctx := context.Background()
+ mgr := NewManager(dir, &HostEnv{})
+ if err := mgr.Start(ctx); err != nil {
+ t.Fatalf("start: %v", err)
+ }
+ defer mgr.Stop(ctx)
+
+ if err := mgr.SetPluginHomepage("hello-world", testHomepage); err != nil {
+ t.Fatalf("set homepage: %v", err)
+ }
+ if err := mgr.Uninstall(ctx, "hello-world"); err != nil {
+ t.Fatalf("uninstall: %v", err)
+ }
+ if _, err := os.Stat(sidecarPath(dir, "hello-world")); !os.IsNotExist(err) {
+ t.Errorf("uninstall should remove the registry sidecar, stat err = %v", err)
+ }
+}
diff --git a/web/components/admin/plugins/BrowseRegistry.module.scss b/web/components/admin/plugins/BrowseRegistry.module.scss
index fa42c16f01..7c9a68f5a8 100644
--- a/web/components/admin/plugins/BrowseRegistry.module.scss
+++ b/web/components/admin/plugins/BrowseRegistry.module.scss
@@ -66,6 +66,14 @@
margin-bottom: 8px !important;
}
+// Plugin homepage link (docs, source repo, tip jar), shown as the
+// URL's hostname between the summary and the preview image.
+.homepage {
+ display: block;
+ font-size: 12px;
+ margin-bottom: 8px;
+}
+
// Author-supplied screenshot/preview for the listing. Constrained so a
// large upload can't blow out the card; object-fit:contain keeps the
// whole image visible without cropping. Sits between the summary and
diff --git a/web/components/admin/plugins/BrowseRegistry.stories.tsx b/web/components/admin/plugins/BrowseRegistry.stories.tsx
index 9627489b53..bf96865be1 100644
--- a/web/components/admin/plugins/BrowseRegistry.stories.tsx
+++ b/web/components/admin/plugins/BrowseRegistry.stories.tsx
@@ -22,7 +22,11 @@ const plugins: RegistryPlugin[] = [
slug: 'welcome-bot',
name: 'Welcome Bot',
authorName: 'Gabe Kangas',
+ // Author link: the "by ..." line renders as a link to this URL.
+ authorURL: 'https://gabekangas.com',
summary: 'Greets new chat participants with a configurable message when they join.',
+ // Plugin homepage: rendered as a hostname link under the summary.
+ homepage: 'https://github.com/owncast/welcome-bot',
tags: ['chat', 'moderation'],
latest: {
version: '1.2.0',
@@ -33,6 +37,7 @@ const plugins: RegistryPlugin[] = [
{
slug: 'now-playing',
name: 'Now Playing',
+ // authorName without authorURL: plain, unlinked "by ..." line.
authorName: 'Owncast Community',
summary: 'Shows the currently playing track pulled from an external music service.',
tags: ['overlay'],
diff --git a/web/components/admin/plugins/BrowseRegistry.tsx b/web/components/admin/plugins/BrowseRegistry.tsx
index f54e3c0a27..e3963907bf 100644
--- a/web/components/admin/plugins/BrowseRegistry.tsx
+++ b/web/components/admin/plugins/BrowseRegistry.tsx
@@ -3,6 +3,7 @@ import { Alert, Button, Card, Empty, Space, Spin, Tag, Tooltip, Typography } fro
import { useTranslation } from 'next-export-i18n';
import { Localization } from '../../../types/localization';
import { isPluginUpdateAvailable } from '../../../utils/apis';
+import { formatLinkHostname } from '../../../utils/format';
import { readableBytes } from '../../../utils/images';
import { PuzzlePiece } from './PluginIcon';
import { permissionDescriptionKey, permissionNameKey } from './permissionDescriptions';
@@ -34,6 +35,9 @@ export type RegistryPlugin = {
// than the square icon; rendered below the summary when present.
previewURL?: string;
authorName?: string;
+ // Optional public link for the author (personal site, GitHub
+ // profile). When present the "by ..." line links to it.
+ authorURL?: string;
latest?: {
version: string;
sizeBytes?: number;
@@ -195,12 +199,32 @@ export const BrowseRegistry = ({
<Text type="secondary"> &middot; {readableBytes(plugin.latest.sizeBytes)}</Text>
) : null}
</div>
- {plugin.authorName && (
- <Text type="secondary" className={s.author}>
- {t(Localization.Admin.Plugins.browseAuthor, { name: plugin.authorName })}
- </Text>
- )}
+ {plugin.authorName &&
+ (plugin.authorURL ? (
+ <Typography.Link
+ href={plugin.authorURL}
+ target="_blank"
+ rel="noopener noreferrer"
+ className={s.author}
+ >
+ {t(Localization.Admin.Plugins.browseAuthor, { name: plugin.authorName })}
+ </Typography.Link>
+ ) : (
+ <Text type="secondary" className={s.author}>
+ {t(Localization.Admin.Plugins.browseAuthor, { name: plugin.authorName })}
+ </Text>
+ ))}
{plugin.summary && <Paragraph className={s.summary}>{plugin.summary}</Paragraph>}
+ {plugin.homepage && (
+ <Typography.Link
+ href={plugin.homepage}
+ target="_blank"
+ rel="noopener noreferrer"
+ className={s.homepage}
+ >
+ {formatLinkHostname(plugin.homepage)}
+ </Typography.Link>
+ )}
{plugin.previewURL && (
<img
className={s.preview}
diff --git a/web/components/admin/plugins/PluginsList.tsx b/web/components/admin/plugins/PluginsList.tsx
index f33a52d568..d350f290a3 100644
--- a/web/components/admin/plugins/PluginsList.tsx
+++ b/web/components/admin/plugins/PluginsList.tsx
@@ -3,6 +3,7 @@ import { Alert, Button, Popconfirm, Space, Switch, Table, Tag, Tooltip, Typograp
import { useTranslation } from 'next-export-i18n';
import dynamic from 'next/dynamic';
import { Plugin } from '../../../interfaces/plugin';
+import { formatLinkHostname } from '../../../utils/format';
import { Localization } from '../../../types/localization';
import { permissionDescriptionKey, permissionNameKey } from './permissionDescriptions';
import { PluginIcon } from './PluginIcon';
@@ -17,6 +18,7 @@ const AppstoreOutlined = dynamic(() => import('@ant-design/icons/AppstoreOutline
ssr: false,
});
const DeleteOutlined = dynamic(() => import('@ant-design/icons/DeleteOutlined'), { ssr: false });
+const LinkOutlined = dynamic(() => import('@ant-design/icons/LinkOutlined'), { ssr: false });
export type PluginsListProps = {
plugins: Plugin[];
@@ -102,6 +104,16 @@ export const PluginsList = ({
{plugin.description}
</Text>
)}
+ {plugin.homepage && (
+ <Typography.Link
+ href={plugin.homepage}
+ target="_blank"
+ rel="noopener noreferrer"
+ className={s.secondaryText}
+ >
+ <LinkOutlined /> {formatLinkHostname(plugin.homepage)}
+ </Typography.Link>
+ )}
{plugin.lastError && (
<Alert
type="error"
diff --git a/web/interfaces/plugin.ts b/web/interfaces/plugin.ts
index 8e7e1751f2..9917cdf2fa 100644
--- a/web/interfaces/plugin.ts
+++ b/web/interfaces/plugin.ts
@@ -50,6 +50,11 @@ export interface Plugin {
botDisplayName?: string;
version?: string;
description?: string;
+ // homepage is an optional external link for the plugin (docs, help
+ // page, source repo, tip jar), recorded from the registry's metadata
+ // when the plugin was installed from the registry. Rendered as a
+ // link in the installed plugins list. Absent for manual uploads.
+ homepage?: string;
permissions?: string[];
path: string;
enabled: boolean;
diff --git a/web/utils/format.ts b/web/utils/format.ts
index 0bb68a2f93..ec6d60f8c4 100644
--- a/web/utils/format.ts
+++ b/web/utils/format.ts
@@ -79,3 +79,15 @@ export function formatUAstring(uaString: string) {
return `${name} ${browserVersion} on ${osName} ${osVersion}
${deviceString}`;
}
+
+// formatLinkHostname reduces an absolute URL to its hostname for use as
+// compact link text (e.g. "https://github.com/x/y" -> "github.com").
+// Falls back to the raw string when it doesn't parse, so a malformed
+// value still renders something clickable rather than throwing.
+export function formatLinkHostname(url: string): string {
+ try {
+ return new URL(url).hostname;
+ } catch {
+ return url;
+ }
+}