1 | # lua-gitweb |
2 |
|
3 | A git web client for Lua/OpenResty, similar to stagit. |
4 |
|
5 | ## Requirements |
6 |
|
7 | Lua modules (Lua 5.1/LuaJIT 2.1.0/OpenResty LuaJIT compatible, accessible from Lua path/cpath): |
8 |
|
9 | | Module | Description | |
10 | | ------ | ----------- | |
11 | | [lfs](https://github.com/keplerproject/luafilesystem) | Filesystem API | |
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) | 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]/lua-gitweb`. (In reality it doesn't matter where, |
33 | as long as it's accessible.) |
34 |
|
35 | 2. Copy your config file (`repos.yaml`) to `/etc/[SITE]/repos.yaml` (or somewhere |
36 | else). |
37 |
|
38 | 3. Add the following near the top (`main` context, outside of any blocks) of your |
39 | OpenResty/nginx configuration file: |
40 | ``` |
41 | env LUA_GITWEB; # Script won't run without this |
42 | env LUA_GITWEB_ENV=PROD; # PROD for Production, DEV for Development. DEV by default. |
43 | env LUA_GITWEB_CONFIG=/etc/[SITE]/repos.yaml; # Wherever you put your configuration file |
44 | ``` |
45 |
|
46 | 4. Add the following to the `http` block in your OpenResty/nginx configuration |
47 | file: |
48 | ``` |
49 | lua_package_path ";;/srv/[SITE]/lua-gitweb/?.lua"; # Add lua-gitweb to your Lua package path |
50 | init_by_lua_file /srv/[SITE]/lua-gitweb/init.lua; # Initialize modules for nginx workers |
51 | ``` |
52 |
|
53 | 5. And in whichever `location` block you wish to serve content: |
54 | ``` |
55 | content_by_lua_file /srv/[SITE]/lua-gitweb/app.lua; |
56 | ``` |
57 |
|
58 | 6. Restart OpenResty/nginx |
59 |
|
60 | ## Copyright and Licensing |
61 |
|
62 | This package is copyrighted by [Joshua 'joshuas3' |
63 | Stockin](https://joshstock.in/) and licensed under the [MIT License](LICENSE). |
64 |
|
65 | <<https://joshstock.in>> | josh@joshstock.in | joshuas3#9641 |
66 |
|