What's really frustrating for me is that with a modern Perl we can make
applications look this pretty, but at the same time are unable to show them
on the Mojolicious frontpage.
use Mojolicious::Lite;
# Render template "index.html.ep" from the DATA section
get '/' => {template => 'index'};
# WebSocket service used by the template to extract the title from a
web site
websocket '/title' => sub ($c) {
$c->on(message => sub ($c, $msg) {
my $title = $c->ua->get($msg)->res->dom->at('title')->text;
$c->send($title);
});
};
app->start;
__DATA__
@@ index.html.ep
% my $url = url_for 'title';
<script>
var ws = new WebSocket('<%= $url->to_abs %>');
ws.onmessage = function (event) { document.body.innerHTML +=
event.data };
ws.onopen = function (event) { ws.send('http://mojolicio.us') };
</script>
--
sebastian
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.