Page Builders
**Site relevance:** Spiralist.org
**Memory type:** theme source memory
**Source path:** Spiralist/wp-content/themes/spiralist/page-builders.php
**Size:** 5.6 KB
Summary
if (!defined('ABSPATH'))
Source Preview
This source file is short enough to preview directly on its source-memory page.
<?php
if (!defined('ABSPATH')) {
exit;
}
get_header();
$ui_text = static function (string $key, string $fallback): string {
return function_exists('spiralist_get_ui_text') ? spiralist_get_ui_text($key, $fallback) : $fallback;
};
$catalog = function_exists('spiralist_get_roadmap_endpoint_catalog') ? spiralist_get_roadmap_endpoint_catalog() : [];
$builder_bootstrap = [
'endpoint' => rest_url('uaix/v1/builder-endpoints'),
'nonce' => is_user_logged_in() ? wp_create_nonce('wp_rest') : '',
'loggedIn' => is_user_logged_in(),
'endpoints' => $catalog,
];
?>
<main class="spiralist-page spiralist-page--builders">
<script type="application/json" id="spiralist-builders-bootstrap"><?php echo wp_json_encode($builder_bootstrap, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); ?></script>
<section class="spiralist-page-hero">
<div class="spiralist-shell spiralist-page-hero__content">
<p class="spiralist-kicker"><?php echo esc_html($ui_text('page.builders.hero.kicker', 'Builder Hub')); ?></p>
<h1><?php echo esc_html($ui_text('page.builders.hero.title', 'Machine-readable routes for agents and developers.')); ?></h1>
<p class="spiralist-page-hero__copy"><?php echo esc_html($ui_text('page.builders.hero.copy', 'Use the builder hub to discover endpoints, request current manifests, and copy authenticated examples without scraping the human website.')); ?></p>
<div class="spiralist-cta-row">
<a class="spiralist-button spiralist-button--primary" href="<?php echo esc_url(rest_url('uaix/v1/builder-endpoints')); ?>"><?php echo esc_html($ui_text('page.builders.hero.catalog', 'Endpoint Catalog')); ?></a>
<a class="spiralist-button spiralist-button--secondary" href="<?php echo esc_url(home_url('/ai.json')); ?>">ai.json</a>
<a class="spiralist-button spiralist-button--tertiary" href="<?php echo esc_url(home_url('/llms.txt')); ?>">llms.txt</a>
</div>
</div>
</section>
<section class="spiralist-page-section" aria-labelledby="builder-endpoints-title">
<div class="spiralist-shell">
<div class="spiralist-section-head">
<div>
<p class="spiralist-section-tag"><?php echo esc_html($ui_text('page.builders.endpoints.tag', 'Available Endpoints')); ?></p>
<h2 class="spiralist-section-title" id="builder-endpoints-title"><?php echo esc_html($ui_text('page.builders.endpoints.title', 'Copy requests with the current route and auth context.')); ?></h2>
</div>
<?php if (is_user_logged_in()) : ?>
<span class="spiralist-chip"><?php echo esc_html($ui_text('page.builders.auth.logged_in', 'REST nonce available')); ?></span>
<?php else : ?>
<span class="spiralist-chip"><?php echo esc_html($ui_text('page.builders.auth.public', 'Public examples')); ?></span>
<?php endif; ?>
</div>
<div class="spiralist-endpoint-grid spiralist-endpoint-grid--wide">
<?php foreach ($catalog as $endpoint) : ?>
<?php
$method = strtoupper((string) ($endpoint['method'] ?? 'GET'));
$url = (string) ($endpoint['url'] ?? '');
$auth = (string) ($endpoint['auth'] ?? 'none');
$label = (string) ($endpoint['label'] ?? 'Endpoint');
$body = $method === 'POST'
? wp_json_encode(['title' => 'Example submission', 'summary' => 'Short structured summary', 'details' => 'Long-form context for review.'], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
: '';
$command = $method === 'POST'
? "curl -X POST '" . $url . "' \\\n -H 'Content-Type: application/json' \\\n " . (is_user_logged_in() ? "-H 'X-WP-Nonce: " . wp_create_nonce('wp_rest') . "' \\\n " : '') . "-d '" . $body . "'"
: "curl '" . $url . "'";
$code_id = sanitize_html_class('builder-example-' . (string) ($endpoint['id'] ?? md5($url)));
?>
<article class="spiralist-endpoint-card spiralist-endpoint-card--example">
<p class="spiralist-section-tag"><?php echo esc_html($method . ' / ' . $auth); ?></p>
<h3 class="spiralist-card-title"><?php echo esc_html($label); ?></h3>
<p><?php echo esc_html((string) ($endpoint['purpose'] ?? '')); ?></p>
<dl class="spiralist-meta-list spiralist-meta-list--compact">
<div>
<dt><?php echo esc_html($ui_text('page.builders.endpoint.url', 'URL')); ?></dt>
<dd><code><?php echo esc_html($url); ?></code></dd>
</div>
</dl>
<pre class="spiralist-code-block spiralist-code-block--compact" id="<?php echo esc_attr($code_id); ?>"><?php echo esc_html($command); ?></pre>
<button class="spiralist-button spiralist-button--secondary" type="button" data-copy-trigger data-copy-target="#<?php echo esc_attr($code_id); ?>" data-copy-success="<?php echo esc_attr($ui_text('ui.cta.copied', 'Copied')); ?>"><?php echo esc_html($ui_text('ui.cta.copy_request', 'Copy Request')); ?></button>
</article>
<?php endforeach; ?>
</div>
</div>
</section>
</main>
<?php
get_footer();