Add the ability to dynamically re-assign the static "folder" (although I realised, I can use symlink as workaround)
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 12.5k
- Forks
- 2.1k
- PR merge metrics
- No merged PRs in 30d
Description
We can set the public "folder" via set such as:
set :public_folder, __dir__ + '/static'
I would like to change the public folder, specifically to serve some video files that
are accessed only via /video/.
(I suppose I could use symlinks to the public "folder" but I find it more elegant to just
re-assign the public "folder" directve.)
Right now I am not sure how this can be done. I thought about doing so within the
route, but set() does not work there, as it only works on the toplevel. Could this
functionality be added, and also documented in the official sinatra tutorial?
I'd like to use another public directory depending on which sub-functionality
is to be used, e. g. one directory for when working with .pdf files, another one
for when working with multimedia files and so forth.
Edit: Hmm, symlinks work, so I have a workaround, even though it is not very
elegant. It works on Linux, though, not sure if that would work on windows.
So I'd still have that use case on windows. Another alternative is to probably
just set the public directory to the root of the filesystem or where I keep
those video files (e. g. /home/x/video/ also on windows, or some other
subdirectory). Not elegant but I guess this here is semi-solved.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing Sinatra's public_folder configuration and the static-file handling used by routes. Define how reassignment should work during request handling, cover the behavior with tests, and update the official tutorial if the feature is accepted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend, web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100