2022-02-27 23:57:06 (UTC-03:00)
Marcel Rodrigues <marcelgmr@gmail.com>
simplify page titles and configure app name
diff --git a/app.lua b/app.lua index 85bef54..95f2ea9 100644 --- a/app.lua +++ b/app.lua @@ -64,6 +64,7 @@ local LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG = 0, 1, 2, 3 local path = arg[1] local conf = dofile(path.."/conf.lua") +local title = conf.title git.init() local groups = scan.scanrepos(path) @@ -93,7 +94,8 @@ local routes = { table.insert(gnames, gname) end end - return lud.template.render_file("view/home.html", {user=user, gnames=gnames}) + local env = {title=title, user=user, gnames=gnames} + return lud.template.render_file("view/home.html", env) end}, {"GET", "/login", function (req) @@ -144,7 +146,7 @@ local routes = { for rname in pairs(groups[gname]) do table.insert(rnames, rname) end - local env = {user=user, gname=gname, rnames=rnames} + local env = {title=title, user=user, gname=gname, rnames=rnames} return lud.template.render_file("view/group.html", env) end}, {"GET", "/group/([%w_-]+)/repo/([%w_-]+)", @@ -157,7 +159,7 @@ local routes = { local bnames = repo:branches() local tnames = repo:tags() local env = { - user=user, repo=repo, gname=gname, + title=title, user=user, repo=repo, gname=gname, rname=rname, bnames=bnames, tnames=tnames, } return lud.template.render_file("view/repo.html", env) @@ -172,7 +174,7 @@ local routes = { local commit = repo:commit(first) local prev = repo:find_prev(commit:id(), conf.limit) local env = { - user=user, gname=gname, rname=rname, bname=bname, + title=title, user=user, gname=gname, rname=rname, bname=bname, commit=commit, limit=conf.limit, prev=prev, first=first, } return lud.template.render_file("view/history.html", env) @@ -190,8 +192,8 @@ local routes = { local time_str = time_fmt(sig) local diff = repo:diff(commit, diff_cb) local env = { - user=user, gname=gname, rname=rname, bname=bname, commit=commit, - time_str=time_str, sig=sig, cid=cid, prev=prev, diff=diff, + title=title, user=user, gname=gname, rname=rname, bname=bname, + commit=commit, time_str=time_str, sig=sig, cid=cid, prev=prev, diff=diff, } return lud.template.render_file("view/commit.html", env) end}, @@ -216,7 +218,7 @@ local routes = { base = base .. "/" end local env = { - user=user, gname=gname, rname=rname, cid=cid, + title=title, user=user, gname=gname, rname=rname, cid=cid, path=path, base=base, parts=parts, node=node, } if node.type_ == "dir" then diff --git a/conf.lua b/conf.lua index 0332ecf..fe12e2e 100644 --- a/conf.lua +++ b/conf.lua @@ -7,6 +7,7 @@ local level_str = {"ERROR", "WARN", "INFO", "DEBUG"} local log_level = LOG_DEBUG return { + title = "cogit", port = 8080, limit = 20, -- page size, for pagination session_age = 2*60*60, -- login session duration in seconds diff --git a/view/commit.html b/view/commit.html index cdf216c..e7c15e6 100644 --- a/view/commit.html +++ b/view/commit.html @@ -2,7 +2,7 @@ <html> <head> <meta charset="utf-8"> - <title>cogit - {{$gname}} - {{$rname}} - {{$cid}}</title> + <title>{{$title}} - {{$rname}}:{{$cid}}</title> <style> #nav-bar { float: left; } #auth-bar { float: right; } diff --git a/view/dir.html b/view/dir.html index c53d6a6..e00f957 100644 --- a/view/dir.html +++ b/view/dir.html @@ -2,7 +2,7 @@ <html> <head> <meta charset="utf-8"> - <title>cogit - {{$gname}} - {{$rname}} - {{$cid}} - {{$path}}</title> + <title>{{$title}} - {{$rname}}:/{{$path}}</title> <style> #nav-bar { float: left; } #auth-bar { float: right; } diff --git a/view/file.html b/view/file.html index 1190b83..b1302df 100644 --- a/view/file.html +++ b/view/file.html @@ -2,7 +2,7 @@ <html> <head> <meta charset="utf-8"> - <title>cogit - {{$gname}} - {{$rname}} - {{$cid}} - {{$path}}</title> + <title>{{$title}} - {{$rname}}:/{{$path}}</title> <style> #nav-bar { float: left; } #auth-bar { float: right; } diff --git a/view/group.html b/view/group.html index 2d37c75..24c68f0 100644 --- a/view/group.html +++ b/view/group.html @@ -2,7 +2,7 @@ <html> <head> <meta charset="utf-8"> - <title>cogit - {{$gname}}</title> + <title>{{$title}} - {{$gname}} repos</title> <style> #nav-bar { float: left; } #auth-bar { float: right; } diff --git a/view/history.html b/view/history.html index 118229e..6263fd1 100644 --- a/view/history.html +++ b/view/history.html @@ -2,7 +2,7 @@ <html> <head> <meta charset="utf-8"> - <title>cogit - {{$gname}} - {{$rname}} - history</title> + <title>{{$title}} - {{$rname}} history</title> <style> #nav-bar { float: left; } #auth-bar { float: right; } diff --git a/view/home.html b/view/home.html index 74253d2..2698bb8 100644 --- a/view/home.html +++ b/view/home.html @@ -2,7 +2,7 @@ <html> <head> <meta charset="utf-8"> - <title>cogit</title> + <title>{{$title}}</title> <style> #nav-bar { float: left; } #auth-bar { float: right; } diff --git a/view/repo.html b/view/repo.html index b0b6808..6ec22be 100644 --- a/view/repo.html +++ b/view/repo.html @@ -2,7 +2,7 @@ <html> <head> <meta charset="utf-8"> - <title>cogit - {{$gname}} - {{$rname}}</title> + <title>{{$title}} - {{$rname}}</title> <style> #nav-bar { float: left; } #auth-bar { float: right; }