| 1 |
|
| 2 |
|
| 3 |
use std::sync::Arc; |
| 4 |
|
| 5 |
use askama::Template; |
| 6 |
|
| 7 |
use crate::auth::SessionUser; |
| 8 |
use crate::git; |
| 9 |
use crate::types::*; |
| 10 |
|
| 11 |
use super::super::CsrfTokenOption; |
| 12 |
|
| 13 |
|
| 14 |
pub struct ReleaseItem { |
| 15 |
pub item: Item, |
| 16 |
pub versions: Vec<Version>, |
| 17 |
} |
| 18 |
|
| 19 |
|
| 20 |
#[derive(Template)] |
| 21 |
#[template(path = "pages/git/repo.html")] |
| 22 |
pub struct GitRepoTemplate { |
| 23 |
pub csrf_token: CsrfTokenOption, |
| 24 |
pub session_user: Option<SessionUser>, |
| 25 |
pub owner: String, |
| 26 |
pub repo_name: String, |
| 27 |
pub description: Option<String>, |
| 28 |
pub current_ref: String, |
| 29 |
pub refs: Vec<git::RefInfo>, |
| 30 |
pub tree_items: Vec<git::TreeItem>, |
| 31 |
pub readme_html: Option<String>, |
| 32 |
pub host_url: Arc<str>, |
| 33 |
|
| 34 |
pub git_ssh_host: Option<String>, |
| 35 |
|
| 36 |
pub linked_project: Option<Project>, |
| 37 |
|
| 38 |
pub release_items: Vec<ReleaseItem>, |
| 39 |
|
| 40 |
pub open_issue_count: i64, |
| 41 |
|
| 42 |
pub is_owner: bool, |
| 43 |
pub active_tab: &'static str, |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
#[derive(Template)] |
| 48 |
#[template(path = "pages/git/tree.html")] |
| 49 |
pub struct GitTreeTemplate { |
| 50 |
pub csrf_token: CsrfTokenOption, |
| 51 |
pub session_user: Option<SessionUser>, |
| 52 |
pub owner: String, |
| 53 |
pub repo_name: String, |
| 54 |
pub current_ref: String, |
| 55 |
pub refs: Vec<git::RefInfo>, |
| 56 |
pub path: String, |
| 57 |
pub parent_path: String, |
| 58 |
|
| 59 |
pub in_subdir: bool, |
| 60 |
pub breadcrumbs: Vec<git::Breadcrumb>, |
| 61 |
pub tree_items: Vec<git::TreeItem>, |
| 62 |
pub open_issue_count: i64, |
| 63 |
pub is_owner: bool, |
| 64 |
pub active_tab: &'static str, |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
#[derive(Template)] |
| 69 |
#[template(path = "pages/git/file.html")] |
| 70 |
pub struct GitFileTemplate { |
| 71 |
pub csrf_token: CsrfTokenOption, |
| 72 |
pub session_user: Option<SessionUser>, |
| 73 |
pub owner: String, |
| 74 |
pub repo_name: String, |
| 75 |
pub current_ref: String, |
| 76 |
pub refs: Vec<git::RefInfo>, |
| 77 |
pub file_path: String, |
| 78 |
pub filename: String, |
| 79 |
pub breadcrumbs: Vec<git::Breadcrumb>, |
| 80 |
pub file_size: String, |
| 81 |
pub line_count: usize, |
| 82 |
pub is_binary: bool, |
| 83 |
pub highlighted_lines: Vec<String>, |
| 84 |
pub open_issue_count: i64, |
| 85 |
pub is_owner: bool, |
| 86 |
pub active_tab: &'static str, |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
#[derive(Template)] |
| 91 |
#[template(path = "pages/git/commits.html")] |
| 92 |
pub struct GitCommitsTemplate { |
| 93 |
pub csrf_token: CsrfTokenOption, |
| 94 |
pub session_user: Option<SessionUser>, |
| 95 |
pub owner: String, |
| 96 |
pub repo_name: String, |
| 97 |
pub current_ref: String, |
| 98 |
pub refs: Vec<git::RefInfo>, |
| 99 |
pub commits: Vec<git::CommitInfo>, |
| 100 |
pub page: usize, |
| 101 |
pub has_more: bool, |
| 102 |
pub open_issue_count: i64, |
| 103 |
|
| 104 |
pub is_owner: bool, |
| 105 |
pub active_tab: &'static str, |
| 106 |
} |
| 107 |
|
| 108 |
|
| 109 |
#[derive(Template)] |
| 110 |
#[template(path = "pages/git/commit.html")] |
| 111 |
pub struct GitCommitDetailTemplate { |
| 112 |
pub csrf_token: CsrfTokenOption, |
| 113 |
pub session_user: Option<SessionUser>, |
| 114 |
pub owner: String, |
| 115 |
pub repo_name: String, |
| 116 |
pub current_ref: String, |
| 117 |
pub refs: Vec<git::RefInfo>, |
| 118 |
pub detail: git::CommitDetail, |
| 119 |
pub diff_files: Vec<git::DiffFile>, |
| 120 |
pub total_files: usize, |
| 121 |
pub total_additions: usize, |
| 122 |
pub total_deletions: usize, |
| 123 |
pub open_issue_count: i64, |
| 124 |
pub is_owner: bool, |
| 125 |
pub active_tab: &'static str, |
| 126 |
} |
| 127 |
|
| 128 |
|
| 129 |
#[derive(Template)] |
| 130 |
#[template(path = "pages/git/blame.html")] |
| 131 |
pub struct GitBlameTemplate { |
| 132 |
pub csrf_token: CsrfTokenOption, |
| 133 |
pub session_user: Option<SessionUser>, |
| 134 |
pub owner: String, |
| 135 |
pub repo_name: String, |
| 136 |
pub current_ref: String, |
| 137 |
pub refs: Vec<git::RefInfo>, |
| 138 |
pub file_path: String, |
| 139 |
pub filename: String, |
| 140 |
pub breadcrumbs: Vec<git::Breadcrumb>, |
| 141 |
pub blame_lines: Vec<git::BlameLine>, |
| 142 |
pub open_issue_count: i64, |
| 143 |
pub is_owner: bool, |
| 144 |
pub active_tab: &'static str, |
| 145 |
} |
| 146 |
|
| 147 |
|
| 148 |
#[derive(Template)] |
| 149 |
#[template(path = "pages/git/repos.html")] |
| 150 |
pub struct GitUserReposTemplate { |
| 151 |
pub csrf_token: CsrfTokenOption, |
| 152 |
pub session_user: Option<SessionUser>, |
| 153 |
pub owner: String, |
| 154 |
pub repos: Vec<crate::db::DbGitRepo>, |
| 155 |
pub is_owner: bool, |
| 156 |
} |
| 157 |
|
| 158 |
|
| 159 |
#[derive(Template)] |
| 160 |
#[template(path = "pages/git/explore.html")] |
| 161 |
pub struct GitExploreTemplate { |
| 162 |
pub csrf_token: CsrfTokenOption, |
| 163 |
pub session_user: Option<SessionUser>, |
| 164 |
pub repos: Vec<crate::db::git_repos::PublicRepoWithOwner>, |
| 165 |
pub page: usize, |
| 166 |
pub has_more: bool, |
| 167 |
pub total_count: i64, |
| 168 |
} |
| 169 |
|
| 170 |
|
| 171 |
#[derive(Template)] |
| 172 |
#[template(path = "pages/git/file_log.html")] |
| 173 |
pub struct GitFileLogTemplate { |
| 174 |
pub csrf_token: CsrfTokenOption, |
| 175 |
pub session_user: Option<SessionUser>, |
| 176 |
pub owner: String, |
| 177 |
pub repo_name: String, |
| 178 |
pub current_ref: String, |
| 179 |
pub refs: Vec<git::RefInfo>, |
| 180 |
pub file_path: String, |
| 181 |
pub filename: String, |
| 182 |
pub breadcrumbs: Vec<git::Breadcrumb>, |
| 183 |
pub commits: Vec<git::CommitInfo>, |
| 184 |
pub page: usize, |
| 185 |
pub has_more: bool, |
| 186 |
pub open_issue_count: i64, |
| 187 |
pub is_owner: bool, |
| 188 |
pub active_tab: &'static str, |
| 189 |
} |
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
#[derive(Template)] |
| 197 |
#[template(path = "pages/git/issues.html")] |
| 198 |
pub struct GitIssueListTemplate { |
| 199 |
pub csrf_token: CsrfTokenOption, |
| 200 |
pub session_user: Option<SessionUser>, |
| 201 |
pub owner: String, |
| 202 |
pub repo_name: String, |
| 203 |
pub current_ref: String, |
| 204 |
pub issues: Vec<crate::db::DbIssueWithMeta>, |
| 205 |
pub open_count: i64, |
| 206 |
pub closed_count: i64, |
| 207 |
pub current_status: String, |
| 208 |
pub search_query: String, |
| 209 |
pub current_page: i64, |
| 210 |
pub total_pages: i64, |
| 211 |
|
| 212 |
pub is_owner: bool, |
| 213 |
|
| 214 |
pub email_address: String, |
| 215 |
} |
| 216 |
|
| 217 |
|
| 218 |
#[derive(Template)] |
| 219 |
#[template(path = "pages/git/issue.html")] |
| 220 |
pub struct GitIssueDetailTemplate { |
| 221 |
pub csrf_token: CsrfTokenOption, |
| 222 |
pub session_user: Option<SessionUser>, |
| 223 |
pub owner: String, |
| 224 |
pub repo_name: String, |
| 225 |
pub current_ref: String, |
| 226 |
pub issue: crate::db::DbIssue, |
| 227 |
pub author_username: String, |
| 228 |
pub comments: Vec<crate::db::DbIssueCommentWithAuthor>, |
| 229 |
pub is_owner: bool, |
| 230 |
pub open_issue_count: i64, |
| 231 |
|
| 232 |
pub email_address: String, |
| 233 |
} |
| 234 |
|
| 235 |
|
| 236 |
#[derive(Template)] |
| 237 |
#[template(path = "pages/git/settings.html")] |
| 238 |
pub struct GitRepoSettingsTemplate { |
| 239 |
pub csrf_token: CsrfTokenOption, |
| 240 |
pub session_user: Option<SessionUser>, |
| 241 |
pub owner: String, |
| 242 |
pub repo_name: String, |
| 243 |
pub current_ref: String, |
| 244 |
pub repo: crate::db::DbGitRepo, |
| 245 |
pub open_issue_count: i64, |
| 246 |
|
| 247 |
pub projects: Vec<crate::db::DbProject>, |
| 248 |
|
| 249 |
pub linked_project_id: String, |
| 250 |
} |
| 251 |
|