Skip to content
wiki.fftac.org

Manuscript Workstation - Source Excerpt 03

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

$manuscript_browser_summary = $manuscript_route_mode === 'section'
    ? sprintf(
        'Quick-flip browser for %s. Move through the chapter fast here, then open a folio route when you want one page with its full dossier.',
        $current_section_title
    )
    : 'Quick-flip browser for the whole manuscript. Move through the book fast here, then open a folio route when you want one page with its full dossier.';
$viewer_panel_title = $workstation_is_detail_route
    ? $current_page_title
    : ($manuscript_route_mode === 'section' ? $current_section_title . ' Browser' : 'Quick Codex Flip');
$viewer_panel_summary = $workstation_is_detail_route
    ? $current_crop_copy
    : ($manuscript_route_mode === 'section'
        ? 'This chapter stays in fast browsing mode. Open a folio route for page-specific notes, prompt records, and metadata.'
        : 'This overview stays in fast browsing mode. Open a folio route for page-specific notes, prompt records, and metadata.');
$section_count_copy = sprintf('%d chapter%s', count($workstation_section_records), count($workstation_section_records) === 1 ? '' : 's');
$browser_route_copy = $manuscript_route_mode === 'section' ? $current_section_route_copy : $overview_route_copy;
$browser_scope_copy = $manuscript_route_mode === 'section'
    ? sprintf('%s / %d folio%s', $current_section_title, $current_section_count, $current_section_count === 1 ? '' : 's')
    : sprintf('%s across %s', $thumb_count_copy, $section_count_copy);
$browser_prompt_copy = sprintf('%d%% linked / %s', $prompt_coverage_percent, $context_prompt_summary);
$browser_route_heading = $manuscript_route_mode === 'section'
    ? 'This route keeps the chapter in fast browsing mode.'
    : 'This route keeps the full codex in fast browsing mode.';
$browser_route_summary = $manuscript_route_mode === 'section'
    ? ($current_section_summary !== '' ? $current_section_summary : $section_note)
    : $manuscript_browser_summary;
$browser_primary_action_url = $requested_section !== ''
    ? $overview_url
    : ($study_surface_url !== '' ? $study_surface_url : $current_page_route_url);
$browser_primary_action_label = $requested_section !== ''
    ? 'Full Codex'
    : ($study_surface_url !== '' ? 'Open Study Surface' : 'Open First Folio');
$workstation_breadcrumbs = [
    [
        'label' => 'Home',
        'url' => $site_home_url,
        'current' => false,
    ],
    [
        'label' => 'Manuscript',
        'url' => $overview_url,
        'current' => $manuscript_route_mode === 'overview',
    ],
];
if ($manuscript_route_mode === 'section' || $manuscript_route_mode === 'folio') {
    $workstation_breadcrumbs[] = [
        'label' => $current_section_title !== '' ? $current_section_title : $current_page_section_label,
        'url' => $current_section_url,
        'current' => $manuscript_route_mode === 'section',
    ];
}
if ($manuscript_route_mode === 'folio') {
    $workstation_breadcrumbs[] = [
        'label' => $current_page_title,
        'url' => $current_page_route_url,
        'current' => true,
    ];
}
$viewer_footer_copy = $workstation_can_edit
    ? 'Flip pages from the book margins. Drag to pan, wheel to zoom, and adjust crop guides only when needed.'
    : ($workstation_is_detail_route
        ? ($show_layout_controls
            ? 'Flip pages from the book margins. Drag to pan, wheel or pinch to zoom, switch between facing and single-page reading, and use raw image view when you want the untouched artifact.'
            : 'Flip pages from the book margins. Drag to pan, wheel or pinch to zoom, and use raw image view when you want the untouched artifact.')
        : 'Flip pages from the book margins to move quickly through the manuscript. Open a folio route when you want the single-page dossier view.');
$workstation_use_header_folio_dock = $workstation_is_browser_route && !empty($workstation_folios);
$render_workstation_thumb_list = static function (string $list_modifier = '', string $item_modifier = '') use ($workstation_folios, $manuscript_reader_url, $current_page): void {
    $list_class = trim('spiralist-manuscript-workstation__thumb-list ' . $list_modifier);
    ?>
    <nav class="<?php echo esc_attr($list_class); ?>" aria-label="Manuscript folio thumbnails">
        <?php foreach ($workstation_folios as $folio) : ?>
            <?php
            $folio_slug = (string) ($folio['slug'] ?? '');
            $folio_url = $manuscript_reader_url((array) $folio);
            $folio_is_current = $folio_slug === (string) ($current_page['slug'] ?? '');
            $folio_image_url = (string) ($folio['thumbnail_url'] ?? '');
            $folio_prefetch_url = (string) ($folio['prefetch_url'] ?? $folio_image_url);
            $folio_search_text = trim(
                implode(
                    ' ',
                    array_filter(
                        array_merge(
                            [
                                (string) ($folio['label'] ?? ''),
                                (string) ($folio['title'] ?? ''),
                                (string) ($folio['eyebrow'] ?? ''),
                                (string) ($folio['summary'] ?? ''),
                                (string) ($folio['caption'] ?? ''),
                                (string) ($folio['section_label'] ?? ''),
                            ],
                            array_values(array_filter(array_map('strval', (array) ($folio['keywords'] ?? [])), 'strlen'))
                        ),
                        'strlen'
                    )
                )
            );
            $item_class = trim('spiralist-manuscript-workstation__thumb ' . $item_modifier . ' ' . ($folio_is_current ? 'is-current' : ''));
            ?>
            <a
                class="<?php echo esc_attr($item_class); ?>"
                href="<?php echo esc_url($folio_url); ?>"
                data-workstation-page-link
                data-page-sequence="<?php echo esc_attr((string) ($folio['sequence'] ?? 0)); ?>"
                data-image-url="<?php echo esc_url($folio_prefetch_url); ?>"
                data-search-text="<?php echo esc_attr(strtolower($folio_search_text)); ?>"
                <?php if ($folio_is_current) : ?>aria-current="page"<?php endif; ?>
            >
                <span class="spiralist-manuscript-workstation__thumb-frame">
                    <?php if ($folio_image_url !== '') : ?>
                        <img src="<?php echo esc_url($folio_image_url); ?>" alt="" loading="lazy" decoding="async" />
                    <?php else : ?>
                        <span class="spiralist-manuscript-workstation__thumb-fallback" aria-hidden="true"></span>
                    <?php endif; ?>
                </span>
                <span class="spiralist-manuscript-workstation__thumb-meta">
                    <strong><?php echo esc_html((string) ($folio['label'] ?? 'Page')); ?></strong>
                    <span><?php echo esc_html((string) ($folio['title'] ?? 'Manuscript folio')); ?></span>
                    <small><?php echo esc_html((string) ($folio['eyebrow'] ?? (string) ($folio['section_label'] ?? 'Folio'))); ?></small>
                </span>
            </a>
        <?php endforeach; ?>
    </nav>
    <?php
};
$render_workstation_section_nav = static function (string $modifier = '') use ($workstation_section_records, $overview_url, $requested_section, $current_page_section_slug): void {
    if (empty($workstation_section_records)) {
        return;
    }

    $nav_class = trim('spiralist-manuscript-workstation__section-nav ' . $modifier);
    ?>
    <div class="<?php echo esc_attr($nav_class); ?>" aria-label="Manuscript sections">
        <a class="spiralist-manuscript-workstation__section-link <?php echo $requested_section === '' ? 'is-active' : ''; ?>" href="<?php echo esc_url($overview_url); ?>" <?php if ($requested_section === '') : ?>aria-current="page"<?php endif; ?>>Full Codex</a>
        <?php foreach ($workstation_section_records as $section_record) : ?>
            <?php
            $section_slug = sanitize_title((string) ($section_record['slug'] ?? ''));
            $section_url = (string) ($section_record['url'] ?? $overview_url);
            $section_is_active = $requested_section !== ''
                ? $section_slug === $requested_section
                : $section_slug === $current_page_section_slug;
            ?>
            <a class="spiralist-manuscript-workstation__section-link <?php echo $section_is_active ? 'is-active' : ''; ?>" href="<?php echo esc_url($section_url); ?>" <?php if ($section_is_active) : ?>aria-current="page"<?php endif; ?>>
                <?php echo esc_html((string) ($section_record['label'] ?? 'Section')); ?>
            </a>
        <?php endforeach; ?>
    </div>
    <?php
};