1
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
2
<section class="yougitai-showcase" data-yougitai-showcase data-theme="<?php echo esc_attr( $theme ); ?>">
3
<header class="yougitai-header">
4
<div>
5
<div class="yougitai-repo-path"><?php echo esc_html( $repository['owner'] ); ?> / <strong><?php echo esc_html( $repository['repo'] ); ?></strong></div>
6
<?php if ( $repository['description'] ) : ?><p><?php echo esc_html( $repository['description'] ); ?></p><?php endif; ?>
7
</div>
8
<span class="yougitai-badge"><?php esc_html_e( 'Verified secure showcase', 'yougitai-secure-showcase' ); ?></span>
9
</header>
10
11
<nav class="yougitai-tabs" aria-label="<?php esc_attr_e( 'Showcase sections', 'yougitai-secure-showcase' ); ?>">
12
<a href="#yougitai-overview"><?php esc_html_e( 'Overview', 'yougitai-secure-showcase' ); ?></a>
13
<a href="#yougitai-code"><?php esc_html_e( 'Code', 'yougitai-secure-showcase' ); ?></a>
14
<a href="#yougitai-architecture"><?php esc_html_e( 'Architecture', 'yougitai-secure-showcase' ); ?></a>
15
<a href="#yougitai-stack"><?php esc_html_e( 'Tech stack', 'yougitai-secure-showcase' ); ?></a>
16
</nav>
17
18
<div class="yougitai-stats" aria-label="<?php esc_attr_e( 'Repository statistics', 'yougitai-secure-showcase' ); ?>">
19
<span><strong><?php echo esc_html( number_format_i18n( $stats['files'] ) ); ?></strong> <?php esc_html_e( 'Files', 'yougitai-secure-showcase' ); ?></span>
20
<span><strong><?php echo esc_html( size_format( $stats['size'] ) ); ?></strong> <?php esc_html_e( 'Public size', 'yougitai-secure-showcase' ); ?></span>
21
<span><strong><?php echo esc_html( number_format_i18n( $stats['redacted'] ) ); ?></strong> <?php esc_html_e( 'Redacted', 'yougitai-secure-showcase' ); ?></span>
22
<?php if ( $stats['languages'] ) : ?><span class="yougitai-languages"><?php echo esc_html( implode( ' · ', array_keys( $stats['languages'] ) ) ); ?></span><?php endif; ?>
23
</div>
24
25
<section id="yougitai-overview" class="yougitai-overview yougitai-section">
26
<div class="yougitai-overview-main">
27
<h2><?php esc_html_e( 'Project overview', 'yougitai-secure-showcase' ); ?></h2>
28
<p class="yougitai-lead"><?php echo esc_html( (string) ( $profile['summary'] ?? $repository['description'] ) ); ?></p>
29
<?php if ( $readme && ! empty( $readme['content'] ) ) : ?>
30
<div class="yougitai-readme">
31
<h3><?php esc_html_e( 'README', 'yougitai-secure-showcase' ); ?></h3>
32
<pre><?php echo esc_html( mb_substr( (string) $readme['content'], 0, 12000 ) ); ?></pre>
33
</div>
34
<?php endif; ?>
35
</div>
36
<aside class="yougitai-overview-side">
37
<h3><?php esc_html_e( 'At a glance', 'yougitai-secure-showcase' ); ?></h3>
38
<dl>
39
<div><dt><?php esc_html_e( 'Branch', 'yougitai-secure-showcase' ); ?></dt><dd><?php echo esc_html( $repository['default_branch'] ); ?></dd></div>
40
<div><dt><?php esc_html_e( 'Modules', 'yougitai-secure-showcase' ); ?></dt><dd><?php echo esc_html( number_format_i18n( count( $profile['modules'] ?? [] ) ) ); ?></dd></div>
41
<div><dt><?php esc_html_e( 'Protected files', 'yougitai-secure-showcase' ); ?></dt><dd><?php echo esc_html( number_format_i18n( (int) ( $profile['redacted'] ?? 0 ) ) ); ?></dd></div>
42
</dl>
43
<?php if ( ! empty( $profile['modules'] ) ) : ?><div class="yougitai-chips"><?php foreach ( $profile['modules'] as $module ) : ?><span><?php echo esc_html( $module ); ?></span><?php endforeach; ?></div><?php endif; ?>
44
</aside>
45
</section>
46
47
<section id="yougitai-code" class="yougitai-section yougitai-code-section">
48
<div class="yougitai-grid">
49
<aside class="yougitai-tree">
50
<h3><?php esc_html_e( 'Repository browser', 'yougitai-secure-showcase' ); ?></h3>
51
<?php if ( ! $files ) : ?><p><?php esc_html_e( 'No public files are available.', 'yougitai-secure-showcase' ); ?></p><?php endif; ?>
52
<?php
53
$tree_summary = static function ( array $nodes ) use ( &$tree_summary ): array {
54
$total = 0;
55
$protected = 0;
56
foreach ( $nodes['__files'] ?? [] as $node_file ) {
57
$total++;
58
if ( (string) ( $node_file['visibility'] ?? '' ) === 'hidden' ) $protected++;
59
}
60
foreach ( $nodes as $key => $children ) {
61
if ( $key === '__files' || ! is_array( $children ) ) continue;
62
$child_summary = $tree_summary( $children );
63
$total += $child_summary['total'];
64
$protected += $child_summary['protected'];
65
}
66
return [ 'total' => $total, 'protected' => $protected ];
67
};
68
$render_tree = static function ( array $nodes, string $prefix = '' ) use ( &$render_tree, $tree_summary, $selected ): void {
69
$files_here = $nodes['__files'] ?? [];
70
unset( $nodes['__files'] );
71
ksort( $nodes, SORT_NATURAL | SORT_FLAG_CASE );
72
if ( $nodes ) {
73
foreach ( $nodes as $name => $children ) {
74
$folder_path = ltrim( $prefix . '/' . $name, '/' );
75
$contains_selected = $selected && str_starts_with( (string) $selected['path'], $folder_path . '/' );
76
$folder_summary = $tree_summary( $children );
77
$folder_fully_protected = $folder_summary['total'] > 0 && $folder_summary['protected'] === $folder_summary['total'];
78
$folder_partially_protected = $folder_summary['protected'] > 0 && ! $folder_fully_protected;
79
$folder_class = $folder_fully_protected ? ' is-protected' : ( $folder_partially_protected ? ' is-partially-protected' : '' );
80
echo '<li class="yougitai-folder' . ( $contains_selected ? ' is-open' : '' ) . $folder_class . '">';
81
echo '<button type="button" class="yougitai-folder-toggle" aria-expanded="' . ( $contains_selected ? 'true' : 'false' ) . '"><span class="yougitai-chevron" aria-hidden="true">›</span><span class="yougitai-folder-icon" aria-hidden="true">📁</span><span>' . esc_html( $name ) . '</span>';
82
if ( $folder_fully_protected ) {
83
echo '<span class="yougitai-protected-indicator" title="' . esc_attr__( 'Protected folder', 'yougitai-secure-showcase' ) . '" aria-label="' . esc_attr__( 'Protected folder', 'yougitai-secure-showcase' ) . '">🔒</span>';
84
} elseif ( $folder_partially_protected ) {
85
echo '<span class="yougitai-protected-indicator is-partial" title="' . esc_attr__( 'Contains protected files', 'yougitai-secure-showcase' ) . '" aria-label="' . esc_attr__( 'Contains protected files', 'yougitai-secure-showcase' ) . '">🛡️</span>';
86
}
87
echo '</button>';
88
echo '<ul class="yougitai-folder-children">';
89
$render_tree( $children, $folder_path );
90
echo '</ul></li>';
91
}
92
}
93
usort( $files_here, static fn( array $a, array $b ): int => strnatcasecmp( (string) $a['filename'], (string) $b['filename'] ) );
94
foreach ( $files_here as $file ) {
95
$active = $selected && (int) $selected['id'] === (int) $file['id'];
96
echo '<li class="yougitai-file">';
97
echo '<a' . ( $active ? ' class="is-active" aria-current="true"' : '' ) . ' href="' . esc_url( add_query_arg( 'yga_file', (int) $file['id'] ) . '#yougitai-code' ) . '">';
98
$file_protected = (string) ( $file['visibility'] ?? '' ) === 'hidden';
99
echo '<span class="yougitai-file-icon" aria-hidden="true">' . ( $file_protected ? '🔒' : '📄' ) . '</span><span class="yougitai-file-name">' . esc_html( $file['filename'] ) . '</span>';
100
if ( $file_protected ) {
101
echo '<span class="yougitai-protected-label">' . esc_html__( 'Protected', 'yougitai-secure-showcase' ) . '</span>';
102
} elseif ( (int) ( $file['redaction_count'] ?? 0 ) > 0 ) {
103
$redaction_count = (int) $file['redaction_count'];
104
$redaction_label = sprintf(
105
_n( '%s redaction', '%s redactions', $redaction_count, 'yougitai-secure-showcase' ),
106
number_format_i18n( $redaction_count )
107
);
108
echo '<span class="yougitai-redaction-badge" title="' . esc_attr__( 'This file contains protected redactions.', 'yougitai-secure-showcase' ) . '">' . esc_html( $redaction_label ) . '</span>';
109
}
110
echo '</a></li>';
111
}
112
};
113
?>
114
<div class="yougitai-tree-actions"><button type="button" data-yougitai-tree-expand><?php esc_html_e( 'Expand all', 'yougitai-secure-showcase' ); ?></button><button type="button" data-yougitai-tree-collapse><?php esc_html_e( 'Collapse all', 'yougitai-secure-showcase' ); ?></button></div>
115
<div class="yougitai-redaction-legend"><span><strong><?php esc_html_e( 'Redactions', 'yougitai-secure-showcase' ); ?>:</strong> <?php esc_html_e( 'A badge such as “3 redactions” marks a partially protected file. Open that file to see the redaction markers in the code.', 'yougitai-secure-showcase' ); ?></span><span>🔒 <?php esc_html_e( 'Fully protected files contain no public code.', 'yougitai-secure-showcase' ); ?></span></div>
116
<ul class="yougitai-file-tree"><?php $render_tree( $file_tree ); ?></ul>
117
</aside>
118
<article class="yougitai-code-panel">
119
<?php if ( $selected ) : ?>
120
<div class="yougitai-code-head"><strong><?php echo esc_html( $selected['path'] ); ?></strong><span><?php echo esc_html( $selected['language'] ); ?></span></div>
121
<?php if ( $selected['visibility'] === 'hidden' ) : ?>
122
<div class="yougitai-protected-file-view" role="status">
123
<div class="yougitai-protected-file-icon" aria-hidden="true">🔒</div>
124
<div>
125
<h3><?php esc_html_e( 'Content protected', 'yougitai-secure-showcase' ); ?></h3>
126
<p><?php esc_html_e( 'The contents of this file are not publicly displayed because they may contain sensitive implementation details, internal security logic, or proprietary business logic.', 'yougitai-secure-showcase' ); ?></p>
127
<p class="yougitai-protected-file-note"><?php esc_html_e( 'The file remains visible so the project structure and architecture can still be understood.', 'yougitai-secure-showcase' ); ?></p>
128
</div>
129
</div>
130
<?php else : ?>
131
<?php if ( $selected['visibility'] === 'redacted' ) : ?>
132
<div class="yougitai-security-note">
133
<strong><?php esc_html_e( 'Protected before publication', 'yougitai-secure-showcase' ); ?></strong>
134
<span><?php printf( esc_html__( '%1$s protected passages across %2$s lines are visibly marked below.', 'yougitai-secure-showcase' ), esc_html( number_format_i18n( (int) $selected['redaction_count'] ) ), esc_html( number_format_i18n( (int) $selected['redacted_lines'] ) ) ); ?></span>
135
</div>
136
<?php endif; ?>
137
<?php
138
$code_lines = preg_split( '/\R/', (string) $selected['content'] );
139
$redactions_by_line = [];
140
foreach ( $selected['redactions'] ?? [] as $redaction ) {
141
$line_start = max( 1, (int) ( $redaction['line_start'] ?? 1 ) );
142
$redactions_by_line[ $line_start ][] = $redaction;
143
}
144
?>
145
<div class="yougitai-code-view" role="region" aria-label="<?php esc_attr_e( 'Public source code with visible protected passages', 'yougitai-secure-showcase' ); ?>">
146
<?php foreach ( is_array( $code_lines ) ? $code_lines : [] as $index => $line ) : $line_no = $index + 1; ?>
147
<div class="yougitai-code-line<?php echo ! empty( $redactions_by_line[ $line_no ] ) ? ' has-redaction' : ''; ?>">
148
<span class="yougitai-line-no" aria-hidden="true"><?php echo esc_html( (string) $line_no ); ?></span>
149
<code><?php echo esc_html( $line ); ?></code>
150
<?php if ( ! empty( $redactions_by_line[ $line_no ] ) ) : ?>
151
<span class="yougitai-blackout-layer" aria-label="<?php esc_attr_e( 'Protected code was removed here.', 'yougitai-secure-showcase' ); ?>">
152
<?php foreach ( $redactions_by_line[ $line_no ] as $redaction ) :
153
$width = max( 6, min( 46, (int) ceil( (int) ( $redaction['original_length'] ?? 8 ) / max( 1, ( (int) ( $redaction['line_end'] ?? $line_no ) - (int) ( $redaction['line_start'] ?? $line_no ) + 1 ) ) ) ) );
154
$left = max( 0, min( 70, (int) ( $redaction['column_start'] ?? 1 ) - 1 ) );
155
?><?php $protected_lines = max( 1, (int) ( $redaction['line_end'] ?? $line_no ) - (int) ( $redaction['line_start'] ?? $line_no ) + 1 ); ?><span class="yougitai-blackout" tabindex="0" style="--yg-blackout-width:<?php echo esc_attr( (string) $width ); ?>ch;--yg-blackout-left:<?php echo esc_attr( (string) $left ); ?>ch" data-yougitai-tooltip="<?php esc_attr_e( 'This area was redacted to protect sensitive or proprietary implementation details.', 'yougitai-secure-showcase' ); ?>" title="<?php esc_attr_e( 'This area was redacted to protect sensitive or proprietary implementation details.', 'yougitai-secure-showcase' ); ?>" aria-label="<?php esc_attr_e( 'This area was redacted to protect sensitive or proprietary implementation details.', 'yougitai-secure-showcase' ); ?>"></span><?php if ( $protected_lines > 1 ) : ?><span class="yougitai-blackout-count" style="--yg-blackout-left:<?php echo esc_attr( (string) $left ); ?>ch"><?php printf( esc_html__( '%s lines protected', 'yougitai-secure-showcase' ), esc_html( number_format_i18n( $protected_lines ) ) ); ?></span><?php endif; ?><?php endforeach; ?>
156
</span>
157
<?php endif; ?>
158
</div>
159
<?php endforeach; ?>
160
</div>
161
<?php endif; ?>
162
<?php else : ?>
163
<div class="yougitai-empty"><h3><?php esc_html_e( 'Secure code browser', 'yougitai-secure-showcase' ); ?></h3><p><?php esc_html_e( 'Select a file to inspect the approved public snapshot. The original repository is never served to visitors.', 'yougitai-secure-showcase' ); ?></p></div>
164
<?php endif; ?>
165
</article>
166
</div>
167
</section>
168
169
<section id="yougitai-architecture" class="yougitai-section yougitai-padded">
170
<h2><?php esc_html_e( 'Architecture', 'yougitai-secure-showcase' ); ?></h2>
171
<p><?php esc_html_e( 'High-level modules detected from the verified public snapshot. Protected implementation details are intentionally omitted.', 'yougitai-secure-showcase' ); ?></p>
172
<div class="yougitai-architecture">
173
<?php foreach ( $profile['architecture'] ?? [] as $layer ) : ?><div class="yougitai-architecture-node"><strong><?php echo esc_html( $layer['label'] ); ?></strong><small><?php echo esc_html( $layer['type'] ); ?></small></div><?php endforeach; ?>
174
<?php if ( empty( $profile['architecture'] ) ) : ?><p><?php esc_html_e( 'No architecture modules were detected in the public snapshot.', 'yougitai-secure-showcase' ); ?></p><?php endif; ?>
175
</div>
176
</section>
177
178
<section id="yougitai-stack" class="yougitai-section yougitai-padded">
179
<h2><?php esc_html_e( 'Technology stack', 'yougitai-secure-showcase' ); ?></h2>
180
<?php if ( ! empty( $profile['tech_stack'] ) ) : ?><div class="yougitai-chips yougitai-stack-chips"><?php foreach ( $profile['tech_stack'] as $tech ) : ?><span><?php echo esc_html( $tech ); ?></span><?php endforeach; ?></div><?php endif; ?>
181
<?php if ( ! empty( $profile['languages'] ) ) : ?><div class="yougitai-language-bars"><?php foreach ( $profile['languages'] as $language ) : ?><div><div class="yougitai-language-label"><span><?php echo esc_html( $language['name'] ); ?></span><strong><?php echo esc_html( number_format_i18n( (float) $language['percent'], 1 ) ); ?>%</strong></div><progress max="100" value="<?php echo esc_attr( (string) $language['percent'] ); ?>"></progress></div><?php endforeach; ?></div><?php endif; ?>
182
</section>
183
184
<footer class="yougitai-showcase-footer"><span>🔒</span> <?php esc_html_e( 'This showcase is rendered exclusively from a verified, redacted public snapshot.', 'yougitai-secure-showcase' ); ?></footer>
185
</section>
186