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