src/content.h
browsing at commit = f94948ee920ac4654a97980edc83bf249aa160f5
#pragma once
#include "git_repo.h"
#include <cppcms/view.h>
#include <string>
#include <vector>
// Data passed from request handlers to the compiled cppcms templates.
namespace content {
// Shared layout fields. `query` is "" or "?id=<oid>" 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<std::string> 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
};
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<TreeEntry> entries;
std::vector<std::string> tags; // tags pointing at commit_oid
std::vector<BranchInfo> 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<std::string> tags; // tags pointing at commit_oid
std::vector<BranchInfo> 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<BlameLine> lines;
};
struct log_view : public master {
std::string commit_oid;
std::vector<CommitInfo> commits;
};
struct object_view : public master {
ObjectView object;
};
struct tags_view : public master {
std::vector<TagInfo> tags;
};
struct tag_view : public master {
TagDetail tag;
};
struct branches_view : public master {
std::vector<BranchInfo> branches;
};
struct commit_view : public master {
CommitDetail commit;
std::vector<BranchInfo> branches; // local branches whose history contains the commit
bool on_default_branch = false; // when true, branch annotation is suppressed
};
} // namespace content