Skip to content

Add showcase-events examples (publicsitedata) - #6

Open
raytiley wants to merge 7 commits into
mainfrom
showcase-events-examples
Open

Add showcase-events examples (publicsitedata)#6
raytiley wants to merge 7 commits into
mainfrom
showcase-events-examples

Conversation

@raytiley

@raytiley raytiley commented Aug 24, 2026

Copy link
Copy Markdown
Member

Adds a showcase-events/ example set for building a live-events feature — "what's live now / coming up" listings and players — on a third-party site.

Everything reads live and upcoming events from GET /cablecastapi/publicsitedata (showcaseEventShows), which is read-only, needs no authentication, and is the one showcase feed available on both self-hosted Cablecast and Reflect+ hosted channels.

Status comes from the server-derived showcaseEventStatus field on each event — an open enum (live / upcoming / vod today; canceled / error reserved). The examples read that field directly and add only the cosmetic client-side "starting soon" split from scheduleStartTime; any value they don't recognise is treated defensively as not-live. Every server that emits showcaseEventShows also emits showcaseEventStatus, so there is no separate older-server derivation to maintain here.

Files

  • event-status.mjs — reads showcaseEventStatus and returns live / starting_soon / upcoming / vod; the shared helper the other examples import
  • browser-player.html — fetch the feed, poll every 15s, mount an HLS player when an event goes live
  • wordpress.php — a [cablecast_live_events] WordPress shortcode
  • iframe-embed.html — no-code embed of the Internet Channel show page
  • showcase-events/README.md + a section in the top-level README.md

Validation

  • node --check on the ESM helper; behavior test across all status branches (server field + reserved values + start-time edges)
  • php -l clean on wordpress.php

🤖 Generated with Claude Code

raytiley and others added 3 commits August 24, 2026 13:13
Building a live-events feature (what's live now / coming up listings and
players) on a third-party site. Everything reads live and upcoming events
from GET /cablecastapi/publicsitedata (showcaseEventShows) — the one showcase
feed available on both self-hosted Cablecast and Reflect+ hosted channels.

- event-status.mjs: status helper mirroring the Internet Channel's
  getEventStatus (live / starting_soon / upcoming / vod), incl. the
  LiveBridge "wait for active" nuance
- browser-player.html: fetch, poll every 15s, mount an HLS player when live
- wordpress.php: [cablecast_live_events] shortcode
- iframe-embed.html: no-code embed of the show page
- README for the folder + a section in the top-level README

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
publicsitedata now carries an authoritative showcaseEventStatus on each event
("live" | "upcoming" | "vod", an open enum with "canceled"/"error" reserved).
Read it instead of re-deriving status from isLive/scheduleStartTime/liveBridgeEventStatus.

- event-status.mjs: getEventStatus prefers showcaseEventStatus and adds only the
  client-side "starting soon" refinement; deriveEventStatus stays as a fallback
  for older servers. Unknown/reserved values are treated as not-live.
- wordpress.php: same preference + fallback (cablecast_derive_event_status).
- README: documents showcaseEventStatus as the field to read, the open-enum
  contract, and the reserved values.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…rror

These examples only ever run over showcaseEventShows entries, which always carry
showcaseEventStatus, and showcase events haven't shipped — so there is no older
server to derive for. Remove the dead deriveEventStatus / cablecast_derive_event_status
paths; getEventStatus now just reads the field and adds the starting_soon refinement.

Document what the reserved values will mean once emitted: canceled (event called
off, will not air) and error (failed to stream) — both terminal not-live states
with nothing to play; stop polling and hide or show an unavailable note.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new showcase-events/ example set demonstrating how to build “what’s live now / coming up” listings and simple players by consuming GET /cablecastapi/publicsitedata (showcaseEventShows) for Internet Channel / Reflect+ compatible integrations.

Changes:

  • Added a shared event-status helper (event-status.mjs) and accompanying documentation for interpreting showcaseEventStatus.
  • Added a minimal browser-based polling player (browser-player.html) and a no-code iframe embed example (iframe-embed.html).
  • Added a WordPress shortcode example (wordpress.php) plus repo-level README linkage.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
showcase-events/event-status.mjs New JS helper for mapping showcaseEventStatus into UI-friendly statuses.
showcase-events/browser-player.html New browser example that polls publicsitedata and mounts an HLS player for live events.
showcase-events/wordpress.php New WordPress shortcode example for listing live/upcoming events and rendering a placeholder player mount point.
showcase-events/README.md New documentation describing the feed and status semantics.
showcase-events/iframe-embed.html New iframe-based embed option for delegating playback lifecycle to the hosted Internet Channel page.
README.md Adds a top-level pointer to the new showcase-events/ examples.
Suppressed comments (2)

showcase-events/wordpress.php:107

  • $host is derived by stripping only a trailing /cablecastapi, but the header comment explicitly supports Reflect+ where the base path is /api. With CABLECAST_API ending in /api, thumbnail URLs will be prefixed incorrectly.
	// thumbnailUrl is a path relative to the Cablecast host.
	$host = preg_replace( '#/cablecastapi$#', '', CABLECAST_API );
	$out  = '<ul class="cablecast-events">';

showcase-events/wordpress.php:113

  • strtotime($show['scheduleStartTime']) is used without checking the field exists or parses. If a feed entry lacks scheduleStartTime (or it’s invalid), this will display the Unix epoch or emit notices instead of a reasonable fallback.
	foreach ( array_merge( $live, $upcoming ) as $show ) {
		$is_live = ! empty( $show['isLive'] ) && cablecast_event_status( $show ) === 'live';
		$when    = $is_live
			? 'Live now'
			: 'Starts ' . date_i18n( 'M j, g:i a', strtotime( $show['scheduleStartTime'] ) );

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread showcase-events/event-status.mjs
Comment thread showcase-events/wordpress.php Outdated
Comment thread showcase-events/browser-player.html Outdated
- wordpress.php: guard the define()s so pasting into functions.php twice does not
  warn; strip either /cablecastapi or /api from the host for thumbnails (Reflect+
  uses /api); guard strtotime against a missing/invalid scheduleStartTime.
- event-status.mjs / wordpress.php: bound the "starting soon" refinement on the
  past side so a far-past "upcoming" is not shown as starting-soon forever.
- browser-player.html: guard the upcoming sort against missing/invalid
  scheduleStartTime so it never compares NaN or renders "Invalid Date".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (3)

Previously missed (3) — in code that hasn't changed since the last review.

showcase-events/wordpress.php:131

  • $is_live is gated on isLive even though the rest of the shortcode treats showcaseEventStatus as the source of truth. If isLive is missing/falsey for a live event, the item will be classified as live earlier but rendered as not-live here (no player, wrong label). This also recomputes cablecast_event_status() for every row.
	foreach ( array_merge( $live, $upcoming ) as $show ) {
		$is_live = ! empty( $show['isLive'] ) && cablecast_event_status( $show ) === 'live';
		// scheduleStartTime can be missing or unparseable; guard so a bad entry does not

showcase-events/wordpress.php:141

  • Accessing $show['title'] without an isset/?? guard can emit a PHP notice if an entry is missing that field. Other fields in this loop are already guarded, so this one should be too.
			'<strong>%s</strong> <span>%s</span>',
			esc_html( $show['title'] ),
			esc_html( $when )

showcase-events/wordpress.php:89

  • On a non-200 / WP error response, the function returns an empty array but does not set the transient. Under API outages this defeats the stated goal of preventing request bursts, because every page view will immediately retry the upstream request.
	if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
		// Non-200 means the feed could not be read; fail soft so the page renders.
		return array();
	}

… isLive

The shortcode now tags each row live/not-live from the bucket cablecast_event_status
sorted it into, instead of re-deriving it (and gating on isLive) in the render loop.
showcaseEventStatus stays the single source of truth, and a live event renders live
even if isLive is absent; also drops the redundant per-row status recompute.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (3)

Previously missed (3) — in code that hasn't changed since the last review.

showcase-events/wordpress.php:89

  • The transient cache is only populated on successful responses. If the API is down or returns non-200, every page view will still call the API, which contradicts the comment about preventing burst traffic from becoming a burst of API calls. Consider caching the empty result for the same 15s window on failures too.
	if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
		// Non-200 means the feed could not be read; fail soft so the page renders.
		return array();
	}

showcase-events/wordpress.php:121

  • $host stripping will fail if CABLECAST_API is configured with a trailing slash (e.g. ".../cablecastapi/"). In that case the API path is not removed and thumbnail URLs will be prefixed incorrectly. Normalizing with rtrim before the regex makes this robust.
	$host = preg_replace( '#/(cablecastapi|api)$#', '', CABLECAST_API );

showcase-events/browser-player.html:25

  • This example pulls video.js from a third-party CDN without Subresource Integrity (SRI). For production deployments, it’s safer to self-host the assets or add integrity/crossorigin attributes to reduce supply-chain risk.
    <link href="https://vjs.zencdn.net/8.10.0/video-js.css" rel="stylesheet" />
    <script src="https://vjs.zencdn.net/8.10.0/video.min.js"></script>

…note

- wordpress.php: cache the empty result for 15s on a failed/non-200 fetch so an
  API outage does not turn every page view into another call; rtrim the base URL
  before stripping so a configured trailing slash still resolves the host.
- browser-player.html: note that the video.js CDN tags should be self-hosted or
  given Subresource Integrity for production use.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

showcase-events/wordpress.php:156

  • The shortcode output assumes every entry has a title key ($show['title']). If the API payload is missing that field for any reason, PHP will emit an "Undefined index" notice. Use a null-coalescing fallback before escaping to keep the example notice-free.
			'<strong>%s</strong> <span>%s</span>',
			esc_html( $show['title'] ),
			esc_html( $when )

Comment thread showcase-events/wordpress.php
rtrim CABLECAST_API before building the publicsitedata fetch URL, matching the
thumbnail host derivation, so a configured trailing slash doesn't produce a
double slash in the request path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants