Bladeren bron

Home page: list DCBA repos as cards, keep the package table usmc-only

PackagesState.build now walks every discovered repository in one
discovery-order pass with a kind branch. USM entries keep feeding the
package rows, counts and byte totals exactly as before. DCBA entries
contribute only a summary card: name, summary, fingerprint, browse link,
the repo.dcbar definition href and the "sudo usm dcba add-repo" snippet,
plus artifact_count and an artifact_total_size summed from the
ARTIFACTS.usml size fields (size-0 entries from older listings count
toward the total but add no bytes).

RepoSummary gains kind ("usm"/"dcba"), artifact_count and
artifact_total_size; the usmr_href/repos_d_snippet members carry the
dcba counterparts for DCBA rows so the card markup stays one block.

home.html renders both card variants from one loop with stm-if/stm-else
branches: a "DCBA - pre-built artifacts" chip vs "USM - source packages",
per-kind wording, the dcba add-repo snippet line, and an artifact
count/size hint; the browse link keeps /repo/{name} for both kinds. The
hero and Packages section copy now state that artifacts live on the
repository pages, and the search placeholder says "source repositories".

A repo-scoped build for a DCBA repository now throws a clear
INVALID_CONFIGURATION (the browse entrypoint degrades to its error card
for those names), instead of trying to render an artifact repository
through the package-table state. Verified against a mixed fixture
parent: overview state, search action over held slots, repo browse
regressions, and per-request base rewriting.
saddle-Clanker-Saddle 1 maand geleden
bovenliggende
commit
cd4346692f
2 gewijzigde bestanden met toevoegingen van 80 en 5 verwijderingen
  1. 59 0
      src/PackagesState.vala
  2. 21 5
      src/pages/home.html

+ 59 - 0
src/PackagesState.vala

@@ -20,10 +20,23 @@ namespace UsmWeb {
      * One repository summary in the overview: the stats card fields plus the
      * per-repository add-repository instruction fields ({@link base_uri},
      * {@link usmr_href}, {@link repos_d_snippet}).
+     *
+     * Both repository kinds render a card; {@link kind} (the
+     * {@link RepositoryKind.to_string} wire name) picks which instruction
+     * block and stats the card shows — a USM card carries its package count
+     * and byte total, a DCBA card its artifact count and artifact byte
+     * total — that total sums the listing's `size` fields, so artifacts
+     * from listings written before the field existed (size 0) contribute
+     * nothing while still counting toward {@link artifact_count}. The
+     * `*_href`/`*_snippet` members are named for the USM card;
+     * a DCBA summary fills them with the `repo.dcbar` / `usm dcba
+     * add-repo` counterparts so the card markup stays one block with a
+     * kind branch.
      */
     public class RepoSummary : Object {
         public string name { get; set; default = ""; }
         public string summary { get; set; default = ""; }
+        public string kind { get; set; default = "usm"; }
         public int package_count { get; set; }
         public string total_size { get; set; default = ""; }
         public string href { get; set; default = ""; }
@@ -31,6 +44,8 @@ namespace UsmWeb {
         public string base_uri { get; set; default = ""; }
         public string usmr_href { get; set; default = ""; }
         public string repos_d_snippet { get; set; default = ""; }
+        public int artifact_count { get; set; }
+        public string artifact_total_size { get; set; default = ""; }
     }
 
     /**
@@ -51,6 +66,20 @@ namespace UsmWeb {
          * per-repository add instructions, and one combined table). Rows are
          * filtered by the case-insensitive `query` substring over name and
          * summary (an empty query keeps every entry).
+         *
+         * The overview lists repositories of **both** kinds as summary
+         * cards, in discovery order, but only the USM source repositories
+         * feed the package table and the package counts and byte totals —
+         * a DCBA entry contributes a card (its artifact count and artifact
+         * byte total from the `ARTIFACTS.usml` sizes) and nothing else, so
+         * pre-built artifacts surface in the detail views, never in the
+         * home package table.
+         *
+         * A repo-scoped build for a DCBA repository throws instead: the
+         * package-table state this builder authors does not describe an
+         * artifact repository, so the browse entrypoint degrades to its
+         * error card for those names (the dedicated DCBA browse view owns
+         * that page).
          */
         public static State build(RepositoryService repositories, UsmWebConfig config,
                 ActionRegistry action_registry, string base_uri, string query, string? repo_name = null) throws Error {
@@ -66,6 +95,35 @@ namespace UsmWeb {
                     continue;
                 }
 
+                if (entry.kind == RepositoryKind.DCBA) {
+                    if (repo_name != null) {
+                        throw new UsmWebError.INVALID_CONFIGURATION(
+                            @"Repository \"$repo_name\" is a DCBA artifact repository — its pre-built artifacts are not listed as packages");
+                    }
+
+                    int64 artifact_bytes = 0;
+                    uint artifact_count = 0;
+                    foreach (var artifact_entry in entry.dcba_listing_entries()) {
+                        artifact_bytes += (int64) artifact_entry.size;
+                        artifact_count++;
+                    }
+
+                    repo_rows.add(new RepoSummary() {
+                        name = repo.name,
+                        summary = repo.summary,
+                        kind = RepositoryKind.DCBA.to_string(),
+                        artifact_count = (int) artifact_count,
+                        artifact_total_size = format_size(artifact_bytes),
+                        href = "/repo/" + repo.name,
+                        key_fingerprint = fingerprint(repo.key.to_hex()),
+                        base_uri = base_uri + "repo/" + repo.name + "/",
+                        usmr_href = base_uri + "repo/" + repo.name + "/repo.dcbar",
+                        repos_d_snippet = "sudo usm dcba add-repo %srepo/%s/repo.dcbar"
+                            .printf(base_uri, repo.name)
+                    });
+                    continue;
+                }
+
                 int64 repo_bytes = 0;
                 uint repo_count = 0;
                 var rows = new Vector<PackageRow>();
@@ -93,6 +151,7 @@ namespace UsmWeb {
                 repo_rows.add(new RepoSummary() {
                     name = repo.name,
                     summary = repo.summary,
+                    kind = RepositoryKind.USM.to_string(),
                     package_count = (int) repo_count,
                     total_size = format_size(repo_bytes),
                     href = "/repo/" + repo.name,

+ 21 - 5
src/pages/home.html

@@ -14,7 +14,8 @@
     <div stm-if="packages != null && (packages.load_error == null || packages.load_error == '')">
         <section class="card hero">
             <h1 stm-text="packages.site_name">Repositories</h1>
-            <p class="summary">Every USM repository served by this host.</p>
+            <p class="summary">Every repository served by this host — USM source
+               repositories and DCBA artifact repositories alike.</p>
             <dl class="stats">
                 <div><dt>Repositories</dt><dd stm-text="packages.repo_count">—</dd></div>
                 <div><dt>Packages</dt><dd stm-text="packages.package_count">—</dd></div>
@@ -33,9 +34,13 @@
         <section class="card">
             <h2>Add a repository</h2>
             <div class="repo-block" stm-for-repo-in="packages.repos" stm-key="repo.name">
+                <span class="chip mono" stm-if="repo.kind == 'dcba'">DCBA · pre-built artifacts</span>
+                <span class="chip mono" stm-else>USM · source packages</span>
                 <h3 stm-text="repo.name">repository</h3>
                 <p class="summary" stm-text="repo.summary">summary</p>
-                <p>Point USM at this repository — its URI is
+                <p stm-if="repo.kind == 'dcba'">Point USM at this artifact repository — its URI is
+                    <code class="mono" stm-text="repo.base_uri">…</code></p>
+                <p stm-else>Point USM at this repository — its URI is
                     <code class="mono" stm-text="repo.base_uri">…</code></p>
                 <ol class="steps">
                     <li>The signed repository definition:
@@ -43,18 +48,29 @@
                            stm-text="repo.usmr_href">repo.usmr</a></li>
                     <li>Add it with USM:</li>
                 </ol>
-                <pre class="mono snippet"><code stm-text="'sudo usm add-repo ' + repo.usmr_href"></code></pre>
+                <pre class="mono snippet" stm-if="repo.kind == 'dcba'"><code
+                    stm-text="'sudo usm dcba add-repo ' + repo.usmr_href"></code></pre>
+                <pre class="mono snippet" stm-else><code
+                    stm-text="'sudo usm add-repo ' + repo.usmr_href"></code></pre>
+                <p class="hint" stm-if="repo.kind == 'dcba'"
+                   stm-text="repo.artifact_count + ' pre-built artifact' + (repo.artifact_count == 1 ? '' : 's') + ' · ' + repo.artifact_total_size + ' total'">2 pre-built artifacts · 1.2 MiB total</p>
+                <p class="hint" stm-else
+                   stm-text="repo.package_count + ' source package' + (repo.package_count == 1 ? '' : 's') + ' · ' + repo.total_size + ' total'">2 source packages · 1.2 MiB total</p>
                 <p class="hint">Signing-key fingerprint:
                     <span class="mono fingerprint" stm-text="repo.key_fingerprint">—</span></p>
-                <p class="hint">Browse the repository's
+                <p class="hint" stm-if="repo.kind == 'dcba'">Browse the repository's
+                    <a stm-attribute.href="repo.href">artifacts</a>.</p>
+                <p class="hint" stm-else>Browse the repository's
                     <a stm-attribute.href="repo.href">packages</a>.</p>
             </div>
         </section>
 
         <section class="card">
             <h2>Packages</h2>
+            <p class="summary">Source packages from every USM repository — pre-built
+                DCBA artifacts are listed on each repository's page.</p>
             <form class="search" stm-action="packages.search">
-                <input type="search" name="query" placeholder="Search all repositories…"
+                <input type="search" name="query" placeholder="Search all source repositories…"
                        stm-attribute.value="packages.query">
                 <button type="submit">Search</button>
             </form>