1 | # resty-gitweb |
2 |
|
3 | A git web interface for Lua/OpenResty. |
4 |
|
5 | ## Requirements |
6 |
|
7 | Lua modules (Lua 5.1/LuaJIT 2.1.0/OpenResty LuaJIT compatible, accessible from |
8 | Lua path/cpath): |
9 |
|
10 | | Module | Description | |
11 | | ------ | ----------- | |
12 | | [lyaml](https://github.com/gvvaughan/lyaml) | Reads and parses YAML config files | |
13 | | [puremagic](https://github.com/wbond/puremagic) | MIME type by content, used in blob rendering | |
14 | | [etlua](https://github.com/leafo/etlua) | Embedded Lua templating (for HTML rendering) | |
15 |
|
16 | Other command line tools (installed on system path, accessible from shell): |
17 |
|
18 | | Program | Description | |
19 | | ------- | ----------- | |
20 | | [md4c](https://github.com/mity/md4c) (md2html) | Renders GitHub flavored Markdown | |
21 | | [highlight](http://www.andre-simon.de/doku/highlight/en/highlight.php) | Syntax highlighting in HTML format | |
22 |
|
23 | Linkable Libraries (installed on system path, accessible with LuaJIT's C FFI): |
24 |
|
25 | | Library | Description | |
26 | | ------- | ----------- | |
27 | | [libgit2](https://github.com/libgit2/libgit2) | Dynamically linkable C API for Git | |
28 |
|
29 | ## Using |
30 |
|
31 | 1. Copy this directory with its scripts to a place OpenResty/nginx workers have |
32 | access, such as `/srv/[SITE]/resty-gitweb`. (In reality it doesn't matter |
33 | where, as long as it's accessible.) |
34 |
|
35 | 2. Copy your config file (`resty-gitweb.yaml`) to |
36 | `/etc/[SITE]/resty-gitweb.yaml` (or somewhere else) |
37 |
|
38 | 3. Add the following near the top (`main` context, outside of any blocks) of |
39 | your OpenResty/nginx configuration file: |
40 |
|
41 | ``` |
42 | # resty-gitweb won't run without this |
43 | env RESTY_GITWEB; |
44 | |
45 | # PROD for Production, DEV for Development. DEV by default. |
46 | env RESTY_GITWEB_ENV=PROD; |
47 | |
48 | # Wherever you put your configuration file |
49 | env RESTY_GITWEB_CONFIG=/etc/[SITE]/resty-gitweb.yaml; |
50 | ``` |
51 |
|
52 | 4. Add the following to the `http` block in your OpenResty/nginx configuration |
53 | file: |
54 |
|
55 | ``` |
56 | # Add resty-gitweb to your Lua package path |
57 | lua_package_cpath "/usr/local/lib/lua/5.1;;" |
58 | lua_package_path "/usr/local/share/lua/5.1;/srv/[SITE]/resty-gitweb/?.lua;;"; |
59 | |
60 | # Initialize modules for nginx workers |
61 | init_by_lua_file /srv/[SITE]/resty-gitweb/init.lua; |
62 | ``` |
63 |
|
64 | 5. And in whichever `location` block you wish to serve content: |
65 |
|
66 | ``` |
67 | # Delegate request to OpenResty through resty-gitweb app script |
68 | content_by_lua_file /srv/[SITE]/resty-gitweb/app.lua; |
69 | ``` |
70 |
|
71 | 6. Reload OpenResty/nginx to update config |
72 |
|
73 | ## OpenResty or nginx? |
74 |
|
75 | Note that I use "OpenResty/nginx" instead of just OpenResty; while you can just |
76 | install and use the pre-built |
77 | [OpenResty](https://openresty.org/en/download.html) package, you could actually |
78 | use nginx with only a few added OpenResty components. These are the only |
79 | OpenResty components you actually need to |
80 | [compile](https://www.nginx.com/resources/wiki/extending/compiling/) to use |
81 | this package: |
82 |
|
83 | #### nginx modules |
84 |
|
85 | * [lua-nginx-module](https://github.com/openresty/lua-nginx-module) |
86 |
|
87 | #### Lua libraries |
88 |
|
89 | (run `sudo make all install LUA_VERSION=5.1` for each) |
90 |
|
91 | * [lua-resty-core](https://github.com/openresty/lua-resty-core) |
92 | * [lua-resty-shell](https://github.com/openresty/lua-resty-shell) |
93 | * [lua-resty-lrucache](https://github.com/openresty/lua-resty-lrucache) |
94 | * [lua-resty-signal](https://github.com/openresty/lua-resty-signal) |
95 | * [lua-tablepool](https://github.com/openresty/lua-tablepool) |
96 |
|
97 | Note that lua-nginx-module is the only nginx module that needs to be installed |
98 | with nginx compatibility. The other dependencies just need to be installed on |
99 | your Lua path/cpath. **If you're compiling OpenResty components yourself, you |
100 | may need to build them with OpenResty's |
101 | [branch](https://github.com/openresty/luajit2) of LuaJIT 2.1.0 instead of the |
102 | original.** |
103 |
|
104 | (The full OpenResty package has far more precompiled OpenResty components, so |
105 | you may just want to use that if resty-gitweb isn't the only thing you want to |
106 | use OpenResty for.) |
107 |
|
108 | ## Copyright and Licensing |
109 |
|
110 | This package is copyrighted by [Joshua 'joshuas3' |
111 | Stockin](https://joshstock.in/) and licensed under the [MIT License](LICENSE). |
112 |
|
113 | <<https://joshstock.in>> | josh@joshstock.in | joshuas3#9641 |
114 |
|