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 | |
| 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')
| -rw-r--r-- | src/local/pager.nim | 2 | ||||
| -rw-r--r-- | src/server/loader.nim | 18 |
2 files changed, 14 insertions, 6 deletions
diff --git a/src/local/pager.nim b/src/local/pager.nim index 2132b6a2..d3382db9 100644 --- a/src/local/pager.nim +++ b/src/local/pager.nim @@ -2155,7 +2155,7 @@ proc saveTo(pager: Pager; data: LineDataDownload; path: string) = pager.loader.resume(data.outputId) data.stream.sclose() pager.lineData = nil - discard pager.gotoURL(newRequest(newURL("download:view").get), + discard pager.gotoURL(newRequest(newURL("about:downloads").get), history = false) else: pager.ask("Failed to save to " & path & ". Retry?").then( 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) |