svenstaro/miniserve

--title flag also changes the wget command

Yusuto opened this issue · 2 comments

When changing the title using --title, the value that title is set to will also be set as the domain name that the wget command generated and displayed using the --show-wget-footer flag. That means that if I set the title to for example »Star«, that the command displayed at the bottom would now be wget -r -c -nH -np --cut-dirs=0 -R "index.html*" --ask-password --user user "http://Star/?raw=true", I don't think it's intended to be like that.

Instead there should be my IP-Address (and port) there, or a domain name, right? I'm not sure if miniserve can even know that, so maybe there should be another flag for that?

I think I have an idea of how to implement this now, the link is formed through the breadcrumbs that listing.rs passes to the page function in renderer.rs. The first element of this path is set to either the title, or if it is missing, to the host address retrieved from the request. The former is what we want for the page title and the heading, but for the wget command we definitely want the host.

I want to implement it without it being a botch or so, but I'm very unsure how exactly to do that. If it were my program I think I'd either make breadcrumbs always use the title if available and in the wget footer, swap the title for the host, or the other way around, but I'm very unsure what is better. The former seems better because it seems like the breadcrumb names are mainly used for displaying them to the user, but then the latter would also seem reasonable because then all the names strung together with slashes in between and a http:// at the front would make a link together.

Does anyone have an idea which of the two would be better?

(Also I clicked the wrong button, Sorry if anyone got E-mail spammed from this)

I discovered this literally a minute after I wrote this, I can just use the abs_url passed to the page function to pass to wget_footer, instead of passing title_path. With some small changes it works just fine! I'm not sure if that counts as a botch though, but I think it should be fine?