diff options
| author | bptato <nincsnevem662@gmail.com> | 2025-01-30 18:45:54 +0100 |
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2025-01-30 19:10:42 +0100 |
| commit | 6131db458fc1d0f8faf17ded996ae25092af8900 (patch) | |
| tree | 2f4276472fbe7abbdd6f42a00d4d0d5b86e3dfab /src/server | |
| parent | 52aba81c301cb4db3a9c34ca2aa285c407d1d848 (diff) | |
| download | chawan-6131db458fc1d0f8faf17ded996ae25092af8900.tar.gz | |
about: move to loader
This means we can now use about:downloads for downloads.
Plus it shaves off some ks from the distribution.
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/loader.nim | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/server/loader.nim b/src/server/loader.nim index 2faadd3a..b8eb0c55 100644 --- a/src/server/loader.nim +++ b/src/server/loader.nim @@ -1180,10 +1180,15 @@ proc parseDownloadActions(ctx: LoaderContext; s: string): seq[DownloadAction] = result.sort(proc(a, b: DownloadAction): int = return cmp(a.n, b.n), Descending) -proc loadDownload(ctx: LoaderContext; handle: InputHandle; request: Request) = +proc loadAbout(ctx: LoaderContext; handle: InputHandle; request: Request) = let url = request.url case url.pathname - of "view": + of "blank": + ctx.loadDataSend(handle, "", "text/html") + of "chawan": + const body = staticRead"res/chawan.html" + ctx.loadDataSend(handle, body, "text/html") + of "downloads": if request.httpMethod == hmPost: # OK/STOP/PAUSE/RESUME clicked if request.body.t != rbtString: @@ -1200,7 +1205,7 @@ proc loadDownload(ctx: LoaderContext; handle: InputHandle; request: Request) = <body> <h1 align=center>Download List Panel</h1> <hr> -<form method=POST action=download:view> +<form method=POST action=about:downloads> <hr> <pre> """ @@ -1227,6 +1232,9 @@ proc loadDownload(ctx: LoaderContext; handle: InputHandle; request: Request) = </body> """ ctx.loadDataSend(handle, body, "text/html") + of "license": + const body = staticRead"res/license.md" + ctx.loadDataSend(handle, body, "text/markdown") else: handle.rejectHandle(ceInvalidURL, "invalid download URL") @@ -1265,8 +1273,8 @@ proc loadResource(ctx: LoaderContext; client: ClientHandle; handle.close() of "data": ctx.loadData(handle, request) - of "download": - ctx.loadDownload(handle, request) + of "about": + ctx.loadAbout(handle, request) else: prevurl = request.url case ctx.config.uriMethodMap.findAndRewrite(request.url) |