/* MIT License Copyright (c) 2026 Poul Sander Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #pragma once #include "git_repo.h" #include #include #include // Data passed from request handlers to the compiled cppcms templates. namespace content { // Shared layout fields. `query` is "" or "?id=" and is appended to links // so navigation stays pinned to the viewed commit. struct master : public cppcms::base_content { std::string title; std::string repo; // current repository name, "" outside a repo std::string query; }; struct frontpage : public master { size_t repo_count = 0; }; struct repo_list : public master { std::vector repos; }; struct repo_home : public master { std::string commit_oid; std::string default_branch; std::string readme_name; // "" when the repo has no README std::string readme_text; // raw markdown, rendered client-side std::string clone_ssh; // "" when origin is not a github.com remote std::string clone_https; // "" when origin is not a github.com remote std::string clone_http; // self-served clone URL; "" when clone is disabled }; struct tree_view : public master { std::string commit_oid; std::string path; // "" at repo root std::string parent_path; // for the ".." link bool is_root = true; std::vector entries; std::vector tags; // tags pointing at commit_oid std::vector branches; // local branches whose history contains commit_oid bool on_default_branch = false; // when true, branch annotation is suppressed }; struct file_view : public master { std::string commit_oid; std::string path; std::string filename; std::string text; bool is_binary = false; bool is_markdown = false; bool is_image = false; uint64_t size = 0; std::vector tags; // tags pointing at commit_oid std::vector branches; // local branches whose history contains commit_oid bool on_default_branch = false; // when true, branch annotation is suppressed }; struct blame_view : public master { std::string commit_oid; std::string path; std::string filename; std::vector lines; }; struct log_view : public master { std::string commit_oid; std::vector commits; bool has_bodies = false; // any commit carries a body beyond its summary }; struct object_view : public master { ObjectView object; }; struct tags_view : public master { std::vector tags; }; struct tag_view : public master { TagDetail tag; }; struct branches_view : public master { std::vector branches; }; struct commit_view : public master { CommitDetail commit; std::vector branches; // local branches whose history contains the commit bool on_default_branch = false; // when true, branch annotation is suppressed }; } // namespace content