darkhttpd icon indicating copy to clipboard operation
darkhttpd copied to clipboard

[FR] ability to use css

Open ITwrx opened this issue 2 years ago • 8 comments

It sure would be nice if i could specify a external style sheet with a --css option or maybe <link rel="stylesheet" href="darkhttpd.css"> could just be hardcoded in the source along with an empty (or basic) darkhttpd.css style sheet also included that could be modified by the user, if desired. I would like to specify body background, font size, colors, etc.

I saw a couple places in the darkhttpd source it looks like it might could "slide on in", but i don't know C, so i'm refraining from submitting a bad guess PR. :)

thanks

ITwrx avatar Feb 26 '23 00:02 ITwrx

CSS will load with <link rel="stylesheet" href="darkhttpd.css"> and darkhttpd.css in the same directory.

guest271314 avatar Mar 19 '23 19:03 guest271314

@guest271314 I guess i should have specified that i mean for the html that darkhttpd generates for serving whatever files happen to be in a directory, not serving my theoretical custom static html files. I'm using it for an alpine linux mirror, for example. i don't have any html it's serving. My understanding is that darkhttpd is generating it's own basic html to show the directories and package tarballs, and this FR asks that the <link rel="stylesheet" href="darkhttpd.css"> be added to that darkhttpd generation source code or a --css flag added.

ITwrx avatar Mar 19 '23 19:03 ITwrx

I guess i should have specified that i mean for the html that darkhttpd generates for serving whatever files happen to be in a directory

I'm not familiar with that option.

I was just reading the source code at https://github.com/emikulic/darkhttpd/blob/master/darkhttpd.c#L1530-L1579 however I don't see a way to serve that by passing options.

guest271314 avatar Mar 19 '23 19:03 guest271314

It looks like this is where the directory listing is generated https://github.com/emikulic/darkhttpd/blob/11d36de0a2c94f21270877a7f6ea0050f4b9a346/darkhttpd.c#L1966-L2056. In theory you should be able to include the CSS in the source code that generates the HTML in a <style> element, then compile darkhttpd.

guest271314 avatar Mar 19 '23 19:03 guest271314

i would rather the <link rel="stylesheet" href="darkhttpd.css"> be included in darkhttpd source, so that each user can just read the docs and add an optional darkhttpd.css. That's why i submitted an FR instead of just modifying my copy and moving on, assuming i could do it correctly since i don't write c. :) thanks

ITwrx avatar Mar 19 '23 20:03 ITwrx

You probably want href="/absolute/path.css" so that it also works from nested directories and not just the root.

This is starting to get into "darkhttpd is not intended to be a production webserver" territory though. Directory listings are meant to be quick and dirty so you can download one of a small number of files in a hurry. If you want stylized ones, at some point you should make your own and save them as a set of index.html files.

emikulic avatar Mar 20 '23 11:03 emikulic

sure, my <link> is really just an example to explain the FR. I know dir listings and the auto-generated html is supposed to be minimalist, and i can get behind that, but i can't predict these dirs, as they are pulled in from rsync'd remote source and just being able to control background color, font size, etc of the generated html would make a huge difference, with only the <link> being added to darkhttpd source. I think users would like it, but it's up to you of course.

ITwrx avatar Mar 20 '23 12:03 ITwrx