-- resty-gitweb@pages/commit.lua -- List commit info -- Copyright (c) 2020 Joshua 'joshuas3' Stockin -- -- This software is licensed under the MIT License. local utils = require("utils/utils") local git = require("git/git") local builder = require("utils/builder") local tabulate = require("utils/tabulate") local nav = require("utils/nav") local _M = function(repo, repo_dir, commit_hash) -- Latest Commit table local commit = git.commit(repo_dir, commit_hash) local build = builder:new() -- Breadcrumb navigation and repository description local breadcrumb_nav = { {string.format("/%s", repo.name), repo.name}, {string.format("/%s/tree/%s", repo.name, commit_hash), commit.shorthash}, } build{ build.h2{nav(breadcrumb_nav, " / ")}, build.p{repo.description} } -- Navigation links local navlinks = { {string.format("/%s/download", repo.name), "Download"}, {string.format("/%s/refs", repo.name), "Refs"}, {string.format("/%s/log/%s", repo.name, commit_hash), "Commit Log"}, {string.format("/%s/tree/%s", repo.name, commit_hash), "Files"} } for _, special in pairs(repo.specialfiles) do -- create nav items for special files local split = string.split(special, " ") table.insert(navlinks, { string.format("/%s/blob/%s/%s", repo.name, commit_hash, split[2]), split[1] }) end build{ build.div{class="nav", nav(navlinks)}, build.h3{"Latest Commit"} } local commits_table_data = {} commits_table_data.class = "log" commits_table_data.headers = { {"count", [[{#}]]}, {"timestamp", "Time"}, {"shorthash", "Hash"}, {"subject", "Subject"}, {"author", "Author"}, {"changed_files", [[#]]}, {"changed_plus", [[(+)]]}, {"changed_minus", [[(-)]]}, {"gpggood", [[GPG?]]} } commits_table_data.rows = {} table.insert(commits_table_data.rows, { git.count(repo_dir, commit.hash), utils.iso8601(commit.timestamp), string.format([[%s]], repo.name, commit.hash, commit.shorthash), utils.html_sanitize(commit.subject), string.format([[%s]], commit.email, utils.html_sanitize(commit.author)), commit.diff.num, commit.diff.plus, commit.diff.minus, commit.gpggood }) build{tabulate(commits_table_data)} return build end return _M