You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Sergiu Dumitriu <se...@gmail.com> on 2012/01/25 19:01:35 UTC

MIME type for velocity templates

Is there a recommended MIME type that should be used for .vm files? I 
found text/velocity on http://www.filesuffix.com/extension/vm.html but 
I'd like to get an official opinion.
-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: MIME type for velocity templates

Posted by Claude Brisson <cl...@renegat.net>.
Concerning filename extensions, ".vhtml" is probably better for the SEO
black magic than ".vm".

For the MIME type, you generally only need it to characterize the type
of the generated content (that is, text/html, text/plain,
text/xml ...).

I guess there would indeed be situations where you need to specify the
MIME type of raw templates. I agree that text/x-velocity or, better,
text/x-apache-velocity would be fine.


  Claude

On Wed, 25 Jan 2012 12:21:23 -0600
Barbara Baughman <ba...@utdallas.edu> wrote:

> I general use the ".vm" file extension to distinguish velocity
> templates from other kinds of text files.  However, I'm sure Velocity
> itself doesn't care about the file extension and everyone uses what
> they please.
> 
> Barbara Baughman
> Systems Analyst
> Information Security
> 972-883-2157
> 
> 
> On 1/25/12 12:01 PM, Sergiu Dumitriu wrote:
> > Is there a recommended MIME type that should be used for .vm files?
> > I found text/velocity on
> > http://www.filesuffix.com/extension/vm.html but I'd like to get an
> > official opinion.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: MIME type for velocity templates

Posted by Barbara Baughman <ba...@utdallas.edu>.
I general use the ".vm" file extension to distinguish velocity templates 
from other kinds of text files.  However, I'm sure Velocity itself 
doesn't care about the file extension and everyone uses what they please.

Barbara Baughman
Systems Analyst
Information Security
972-883-2157


On 1/25/12 12:01 PM, Sergiu Dumitriu wrote:
> Is there a recommended MIME type that should be used for .vm files? I 
> found text/velocity on http://www.filesuffix.com/extension/vm.html but 
> I'd like to get an official opinion.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: MIME type for velocity templates

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Greg,

On 1/31/12 11:10 AM, Greg Thomas wrote:
> On 31 January 2012 15:48, Christopher Schultz
> <ch...@christopherschultz.net> wrote:
>> Nathan,
>>
>> On 1/25/12 1:16 PM, Nathan Bubna wrote:
>>> text/velocity sounds fine to me.  this isn't something that i recall
>>> coming up previously, so i'm pretty sure there's no official opinion.
>>
>> Why not text/plain?
> 
> It used to be the case that IE, on seeing a text/plain MIME type,
> would completely ignore the MIME type and guess a format based on the
> filename of the download in question.

I thought it did content-sniffing:

http://msdn.microsoft.com/en-us/library/ie/ms775148%28v=vs.85%29.aspx
http://blogs.msdn.com/b/ie/archive/2005/02/01/364581.aspx

> Later versions of IE are streets ahead thatn the older versions in
> many ways so hopefully this mis-feature has been corrected, but I'd
> be wary of serving any file with a text/plain MIME type unless it was
> called something.txt or similar.

I make it a point to always have the template itself (or, usually, the
servlet handling the incoming request -- like VelocityViewServlet, etc.)
set the Content-Type (and the encoding as well).

-chris


Re: MIME type for velocity templates

Posted by Greg Thomas <gr...@gmail.com>.
On 31 January 2012 15:48, Christopher Schultz
<ch...@christopherschultz.net> wrote:
> Nathan,
>
> On 1/25/12 1:16 PM, Nathan Bubna wrote:
>> text/velocity sounds fine to me.  this isn't something that i recall
>> coming up previously, so i'm pretty sure there's no official opinion.
>
> Why not text/plain?

It used to be the case that IE, on seeing a text/plain MIME type,
would completely ignore the MIME type and guess a format based on the
filename of the download in question. Later versions of IE are streets
ahead thatn the older versions in many ways so hopefully this
mis-feature has been corrected, but I'd be wary of serving any file
with a text/plain MIME type unless it was called something.txt or
similar.

Greg

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: MIME type for velocity templates

Posted by Sergiu Dumitriu <se...@xwiki.com>.
On 01/31/2012 11:00 AM, Christopher Schultz wrote:
> Nathan,
>
> On 1/31/12 10:52 AM, Nathan Bubna wrote:
>> On Tue, Jan 31, 2012 at 7:48 AM, Christopher Schultz
>> <ch...@christopherschultz.net>  wrote:
>>> Nathan,
>>>
>>> On 1/25/12 1:16 PM, Nathan Bubna wrote:
>>>> text/velocity sounds fine to me.  this isn't something that i recall
>>>> coming up previously, so i'm pretty sure there's no official opinion.
>>>
>>> Why not text/plain?
>>
>> If you you are serving up plain text, sure, why not?
>
> I thought the OP was asking about the .vm files themselves. If you
> request a .vm file and you just get the source, then it's text/plain. If
> you are evaluating the template and returning something, then it's up to
> the application: I use Velocity to generate plain text, XHTML, SVG, etc.
> Each of these applications needs a different MIME type that can't be
> predicted simply by looking at the extension of the template (which is
> pretty much always .vm).
>
>> You can use
>> plain text as a template, or almost plain text.  But what if they are
>> serving up an un-rendered template that has enough VTL directives in
>> it to clearly not be plain text.  Wouldn't that seem like a more
>> fitting place for text/x-velocity?  I was just assuming the mime type
>> was for a template itself, not the rendered contents of a template. :)
>
> Yeah, me too. But what makes text "plain"? It's just nothing special,
> right? I've seen MIME types for Java source that are both text/plain and
> text/x-java.

Yep, the question is about downloading the .vm files themselves, not 
about the rendering result.

Considering all the answers, I'll go with text/x-velocity. Given that 
most of the templates contain a mixture of Velocity code and HTML 
markup, it would make sense to go for a neutral MIME type, like 
text/plain, but I feel that the HTML is just part of the output. Does a 
Java file full of String concatenation, where the strings are XML 
markup, warrant an application/xml MIME type just because it has more 
than 50% XML in it?

Thanks everyone for your answers.
-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: MIME type for velocity templates

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Nathan,

On 1/31/12 10:52 AM, Nathan Bubna wrote:
> On Tue, Jan 31, 2012 at 7:48 AM, Christopher Schultz
> <ch...@christopherschultz.net> wrote:
>> Nathan,
>>
>> On 1/25/12 1:16 PM, Nathan Bubna wrote:
>>> text/velocity sounds fine to me.  this isn't something that i recall
>>> coming up previously, so i'm pretty sure there's no official opinion.
>>
>> Why not text/plain?
> 
> If you you are serving up plain text, sure, why not?

I thought the OP was asking about the .vm files themselves. If you
request a .vm file and you just get the source, then it's text/plain. If
you are evaluating the template and returning something, then it's up to
the application: I use Velocity to generate plain text, XHTML, SVG, etc.
Each of these applications needs a different MIME type that can't be
predicted simply by looking at the extension of the template (which is
pretty much always .vm).

> You can use
> plain text as a template, or almost plain text.  But what if they are
> serving up an un-rendered template that has enough VTL directives in
> it to clearly not be plain text.  Wouldn't that seem like a more
> fitting place for text/x-velocity?  I was just assuming the mime type
> was for a template itself, not the rendered contents of a template. :)

Yeah, me too. But what makes text "plain"? It's just nothing special,
right? I've seen MIME types for Java source that are both text/plain and
text/x-java.

-chris


Re: MIME type for velocity templates

Posted by Nathan Bubna <nb...@gmail.com>.
On Tue, Jan 31, 2012 at 7:48 AM, Christopher Schultz
<ch...@christopherschultz.net> wrote:
> Nathan,
>
> On 1/25/12 1:16 PM, Nathan Bubna wrote:
>> text/velocity sounds fine to me.  this isn't something that i recall
>> coming up previously, so i'm pretty sure there's no official opinion.
>
> Why not text/plain?

If you you are serving up plain text, sure, why not?  You can use
plain text as a template, or almost plain text.  But what if they are
serving up an un-rendered template that has enough VTL directives in
it to clearly not be plain text.  Wouldn't that seem like a more
fitting place for text/x-velocity?  I was just assuming the mime type
was for a template itself, not the rendered contents of a template. :)

> -chris
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: MIME type for velocity templates

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Nathan,

On 1/25/12 1:16 PM, Nathan Bubna wrote:
> text/velocity sounds fine to me.  this isn't something that i recall
> coming up previously, so i'm pretty sure there's no official opinion.

Why not text/plain?

-chris


Re: MIME type for velocity templates

Posted by Israel Alanis <IA...@e-dialog.com>.
Types that aren't registered with IANA are supposed to start with an "x-"
or "x.".
So, "text/velocity" would be an RFC violation, but "text/x-velocity" would
be OK.

http://www.ietf.org/rfc/rfc2045.txt    section 5.1

http://www.ietf.org/rfc/rfc4288.txt    section 4.3






On 1/25/12 1:16 PM, "Nathan Bubna" <nb...@gmail.com> wrote:

>text/velocity sounds fine to me.  this isn't something that i recall
>coming up previously, so i'm pretty sure there's no official opinion.
>
>On Wed, Jan 25, 2012 at 10:01 AM, Sergiu Dumitriu
><se...@gmail.com> wrote:
>> Is there a recommended MIME type that should be used for .vm files? I
>>found
>> text/velocity on http://www.filesuffix.com/extension/vm.html but I'd
>>like to
>> get an official opinion.
>> --
>> Sergiu Dumitriu
>> http://purl.org/net/sergiu/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>For additional commands, e-mail: user-help@velocity.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: MIME type for velocity templates

Posted by Nathan Bubna <nb...@gmail.com>.
text/velocity sounds fine to me.  this isn't something that i recall
coming up previously, so i'm pretty sure there's no official opinion.

On Wed, Jan 25, 2012 at 10:01 AM, Sergiu Dumitriu
<se...@gmail.com> wrote:
> Is there a recommended MIME type that should be used for .vm files? I found
> text/velocity on http://www.filesuffix.com/extension/vm.html but I'd like to
> get an official opinion.
> --
> Sergiu Dumitriu
> http://purl.org/net/sergiu/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org