On Wednesday, August 8, 2012 4:58:27 PM UTC+2, Farski wrote:
>
> Just out of curiosity, do you have any examples of multiple extensions 
> where those other than the root extension aren't a compression or archive 
> format? I ask in the context of this being considered a bad practice. To 
> me, naming something anImage.jpg.zip.tar.gz means I started with a JPEG, 
> and then stuck that inside a zip, then put the zip in a tar, then the tar 
> in a gzip. Those "extra" extensions are all container formats, so it makes 
> sense to show that there's a file of a different format nested inside them. 
> If things become more arbitrary, say anImage.jpg.txt, which just returns 
> the JPEG's binary data as text/plain, that doesn't really hold up for me. 
> That seems presentational, not a text file containing a jpeg.
>
> If the only time that multiple extensions ever come into play is 
> archive/compression, middleware still seems like a good option. The URL 
> helpers could remain fairly consistent (eg, resource_path(@resource, 
> :format => [:xml, :zip]) and the additional functionality be transparent. 
> Rails really doesn't need to know it's happening as long as it's generating 
> correct URLs. If zipping is far and away the most likely case for this 
> (which I think is likely), resource_path(@resource, :zipped => :xml) may 
> even make sense.
>
> Basically, for all the examples I've thought of, anytime multiple 
> extensions are being used appropriately, the root extension is the only one 
> that it makes sense to Rails to actually handle. But if there are examples 
> to indicate otherwise I'd be interested to hear them.
>
> The only things I've gotten close on is like:
> /runs/1 => web view of a GPS recorded running route
> /runs/1.json => JSON version
> /runs/1.xml => XML version
> /runs/1.xml.gpx => XML that adheres to GPX standard
> /runs/1.xml.tcx => XML that adheres to TCX standard
> But those last two, to me, are simply improperly name.
>

I agree that it looks like a good solution to make middleware execute such 
straightforward tasks as compression, and only extend Rails URL helpers.  I 
am not sure i would be able to do something about this myself, looks like 
more work than just changing the parsing rules.

All examples of double extensions i can think of would be of the following 
two types:

1. a file foo.ext1.ext2 after some processing allows to recover the file 
foo.ext1.
Examples: foo.csv.zip, foo.tar.gz, foo.css.sass, foo.html.erb

2. the first extension is a custom one, and the second is a "legal" one.
Examples: foo.source.txt, foo.miminized.js

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-core/-/_B_uIfTcdYQJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to