use export::http::{Path, Response, State}; use maud::html; use crate::handler::html::{HtmlRepoPath, archived_class, resolve, response_html}; use crate::service::GitService; use crate::share::access::BasicAuth; #[utoipa::path( get, path = "/repos/{space_name}/{repo_name}/html/refs-summary", tag = "html", description = "渲染分支与标签数量摘要片段。", operation_id = "render_refs_summary", params(HtmlRepoPath), responses( (status = 200, description = "refs summary html fragment", content_type = "text/html"), (status = 404, description = "repo not found") ) )] pub async fn render_refs_summary( State(service): State, Path(path): Path, auth: BasicAuth, ) -> Response { let ctx = match resolve(service, path, auth).await { Ok(c) => c, Err(resp) => return resp, }; let branch_count = ctx.dto.branches_count; let tag_count = ctx.dto.tags_count; let base = "git-refs-summary flex items-center gap-3 text-sm text-zinc-600"; let cls = archived_class(&ctx.dto, base); let markup = html! { div class=(cls) data-component="git-refs-summary" data-space=(ctx.space_name) data-repo=(ctx.repo_name) data-branches=(branch_count) data-tags=(tag_count) data-archived=(if ctx.dto.is_archived { "true" } else { "false" }) { span class="flex items-center gap-1" { svg class="h-4 w-4" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg" { path d="M11.75 2.5a.75.75 0 100 1.5.75.75 0 000-1.5zm-2.25.75a2.25 2.25 0 113 2.122V6A2.5 2.5 0 0110 8.5H6a1 1 0 00-1 1v1.128a2.5 2.5 0 11-1.5 0V5.372a2.5 2.5 0 011.5-2.122h4.5z" {} } span class="font-mono" { (branch_count) } span { "branches" } } span class="flex items-center gap-1" { svg class="h-4 w-4" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg" { path d="M1 7.775V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775z" {} } span class="font-mono" { (tag_count) } span { "tags" } } } }; response_html(markup, 30) }