login

<     >

2022-02-26 21:26:15 (UTC-03:00)

Marcel Rodrigues <marcelgmr@gmail.com>

allow page limit configuration

diff --git a/app.lua b/app.lua
index a000ed4..f18b2b5 100644
--- a/app.lua
+++ b/app.lua
@@ -6,6 +6,7 @@ local lud = require "ludweb"
 git.init()
 
 local path = "/tmp/cogit"
+local limit = 20
 local groups = scan.scanrepos(path)
 
 local routes = {
@@ -33,8 +34,8 @@ local routes = {
     {"GET", "/group/([%w_-]+)/repo/([%w_-]+)/history/([%w_-]+)", function (req, gname, rname, first)
         local repo = groups[gname][rname]
         local commit = repo:commit(first)
-        local prev = repo:find_prev(commit:id(), 20)
-        local env = {gname=gname, rname=rname, bname=bname, commit=commit, prev=prev, first=first}
+        local prev = repo:find_prev(commit:id(), limit)
+        local env = {gname=gname, rname=rname, bname=bname, commit=commit, limit=limit, prev=prev, first=first}
         return lud.template.render_file("view/history.html", env)
     end},
 }

diff --git a/view/history.html b/view/history.html
index 911a798..ed3c8fe 100644
--- a/view/history.html
+++ b/view/history.html
@@ -8,7 +8,7 @@
   <p>Commits:</p>
   <ul>
     % set i = 0
-    % while $commit and $i < 20 do
+    % while $commit and $i < $limit do
     <li><a href="/group/{{$gname}}/repo/{{$rname}}/commit/{{$commit:id()}}">{{$commit:summary()}}</a></li>
       % set commit = $commit:parent()
       % set i = $i + 1