index.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * Public client handbook: every document and every source file of
  5. * client-package/ on one page.
  6. *
  7. * Rendering happens in the browser with the vendored marked.js, exactly like
  8. * the two internal viewers. The Markdown source sits in the page as plain text
  9. * rather than in a script tag, so the page also works without JavaScript and so
  10. * that a tool extracting text from the HTML receives the whole handbook.
  11. *
  12. * A client that does not ask for HTML (curl, most agent fetchers) gets the
  13. * plain-text rendering instead; see llms.php.
  14. */
  15. require_once __DIR__ . "/inc/handbook.php";
  16. $accept = (string) ($_SERVER["HTTP_ACCEPT"] ?? "");
  17. $wantsText = isset($_GET["format"]) && $_GET["format"] === "md";
  18. // No Accept header at all, or one that never mentions HTML: not a browser.
  19. if (!$wantsText && !str_contains(strtolower($accept), "text/html")) {
  20. $wantsText = true;
  21. }
  22. if ($wantsText) {
  23. require __DIR__ . "/llms.php";
  24. return;
  25. }
  26. $inventory = handbookInventory();
  27. $markdown = handbookBuildMarkdown(true);
  28. $self = handbookSelfUrl();
  29. ?>
  30. <!DOCTYPE html>
  31. <html lang="de">
  32. <head>
  33. <meta charset="UTF-8">
  34. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  35. <title>Manage Client – Handbuch</title>
  36. <meta name="description" content="Update- und Backup-Client für PHP-Projekte: vollständige Dokumentation, Quellcode und HTTP-Schnittstelle auf einer Seite.">
  37. <link rel="stylesheet" href="assets/docs.css">
  38. <link rel="alternate" type="text/markdown" href="llms.txt" title="Handbuch als reiner Text">
  39. <script>document.documentElement.className += ' has-js';</script>
  40. </head>
  41. <body>
  42. <header class="docs-header">
  43. <div class="docs-header-inner">
  44. <a class="docs-brand" href="index.php">Manage Client – Handbuch</a>
  45. <nav class="docs-header-links">
  46. <a href="llms.txt">Reiner Text</a>
  47. <a href="api.php">API-Referenz</a>
  48. <a href="openapi.php">OpenAPI</a>
  49. </nav>
  50. </div>
  51. </header>
  52. <div class="docs-layout">
  53. <nav class="docs-nav" aria-label="Inhalt">
  54. <p class="docs-nav-title">Einstieg</p>
  55. <ul>
  56. <li><a href="#part-intro">Überblick</a></li>
  57. <li><a href="#part-api">HTTP-API</a></li>
  58. <li><a href="#part-inventory">Dateiübersicht</a></li>
  59. </ul>
  60. <p class="docs-nav-title">Dokumentation</p>
  61. <ul>
  62. <?php foreach ($inventory["docs"] as $relative => $title): ?>
  63. <li>
  64. <a href="#<?php echo handbookEscape(handbookAnchor("doc", $relative)); ?>">
  65. <?php echo handbookEscape($title); ?>
  66. </a>
  67. </li>
  68. <?php endforeach; ?>
  69. </ul>
  70. <p class="docs-nav-title">Quellcode</p>
  71. <ul class="docs-nav-code">
  72. <?php foreach ($inventory["code"] as $relative): ?>
  73. <li>
  74. <a href="#<?php echo handbookEscape(handbookAnchor("code", $relative)); ?>">
  75. <?php echo handbookEscape($relative); ?>
  76. </a>
  77. </li>
  78. <?php endforeach; ?>
  79. </ul>
  80. </nav>
  81. <main class="docs-main">
  82. <div class="docs-note">
  83. <p><strong>Sie sind ein LLM oder ein Skript?</strong> Dieselbe Seite als reiner
  84. Text, ohne Auszeichnung: <a href="llms.txt"><?php echo handbookEscape($self); ?>/llms.txt</a></p>
  85. <p>Aufrufe ohne <code>Accept: text/html</code> erhalten diese Fassung automatisch.</p>
  86. </div>
  87. <article id="handbook" class="markdown-body">
  88. <pre class="handbook-source" id="handbook-source"><?php echo handbookEscape($markdown); ?></pre>
  89. </article>
  90. </main>
  91. </div>
  92. <footer class="docs-footer">
  93. <p>Erzeugt aus <code>client-package/</code> des Manage-Repositories, bei jedem Aufruf neu.
  94. Gerendert mit <a href="https://marked.js.org/">marked</a>, API-Referenz mit
  95. <a href="https://swagger.io/tools/swagger-ui/">Swagger UI</a>; beide liegen mit im
  96. Repository, es werden keine fremden Server kontaktiert.</p>
  97. </footer>
  98. <script src="assets/marked.min.js"></script>
  99. <script>
  100. (function () {
  101. var source = document.getElementById('handbook-source');
  102. var target = document.getElementById('handbook');
  103. if (!source || !target || typeof marked === 'undefined') {
  104. // Without marked the plain-text fallback stays visible.
  105. document.documentElement.className =
  106. document.documentElement.className.replace(' has-js', '');
  107. return;
  108. }
  109. target.innerHTML = marked.parse(source.textContent || '', { gfm: true, breaks: false });
  110. })();
  111. </script>
  112. </body>
  113. </html>