jlong / serve

Serve is a small Rack-based web server and rapid prototyping framework for Web applications (specifically Rails apps). Serve is meant to be a lightweight version of the Views part of the Rails MVC. This makes Serve an ideal framework for prototyping Rails applications or creating simple websites. Serve has full support for Rails-style partials and layouts.
http://get-serve.com
Other
836 stars 90 forks source link

serve export overwrites html files without warning #36

Open rmetzler opened 13 years ago

rmetzler commented 13 years ago

I had a Compass project that I converted into a Serve project. This procedure left an index.html file inside the public folder.

When I start serve export it seems like it first renders everything to the target folder and then copies the public folder into target overwriting existing files inside the target folder.

I think there are several methods how to deal with this.

  1. the most simple approach would be to change the order of these two tasks
  2. there should be a warning whenever an existing file is overwritten
  3. there should be an interactive query for the user: "Overwrite? [Yn]"

I guess there are several other methods more for handling this problem. I would vote for 1 and could provide a patch if needed. Please tell me what you think.

jlong commented 13 years ago

I think this is the expected behavior. On a web server this would fail silently too because files in public would be served instead of files from the app. Or am I missing something?

rmetzler commented 13 years ago

When I go to http://localhost:4000/ serve shows views/index.html.erb and not public/index.html After exporting export/index.html is the same as public/index.html. It's just a little bit inconsistent and it fails silently.

jlong commented 13 years ago

Good point. :)

I think I can switch this around for Serve. Let me look into it.

jlong commented 13 years ago

There's not an easy way to do this. I'd have to rewrite the Rack directory indexing stuff... Hrmmm...

rmetzler commented 13 years ago

I didn't test it, but I would expect if you move line 21 of https://github.com/jlong/serve/blob/master/lib/serve/export.rb to the start of the method it should work.

jlong commented 13 years ago

That's true, but I want it to work that way. What I would like to do is get Serve to function the other way so that it mimics the functionality of both export and a normal Ruby deployment.

ntalbott commented 12 years ago

So the way you want it to work is that serve first renders the .html file, and only processes the template if the .html file doesn't exist?

jlong commented 12 years ago

Right, just like a regular Rack app.

jlong commented 12 years ago

Files in public should be served first, then if those URLs don't exist Serve should check the views directory.

ntalbott commented 12 years ago

Got it - will see what I can do about that.