Index

resty-gitweb / 1bf7bae

A git web interface for Lua/OpenResty (you're on it right now!)

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
1405 Mar 2021 00:231bf7baeAdd temporary commits pageJosh Stockin1950G

Blob @ resty-gitweb / pages / commit.lua

text/plain3155 bytesdownload raw
1-- resty-gitweb@pages/commit.lua
2-- List commit info
3
4-- Copyright (c) 2020 Joshua 'joshuas3' Stockin
5-- <https://git.joshstock.in/resty-gitweb>
6-- This software is licensed under the MIT License.
7
8local utils = require("utils/utils")
9local git = require("git/git")
10
11local builder = require("utils/builder")
12local tabulate = require("utils/tabulate")
13local nav = require("utils/nav")
14
15local _M = function(repo, repo_dir, commit_hash)
16
17 -- Latest Commit table
18 local commit = git.commit(repo_dir, commit_hash)
19
20 local build = builder:new()
21
22 -- Breadcrumb navigation and repository description
23 local breadcrumb_nav = {
24 {string.format("/%s", repo.name), repo.name},
25 {string.format("/%s/tree/%s", repo.name, commit_hash), commit.shorthash},
26 }
27 build{
28 build.h2{nav(breadcrumb_nav, " / ")},
29 build.p{repo.description}
30 }
31
32 -- Navigation links
33 local navlinks = {
34 {string.format("/%s/download", repo.name), "Download"},
35 {string.format("/%s/refs", repo.name), "Refs"},
36 {string.format("/%s/log/%s", repo.name, commit_hash), "Commit Log"},
37 {string.format("/%s/tree/%s", repo.name, commit_hash), "Files"}
38 }
39
40 for _, special in pairs(repo.specialfiles) do -- create nav items for special files
41 local split = string.split(special, " ")
42 table.insert(navlinks, {
43 string.format("/%s/blob/%s/%s", repo.name, commit_hash, split[2]),
44 split[1]
45 })
46 end
47
48 build{
49 build.div{class="nav", nav(navlinks)},
50 build.h3{"Latest Commit"}
51 }
52
53 local commits_table_data = {}
54 commits_table_data.class = "log"
55 commits_table_data.headers = {
56 {"count", [[<span class="q" title="Commit number/count">{#}</span>]]},
57 {"timestamp", "Time"},
58 {"shorthash", "Hash"},
59 {"subject", "Subject"},
60 {"author", "Author"},
61 {"changed_files", [[<span class="q" title="# of files changed">#</span>]]},
62 {"changed_plus", [[<span class="q" title="Insertions">(+)</span>]]},
63 {"changed_minus", [[<span class="q" title="Deletions">(-)</span>]]},
64 {"gpggood", [[<span class="q" title="GPG signature status
65
66G: Good (valid) signature
67B: Bad signature
68U: Good signature with unknown validity
69X: Good signature that has expired
70Y: Good signature made by an expired key
71R: Good signature made by a revoked key
72E: Signature can't be checked (e.g. missing key)
73N: No signature">GPG?</span>]]}
74 }
75 commits_table_data.rows = {}
76
77 table.insert(commits_table_data.rows, {
78 git.count(repo_dir, commit.hash),
79 utils.iso8601(commit.timestamp),
80 string.format([[<a href="/%s/commit/%s">%s</a>]], repo.name, commit.hash, commit.shorthash),
81 utils.html_sanitize(commit.subject),
82 string.format([[<a href="mailto:%s">%s</a>]], commit.email, utils.html_sanitize(commit.author)),
83 commit.diff.num,
84 commit.diff.plus,
85 commit.diff.minus,
86 commit.gpggood
87 })
88
89 build{tabulate(commits_table_data)}
90
91
92 return build
93end
94
95return _M
96