The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2016-05-12

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:37 trwww joined #mojo
02:09 noganex_ joined #mojo
02:10 trwww joined #mojo
02:21 Crisewng joined #mojo
02:36 zivester joined #mojo
03:50 Guest-quest joined #mojo
04:12 inokenty-w joined #mojo
04:44 Guest-quest left #mojo
04:44 Guest-quest joined #mojo
04:52 asarch joined #mojo
05:41 trone joined #mojo
05:55 dod joined #mojo
06:00 dod joined #mojo
06:03 n16gel joined #mojo
06:16 gtodd joined #mojo
06:42 jacoby joined #mojo
06:44 bwf joined #mojo
06:46 gtodd joined #mojo
06:52 dod joined #mojo
06:56 Vandal joined #mojo
07:04 jnbek joined #mojo
07:10 degeberg joined #mojo
07:12 AndrewIsh joined #mojo
07:17 trone joined #mojo
07:45 Atog joined #mojo
07:57 marcus joined #mojo
07:58 trone joined #mojo
08:41 henq joined #mojo
08:43 punter joined #mojo
08:44 osfabibisi joined #mojo
09:10 henq joined #mojo
09:12 trone joined #mojo
09:15 Crisewng left #mojo
09:32 Sebbe jberger: Have you given any further consideration to https://github.com/jberger/Mojo-Phantom/pull/2 ? :)
10:21 icjs joined #mojo
10:23 henq joined #mojo
10:23 icjs hello all! i have a mojo app that i want to profile using NYTProf - the app has a startup script that is designed to be used woth morbo or hypnotoad but when i run it with "perl -d:NYTProf script/my_app" i get a usage message
10:24 pink_mist try adding daemon at the end
10:25 pink_mist unless your startup script isn't a regular app script
10:30 icjs pink_mist, thanks, works
10:30 icjs gotta file an issue about "Server available at http://127.0.0.1:6666" even though i've specified all interfaces (*) in the -l flag
10:31 pink_mist no, that's not an issue.
10:31 pink_mist that's by design
10:32 icjs "Server available at http://0.0.0.0:6666" makes more sense when i've specified * in my listen flag no?
10:32 pink_mist no
10:32 pink_mist https://github.com/kraih/mojo/issues/899
10:32 pink_mist see kraih's response to that issue
10:33 icjs i'm having deja va, pretty sure i mentioned this a year or so ago here :) educate me pls
10:35 icjs looked at the bug report, and i get it. the thing is that something is listening on 127.0.0.1:666 but also on "any ip of host":666
10:36 icjs might be significiant if someone is running it in production and doesnt realise that the port is expose on their external IPs too - prolly small chance and i'm being a bit OCD about it but still
10:38 pink_mist the purpose of the line is so you can get a link from your terminal that you can just click to check that your app is running properly
10:38 pink_mist with 0.0.0.0 that won't work across all OSes
10:42 pink_mist icjs: and the message specifically doesn't mention that it's listening on only that ip. it uses the word "available", which is in most cases true unless your setup is odd
10:43 pink_mist s/all OSes\K/ and browsers/
10:55 tchaves joined #mojo
11:00 dvinciguerra joined #mojo
11:05 tchaves joined #mojo
11:17 Kripton joined #mojo
12:19 asarch joined #mojo
12:38 meshl joined #mojo
12:49 jberger Sebbe: I'll admit, I forgot all about it
12:49 jberger I probably should audit all of my github queues :s
13:09 kaare joined #mojo
13:09 ramortegui joined #mojo
13:11 Kripton joined #mojo
13:13 zivester joined #mojo
13:17 jberger Sebbe: oddly your test stalls on my box
13:19 genio perlbrew exec prove -lr t
13:19 genio gah.  sorry.  (cursor-based focus)--
13:21 jacoby joined #mojo
13:30 jacoby joined #mojo
13:36 gtodd hmm so if I'm using Mojo::Pg as a "command line" application (towhit the "say" instead of "->render" in the POD Synopsis) and this is not a "antipattern hack" but is something the is done by lots of people ;-) that means that if I want to make a reporting tool for a database then instead of rendering HTML and a webpage I could put the results of things Mojo::Pg  grabs from the database into a shiny PDF ...
13:40 batman gtodd: you also have https://metacpan.org/pod/Mojo::PDF
13:40 batman it's experimental though...
13:41 gtodd so I could add fancy shiny to PDFs inside a Mojo app where routes never even get sent to a webpage ... it just connects to a database grabs what it wants renders a PDF and exits ...  there's other more traditional ways to do that but someone could leverage their knowledge of Mojolicious to do it ...
13:41 gtodd batman: excellent :)
13:44 gtodd by traditional I mean someone could probably do a lot with psql <whatever> | a2ps    ... :-D
13:45 gtodd but Mojolicious provides unicorns and rainbows ;)
13:55 punter joined #mojo
14:12 jberger gtodd: for generating PDF you have a few other options too
14:12 jberger you could template a LaTeX file using Mojo::Template and then compile it
14:13 jberger or you could generate a webpage with a css print mode and then run it through wkhtmltopdf
14:14 jberger perl-based PDF generators may work but IME they are pretty hard to make do anything but the simplest of stuff
14:14 gtodd k
14:14 jberger that said, I'm a big fan of LaTeX and others may not appreciate it as much as I do
14:15 pink_mist there's perl scripts that will help converting latex to pdf too
14:15 genio https://pbs.twimg.com/media/CiMNh9rWEAAdM6Q.png:large
14:15 pink_mist afaik latexmk was perl last I looked at least
14:15 genio I know, I know. it was posted yesterday, but I still find it funny. :)
14:16 gtodd I'm just having fun with the idea of routes that "render" ... but which I don't use to make a webpage
14:16 jberger gtodd: I think you are conflating a few different ideas
14:16 jberger pink_mist: latexmk is what I would recommend too
14:17 jberger only I don't THINK it is a library, just a script
14:17 pink_mist probably true
14:17 jberger that said, it is a very useful script
14:20 gtodd jberger:  yes, I don't know why but realising the Mojo::Pg docs had "say" instead of "render" in a few spots made me get all excited about RESTful interfaces to Mojo based magical unicorns :) ... when I could probably just write a perl script
14:21 gtodd and use Getopt::Long
14:22 jberger gtodd: then you should look at the Mojolicious command system
14:22 jberger for example Mojolicious::Command::nopaste on cpan
14:23 jberger or likewise how Minion adds a command to the mojolicious apps that use it
14:26 gtodd cool about minion
14:28 gtodd I did create a custom "darkpan" Mojo command once for deploying an app with all its dependencies using "scp" ... but I think Carton and the like are better approaches
14:35 gtodd jberger: basically for a minute there I thought replicating the entire psql console application in an Mojo based HTML5 web app might actually be "easy"  :)
14:45 n16gel joined #mojo
15:01 vicash gtodd: it is called pgadmin
15:03 PryMar56 joined #mojo
15:04 gtodd vicash: but that's boring compared to Mojolicious version I almost began to write ;)
15:13 zivester joined #mojo
15:15 ZoffixW joined #mojo
15:19 ZoffixW How  can I add config for `daemon`? I need app->config(hypnotoad => {proxy => 1}), but for when I start my app with perl app.pl daemon.
15:23 jberger daemon arguments get passed as command line options
15:23 ZoffixW Ah. Alright. Thanks.
15:23 jberger I think if you read them out of the configuration it would be too late
15:23 jberger hypnotoad forks off daemon with the configuration that it reads from the app on the first load
15:24 jberger s/daemon/daemons/
15:24 ZoffixW Makes sense. Can't run hypnotoad on this box. It's Win2008 server :/
15:25 jberger eh, nope
15:27 jberger ZoffixW: not that it helps you, but we did get some recent successes using hypnotoad on win10+ubuntu-on-windows
15:28 ZoffixW Yeah, I saw tweet/Issue
15:28 jberger which prompted this: https://github.com/kraih/mojo/commit/dc0da0f37004eeca928df0851ae48c9ce9efd981#diff-6be2b0f672c3cc12d7ecbad53dff1710R38
15:28 jberger ah cool
16:11 gtodd sometimes - for myself at least - TIMTOWDI with perl makes it easy to do things in an embarrassingly bad way ... that works
16:11 Adura If it works and runs reasonably fast, it's good.
16:16 ribasushi Adura: imagemagick tragically disagrees with you
16:17 gtodd I guess I mean I can even abuse Mojolicious to write an "app" :-\ ... that has no design or API or way of being improved without being completely rewritten ...  well, except for what Mojo provides thanks to Sri and everyone  ... so I guess that is "good" because it will be easy to rewrite the next version
16:17 Adura If you're writing software for other people to write software, I guess my sentiment doesn't apply.
16:18 gtodd Adura: ah excellent ... good point
16:20 gtodd Adura: I am not enabling five star food preparation in the restaurant kitchens of a world famous hotel resort chain ... I'm making a sandwich
16:20 Adura Sure, the scope of your project is a factor.
16:24 Zen joined #mojo
16:25 Zen hi, I am trying to get hypnotoad to run on a different port: have been googling but somehow it's still unclear to me how to do this
16:26 gtodd Zen: are you using Windows :-)  ?
16:26 Zen can someone please give me an example of how to point to a conf file and an example of the conf in question
16:26 Zen gtodd: thank god no
16:27 gtodd :-D
16:27 gtodd it doesn't really work there
16:27 Zen ok cool, real applications doesnt get hosted on that platform anyways
16:28 Zen so I have this:
16:28 Zen $morbo = Mojo::Server::Hypnotoad->new;
16:29 Zen $morbo->run('yce.pl');
16:29 Zen and that works great, but sometimes we cannot use port 8080
16:29 tinita joined #mojo
16:34 Zen so how do I load an configuration for hypnotoad? and how is this config formatted?
16:35 Zen if I just want to start it from the commandline it's easy using "daemon -l http://*:8081" for example
16:36 dod joined #mojo
16:37 gtodd Zen" probably tell the app.pl  where to listen with:   app->config(hypnotoad => {listen => ['http://*:8080']});
16:38 gtodd Zen: or something like that I don't know if there is a ENV variable it looks for or not ...
16:39 pink_mist MOJO_LISTEN ?
16:40 jberger Zen: you are using an especially confusing set of names there :-P
16:40 gtodd yeah .. does that work for hypnotoad ?  I thought it seemed like Zen was unable to get it working
16:40 jberger also, why are you invoking Hypnotoad as a class, one normally just uses the script hypnotoad
16:41 gtodd Zen: are you running a restaurant or making a sandwich :-D
16:42 Zen gtodd: thanks! this seems to work with a little testscript
16:42 gtodd Zen: oh ignore that ... you joined after my attempt at levity by comparing Mojo apps to food prep
16:42 Zen jberger: im sorry, my collegue built a morbo test setup and now I am supposed to conver it to hypnotoad
16:43 jberger morbo is a development server, hypnotoad is the production server
16:43 Zen gtodd: guess i am running a restaurant?
16:43 jberger neither one needs to be invoked as a class most times
16:43 gtodd Zen: do NOT stare into the eyes of hypnotoad
16:45 Zen jberger: maybe that would be easier to just run it through the hypnotoad script indeed
16:45 pink_mist that's what you're meant to do
16:45 Zen thank you all for the information, going to eat some chili and then get back at it! :D
16:46 pink_mist nice
16:46 pink_mist enjoy
16:46 pink_mist (now I want chili too)
16:46 gtodd https://media.giphy.com/media/FN1drtU5Fq6pW/giphy.gif
16:46 meshl joined #mojo
16:47 gtodd so do I ....
16:47 Zen if you live in the netherlands feel free to drop by :D
16:48 Zen otherwise kinda long trip for some food ^_^
16:48 * pink_mist could drive down there by tomorrow evening -- but won't
17:05 tinita joined #mojo
17:12 gtodd my sandwich "worked" appeared instantly, tasted good ...  but I had no butter so I slathered it with pumpkin seed puree and then fed the mouldy left over ham to the neighbor's dog ... I will never make that sandwich again or much less serve versions of it to anyone ... it was Mojolicious ...  :-P
17:26 punter joined #mojo
17:27 punter it's not possible to nest layouts, is it? (one inside the other)
17:32 gtodd @@ layouts/whatever.html.ep
17:32 gtodd % 'otherlayout'  ;
17:34 gtodd and then have 'otherlayout' included whenever   % 'whatever' ;   is used ?
17:34 punter But otherlayout contains a header and a footer
17:34 punter header goes on top, footer below
17:35 punter hm
17:35 punter anyway
17:35 punter Just typing % 'otherlayout' doesn't do anything on my machine
17:35 punter for some reason
17:42 gtodd I mostly use __DATA__ and .ep sections but when it gets too complicated  I resort to including things from static files using <link> etc.  I did play with the "template blocks"  feature which seemed like it allowed for a programmatic approach to including templates etc.  not sure if that is the case or if it would help :-D
17:48 Zen thank you guys so much! I was stuck in the "well my colleague made this script to start it so I guess I'll need to tweak this to get it working" mode
17:49 Zen turns out it's way easier this way :D
17:55 jberger Zen++
18:02 cfedde joined #mojo
18:03 punter jberger: I have a question, because I'm making a website which I'd like to have many subdomains. Couldn't we somehow allow a "host" attribute (maybe a stash value) to the routes, so that when we type $c->url_for('view_profile')->to_abs, the host of the url becomes profiles.mysite.com ?
18:04 trone joined #mojo
18:04 jberger punter: there are already ways to do that
18:04 punter really??
18:04 punter that's interesting
18:04 punter could you please point a few?
18:05 jberger easiest is to do it with a reverse proxy (nginx?) and set the reverse proxy field so that your app gets the correct host
18:06 jberger if you want to mount different hosts into the same app there are things like http://mojolicious.org/perldoc/Mojolicious/Guides/Routing#Conditions
18:06 punter I already use nginx, and Mojolicious knows the host of the CURRENT web request, but that's not the problem I'm having.
18:06 jberger you want url_for to link to a different host?
18:07 punter yes, when the $target is a different wepage
18:07 jberger pass an argument to to_abs
18:07 punter oh, thanks!
18:07 jberger http://mojolicious.org/perldoc/Mojo/URL#to_abs
18:08 jberger it will have the base attribute set to the current host, but if you pass a different base (or change the base attribute) it will do what you want
18:08 henq joined #mojo
18:08 jberger then you could wrap that logic into a helper if you need to do it often
18:09 punter ok
18:09 punter my_abs($target, 'host_codename')
18:09 punter no
18:09 punter ok, got it
18:10 punter but there's no way to attach an "attribute" or something readable to the routes, is there?
18:11 punter maybe if I subclass them and add a property?
18:11 punter no
18:15 punter jberger: is there no way to read the default stash property that a route has, if I'm not currently on that route?
18:15 jberger honestly I can't remember
18:17 punter ok
18:17 jberger punter: mojo eval -V 'app->routes->find("whatever")->pattern->defaults->{text}'
18:18 punter :-))))
18:18 punter thanks
18:19 jberger use that carefully, "with great power ..." and all that
18:20 simcop2387 joined #mojo
18:21 henq joined #mojo
18:22 punter heh
18:56 henq joined #mojo
18:57 jb360 joined #mojo
19:06 Zen ok seems like I'm not out of the woods yet
19:07 Zen my colleague used "Mojolicious::Commands->start_app('Yce');"
19:07 Zen to start the app, but I need to use "app->config(hypnotoad => {listen => ['http://*:8081']});"
19:07 Zen to get it to listen on a different port, how to I define the app in question in that case?
19:08 Zen $ENV{MOJO_APP} = 'Yce';
19:08 Zen doesnt seem to work...
19:13 Zen to clarify, it does run on port 8081 like I ask it to
19:13 Zen but it does not load the app in question
19:17 gtodd hmm grepping through my hackish scripts I found this:
19:17 gtodd get '/' => sub { my $cnxn  = shift; my $db = $cnxn->pg->db; $cnxn->render( "text" => $db->query('select year,ecorp2 from bckwht')->text, format => "text" ) ;  } ; ... why do I have the word text in there so many times ?  sheesh what am I doing wrong :-\
19:32 jberger Zen: http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Hypnotoad
19:32 jberger gtodd: that looks fine to me
19:33 jberger people sometimes don't understand that rendering text (using the text stash key) still sends a content_type of text/html
19:33 jberger which is why you use the format "text"
19:34 Grinnz yeah, 'text' as a stash key is more to contrast 'data' meaning raw bytes iirc
19:34 jberger right, text means "encode this as utf8" where data means "this is the raw data"
19:47 gtodd oh OK ... sigh it was "working" in various guises ... since I was dumping one time query results to a web page I didn't care how :-\ fiwth out format => "text" "content_type of text/html"  was formatting the response as an html <p> or something I guess
19:51 gtodd I think I had it working somehow with $cnxn->render( "text" => $db->query('select year,ecorp2 from bckwht')->hash ; but I forgot to save that vim buffer ;-)  ... cheers and thanks for Mojo and #mojo
20:08 osfabibisi joined #mojo
20:27 perlpilot joined #mojo
20:28 Zen jberger: thank you for the link, I do get the "Hello Wor...ALL GLORY TO THE HYPNOTOAD!" example running but somehow I just cannot find how one should point to an app when using the app->config way: am I overlooking something really silly here?
20:48 jb360 joined #mojo
21:05 trwww joined #mojo
21:12 mgrimes Zen: are you using ::Lite? Are you using a config plugin (plugin 'Config' or 'JSONConfig)?
21:14 meshl joined #mojo
21:14 Zen mgrimes: I am using ::Lite, nog config plugin no JSONConfig
21:15 PopeFelix joined #mojo
21:16 Zen I just want to define like "Mojolicious::Commands->start_app('Yce');" but then in a way like "app->config(hypnotoad => {listen => ['http://*:8081']});"
21:16 Zen so it knows which app to load so I dont get the "raptor not found" msg anymore
21:17 mgrimes You seem to be mixing ::Lite and a full app. Usually a lite app is a single file that ends in app->start.
21:17 Sebbe jberger: (just got back and saw your report on the test stalling) Hm, oh dear. Is it the phantomjs process hanging? If so, does it also hang if you manually call it with the generated script?
21:18 mgrimes a full app, you would define in in lib/Yce.pm, then have a starter script that uses Mojolicious::Comamdns->start...
21:21 mgrimes Zen: I think you want to include in lib/Yce.pm "$self->config(hypnotoad...);"
21:23 mgrimes Zen: your starter script(say 'my_app.pl')) should have the Mojolicious::Commands->start_app('Yce'); Which you would launch with '$ hypnotoad my_app.pl'
21:26 disputin joined #mojo
21:33 n16gel joined #mojo
21:43 Zen mgrimes++
21:43 Zen thank you so much, it works now :D
21:46 osfabibisi joined #mojo
21:55 PopeFelix I'm trying to create a simple Mojo app to be run inside a unit test. Trying to do it with Mojo::Server::Daemon, but I think I'm doing something wrong.
21:55 PopeFelix It listens on the provided port, but it doesn't respond to requests.
21:58 Zen I have no clue but maybe try sniffing the network traffic for clues?
21:59 PopeFelix Zen, I think it's more basic than that. I'm missing some fundamental Mojo thing. :)
22:00 PopeFelix I think maybe I'm not doing the embedding right.
22:00 PopeFelix http://search.cpan.org/dist/Mojolicious/lib/Mojolicious/Guides/Cookbook.pod#Web_server_embedding
22:01 jberger Sebbe: yeah, it seems that specifying --cookie-file="$tmpfile" fails
22:02 jberger but if I make the target file just some file in a local path it works just fine
22:02 jberger very confusing
22:05 PopeFelix oh, i think i see. it doesn't fork.
22:05 bpmedley PopeFelix: Do you have a smallish example script?
22:06 jberger PopeFelix: strange, I wonder why not
22:06 PopeFelix bpmedley, I do.
22:06 PopeFelix jberger, probably something I'm missing. :)
22:06 jberger sorry, not PopeFelix
22:06 bpmedley PopeFelix: Would you share?
22:06 PopeFelix Yeah, just a moment
22:06 jberger PopeFelix: that was an acceptable answer ("it doesn't fork") to the question Sebbe and I were having
22:07 PopeFelix lol
22:07 Sebbe Hehe
22:08 Sebbe jberger: So like 'phantomjs --cookies-file=/tmp/whatever' fails, but 'phantomjs --cookies-file=./whatever' doesn't? That is pretty weird.
22:08 jberger and more weird, if I dump out the /tmp/whatever filename that it generates and for it to use that same one the next time, then it works
22:09 jberger the failure mode seems to be that it doesn't even make the web request
22:09 PopeFelix bpmedley, http://paste.scsys.co.uk/513651
22:09 Sebbe phantomjs can be so flaky sometimes, I find.
22:12 bpmedley PopeFelix: $daemon->start->ioloop->start;  <-- Try that
22:15 PopeFelix bpmedley, that did it, thanks!
22:15 bpmedley Cool.  Does that make sense?
22:15 PopeFelix Kinda.
22:16 bpmedley One starts the socket connections and the other starts the event loop.
22:16 PopeFelix There's the IO Loop and the daemon, and the IO loop governs the app responses.
22:16 Sebbe jberger: Perhaps the test should change the path and call a dummy executable instead, that just lets us check that it got the right arguments. Avoids any issues with bugs in PhantomJS regarding that flag...
22:16 PopeFelix And it's the event loop that responds to the requests that come in on the socket.
22:16 bpmedley Works for me.. :)
22:17 jberger Sebbe: while that would work, I don't just like avoiding a problem like that :s
22:17 PopeFelix Except it looks like I'm still going to have to fork it.
22:17 PopeFelix Which is OK. I just thought Mojo::Server::Daemon took care of that automagically for some reason.
22:19 Sebbe jberger: Well, true. However, the test really is meant to measure whether the phantomjs is called with the correct arguments, and not so much if PhantomJS responds correctly to the argument.
22:21 PopeFelix bpmedley, I'm correct in that I'm going to have to fork if I want the call to ioloop->start to be (effectively) non blocking, right?
22:21 bpmedley PopeFelix: That might vary on what you wanna do.  What's your goal?
22:22 PopeFelix bpmedley, to start and stop the responder in the script, but have it accessible via HTTP.
22:22 PopeFelix This is going in a unit test where the thing being tested sends a processing report.
22:23 bpmedley Can you make a smallish script that includes a test you wanna call?
22:23 PopeFelix So thing->start_processing(data) will immediately return "OK, I'll work on it".
22:24 PopeFelix bpmedley, not really. But I can simulate it some.
22:27 PopeFelix http://paste.scsys.co.uk/513652
22:56 jnbek joined #mojo
23:03 bpmedley Test Responder for PopeFelix https://www.irccloud.com/pastebin/pCbIOnip/test_responder.pl
23:04 bpmedley PopeFelix: ^^ Not sure if this is best practice, or not..
23:10 punter joined #mojo
23:16 hernan604 joined #mojo
23:27 mtj joined #mojo

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary