| Author |
Message |
|
| filippo |
Posted: Sun Mar 11, 2007 9:01 pm |
|
|
|
User
Joined: 22 Nov 2006
Posts: 19
Location: Siena
|
|
| Back to top |
|
| Guest |
Posted: Mon Mar 12, 2007 9:20 am |
|
|
|
Guest
|
Filippo Pacini wrote:
> Hi all,
> I'm working on an Erlang template language based on String Template
> www.stringtemplate.org
>
What would be the best way to let yaws handle .eg .st files
Should I allow for external renderers to register their
file suffixes and associate those to a render module.
Maybe a good idea would be to rip the .yaws support
out from yaws_server.erl, put it in an external module
and then register that external module as the handler for
pages with .yaws suffix ?? and then the same thing for cgi etc ...
That way it will be easy to plug in any external rendering
engine, for example a string template implementattion
??
/klacke
--
Claes Wikstrom -- Caps lock is nowhere and
http://www.tail-f.com -- everything is under control
cellphone: +46 70 2097763
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Mon Mar 12, 2007 9:33 am |
|
|
|
Guest
|
On 3/12/07, Claes Wikström <klacke@tail-f.com> wrote:
> Filippo Pacini wrote:
> > Hi all,
> > I'm working on an Erlang template language based on String Template
> > www.stringtemplate.org
> >
>
> What would be the best way to let yaws handle .eg .st files
> Should I allow for external renderers to register their
> file suffixes and associate those to a render module.
>
> Maybe a good idea would be to rip the .yaws support
> out from yaws_server.erl, put it in an external module
> and then register that external module as the handler for
> pages with .yaws suffix ?? and then the same thing for cgi etc ...
>
> That way it will be easy to plug in any external rendering
> engine, for example a string template implementattion
It would be great if yaws was split into more components like that. We
only use it because it's a working HTTP server protocol
implementation. We're serving appmods from it, and nothing else (not
even static files). We've also got all of the logging shut off because
we have application-specific logs. I would prefer a lighter and easier
to understand solution than Yaws, but I couldn't find an alternative
HTTP implementation that was half-decent and didn't suffer from the
same kind of monolithic bloat that yaws and httpd do.
On another note, when I was prototyping something w/ Yaws yesterday I
thought it would be nice if there was a return value that could be
used to serve a file from disk from an appmod. Right now I just read
the whole thing as a binary and return that, but it would be
preferable if I could just give the path to yaws and let it serve the
file... e.g. {file, ContentType, Path}. Maybe even allow IoDevice in
addition to paths to support already open files?
-bob
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
| tobbe |
Posted: Mon Mar 12, 2007 9:39 am |
|
|
|
User
Joined: 19 Jan 2005
Posts: 274
Location: Stockholm, Sweden
|
|
| Back to top |
|
| filippo |
Posted: Mon Mar 12, 2007 1:07 pm |
|
|
|
User
Joined: 22 Nov 2006
Posts: 19
Location: Siena
|
I like this way to integrate different templates in yaws.
I did a quick test with sgte and it seems to work with few modifications.
The only problem I see is that sometimes it find useful compiling a
template as a simple string instead of having it in a separate file
(e.g. a sql query, or a small piece of html used in different pages).
It would be nice to manage also this case.
--
filippo
Torbjorn Tornkvist wrote:
> Claes Wikstr |
|
|
| Back to top |
|
| tobbe |
Posted: Mon Mar 12, 2007 3:10 pm |
|
|
|
User
Joined: 19 Jan 2005
Posts: 274
Location: Stockholm, Sweden
|
Filippo Pacini wrote:
> I like this way to integrate different templates in yaws.
>
> I did a quick test with sgte and it seems to work with few modifications.
>
> The only problem I see is that sometimes it find useful compiling a
> template as a simple string instead of having it in a separate file
> (e.g. a sql query, or a small piece of html used in different pages).
> It would be nice to manage also this case.
Yes, there could be.
register_file/2 % as shown before
register_template(Name, Template, Module)
Example:
register_template(myselect, "SELECT $join \",\" columns$ FROM $table$",
sgte)
...
lookup(myselect)
etc...
Cheers, tobbe
>
> --
> filippo
>
>
> Torbjorn Tornkvist wrote:
>> Claes Wikstr |
|
|
| Back to top |
|
| Guest |
Posted: Tue Mar 13, 2007 1:32 am |
|
|
|
Guest
|
Hi Bob,
But that is already possible, just use:
{content, Mimetype, Content} OR
{streamcontent,...}
Here a fragment from an appmod I'm using:
_Other ->
F = WikiRoot++"/"++Page,
{ok, Content} = file:read_file(F),
{content, yaws_api:mime_type(Page), Content}
end.
Regards
/Rob
-----Original Message-----
From: erlyaws-list-bounces@lists.sourceforge.net [mailto:erlyaws-list-bounces@lists.sourceforge.net] On Behalf Of Bob Ippolito
Sent: 12 March 2007 17:33
To: Claes Wikstr |
|
|
| Back to top |
|
| Guest |
Posted: Tue Mar 13, 2007 1:50 am |
|
|
|
Guest
|
Yes of course it's possible, I said I did something almost exactly
like that in my original reply... but that's code I shouldn't have to
write!
I should only have to return something like:
{file, yaws_api:mime_type(Path), Path}
Yaws should take care of sending that file to the client in the most
efficient way possible. For large files that's obviously not going to
be {content, _, _}, it's going to want to read it in parts and stream
it. Possibly as a range request or something. Maybe it would use a
sendfile [1] type optimization in the future.
Regardless, it shouldn't be my business to re-implement something that
Yaws is already very good at. Lighttpd has a feature like this that's
done by the X-Sendfile HTTP header and Nginx has a somewhat less
convenient X-Accel-Redirect. Realistically if I were using this in
production and performance mattered I would probably be using nginx in
the front with X-Accel-Redirect for static files... but in this
particular case I wanted the feature only because it would've saved me
a few lines of code.
-bob
On 3/12/07, Robert Schmersel (BJ/CBC) <robert.schmersel@ericsson.com> wrote:
> Hi Bob,
>
> But that is already possible, just use:
> {content, Mimetype, Content} OR
> {streamcontent,...}
>
> Here a fragment from an appmod I'm using:
> _Other ->
> F = WikiRoot++"/"++Page,
> {ok, Content} = file:read_file(F),
> {content, yaws_api:mime_type(Page), Content}
> end.
>
> Regards
> /Rob
>
> -----Original Message-----
> From: erlyaws-list-bounces@lists.sourceforge.net [mailto:erlyaws-list-bounces@lists.sourceforge.net] On Behalf Of Bob Ippolito
> Sent: 12 March 2007 17:33
> To: Claes Wikström
> Cc: erlyaws-list@lists.sourceforge.net; Filippo Pacini; Erlang Users' List
> Subject: Re: [Erlyaws-list] sgte - erlang template engine
>
> On 3/12/07, Claes Wikström <klacke@tail-f.com> wrote:
> > Filippo Pacini wrote:
> > > Hi all,
> > > I'm working on an Erlang template language based on String Template
> > > www.stringtemplate.org
> > >
> >
> > What would be the best way to let yaws handle .eg .st files Should I
> > allow for external renderers to register their file suffixes and
> > associate those to a render module.
> >
> > Maybe a good idea would be to rip the .yaws support out from
> > yaws_server.erl, put it in an external module and then register that
> > external module as the handler for pages with .yaws suffix ?? and then
> > the same thing for cgi etc ...
> >
> > That way it will be easy to plug in any external rendering engine, for
> > example a string template implementattion
>
> It would be great if yaws was split into more components like that. We only use it because it's a working HTTP server protocol implementation. We're serving appmods from it, and nothing else (not even static files). We've also got all of the logging shut off because we have application-specific logs. I would prefer a lighter and easier to understand solution than Yaws, but I couldn't find an alternative HTTP implementation that was half-decent and didn't suffer from the same kind of monolithic bloat that yaws and httpd do.
>
> On another note, when I was prototyping something w/ Yaws yesterday I thought it would be nice if there was a return value that could be used to serve a file from disk from an appmod. Right now I just read the whole thing as a binary and return that, but it would be preferable if I could just give the path to yaws and let it serve the file... e.g. {file, ContentType, Path}. Maybe even allow IoDevice in addition to paths to support already open files?
>
> -bob
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Erlyaws-list mailing list
> Erlyaws-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/erlyaws-list
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Tue Mar 13, 2007 1:51 am |
|
|
|
Guest
|
I forgot to include the [1] footnote reference to the sendfile patch:
http://www.erlang.org/pipermail/erlang-patches/2003-November/000068.html
On 3/12/07, Bob Ippolito <bob@redivi.com> wrote:
> Yes of course it's possible, I said I did something almost exactly
> like that in my original reply... but that's code I shouldn't have to
> write!
>
> I should only have to return something like:
> {file, yaws_api:mime_type(Path), Path}
>
> Yaws should take care of sending that file to the client in the most
> efficient way possible. For large files that's obviously not going to
> be {content, _, _}, it's going to want to read it in parts and stream
> it. Possibly as a range request or something. Maybe it would use a
> sendfile [1] type optimization in the future.
>
> Regardless, it shouldn't be my business to re-implement something that
> Yaws is already very good at. Lighttpd has a feature like this that's
> done by the X-Sendfile HTTP header and Nginx has a somewhat less
> convenient X-Accel-Redirect. Realistically if I were using this in
> production and performance mattered I would probably be using nginx in
> the front with X-Accel-Redirect for static files... but in this
> particular case I wanted the feature only because it would've saved me
> a few lines of code.
>
> -bob
>
> On 3/12/07, Robert Schmersel (BJ/CBC) <robert.schmersel@ericsson.com> wrote:
> > Hi Bob,
> >
> > But that is already possible, just use:
> > {content, Mimetype, Content} OR
> > {streamcontent,...}
> >
> > Here a fragment from an appmod I'm using:
> > _Other ->
> > F = WikiRoot++"/"++Page,
> > {ok, Content} = file:read_file(F),
> > {content, yaws_api:mime_type(Page), Content}
> > end.
> >
> > Regards
> > /Rob
> >
> > -----Original Message-----
> > From: erlyaws-list-bounces@lists.sourceforge.net [mailto:erlyaws-list-bounces@lists.sourceforge.net] On Behalf Of Bob Ippolito
> > Sent: 12 March 2007 17:33
> > To: Claes Wikström
> > Cc: erlyaws-list@lists.sourceforge.net; Filippo Pacini; Erlang Users' List
> > Subject: Re: [Erlyaws-list] sgte - erlang template engine
> >
> > On 3/12/07, Claes Wikström <klacke@tail-f.com> wrote:
> > > Filippo Pacini wrote:
> > > > Hi all,
> > > > I'm working on an Erlang template language based on String Template
> > > > www.stringtemplate.org
> > > >
> > >
> > > What would be the best way to let yaws handle .eg .st files Should I
> > > allow for external renderers to register their file suffixes and
> > > associate those to a render module.
> > >
> > > Maybe a good idea would be to rip the .yaws support out from
> > > yaws_server.erl, put it in an external module and then register that
> > > external module as the handler for pages with .yaws suffix ?? and then
> > > the same thing for cgi etc ...
> > >
> > > That way it will be easy to plug in any external rendering engine, for
> > > example a string template implementattion
> >
> > It would be great if yaws was split into more components like that. We only use it because it's a working HTTP server protocol implementation. We're serving appmods from it, and nothing else (not even static files). We've also got all of the logging shut off because we have application-specific logs. I would prefer a lighter and easier to understand solution than Yaws, but I couldn't find an alternative HTTP implementation that was half-decent and didn't suffer from the same kind of monolithic bloat that yaws and httpd do.
> >
> > On another note, when I was prototyping something w/ Yaws yesterday I thought it would be nice if there was a return value that could be used to serve a file from disk from an appmod. Right now I just read the whole thing as a binary and return that, but it would be preferable if I could just give the path to yaws and let it serve the file... e.g. {file, ContentType, Path}. Maybe even allow IoDevice in addition to paths to support already open files?
> >
> > -bob
> > -------------------------------------------------------------------------
> > Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> > _______________________________________________
> > Erlyaws-list mailing list
> > Erlyaws-list@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/erlyaws-list
> >
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
| tobbe |
Posted: Tue Mar 13, 2007 2:11 pm |
|
|
|
User
Joined: 19 Jan 2005
Posts: 274
Location: Stockholm, Sweden
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|
|