1 | -- resty-gitweb@init.lua |
2 | -- Preloads scripts and config for OpenResty workers |
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 |
|
8 | local git = require "git/git" |
9 |
|
10 | local pages_blob = require "pages/blob" |
11 | local pages_commit = require "pages/commit" |
12 | local pages_download = require "pages/download" |
13 | local pages_index = require "pages/index" |
14 | local pages_log = require "pages/log" |
15 | local pages_row = require "pages/raw" |
16 | local pages_refs = require "pages/refs" |
17 | local pages_tree = require "pages/tree" |
18 |
|
19 | local builder = require "utils/builder" |
20 | local nav = require "utils/nav" |
21 | local parse_uri = require "utils/parse_uri" |
22 | local tabulate = require "utils/tabulate" |
23 | local utils = require "utils/utils" |
24 |
|
25 | -- Load YAML configuration |
26 | local _lyaml = require "lyaml" |
27 |
|
28 | -- TODO: Read config file location from nginx env settings |
29 | local _yaml_config_file = io.open("/home/josh/repos/joshstock.in/resty-gitweb.yaml") |
30 | yaml_config = _lyaml.load(_yaml_config_file:read("*a")) |
31 | _yaml_config_file:close() |
32 |
|
33 | local ffi = require("ffi") |
34 |
|
35 | ffi.include = function(header) |
36 | local p = io.popen("echo '#include <"..header..">' | gcc -E -") |
37 | local c = {} |
38 | while true do |
39 | local line = p:read() |
40 | if line then |
41 | if not line:match("^#") then |
42 | table.insert(c, line) |
43 | end |
44 | else |
45 | break |
46 | end |
47 | end |
48 | p:close() |
49 | ffi.cdef(table.concat(c, "\n")) |
50 | end |
51 |
|
52 | ffi.include("git2.h") |
53 | git2 = ffi.load("git2") |
54 | git2.git_libgit2_init() |
55 |
|