//! Templates for the public git source browser, issues, and repo settings. use std::sync::Arc; use askama::Template; use crate::auth::SessionUser; use crate::git; use crate::types::*; use super::super::CsrfTokenOption; /// An item paired with its versions, for release display on the git repo page. pub struct ReleaseItem { pub item: Item, pub versions: Vec, } /// Repository overview: file tree at HEAD + README. #[derive(Template)] #[template(path = "pages/git/repo.html")] pub struct GitRepoTemplate { pub csrf_token: CsrfTokenOption, pub session_user: Option, pub owner: String, pub repo_name: String, pub description: Option, pub current_ref: String, pub refs: Vec, pub tree_items: Vec, pub readme_html: Option, pub host_url: Arc, /// Hostname for SSH clone URLs (e.g., "git.makenot.work"). Hidden when `None`. pub git_ssh_host: Option, /// Linked project, if this repo is associated with a public project. pub linked_project: Option, /// Public items with versions from the linked project (releases). pub release_items: Vec, /// Number of open issues for the nav bar badge. pub open_issue_count: i64, /// Whether the current viewer is the repo owner (for settings link). pub is_owner: bool, pub active_tab: &'static str, } /// Subdirectory listing with breadcrumb navigation. #[derive(Template)] #[template(path = "pages/git/tree.html")] pub struct GitTreeTemplate { pub csrf_token: CsrfTokenOption, pub session_user: Option, pub owner: String, pub repo_name: String, pub current_ref: String, pub refs: Vec, pub path: String, pub parent_path: String, /// Whether we're in a subdirectory (for ".." link and path joining). pub in_subdir: bool, pub breadcrumbs: Vec, pub tree_items: Vec, pub open_issue_count: i64, pub is_owner: bool, pub active_tab: &'static str, } /// File viewer with syntax highlighting and line numbers. #[derive(Template)] #[template(path = "pages/git/file.html")] pub struct GitFileTemplate { pub csrf_token: CsrfTokenOption, pub session_user: Option, pub owner: String, pub repo_name: String, pub current_ref: String, pub refs: Vec, pub file_path: String, pub filename: String, pub breadcrumbs: Vec, pub file_size: String, pub line_count: usize, pub is_binary: bool, pub highlighted_lines: Vec, pub open_issue_count: i64, pub is_owner: bool, pub active_tab: &'static str, } /// Commit log with pagination. #[derive(Template)] #[template(path = "pages/git/commits.html")] pub struct GitCommitsTemplate { pub csrf_token: CsrfTokenOption, pub session_user: Option, pub owner: String, pub repo_name: String, pub current_ref: String, pub refs: Vec, pub commits: Vec, pub page: usize, pub has_more: bool, pub open_issue_count: i64, /// Whether the current viewer is the repo owner (for settings link). pub is_owner: bool, pub active_tab: &'static str, } /// Commit detail page with inline diffs. #[derive(Template)] #[template(path = "pages/git/commit.html")] pub struct GitCommitDetailTemplate { pub csrf_token: CsrfTokenOption, pub session_user: Option, pub owner: String, pub repo_name: String, pub current_ref: String, pub refs: Vec, pub detail: git::CommitDetail, pub diff_files: Vec, pub total_files: usize, pub total_additions: usize, pub total_deletions: usize, pub open_issue_count: i64, pub is_owner: bool, pub active_tab: &'static str, } /// Blame view for a single file. #[derive(Template)] #[template(path = "pages/git/blame.html")] pub struct GitBlameTemplate { pub csrf_token: CsrfTokenOption, pub session_user: Option, pub owner: String, pub repo_name: String, pub current_ref: String, pub refs: Vec, pub file_path: String, pub filename: String, pub breadcrumbs: Vec, pub blame_lines: Vec, pub open_issue_count: i64, pub is_owner: bool, pub active_tab: &'static str, } /// User's repository listing page. #[derive(Template)] #[template(path = "pages/git/repos.html")] pub struct GitUserReposTemplate { pub csrf_token: CsrfTokenOption, pub session_user: Option, pub owner: String, pub repos: Vec, pub is_owner: bool, } /// Public explore page listing all public repos across all users. #[derive(Template)] #[template(path = "pages/git/explore.html")] pub struct GitExploreTemplate { pub csrf_token: CsrfTokenOption, pub session_user: Option, pub repos: Vec, pub page: usize, pub has_more: bool, pub total_count: i64, } /// Per-file commit history with breadcrumb context. #[derive(Template)] #[template(path = "pages/git/file_log.html")] pub struct GitFileLogTemplate { pub csrf_token: CsrfTokenOption, pub session_user: Option, pub owner: String, pub repo_name: String, pub current_ref: String, pub refs: Vec, pub file_path: String, pub filename: String, pub breadcrumbs: Vec, pub commits: Vec, pub page: usize, pub has_more: bool, pub open_issue_count: i64, pub is_owner: bool, pub active_tab: &'static str, } // ============================================================================ // Git Issues // ============================================================================ /// Issue list page with status tabs and search (read-only). #[derive(Template)] #[template(path = "pages/git/issues.html")] pub struct GitIssueListTemplate { pub csrf_token: CsrfTokenOption, pub session_user: Option, pub owner: String, pub repo_name: String, pub current_ref: String, pub issues: Vec, pub open_count: i64, pub closed_count: i64, pub current_status: String, pub search_query: String, pub current_page: i64, pub total_pages: i64, /// Whether the current viewer is the repo owner (for settings link). pub is_owner: bool, /// Email address for submitting new issues. pub email_address: String, } /// Issue detail page with comments (read-only). #[derive(Template)] #[template(path = "pages/git/issue.html")] pub struct GitIssueDetailTemplate { pub csrf_token: CsrfTokenOption, pub session_user: Option, pub owner: String, pub repo_name: String, pub current_ref: String, pub issue: crate::db::DbIssue, pub author_username: String, pub comments: Vec, pub is_owner: bool, pub open_issue_count: i64, /// Email address for submitting new issues. pub email_address: String, } /// Repository settings page (owner only). #[derive(Template)] #[template(path = "pages/git/settings.html")] pub struct GitRepoSettingsTemplate { pub csrf_token: CsrfTokenOption, pub session_user: Option, pub owner: String, pub repo_name: String, pub current_ref: String, pub repo: crate::db::DbGitRepo, pub open_issue_count: i64, /// Owner's projects for the link dropdown. pub projects: Vec, /// ID of the currently linked project as a string (for dropdown comparison). pub linked_project_id: String, }