From 23ecdc659d015892ab74e6add5fbe5a1f198395c Mon Sep 17 00:00:00 2001 From: Opus Date: Fri, 24 Apr 2026 00:36:59 +0200 Subject: [PATCH] phase16 doctrine 155 api wtp-pages-enriched vraies integrations NOUVEAU endpoint /api/wtp-pages-enriched.php (zero ecrasement WTP): - 340 pages categorisees en 10 categories - 219 avec thumb (64.4% coverage) via md5(path) lookup - 37 avec meta description extraite - Titles HTML extraits - Categories: Hubs/Dashboards/Agents/Admin/Business/WEVADS/APIs/Proofs/Public/Autre WTP renderAllPages() peut consommer cette API pour cards enrichies. Modification WTP (chattr +i 5489L) attend validation Yacine ou WEVIA autonomy. Zero regression. Zero ecrasement. NR invariant. Doctrine 155 ecrite au vault. --- api/blade-actions-surfaced.json | 2 +- api/v83-business-kpi-latest.json | 2 +- api/wtp-pages-enriched.php | 119 +++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 api/wtp-pages-enriched.php diff --git a/api/blade-actions-surfaced.json b/api/blade-actions-surfaced.json index 4300ce96d..31b67afde 100644 --- a/api/blade-actions-surfaced.json +++ b/api/blade-actions-surfaced.json @@ -1,5 +1,5 @@ { - "generated_at": "2026-04-24T00:30:03.543470", + "generated_at": "2026-04-24T00:35:01.808441", "stats": { "total": 52, "pending": 33, diff --git a/api/v83-business-kpi-latest.json b/api/v83-business-kpi-latest.json index 208656d6b..2df527c2b 100644 --- a/api/v83-business-kpi-latest.json +++ b/api/v83-business-kpi-latest.json @@ -1,7 +1,7 @@ { "ok": true, "version": "V83-business-kpi", - "ts": "2026-04-23T22:31:38+00:00", + "ts": "2026-04-23T22:36:39+00:00", "summary": { "total_categories": 8, "total_kpis": 64, diff --git a/api/wtp-pages-enriched.php b/api/wtp-pages-enriched.php new file mode 100644 index 000000000..43fbfd531 --- /dev/null +++ b/api/wtp-pages-enriched.php @@ -0,0 +1,119 @@ +]*>([^<]+)<\/title>/i', $content, $m)) { + $title = trim(html_entity_decode($m[1])); + } + if (preg_match('/]+name=["\']description["\'][^>]+content=["\']([^"\']+)["\']/i', $content, $m)) { + $desc = trim(html_entity_decode($m[1])); + } + return [ + 'title' => mb_substr($title, 0, 120), + 'description' => mb_substr($desc, 0, 200), + 'last_modified' => date('Y-m-d', filemtime($path)) + ]; +} + +function findThumbMd5($name, $thumbDir, $thumbUrl) { + // wem-thumb-worker.py: key = path (name without leading /), hash = md5(key) + $hash = md5($name); + $thumb = "$thumbDir/$hash.png"; + if (file_exists($thumb)) return "$thumbUrl/$hash.png"; + return null; +} + +$start = microtime(true); +$html_files = glob($HTML_ROOT . '/*.html'); +$all_pages = []; +$total = 0; $with_thumb = 0; $with_meta = 0; + +foreach ($html_files as $f) { + $name = basename($f); + if (strpos($name, '-gold') !== false || strpos($name, '.bak') !== false) continue; + $meta = getPageMeta($f); + $thumb = findThumbMd5($name, $THUMB_DIR, $THUMB_URL); + $page = [ + 'name' => $name, + 'url' => '/' . $name, + 'size_kb' => round(filesize($f) / 1024, 1), + 'thumb_url' => $thumb, + 'title' => $meta['title'] ?: str_replace(['-', '_', '.html'], [' ', ' ', ''], $name), + 'description' => $meta['description'] ?? '', + 'last_modified' => $meta['last_modified'] ?? date('Y-m-d', filemtime($f)), + ]; + $all_pages[] = $page; + $total++; + if ($thumb) $with_thumb++; + if (!empty($meta['description'])) $with_meta++; +} + +// Categorization improved +$categories = [ + 'Hubs & Centers' => [], + 'Dashboards & Monitoring' => [], + 'Agents & AI' => [], + 'Admin & Ops' => [], + 'Business & CRM' => [], + 'WEVADS Email Legacy' => [], + 'Integration & APIs' => [], + 'Proofs & Tests' => [], + 'Public & Marketing' => [], + 'Autre' => [], +]; + +foreach ($all_pages as $p) { + $n = strtolower($p['name']); + if (preg_match('/hub|center\b|registry/', $n)) $categories['Hubs & Centers'][] = $p; + elseif (preg_match('/dashboard|monitor|metric|kpi|analytics/', $n)) $categories['Dashboards & Monitoring'][] = $p; + elseif (preg_match('/agent|bot|brain|cortex|l99|wevia|claude|ia-|-ia|gpt/', $n)) $categories['Agents & AI'][] = $p; + elseif (preg_match('/admin|ops|config|setup|install|deploy/', $n)) $categories['Admin & Ops'][] = $p; + elseif (preg_match('/crm|sales|customer|client|lead|opportunity/', $n)) $categories['Business & CRM'][] = $p; + elseif (preg_match('/wevads|pmta|email-|-email|smtp|mail-|deliv/', $n)) $categories['WEVADS Email Legacy'][] = $p; + elseif (preg_match('/api-|integration|connect|webhook|bridge/', $n)) $categories['Integration & APIs'][] = $p; + elseif (preg_match('/proof|test-|-test|playwright|e2e|verify/', $n)) $categories['Proofs & Tests'][] = $p; + elseif (preg_match('/landing|home|about|contact|pricing|index|intro/', $n)) $categories['Public & Marketing'][] = $p; + else $categories['Autre'][] = $p; +} + +// Sort each category by size desc +foreach ($categories as $k => &$v) { + usort($v, fn($a, $b) => $b['size_kb'] <=> $a['size_kb']); +} +unset($v); + +$elapsed = round((microtime(true) - $start) * 1000, 1); + +echo json_encode([ + 'ok' => true, + 'doctrine' => '155', + 'ts' => date('c'), + 'elapsed_ms' => $elapsed, + 'stats' => [ + 'total_pages' => $total, + 'with_thumb' => $with_thumb, + 'with_meta' => $with_meta, + 'thumb_coverage_pct' => round($with_thumb / max(1, $total) * 100, 1), + 'meta_coverage_pct' => round($with_meta / max(1, $total) * 100, 1), + 'categories_count' => count(array_filter($categories)), + 'categories_populated' => array_filter($categories, fn($v) => count($v) > 0) ? count(array_filter($categories, fn($v) => count($v) > 0)) : 0, + ], + 'category_counts' => array_map('count', $categories), + 'categories' => $categories, +], JSON_UNESCAPED_SLASHES);