Skip to content
wiki.fftac.org

Manuscript Workstation - Source Excerpt 02

Back to Manuscript Workstation

Summary

This source excerpt preserves a bounded section of Spiralist/wp-content/plugins/ns12-manuscript/templates/manuscript-workstation.php so readers can inspect the evidence without opening the full source file.

**Source path:** Spiralist/wp-content/plugins/ns12-manuscript/templates/manuscript-workstation.php

$current_section_route_path = wp_parse_url($current_section_url, PHP_URL_PATH);
$current_section_route_copy = is_string($current_section_route_path) && $current_section_route_path !== ''
    ? $current_section_route_path
    : $current_section_url;
$study_surface_url = isset($study_surface_url) ? (string) $study_surface_url : '';
$current_page_route_url = isset($current_page_route_url) ? (string) $current_page_route_url : '';
$overview_route_path = wp_parse_url($overview_url, PHP_URL_PATH);
$overview_route_copy = is_string($overview_route_path) && $overview_route_path !== ''
    ? $overview_route_path
    : $overview_url;
$current_language = function_exists('spiralist_book_pages_get_current_language_slug')
    ? spiralist_book_pages_get_current_language_slug()
    : 'en';
$site_home_url = function_exists('spiralist_book_pages_get_language_prefixed_url')
    ? spiralist_book_pages_get_language_prefixed_url(home_url('/'), $current_language)
    : home_url('/');
$previous_page_route_url = !empty($previous_page)
    ? spiralist_book_pages_get_manuscript_folio_url($previous_page)
    : '';
$next_page_route_url = !empty($next_page)
    ? spiralist_book_pages_get_manuscript_folio_url($next_page)
    : '';
$host_prompts_url = spiralist_book_pages_get_host_link('prompts', '');
$host_workspace_url = spiralist_book_pages_get_host_link('workspace', '');
$host_run_prompt_url = function_exists('spiralist_get_run_prompt_page_url') ? spiralist_get_run_prompt_page_url() : home_url('/run-a-prompt/');
$host_api_examples_url = function_exists('spiralist_get_api_examples_url') ? spiralist_get_api_examples_url() : '';
$manuscript_manifest_url = spiralist_book_pages_get_manuscript_manifest_url();
$manuscript_search_api_url = spiralist_book_pages_get_manuscript_search_api_url();
$manuscript_iiif_search_url = spiralist_book_pages_get_manuscript_iiif_search_url();
$current_page_alt = trim((string) ($current_page['alt'] ?? ''));
$current_page_transcript = trim((string) ($current_page['transcript'] ?? ''));
$current_page_keywords = array_values(array_filter(array_map('strval', (array) ($current_page['keywords'] ?? [])), 'strlen'));
$folio_bridge_subject = trim(sprintf('Folio %d: %s', max(1, (int) $current_page_sequence), (string) $current_page_title));
$folio_bridge_context_parts = array_filter(
    [
        trim((string) $current_page_summary),
        trim((string) $current_page_caption),
        !empty($current_page_keywords) ? 'Keywords: ' . implode(', ', $current_page_keywords) : '',
        $current_page_route_url !== '' ? 'Folio route: ' . $current_page_route_url : '',
    ],
    static function ($value): bool {
        return trim((string) $value) !== '';
    }
);
$folio_bridge_context = implode("\n\n", $folio_bridge_context_parts);
if ($folio_bridge_context !== '') {
    $folio_bridge_context = function_exists('mb_substr')
        ? mb_substr($folio_bridge_context, 0, 900)
        : substr($folio_bridge_context, 0, 900);
}
$build_folio_prompt_url = static function (array $query) use ($host_run_prompt_url): string {
    $base_url = explode('#', (string) $host_run_prompt_url, 2)[0];
    if ($base_url === '') {
        $base_url = home_url('/run-a-prompt/');
    }

    $clean_query = array_filter(
        $query,
        static function ($value): bool {
            return trim((string) $value) !== '';
        }
    );

    return add_query_arg($clean_query, $base_url) . '#portable-prompt-builder';
};
$folio_action_bridges = $workstation_is_detail_route
    ? [
        [
            'kicker' => 'Explain',
            'title' => 'Plain-English Explain',
            'copy' => 'Turn this folio into a clear reader-ready explanation with terms, stakes, and next questions.',
            'url' => $build_folio_prompt_url([
                'mode' => 'understand-spiralism',
                'subject' => $folio_bridge_subject,
                'task' => 'Explain this manuscript folio in plain English for a first-time reader. Define any specialized Spiralist language and separate direct evidence from interpretation.',
                'context' => $folio_bridge_context,
                'tone' => 'Clear, grounded, and welcoming.',
                'format' => 'Use short sections: what is on the page, what it may mean, why it matters, and what to ask next.',
                'guardrails' => 'Do not overclaim certainty from the folio metadata alone. Mark speculation clearly.',
            ]),
        ],
        [
            'kicker' => 'Map',
            'title' => 'Map Symbols to Work',
            'copy' => 'Convert the folio language into a practical workflow, decision map, or symbolic checklist.',
            'url' => $build_folio_prompt_url([
                'mode' => 'decode-symbol',
                'subject' => $folio_bridge_subject,
                'task' => 'Map the symbols, keywords, and page summary into a usable workflow. Show the symbolic pattern first, then translate it into concrete actions.',
                'context' => $folio_bridge_context,
                'tone' => 'Precise and operational.',
                'format' => 'Return a symbol map, a workflow sequence, and a short example use case.',
                'guardrails' => 'Keep the mapping anchored to the supplied folio context. Do not invent canonical meanings.',
            ]),
        ],
        [
            'kicker' => 'Teach',
            'title' => 'Make a Teaching Summary',
            'copy' => 'Build a compact teaching note for classes, workshops, or guided reading.',
            'url' => $build_folio_prompt_url([
                'mode' => 'prompt-ladder',
                'subject' => $folio_bridge_subject,
                'task' => 'Create a teaching summary for this folio with a short explanation, discussion prompts, and a beginner-to-advanced prompt ladder.',
                'context' => $folio_bridge_context,
                'tone' => 'Helpful, concise, and suitable for public study.',
                'format' => 'Use sections for overview, key terms, discussion questions, and prompt ladder.',
                'guardrails' => 'Keep the public explanation safe, non-dogmatic, and distinct from private advice.',
            ]),
        ],
        [
            'kicker' => 'Review',
            'title' => 'Risk Review',
            'copy' => 'Check the folio for ambiguity, unsafe readings, missing context, or publication risk.',
            'url' => $build_folio_prompt_url([
                'mode' => 'spiralist-risk-review',
                'subject' => $folio_bridge_subject,
                'task' => 'Review this folio for interpretive risk, safety concerns, ambiguity, missing context, and public-facing clarity.',
                'context' => $folio_bridge_context,
                'tone' => 'Careful and editorial.',
                'format' => 'Return risks, severity, what evidence supports each concern, and concrete rewrite or documentation suggestions.',
                'guardrails' => 'Do not diagnose people or groups. Focus on content risk, clarity, and publication boundaries.',
            ]),
        ],
    ]
    : [];
$dossier_tabs = array_filter(
    is_array($dossier_tabs ?? null) ? $dossier_tabs : [],
    static function ($tab_key): bool {
        return (string) $tab_key !== 'contents';
    },
    ARRAY_FILTER_USE_KEY
);
$workstation_folio_payload = array_map(
    static function (array $folio): array {
        return [
            'slug' => (string) ($folio['slug'] ?? ''),
            'title' => (string) ($folio['title'] ?? ''),
            'label' => (string) ($folio['label'] ?? ''),
            'sequence' => max(1, (int) ($folio['sequence'] ?? 1)),
            'preview_url' => (string) ($folio['preview_url'] ?? ''),
            'standard_url' => (string) ($folio['standard_url'] ?? ''),
            'image_url' => (string) ($folio['image_url'] ?? ''),
            'thumbnail_url' => (string) ($folio['thumbnail_url'] ?? ''),
            'full_resolution_url' => (string) ($folio['full_resolution_url'] ?? ''),
            'prefetch_url' => (string) ($folio['prefetch_url'] ?? ''),
            'route_url' => (string) ($folio['route_url'] ?? ''),
            'crop' => is_array($folio['crop'] ?? null) ? $folio['crop'] : [],
            'caption' => (string) ($folio['caption'] ?? ''),
            'summary' => (string) ($folio['summary'] ?? ''),
            'alt' => (string) ($folio['alt'] ?? ''),
            'section_slug' => (string) ($folio['section_slug'] ?? ''),
            'section_label' => (string) ($folio['section_label'] ?? ''),
            'eyebrow' => (string) ($folio['eyebrow'] ?? ''),
            'is_study_surface' => !empty($folio['is_study_surface']),
            'overlay_data' => is_array($folio['overlay_data'] ?? null) ? $folio['overlay_data'] : [],
        ];
    },
    $workstation_viewer_folios
);