Re: [Mojolicious] coro interface to Mojolicious

2015-05-13 Thread Eugene Toropov
Hi Jan,

Thank you. I’ll take a look.

Cheers
Eugene

On 13 May 2015, at 10:58, Jan Henning Thorsen  wrote:

> I haven't done this myself, but looks like sri drafted an idea which you 
> might get some ideas from:
> 
> https://gist.github.com/kraih/6082061
> 
> 
> On Friday, May 8, 2015 at 3:57:57 PM UTC+2, Eugene Toropov wrote:
> Greetings,
> 
> Is there a working recipe to run mojo application in “coro mode” so that it 
> is run in coroutine similar to this - 
> http://search.cpan.org/~unera/Coro-Twiggy-0.03/lib/Coro/Twiggy.pm ?
> 
> Cheers
> Eugene
> 
> -- 
> 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 mojolicious+unsubscr...@googlegroups.com.
> To post to this group, send email to mojolicious@googlegroups.com.
> Visit this group at http://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Get at name of current template?

2015-05-13 Thread Justin Hawkins

> On 14 May 2015, at 2:48 am, Juergen Nickelsen  
> wrote:
> 
> for a while I have been trying to get at the name of the template that
> is just being rendered, to use it in the layout.

I can’t answer your question directly, but this requirement sounds like a bit 
of a code smell. What are you trying to accomplish?

You should probably be setting something in the stash to drive logic required 
for presentation in the layout, not depending on what template is being 
rendered.

For example (untested):

sub some_controller_method {
  my $self = shift;
  $self->stash( has_login_box => 1 );
  $self->render(template => ‘foo’);
}

then in the layout:

% if (stash(‘has_login_box’)) {

...

% }

or better:

% if (stash(‘has_login_box’)) {
%   include ‘page_bits/login’;
% }

If you literally just want the name of the template, well, I don’t know how to 
do that, and I don’t know why you’d want to do that :-)

- Justin

-- 
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 mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Get at name of current template?

2015-05-13 Thread Juergen Nickelsen
Hello all,

for a while I have been trying to get at the name of the template that
is just being rendered, to use it in the layout. I have dug through
documentation and source code, and while I found the place where the
debug message qq{Rendering template "$name"} is emitted, I haven't yet
found a good way to get at that name.

Now I did this (as a helper function):

sub current_template_name {
my ($c) = @_;
my $loghist = $c->app()->log()->{history};
my $try = -1;
my $msg;
do {
$msg = $loghist->[$try--]->[2];;
} while ($msg =~ m{\"layouts/} && -$try < @{$loghist});
$msg =~ s/^[^"]*"(.*)".*/$1/;
return $msg;
}

I am pretty certain everybody agrees that this is as ugly as it can get.
Now, what is the preferred way to get at the template name?


(BTW, I *really* like Mojolicious. While I am an experienced programmer,
this is my first real endeavor into web applications, so I was a bit
overwhelmed at first. An excellent training by Renée Bäcker put me on
the right track, and now I am happily hacking away.)

Regards, Juergen.

-- 
 Tel +49.30.838-50740 Fax -450740
Zentraleinrichtung fuer Datenverarbeitung, Central Systems (Unix)
Freie Universitaet Berlin, Fabeckstrasse 32, 14195 Berlin, DE

-- 
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 mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: toadfarm - how to tell which domain is calling app ?

2015-05-13 Thread Jan Henning Thorsen
You should also be able to use:

  $domain = $c->req->url->to_abs->host;

On Wednesday, May 13, 2015 at 1:55:45 PM UTC+2, mjb152 wrote:
>
> apologies for self answering, but it might be of use to somebody else.
>
> my $base = $self->req->headers->header('X-Request-Base');
>

-- 
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 mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: toadfarm - how to tell which domain is calling app ?

2015-05-13 Thread mjb152
apologies for self answering, but it might be of use to somebody else.

my $base = $self->req->headers->header('X-Request-Base');

-- 
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 mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] toadfarm - how to tell which domain is calling app ?

2015-05-13 Thread mjb152
I'm using toadfarm to handle 3 domains, and each of these has several 
subdomains pointing at it.
How can I detect which domain is calling my app ?

mount "/apps/xx/script/myapp" => { "X-Request-Base" => 
"http://d1.domain.co.uk"; };
mount "/apps/xx/script/myapp" => { "X-Request-Base" => 
"http://d2.domain.co.uk"; };
mount "/apps/xx/script/myapp" => { "X-Request-Base" => 
"http://d3.domain.co.uk"; };

-- 
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 mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Perhaps missing something...but emulate SSH terminal session?

2015-05-13 Thread Jan Henning Thorsen
I've implemented a basic terminal: https://metacpan.org/pod/App::screenorama

You can try it out with something like this:

  SCREENORAMA_STDIN=1 screenorama daemon -- bash

I've been looking at stealing some code 
from https://github.com/chjj/term.js to make arrow keys work, but haven't 
gotten to that yet. I just tried out term.js directly which seems to work, 
but I don't want a fixed col/row terminal, but rather have it fit into the 
parent html element.


On Tuesday, May 12, 2015 at 4:35:27 PM UTC+2, Brian Manning wrote:
>
> On Monday, May 11, 2015 at 12:24:12 PM UTC-7, Aaron wrote:
>>
>> Ladies and Gents,
>>
>> I would like to implement a remote terminal in my current web application 
>> such that users can log into a Hadoop cluster, thus, I would think, need to 
>> be able to SSH into the login node and then run a Spark shell or whatever 
>> else they would want to do...
>>
>> Am I missing an existing example?  I can't imagine that I am the first to 
>> want to implement this functionality...If my Google-Foo has been sub-par, I 
>> apologize ahead of time...
>>
>
> Not Mojolicious based, but https://code.google.com/p/shellinabox/
>
> It's in the Debian/Ubuntu package repos.
>
> Thanks,
>
> Brian
>
>>

-- 
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 mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: coro interface to Mojolicious

2015-05-13 Thread Jan Henning Thorsen
I haven't done this myself, but looks like sri drafted an idea which you 
might get some ideas from:

https://gist.github.com/kraih/6082061


On Friday, May 8, 2015 at 3:57:57 PM UTC+2, Eugene Toropov wrote:
>
> Greetings,
>
> Is there a working recipe to run mojo application in “coro mode” so that 
> it is run in coroutine similar to this - 
> http://search.cpan.org/~unera/Coro-Twiggy-0.03/lib/Coro/Twiggy.pm ?
>
> Cheers
> Eugene
>

-- 
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 mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.