New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow file_server browse
templates to use the same functions as templates
#3637
Comments
Hi, new contributor here 👋. I can work on this issue. |
Cool! Go for it @divbhasin 😄 |
Here is what I am thinking: I need to make the Am I on the right track @francislavoie? |
Yeah, that sounds about right. Maybe the |
Hmm, this is tricky though because in order to support of all of This will need more consideration/discussion; I think there'll need to be some sort of new function or method that is exported to wrap all the unexported logic needed for this, without having to create a whole HTTP handler or something. |
@mholt yeah I have been struggling with how to incorporate the Templates type into browse. |
Until this is resolved, what's the best workaround? A fork? A Caddy module? Thanks. |
@0xbzho I think this one is just waiting for a proper PR. If you have the capability to make a working fork or a functionally equivalent module, maybe just send a PR. |
There's an open but incomplete PR here: #3982 If you wish to help finish it, feel free to contribute. |
FYI all, #3982 (the PR) is closed due to inactivity. |
Hi @francislavoie and @princemaple , I can help on this, I actually already have patches locally. If this feature is still needed, I can raise a PR in a few days. I have been working with Caddy in my recent project. |
Yes, PRs welcome 👍 |
Hi @francislavoie, going to provide the detailed test cases done on the PR and the test caddyfile soon. |
|
|
I'm not a maintainer :) Just a random guy patiently waiting on this feature. |
@mholt @francislavoie I tested with both html & json modes, also included a test on the templates plugin. |
See the discussion here: https://caddy.community/t/v2-http-handlers-templates-functions-in-file-server-browse-template/9214
The
file_server
directive has abrowse
option which enables a directory index to be served when a directory is requested. By default, this index is rendered using a template which can be found in the code. The default can be overridden with a template provided by the user.It seems that the
file_server browse
template doesn't use the same code paths as thetemplates
directive, which means that the functions documented here cannot also be used.The code should be refactored such that the logic for the templates is shared between these two such that all the template functions Caddy provides works both for the general templates and for the file server directory index.
The text was updated successfully, but these errors were encountered: