kenichi / angelo

Sinatra-like DSL for Reel that supports WebSockets and SSE
Other
303 stars 23 forks source link

Multiple public dirs #36

Closed mighe closed 9 years ago

mighe commented 9 years ago

I need to serve static files from two different folders.

Here is my idea:

The biggest issue is that the method public_dir, when used as an accessor, has to return an array: to solve it I'd implement a couple of new methods called send_public_file(file_name) and public_file?(file_name), that way it's unlikely that a user will use public_dir directly in his/her code.

What do you think? Since I need it I'm going to implement it immediately, if you think it is a valuable feature you will have a pull request in a couple of days

mighe commented 9 years ago

Here the first implementation, but I think there's still a inconsistency:

public_dir 'my_dir' returns [ root/my_dir ], making hard to do something like public_dir( ['other_dir'] + public_dir) to prepend a new folder.

Any ideas? :smile_cat:

kenichi commented 9 years ago

hrm, seems pretty complex. i don't think sinatra does this? maybe something like symlinks can work?

i have an angelo app running behind nginx and nginx is configured to serve "public" files so that the request doesn't even hit the angelo app - i imagine nginx could serve more than one with a bit more config... but you probably have a different environment.

can you help me understand the requirements a bit better?

mighe commented 9 years ago

Our app will be deployed in many systems, sharing a great number of html and js files; every system could have "custom" files, for example a css that "overrides" the default one or a different html view. The idea is to keep the common files in a directory and the custom ones in another directory.

Probably you're right: I could use Angelo to manage websockets and the api, while serving static files with another server, without screwing up Angelo for a very specific scenario like mine.

kenichi commented 9 years ago

@mighe see recent issue about sinatra-multiroute and thoughts of "angelo-contrib"; if this is something you think would be a good fit as a plugin, go ahead and reopen.