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 | 8472c38a70c97d06af90072a53cd9826238afbd5 |
parent | 7291b93a9bf785883cb4e0e5c372f7b488dfaba9 |
author | Dimitrije Dobrota < mail@dimitrijedobrota.com > |
date | Sat, 3 May 2025 09:42:47 +0200 |
Utilize common tag shorthands
M | source/document.cpp | | | +++++++++++++ --------------------------------------------------------------- |
M | source/startgit-index.cpp | | | + - |
M | source/startgit.cpp | | | +++++++++++++++++ --------------------------- |
3 files changed, 31 insertions(+), 91 deletions(-)
diff --git a/ source/document.cpp b/ source/document.cpp
@@ -20,70 +20,21 @@
void document::render(std::ostream& ost, const content_t& content) const
head {
title {m_title},
// Meta tags
meta {{
{"charset", "UTF-8"},
}},
meta {{
{"name", "author"},
{"content", m_author},
}},
meta {{
{"name", "description"},
{"content", m_desc},
}},
meta {{
{"content", "width=device-width, initial-scale=1"},
{"name", "viewport"},
}},
// Stylesheets
link {{
{"rel", "stylesheet"},
{"type", "text/css"},
{"href", args.resource_url + "/css/index.css"},
}},
link {{
{"rel", "stylesheet"},
{"type", "text/css"},
{"href", args.resource_url + "/css/colors.css"},
}},
metaUTF8 {},
metaName {"author", m_author},
metaName {"description", m_desc},
metaName {"viewport", "width=device-width, initial-scale=1"},
// Rss feed
!m_has_feed ? element {} : [&]() -> element
{
return link {{
{"rel", "alternate"},
{"type", "application/atom+xml"},
{"title", "RSS feed"},
{"href", m_relpath + "rss.xml"},
}};
}(),
linkStylesheet {args.resource_url + "/css/index.css"},
linkStylesheet {args.resource_url + "/css/colors.css"},
// Atom feed
!m_has_feed ? element {} : [&]() -> element
{
return link {{
{"rel", "alternate"},
{"type", "application/atom+xml"},
{"title", "Atom feed"},
{"href", m_relpath + "atom.xml"},
}};
}(),
m_has_feed ? element {
linkRss {"RSS feed", m_relpath + "rss.xml"},
linkAtom {"Atom feed", m_relpath + "atom.xml"},
} : element {},
// Icons
link {{
{"rel", "icon"},
{"type", "image/png"},
{"sizes", "32x32"},
{"href", args.resource_url + "/img/favicon-32x32.png"},
}},
link {{
{"rel", "icon"},
{"type", "image/png"},
{"sizes", "16x16"},
{"href", args.resource_url + "/img/favicon-16x16.png"},
}},
linkIcon {"32x32", args.resource_url + "/img/favicon-32x32.png"},
linkIcon {"16x16", args.resource_url + "/img/favicon-16x16.png"},
},
body {
input {{
@@ -127,8 +78,7 @@
void document::render(std::ostream& ost, const content_t& content) const
" color: var(--theme_red);"
"} .inline {"
" white-space: pre;"
"}"
},
"}"},
},
},
};
diff --git a/ source/startgit-index.cpp b/ source/startgit-index.cpp
@@ -27,7 +27,7 @@
hemplate::element write_table_row(const std::filesystem::path& repo_path)
const auto url = repo.get_name() + "/master/log.html";
return tr {
td {a {{{"href", url}}, repo.get_name()}},
td {aHref {url, repo.get_name()}},
td {repo.get_description()},
td {repo.get_owner()},
td {branch.get_commits()[0].get_time()},
diff --git a/ source/startgit.cpp b/ source/startgit.cpp
@@ -76,16 +76,16 @@
element page_title(
tr {
td {
"git clone ",
a {{{"href", repo.get_url()}}, repo.get_url()},
aHref {repo.get_url(), repo.get_url()},
},
},
tr {
td {
a {{{"href", relpath + "log.html"}}, "Log"},
aHref {relpath + "log.html", "Log"},
" | ",
a {{{"href", relpath + "files.html"}}, "Files"},
aHref {relpath + "files.html", "Files"},
" | ",
a {{{"href", relpath + "refs.html"}}, "Refs"},
aHref {relpath + "refs.html", "Refs"},
transform(
branch.get_special(),
[&](const auto& file)
@@ -97,7 +97,7 @@
element page_title(
return element {
" | ",
a {{{"href", relpath + filename}}, name},
aHref {relpath + filename, name},
};
}
),
@@ -122,7 +122,7 @@
element commit_table(const branch& branch)
return tr {
td {commit.get_time()},
td {a {{{"href", url}}, commit.get_summary()}},
td {aHref {url, commit.get_summary()}},
td {commit.get_author_name()},
td {commit.get_diff().get_files_changed()},
td {commit.get_diff().get_insertions()},
@@ -149,7 +149,7 @@
element files_table(const branch& branch)
return tr {
td {file.get_filemode()},
td {a {{{"href", url}}, path}},
td {aHref {url, path}},
td {size},
};
}
@@ -175,7 +175,7 @@
element branch_table(const repository& repo, const std::string& branch_name)
return tr {
td {name},
td {a {{{"href", url}}, branch.get_name()}},
td {aHref {url, branch.get_name()}},
td {last.get_time()},
td {last.get_author_name()},
};
@@ -239,7 +239,7 @@
element file_changes(const diff& diff)
return tr {
td {std::string(1, marker[delta->status])}, // NOLINT
td {a {{{"href", link}}, delta->new_file.path}},
td {aHref {link, delta->new_file.path}},
td {"|"},
td {
span {{{"class", "add"}}, std::string(add, '+')},
@@ -325,9 +325,9 @@
element file_diffs(const diff& diff)
{{"id", delta->new_file.path}},
"diff --git",
"a/",
a {{{"href", new_link}}, new_file},
aHref {new_link, new_file},
"b/",
a {{{"href", old_link}}, old_file},
aHref {old_link, old_file},
},
transform(delta.get_hunks(), diff_hunk),
};
@@ -347,7 +347,7 @@
element commit_diff(const commit& commit)
tbody {
tr {
td {b {"commit"}},
td {a {{{"href", url}}, commit.get_id()}},
td {aHref {url, commit.get_id()}},
},
commit.get_parentcount() == 0 ? element {} : [&]() -> element
{
@@ -356,7 +356,7 @@
element commit_diff(const commit& commit)
return tr {
td {b {"parent"}},
td {a {{{"href", purl}}, commit.get_parent_id()}},
td {aHref {purl, commit.get_parent_id()}},
};
}(),
tr {
@@ -364,10 +364,7 @@
element commit_diff(const commit& commit)
td {
commit.get_author_name(),
"<",
a {
{{"href", mailto}},
commit.get_author_email(),
},
aHref {mailto, commit.get_author_email()},
">",
},
},
@@ -611,15 +608,8 @@
void write_atom(
id {base_url + '/'},
updated {format_time_now()},
author {name {args.author}},
link {{
{"href", base_url + "/atom.xml"},
{"rel", "self"},
}},
link {{
{"href", args.resource_url},
{"rel", "alternate"},
{"type", "text/html"},
}},
linkSelf {base_url + "/atom.xml"},
linkAlternate {args.resource_url},
transform(
branch.get_commits(),
[&](const auto& commit)
@@ -631,7 +621,7 @@
void write_atom(
id {url},
updated {format_time(commit.get_time_raw())},
title {commit.get_summary()},
link {{{"href", url}}},
linkHref {url},
author {
name {commit.get_author_name()},
email {commit.get_author_email()},