startgitStatic page generator for git repositories |
git clone git://git.dimitrijedobrota.com/startgit.git |
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING | |
commit | e3e9c982a83fb0e54b33c6e09e8f5a43c0197d5e |
parent | e6c7a87e81e7d8b564ecac48a068a7c6b8682467 |
author | Dimitrije Dobrota <mail@dimitrijedobrota.com> |
date | Thu, 9 Jan 2025 13:49:07 +0100 |
Add title bar with links
Diffstat:M | source/main.cpp | | | ++++++++++++++++++++++++++++++++++++++-------------- |
1 files changed, 38 insertions(+), 14 deletions(-)
diff --git a/source/main.cpp b/source/main.cpp
@@ -76,21 +76,45 @@ void write_title(std::ostream& ost,
{
using namespace hemplate; // NOLINT
ost << html::h1(repo.get_name());
ost << html::h2(repo.get_description());
ost << html::label("Branch: ").set("for", "branch");
ost << html::select(
{{"id", "branch"}, {"onChange", "switchPage(this.value)"}});
for (const auto& branch : repo.get_branches()) {
auto option = html::option(branch.get_name());
option.set("value", branch.get_name());
if (branch.get_name() == branch_name) {
option.set("selected", "true");
const auto dropdown = [&]()
{
auto span = html::span();
span.add(html::label("Branch: ").set("for", "branch"));
span.add(html::select(
{{"id", "branch"}, {"onChange", "switchPage(this.value)"}}));
for (const auto& branch : repo.get_branches()) {
auto option = html::option(branch.get_name());
option.set("value", branch.get_name());
if (branch.get_name() == branch_name) {
option.set("selected", "true");
}
span.add(option);
}
ost << option;
}
ost << html::select();
span.add(html::select());
return span;
}();
ost << html::table();
ost << html::tr().add(html::td()
.add(html::h1(repo.get_name()))
.add(html::span(repo.get_description())));
ost << html::tr().add(
html::td().add(html::span("git clone ")).add(html::a(repo.get_name())));
ost << html::tr().add(html::td()
.add(html::a("Log").set("href", branch_name + "_log.html"))
.add(html::span(" | "))
.add(html::a("Files").set("href", branch_name + "_files.html"))
.add(html::span(" | "))
.add(html::a("Refs").set("href", branch_name + "_refs.html"))
.add(html::span(" | "))
.add(html::a("README").set("href", "./"))
.add(html::span(" | "))
.add(html::a("LICENCE").set("href", "./"))
.add(html::span(" | "))
.add(dropdown));
ost << html::table();
}
void write_commit_table(std::ostream& ost, git2wrap::revwalk& rwalk)