local utils = require("utils") local git = require("git_commands") ngx.say("") ngx.say("") local md2html = function(file) local formatted_command = string.format( "/usr/local/bin/md2html --github %s", file ) return utils.process(formatted_command) end print_table = function(t, l) l = l or 0 local n = 0 for i,v in pairs(t) do n = n + 1 break end if n > 0 then ngx.print("{\n") for i,v in pairs(t) do for i=0,l do ngx.print(" ") end ngx.print("",i,": ") if type(v) ~= "table" then if type(v) == "string" then ngx.print("\"") local s = v:gsub("&", "&"):gsub("<","<"):gsub(">",">") ngx.print(s) ngx.print("\"") else ngx.print(v) end else print_table(v,l+1) end ngx.print("\n") end for i=0,l-1 do ngx.print(" ") end ngx.print("}") else ngx.print("{}") end end local name = "ncurses-minesweeper" --local name = "lognestmonster" --local name = "auto-plow" --local name = "joshstock.in" local repo = "/home/josh/repos/"..name local commits_head = git.log(repo, "@", 10, 0, true) ngx.say("

"..name.." / master

") ngx.say("

Terminal game of Minesweeper, implemented in C with ncurses.

") ngx.say("

Log | Files | Refs | README | LICENSE

") ngx.say("") ngx.print("") ngx.print("") ngx.print("") ngx.print("") ngx.print("") ngx.print("") ngx.print("") ngx.print("") ngx.print("") ngx.print("") for i,commit in pairs(commits_head) do ngx.print("") ngx.print("") ngx.print("") ngx.print("") ngx.print("") ngx.print("") ngx.print("") ngx.print("") ngx.print("") ngx.say("") end ngx.say("
DateHashSubjectAuthorEmail+-GPG?
",utils.iso8601(commit.timestamp),"",commit.shorthash,"",commit.subject,"",commit.author,"",commit.email,"commit.diff.minus and "green;font-weight:bold" or "inherit","\">",commit.diff.plus,"commit.diff.plus and "red;font-weight:bold" or "inherit","\">",commit.diff.minus,"",commit.gpggood,"
") ngx.say("
") ngx.say("
README
") ngx.say(md2html(repo.."/README.md")) ngx.say("
") ngx.say("") ngx.exit(ngx.HTTP_OK)