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

IRC log for #mojo, 2014-07-15

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

All times shown according to UTC.

Time Nick Message
00:07 batman riche: i need a code example to understand what you want
00:07 batman it might be because it's 2am, but it also sounds like you're trying to explain to me two things
00:07 * batman <3 new convos
00:08 riche batman: lol yah well 2 things I put in tix on github
00:09 riche the 'externalized list of assets' is just how I like to manage things, and I can do it without impacting your module
00:10 riche but it's working cool and it really makes the template look cleaner ;)
00:15 batman i commented on github now
00:15 batman almost out of battery
00:19 riche nods no problem
00:19 riche I usually always code in mojo full on apps, so getting it into a Lite app is a bit different for me ...
00:20 batman riche: AssetPack works for both full and lite
00:20 batman as every other plugin
00:21 riche nods, what I mean is I will try to repro it into Lite
00:21 riche cuz full app isn't exactly minimalistic
00:21 marcus__ joined #mojo
00:21 riche it's good practice for me anyways
00:21 batman oh. just copy/paste the part of the code that fail
00:21 batman ok.
00:27 marcus__ hey batman.
00:27 marcus__ Now it works, maybe it wasn't connected earlier.
00:29 riche __finally__ did it in Lite .. man that made me feel like a noob ... got way too comfortable in full apps
00:29 batman marcus__: i think you didn't remove the assets from the packed dir
00:32 riche batman: posted
00:32 riche also got an ugly error when file is missing ... but perhaps that's what you want
00:33 disputin joined #mojo
00:34 batman riche: i want to know everything you know.
00:35 riche that's eerily reminding me of kill bill vol 1
00:45 dvinciguerra joined #mojo
00:47 jberger EOMGBACKLOG
00:48 jberger btw, what new convos?
00:49 batman jberger: demo.convos.by <-- trying it out there first
00:49 batman probably some rough edges :)
00:50 jberger ah
00:51 jberger remember that 0.7 didn't index correctly
00:52 * jberger looks forward to new convos
00:52 batman me to :)
00:52 batman too
00:52 jberger tooo
01:06 laouji joined #mojo
01:10 batman jberger: cpan_new is dead?
01:10 batman riche: a new assetpack is on it's way to cpan now
01:12 riche batman: cool
01:12 riche you are too efficient
01:12 batman that is impossible!!!
01:12 batman ;)
01:12 riche yah looked at your commit ... neato
01:13 batman it's a bit weird that JavaScript::Minifier::XS return undef if no javascript was found...
01:13 batman 03:13 *logging off*
01:35 camelo joined #mojo
01:35 camelo Hi
01:37 klapperl joined #mojo
01:39 bpmedley camelo: Morning
01:45 asarch joined #mojo
01:46 Averna joined #mojo
01:47 asarch If I do: my @files; foreach (File::Find::Rule->file()->in('.')) { my $tmp = {filename => $_}; push(@files, $tmp);}
01:47 asarch Then I could pass the array to the template: $self->stash(file => \@files);
01:48 asarch And, in the template: <ul>% foreach (@$file) { <li><%== $_->{file} %></li> }</ul>
01:49 asarch However, if I do directly: my @files = File::Find::Rule->file()->in('.'); $self->stash(files => \@files);
01:50 asarch How could I get the value of each one of the elements of the array in the template: <ul> % foreach (@$file) { <li> <%== $_ %> </li> } </ul>
01:50 asarch ?
01:50 asarch $_->{_}     <- ?
01:53 riche for readability I would do the foreach on sep line using %= syntax ... easier to read
01:54 riche that will make the emit a non issue at that point
02:09 jberger batman: its not dead, its resting
02:09 jberger I haven't had time to figure out why it stops notifying
02:24 cpan_mojo joined #mojo
02:28 cpan_mojo joined #mojo
02:31 cpan_mojo joined #mojo
02:32 camelo joined #mojo
02:38 cpan_mojo joined #mojo
02:39 Eke- joined #mojo
02:39 jberger more logging
02:46 jberger asarch: if you want to see an extreme example: https://github.com/jberger/Galileo/blob/master/lib/Galileo/files/templates/admin/users.html.ep
02:47 jberger though some people think that that is taking things too far
02:48 jberger eeek, I see some slight bugs
02:49 preaction isn't there a few languages that compile to html using structured indentation? and some css versions of it too
02:50 preaction Jade. http://jade-lang.com
02:51 Adura haml comes to mind.
02:59 sri jade is pretty nice, same as slim
03:00 neyasov__ joined #mojo
03:06 jberger asarch: tweaks accomplished
03:07 riche sri: did you finalize the 'powered by mojo' logo?
03:08 sri nope
03:09 riche okay I will keep a look out for it ...
03:09 asarch %= tag th => "user_id"
03:09 asarch ?
03:09 asarch What does "tag" mean?
03:09 Adura Means to tag something.
03:09 asarch Like: tag(th => "user_");
03:09 asarch ?
03:10 Adura tag(arg1, arg2)
03:10 asarch tag a => href => "/admin/user/$name" => "Edit"
03:10 Adura Check the docs?
03:10 asarch I didn't know this was a valid Perl sentence
03:10 sri riche: i ran out of ideas, not sure it will get finished anytime soon
03:11 Adura sub arg1, arg2... sure.
03:11 asarch What a great piece of code :-)
03:11 preaction asarch: provided tag is a sub, or a is a class and a::tag is a sub
03:11 preaction if tag is the sub it needs a prototype
03:12 sri http://mojolicio.us/perldoc/Mojolicious/Plugin/TagHelpers#tag
03:12 preaction wait. indirect-object syntax might not apply here
03:12 asarch I see
03:12 asarch Thank you guys :-)
03:13 sri http://mojolicio.us/perldoc/Mojolicious/Plugin/TagHelpers#t
03:17 riche sri: i liked the one you had maybe a week or so ago ... but i was way too buried to comment
03:31 sri riche: well, it was in master for about 10 minutes https://github.com/kraih/mojo/commit/7174bc3ff06a0c3d0b333048dbfc19dc2d3ca338
03:31 KCL_ joined #mojo
03:33 * sri wonders how many more little changes there are out there that can make Mojo::DOM significantly faster
03:33 Adura index instead of regex!
03:33 sri simple /o modifier got us about 30% :o
03:34 sri perhaps some regex wizard could optimize the actual regular expressions
03:39 gatitskiy joined #mojo
03:40 irq joined #mojo
03:40 Adura Wait... you do = ~ /$ATTR_RE/ but is there no circumstance where you could just =~ $ATTR_RE
03:40 Adura Mind that errant space.
03:53 basic6_ joined #mojo
03:54 jberger preaction: did you really think that sri designed a template language around indirect object syntax :-P
03:55 preaction no. i was explaining the different ways that statement could be interpreted by perl
03:56 jberger true enough
03:56 preaction and indirect-object syntax pops up where you least suspect it, turning what should be a syntax error into runnable code
03:56 preaction i should start putting 'no indirect' in all my base modules
03:57 preaction and indirect should be core so that everyone can disable it :p
03:57 jberger the only one I know that people mean is `print STDERR "something"` => `STDERR->print("something")`
03:57 jberger it should just go away
03:58 preaction we'd have to deprecate it for a while first, and making "no indirect" a core module would help people find their usage of it
04:03 jberger ye gods, indirect.xs is rediculous
04:07 disputin joined #mojo
04:16 JohnDRockefeller joined #mojo
04:19 reno joined #mojo
05:03 cpan_mojo Statocles 0.020 by Doug Bell - http://metacpan.org/release/PREACTION/Statocles-0.020 (depends on Mojolicious)
06:06 salparadise joined #mojo
06:08 denis_boyun joined #mojo
06:11 laouji joined #mojo
06:16 R0b0t1 joined #mojo
06:16 R0b0t1 Where's the documentation for the context? I'm kind of confused as to what it manages, and how.
06:18 sujithm joined #mojo
06:23 Eke- joined #mojo
06:31 mishantil R0b0t1: context?
06:35 R0b0t1 mishantil: Argument passed to route handlers?
06:35 R0b0t1 In the examples it's $c.
06:36 mishantil R0b0t1: $c == $controller in the examples, as far as I can remember.
06:37 riche I think the furthest you'll get is Mojolicious::Guides::Routing
06:37 riche other than that may need to read cod
06:37 riche *code
06:38 Vandal joined #mojo
06:38 riche yah Mojolicious::Routes doc is pretty light, most likely due to the assumption the Guide is where to go
06:43 mishantil riche: If I ever get the time I'll try to flesh out the docs a little in places like that.
06:44 mishantil Mojo has in my opinion a good documentation, but the feedback I have gotten is that if something isn't explained through an example in the guides it is pretty hard to find info on it.
06:46 mishantil Personally I love the guides as they show practical application, but sometimes I do long for a reference documentation.
06:46 mishantil Especially when I know approximately what I am looking for, but not exactly what it is called or where to find it.
06:51 R0b0t1 riche: Ok thanks
06:51 R0b0t1 that seems to have more info
06:52 R0b0t1 I have a text_like test that is failing: text_like('html body' => qr/Logout/);
06:52 R0b0t1 That text is in the body.
06:52 riche yah perhaps having an index that has podlinks to the various guides would help too
06:53 riche I find myself reading a short story every time i go into them ;)
06:53 riche gotta go ...
06:56 rawler joined #mojo
06:56 R0b0t1 (that last one was to anybody)
07:00 R0b0t1 I think the Guides::Growing has an error in it. The provided test module uses the above text_like call, but the text is inside an anchor element so it doesn't seem to work
07:01 Averna joined #mojo
07:03 _eugen joined #mojo
07:05 condor66 joined #mojo
07:06 eseyman joined #mojo
07:10 KCL_ joined #mojo
07:11 kyshtynbai joined #mojo
07:12 sujithm joined #mojo
07:26 R0b0t1 So, um... how do I get text_like to consider anchors?
07:42 dod joined #mojo
07:44 R0b0t1 (◕︵◕)
07:49 mishantil R0b0t1: What happens if you do 'a' => qw/Logout/ ?
08:01 riche joined #mojo
08:02 batman jberger: hehe (resting)
08:03 batman maybe you could add a cronjob that restarts it every five minutes?
08:08 R0b0t1 mishantil: Oh wow thanks
08:08 Martin90 joined #mojo
08:08 R0b0t1 didn't know it was 'a'
08:08 R0b0t1 but tried essentially that
08:09 mishantil R0b0t1: Hope you got it working. :)
08:12 R0b0t1 Yep, works now.
08:15 sri mishantil/riche: umm... it's one of the first things in the tutorial... http://mojolicio.us/perldoc/Mojolicious/Lite#Routes
08:16 basiliscos joined #mojo
08:20 sri riche: an index like literally our documentation page? http://mojolicio.us/perldoc#TUTORIAL
08:21 sri consider yourself yelled at!
08:21 sri (it's still too early here to actually yell...)
08:22 irq joined #mojo
08:25 sujithm joined #mojo
08:27 dabudabu Hmm, I defined a helper, and I can use it in my backend, but when I try to use it from a template, I get "Undefined subroutine &Mojo::Template::SandBox::json_encode called at template settings/en/register_get.html.ep line 81." :(
08:28 marcus__ joined #mojo
08:28 mishantil sri: The index is there, so that is a non-issue. :)
08:28 riche sri: well, someone was asking for a reference type thing and I'm not familiar w that guz i just goto the guides
08:28 neyasov__ joined #mojo
08:29 riche man long day can't even type
08:29 mishantil Happens to  the best of us.
08:48 dabudabu Geez. Never mind what I said earlier.
08:48 dabudabu The helper was called encode_json, not json_encode ;-;
08:48 reno joined #mojo
08:56 riche joined #mojo
08:56 meshl joined #mojo
09:05 chankey joined #mojo
09:24 sri for the record, this is where the documentation mentions that /o is supposed to do nothing on newer perls http://perldoc.perl.org/perlfaq6.html#What-is-%2fo-really-for%3f
09:25 sri the pattern never changes
09:25 hahainternet oh nice
09:25 hahainternet i didn't even realise that had been made automatic
09:27 batman joined #mojo
09:28 jberger_ joined #mojo
09:29 * sri wonders if the comparison perl has to do is too expensive for big regular expressions
09:30 hahainternet does it do it at runtime or does it do static analysis?
09:53 sri hmm, "use re 'debug'" tells me that it's recompiling the big regex all the fricking time Oo
09:54 andrefs joined #mojo
10:03 Jonneh joined #mojo
10:12 Martin90 Hello, how to get selected file name (object) from input form to perl
10:12 Martin90 http://pastebin.com/hkFYsxca
10:13 Martin90 basicly how to access this file from perl
10:14 Martin90 in php there is $_FILES['files']; how to do it in perl ?
10:14 bpmedley http://mojolicio.us/perldoc/Mojolicious/Lite#File_uploads
10:19 dotan_dimet joined #mojo
10:24 good_news_everyon joined #mojo
10:24 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/mZQ4pw
10:24 good_news_everyon mojo/master 502e791 Sebastian Riedel: improved Mojo::DOM::HTML performance slightly
10:24 good_news_everyon left #mojo
10:25 sri this one is very small... brings the html5 spec from 5.1s down to 5.0s
10:32 good_news_everyon joined #mojo
10:32 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/0xQYcQ
10:32 good_news_everyon mojo/master 92e466d Sebastian Riedel: more consistent formatting of regular expressions
10:32 good_news_everyon left #mojo
10:35 good_news_everyon joined #mojo
10:35 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/VbuPjQ
10:35 good_news_everyon mojo/master 08e35af Sebastian Riedel: another small formatting change
10:35 good_news_everyon left #mojo
10:36 sri re 'debug' gets really hard to follow with bigger regular expressions :S
10:50 d4rkie_ joined #mojo
10:54 lipizzan joined #mojo
11:04 mattastrophe joined #mojo
11:20 bpmedley_ joined #mojo
11:29 sujithm joined #mojo
11:32 D4RK-PH0ENiX joined #mojo
11:34 jberger sri: you could try rxrx
11:37 Martin90 is it possible to move all mojo module files to my website directory just to avoid future reinstall of module in case of server change ?
11:39 jberger Martin90: mojolicious is a pure perl module, you can deploy it however you like
11:39 jberger You might want to look into Carton
11:39 jberger Makes things easy
11:40 Martin90 thanks :)
11:41 mire joined #mojo
11:46 mishantil jberger: Used Carton together with Pinto?
11:49 Martin90 my $file = $c->param('file'); -> refers to input form, file->{filename} returns filename but how to get the list of file when I selected more then one file ?
11:52 jberger mishantil: i haven't, but I'm pretty sure I've heard that it works
11:54 jberger Martin90: there are examples in the param doc
11:54 jberger And i don't want to be rude, but even Ian starting to notice quite a few questions that come straight from the doc
11:55 jberger s/Ian/i'm/ # damn swipe type
11:56 neyasov joined #mojo
11:57 mishantil jberger: Wrt docs; yeah, there seems to be some confusion (and I am myself confused from time to time).
11:57 philly joined #mojo
11:57 mishantil It seems people read and try to follow the docs, and they are largely _very_ good, but still the questions arise.
11:58 mishantil My hypothesis is that questions might arise when they see a method-call in an example, but are unable to find a clear definition of a method.
11:59 mishantil Like "Takes the following X parameters:". Instead it usually have a short example and a notice about parameters inherited from somewhere else.
12:00 jberger Occasional questions are fine of course. I just don't fancy this channel becoming a replacement for the doc search
12:00 mishantil jberger: I agree with you there. Do you think a separate channel for those who have questions after looking in the docs would be better?
12:00 philly Hi all. What is the recommend way of unit testing methods defined in plugin helpers using Mojo?
12:01 marcus create a lite app, and test the helpers using that.
12:02 jberger philly: what marcus said
12:02 bpmedley philly: https://metacpan.org/source/JHTHORSEN/Mojolicious-Plugin-AssetPack-0.17/t  <— Here are some examples.  Probably quite a few examples on cpan.
12:03 jberger mishantil: we talked about that once and we were worried that the help channel would end up empty
12:04 philly many thanks all
12:04 mishantil jberger: That is indeed a risk.
12:05 mishantil jberger: One of the things I have really enjoyed about mojo is the friendlyness of the community and being able to get good answers from people "in the know".
12:06 jberger mishantil: that is important
12:07 mishantil jberger: Yeah, especially if we want people to spread the gospel. :)
12:07 jberger We are proud of that
12:07 mishantil And you have every right to be. That is one more area where mojo shines.
12:08 mishantil And it is in stark contrast to a couple of other channels for popular perl-frameworks.
12:11 jberger Meantime it is important that users (especially new ones) do their part by reading the doc (probably twice) so that the signal to noise here stays high
12:11 mishantil Indeed.
12:11 mishantil *looking to see if mojo has a FAQ-section*
12:12 mishantil So it does..
12:13 mishantil Could that be a good place to put answers to recurring questions, or is it meant as more of a page for obscure issues?
12:13 bpmedley mishantil: The guides and the tutorial are fantastic for recurring questions.
12:13 jberger Mostly we  try to improve the relevant doc for repeated questions
12:14 jberger Or else try to improve the framework to mitigate recurring problems in extreme cases
12:15 mishantil Ah ok. I don't really know how you guys work, so I might ask questions and suggest things that have already been discussed.
12:16 mishantil jberger: How do you organize which things need doing? Do you have a set of tasks defined somewhere?
12:17 jberger Dev is usually very fast here
12:18 jberger Ideas go from proposal to implementation to inclusion often in a matter of hours
12:18 jberger Mostly coordinated here
12:20 mire joined #mojo
12:21 sri it's so frustrating when people don't find the documentation
12:21 sri but i don't see much we can do
12:22 jberger The doc search on the website is very handy
12:22 Martin90 Mojo::Upload attributes can be accesed without usign this module ;)
12:26 mishantil sri: Can it perhaps be that people have an issue 'orienting' themselves in the documentation?
12:26 neilhwatson joined #mojo
12:27 mishantil Oh, now I noticed the 'Reference
12:27 mishantil ' section
12:27 mishantil Has that been there for long? That seems very handy. :)
12:28 bpmedley mishantil: http://mojolicio.us/perldoc/Mojolicious/Lite#TUTORIAL <— Have you seen that?
12:29 mishantil bpmedley: Yeah, I used that for "quick-starting" when picking up mojo. So looked at that for a couple of days while I got a feel for mojo.
12:29 mishantil But very quickly my needs changed wrt what kind of documentation I needed.
12:29 sri reference was added a few weeks ago
12:30 mishantil Explains why I haven't seen it until now. It is a nice addition.
12:31 mishantil I have (up until now) relied on the POD available in shell, and as a backup I've been reading the sourcecode.
12:37 Martin90 $c->param('file'); => get the info about file size no way ;(
12:38 Martin90 nothing from doc works
12:39 mishantil Martin90: Mojo::Upload has a ->size() method. Have you tried that? Or is the issue that you haven't found a way to get the Mojo::Upload object?
12:40 mishantil Martin90: And are you sure that the form has been submitted as multipart/form-data?
12:41 mishantil $c->param('myfilefield') _should_ give you a Mojo::Upload-object
12:42 Martin90 yes it gives
12:42 Insane $c->param('file')->filename <- filename, $c->param('file')->slurp <- content, and 'if $self->req->is_limit_exceeded' as filesize limit check
12:43 Martin90 $c->param('file')->filename => returns filename only
12:43 Insane $c->param('file')->slurp will return file contents
12:43 Insane and you can calculate filesize from it
12:43 mishantil Martin90: ..and $c->param('file')->size returns the size.
12:44 Insane or use ->size, yep
12:44 mishantil Martin90: Calling $c->param('file') gives you a Mojo::Upload object. With methods as described here: http://search.cpan.org/~sri/Mojolicious-5.12/lib/Mojo/Upload.pm
12:45 Martin90 my $size = $c->param('file')->size; # ?
12:45 mishantil Martin90: Yes.
12:45 Martin90 guess what
12:45 purl All of the above.
12:45 mishantil Martin90: Remember that what you get is the size in bytes.
12:46 Martin90 unfortunately no ;/
12:46 Martin90 What it returns me is word "size"
12:46 Martin90 one sec
12:47 Martin90 ok now it seems to work
12:47 Martin90 fro mstart I was typo i nmy code ehh o.0
12:47 Martin90 Thank you guys ;-)
12:48 Martin90 but the way to get is a bit complicated, we can get filename by simple $file->{filename}; why not do the same way filesize ?
12:49 mishantil Martin90: No problem. Next time though: paste some code on pastebin. Makes it easier for people to help.
12:50 mishantil Martin90: Not complicated at all? my $file = $c->param('file'); $file->size (for size) $file->filename (for filename) $file->move_to (to put file somewhere else)
12:51 Martin90 Problem arrise when you select more then one file
12:52 Martin90 So far I can see why to handle array of files
12:52 Martin90 can't*
12:55 mishantil Martin90: Have a look at $c->req->uploads . I think there you will find a list of all uploads.
13:01 Martin90 yeah looks like it contains all info, thanks ;)
13:02 mishantil Martin90: Happy to help.
13:06 WildPIkachu_ where would be the best place to connect to a DB so my fcgi app gets 1 db connection per child spawned?
13:06 sujithm joined #mojo
13:07 bpmedley WildPIkachu_: You might consider a helper and a state variable.
13:07 WildPIkachu_ now thats a good idea
13:11 crab joined #mojo
13:13 WildPIkachu_ https://github.com/kraih/mojo/wiki/Hypnotoad-prefork-web-server#tips  <= something like this bpmedley ? that little snippet of code there
13:14 bpmedley Moment
13:15 bpmedley WildPIkachu_: https://gist.github.com/jberger/6984421  <— This may be simpler
13:17 * neilhwatson uses a helper too.
13:17 * WildPIkachu_ thinks really hard how he will get that into his non-Lite app :)
13:19 neilhwatson WildPIkachu_: see if this example helps. Might not be the best code, still learning Mojo, but it does work: https://github.com/evolvethinking/delta_reporting/blob/master/app/lib/DeltaR.pm
13:19 crab by converting "helper blah => ..." to $app->helper(blah => ...)"
13:19 Martin90 $c->render(text => "@$file_list"); => ok, returns whole array elem. |  $c->render(text => @$file_list); => not work only single array elm is returned
13:19 WildPIkachu_ thanks guys :)
13:19 WildPIkachu_ I think I"m on the right track now, thanks again :)
13:20 crab if you have to think hard about how to do something in non-lite that can be done in lite, you're doing it wrong
13:20 Martin90 $c->render(text =>""); doesn't work without quotes which isn't good
13:20 sri Martin90: $file->{filename} is *NOT* a supported feature, you're poking into an object, which will break in the future
13:20 bpmedley WildPIkachu_: http://pastie.org/9393454
13:20 sri don't ever poke into objects, use the documented api
13:21 Martin90 sri, ok ;)
13:21 Martin90 encapsulatin right ?
13:22 philly joined #mojo
13:23 * genio wonders what's going on with p5-mop these days
13:24 bpmedley WildPIkachu_: Do you understand the methodology a Lite uses to create its micro-web framework environment?
13:25 WildPIkachu_ bpmedley, I believe I have a grip, and I also understand there are many many ways to do things, I just don't want to choose a clearly wrong way :)
13:26 bpmedley WildPIkachu_: https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Lite.pm#L47 <— See how it imports the subs into the caller?
13:26 Kripton joined #mojo
13:27 WildPIkachu_ yep, I didn't link helper in my head tho, I knew that get/put/post were like that :), it makes things really easy
13:29 sri ideas for making this regex more efficient welcome btw. https://github.com/kraih/mojo/blob/master/lib/Mojo/DOM/HTML.pm#L24
13:31 marty joined #mojo
13:33 neilhwatson Wow, some things you just can't unsee :)
13:35 sri funny thing is, that's probably the most readable html parser you'll ever come across ;p
13:38 neilhwatson Perl is always about use CPAN, yet you seem to be going it alone versus using an existing module.  Curious, why?
13:38 sri what should i use instead?
13:38 WildPIkachu_ neilhwatson, you say that, but one of the strongest points I find with Mojo is 0 deps :)
13:39 genio I'll give you that, it's fairly easy to grasp how you're doing it.  as for the expression, I don't really see anything to improve on it at the moment
13:39 sri 0 deps is not a goal for mojolicious, if cpan components are good enough we'll use them
13:39 genio although there are things later that kind of make me wonder... L123
13:40 neilhwatson I don't know, I'm not that experienced, but for me I always assume someone someone has already done it, and usually better than I could. I'm not criticising, but trying to learn from other Perl devs.
13:41 sri neilhwatson: maybe try not making your question sound like an accusation then
13:42 genio neilhwatson: I was asking that a lot when starting with Mojo, but the more I use Mojo, the more I realize that the wheels that have been recreated have been recreated... a lot better than the previous.  Smoother ride.
13:42 Martin90 for (1..10) {$c->render(text => "$file_list"); } why this prints only once ?
13:42 sri neilhwatson: but to answer for you... if you want a decent html5 capable parser from cpan... you have the choice between libxml and libxml
13:43 WildPIkachu_ sri, understood ... its just one of the aspects that makes it so extremely  easy to use on embedded systems where adding additional per modules is a pain, or to incorporate in other perl apps which do target minimal deps :)
13:43 sri HTML::Parser if you're really desparate
13:43 sri they're all XS
13:44 sri i made Mojo::DOM because i wanted a kick ass pure perl parser that eats just about anything that looks like tag soup, yet close to the html5 spec
13:48 neilhwatson Not more efficient, but would named capture groups help readers to understand the regex better? It's a big re to try matching so many captures via ().
13:48 sri fun fact, Mojo::DOM (pure perl) is actually faster and more correct than HTML::TreeBuilder (XS HTML::Parser)
13:48 sri neilhwatson: you can't use named capture groups
13:49 sri they did leak until 5.18 or so
13:49 genio I've never been a fan of named captures, they just muddy up the expression to me.
13:50 sri Martin90: please don't cross post
13:50 sri it's very rude
13:51 sujithm joined #mojo
13:51 dotan joined #mojo
13:52 genio Oh, nevermind on my comment on L123.  I see $tag can possibly have newlines and such still; thus [\s\S]*  I made a mental assumption about $tag without going back to see where it was coming from
13:55 sri genio: i'm sure not all those regular expressions are ideal yet either
13:55 sri so feel free to experiment
13:56 sri they are not very high in my nytprof data... but who knows, maybe you can get a few % out of them anyway
13:57 sri btw. this is still my favorite profiling test for Mojo::DOM
13:57 sri perl -Ilib -Mojo -MTime::HiRes=time -E 'my $res = g($ARGV[0]); say my $start = time; $res->dom; say time - $start' http://www.whatwg.org/specs/web-apps/current-work/
13:57 sri parsing the full html5 spec
13:58 sri 7.7mb of very wild html markup
13:59 sri "-d:NYTProf" if you want to dig deeper
14:00 sri this html5 parser is actually quite readable... little verbose though :D https://github.com/html5lib/html5lib-python/blob/master/html5lib/html5parser.py
14:00 sri official algorithm though, can;t parse xml with that
14:00 hahainternet 2723 source lines
14:00 hahainternet jesus
14:01 sri that was only the parser, the tokenizer is pretty big too ;p https://github.com/html5lib/html5lib-python/blob/master/html5lib/tokenizer.py
14:01 mishantil sri: 2.95399808883667 for me. I see absolutely no load while parsing it though. :)
14:01 hahainternet sri: bloody python :D
14:01 sri oh, fast box
14:02 hahainternet hold on
14:02 sri mishantil: my macbook air needs 5.0s :S
14:02 hahainternet lets try on a REALLY fast box
14:02 hahainternet dunno if i have the latest mojo on there though
14:02 sri mojo version matters *a lot*
14:02 sri 5.14 is much faster
14:02 hahainternet yeah just building it against perl 5.16.3
14:02 mishantil sri: Just noticed that I ran it on 4.19. :-/
14:03 sri :O
14:03 mishantil version 4.19 that is
14:03 hahainternet sri: single or multithreaded in this case?
14:03 hahainternet i'm guessing it's single
14:04 hahainternet 1405433040.9213
14:04 hahainternet 3.10511994361877
14:04 hahainternet two outputs
14:04 hahainternet lets grab latest perl too
14:06 sri for comparison, with 5.13 it took 7.2s on my macbook
14:06 mishantil That means it should be very fast here on the newest mojo.
14:06 sri so if you parse stuff, really upgrade
14:08 hahainternet 3.1s is pretty good for the entire spec to be honest
14:09 hahainternet and that probably included some cpu ramping time
14:09 hahainternet i can't imagine that 4.19 managed it in 2.95s
14:09 hahainternet unless you're on some ridiculous machine
14:09 hahainternet anyway sri i don't have anything else to compare it to
14:09 hahainternet but as usual gj on your incredibly rapid iteration and improvement
14:12 mishantil The machine is not that ridiculous I think.
14:15 mishantil From /proc/cpuinfo : "Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz"
14:16 mishantil ...but it seems like it is running at 800mHz on all cores while doing the benchmark.
14:16 mishantil And only putting load on one of them.
14:21 hahainternet 4770k is a pretty nice
14:21 hahainternet i have the old 3770k but at 4.4ghz
14:22 hahainternet ok perl 5.20.0 brings it down about 0.1s on average
14:23 hahainternet getting consistently under 3s now
14:23 hahainternet but there's not much in the way of load there as mishantil said
14:23 hahainternet so probably burning a bit of time elsewhere
14:32 ryozi joined #mojo
14:32 disputin joined #mojo
14:33 mishantil Most of the time seems to be spent in IO::Poll::_poll (74.46%)
14:34 mishantil Oh wait, that is for the entire thing. Forgot that I should disregard that part.
14:40 hahainternet yeah but even so
14:40 hahainternet i'll try and profile it in a bit
14:40 hahainternet distracted atm
14:42 mishantil Me too. Really need to put my head back into proofreading and supplementing a grant application (the money-kind). Keep finding ways to distract myself.
14:42 mishantil Unbelievably boring stuff...
14:45 neyasov joined #mojo
14:45 Martin90 joined #mojo
14:50 Martin90 ehh ;(
14:50 Martin90 why this code doesn't work http://pastebin.com/e9ZE8Mg2
14:51 sh4 joined #mojo
14:51 mishantil Martin90: Because you try to grab only a single upload?
14:51 Martin90 hmm why single ?
14:52 mishantil Martin90: Try something like: http://pastebin.com/KDSk47eK I have not verified that it works though.
14:52 Martin90 Can't call method "filename" on unblessed reference at C:\Users\Martin\Desktop\Drag and frop upload\script.pl line 15.
14:54 Martin90 that's the output after change upload method to uploads
14:54 mishantil It might be that ->uploads return an arrayref. I can't remember really.
14:54 Martin90 it does
14:55 Martin90 but then I try to call method filename on each of elemnt and it doesn't work
14:56 rawler joined #mojo
14:56 crab drag and frop!
14:57 mishantil :)
14:57 mishantil Drag and fap?
14:57 mishantil Martin90: Anyway; you could try something like this: http://pastebin.com/srpX7Nb7
14:58 mishantil It still doesn't do what I think you want it to do, but what you really need to do at this point i start digging into what each method you call (like ->uploads) give you.
14:58 Martin90 crab: it's typo but where have yo useen that ?
14:58 mishantil point i => point is
14:59 disputin joined #mojo
14:59 meshl joined #mojo
15:00 Martin90 mishantil: ->uploads gives me array ref
15:00 Martin90 and that's ok
15:00 Martin90 the problem arise when I try to call method on these elemnts
15:01 Martin90 And for what I see "$c->render(text => "@file_names"); " prints only one elemnts not enire array !
15:03 Martin90 or not
15:05 mishantil Martin90: Yes, but that is just because you need to read up on exactly how perl handles types in which context.
15:07 mishantil Martin90: I would strongly recommend the book Programming Perl as a start. It takes you through basic perl concepts like types and context, and then move on to more and more cool stuff.
15:07 Martin90 I already know that
15:08 Martin90 one sec and I show you something weird
15:09 disputin joined #mojo
15:12 Martin90 http://pastebin.com/h50SqKny
15:12 Martin90 Browser output => First file => Chrysanthemum.jpg ; FIle names ->
15:13 Martin90 It shows that something is wrong with this module
15:13 Martin90 my $file_1 = $files->[0]->filename; #works
15:13 Martin90 but when in loop $id->filename #doesn't work
15:14 Martin90 any idea ;/ ?
15:15 Martin90 Ahhh
15:15 Adura It's a logic error in your foreach...
15:15 Martin90 how stupid
15:15 Martin90 no logic
15:15 purl no logic is probably for those with no imagination
15:16 Martin90 Adura where yo usee logic error, I should put $i= outside the loop ;)
15:16 Adura Heh.
15:17 Martin90 but even with these mistake it shold prints out single filename hmmm
15:17 Martin90 mishantil: thanks you anyway ;)
15:21 marty Martin90: You are reseting $i to 0 on each loop iteration.
15:21 Martin90 as for documentation, sri: in Mojo:upload is not even single word about "$c->req->uploads"
15:21 Martin90 marty: right I alredy figured it out (see above) ;)
15:27 Adura http://mojolicio.us/perldoc/Mojo/Message#uploads It's part of the req(est), so it's Mojo::Message.
15:29 basic6 joined #mojo
15:30 sujithm joined #mojo
15:30 Martin90 Sure it is somewhere in doc but IMHO, it bad that it isn't present in Mojo::upload doc and you have too look in several locations to gather information ralated to one task
15:31 KCL joined #mojo
15:31 Adura Related to the object you're calling the method on...
15:35 Martin90 to start upload process we use move_to method ?
15:35 Martin90 looks strange
15:47 meshl joined #mojo
15:49 mattastrophe joined #mojo
16:12 Mad_Dud joined #mojo
16:35 janliesendahl joined #mojo
16:57 Martin90 joined #mojo
17:03 marcus__ joined #mojo
17:06 Martin90 when the content of @@ foo.html.ep is exec ?
17:06 Kripton joined #mojo
17:06 Martin90 Essentially how to open @@ index.html.ep
17:18 crab index.html.ep will be first loaded when something calls ->render() for it
17:18 ua joined #mojo
17:18 crab that might be an explicit render call, or implicit because it matches a route name, etc.
17:18 crab i don't understand your question about "how to open" it, though.
17:20 ua1 joined #mojo
17:39 ua joined #mojo
17:56 * sri yawns
17:56 * mishantil echos
18:09 * tempire squeals
18:13 mishantil All lady-like I hope? That's the best kind.
18:14 tempire http://www.youtube.com/watch?v=7mZZd4gQrrg
18:15 sri \o/
18:17 genio heh.  I'm tempted to do that around the office now.  It looks fun
18:20 marcus__ joined #mojo
18:22 reno joined #mojo
18:22 reno hi guys
18:23 disputin joined #mojo
18:23 tempire HI RENO
18:23 tempire WE'RE RUNNING
18:23 tempire RUNNING
18:23 tempire WEEEEEEEEEEE!!!!!!!!!!one
18:24 * lb shoots tempire
18:24 * tempire keeps running
18:24 reno :)
18:24 mishantil lb: Oyh!
18:24 * mishantil finds his trout from yesteryear
18:25 lb mst?
18:25 purl well, mst is that limey twat with delusions of grandeur or http://shadow.cat/blog/matt-s-trout or mystery science theatre or maladie sexuellement transmissible or fails at carting or location determined by a superposition or melting in sundry timezones or HATEOSAURUS REX or not webscale or perl's Dr. House or a wizard or knows the future
18:26 marcus__ o/ lb
18:26 lb marcus__: so did you notice what i said about mojoconf
18:31 Eke- joined #mojo
18:42 * sri pokes marcus with a stick
18:42 marcus__ I did not notice.
18:42 marcus__ What did you say?
18:42 purl I'm sorry, I'm sorry, what I actually said is, *gets megaphone* HOW WOULD YOU LIKE TO LICK MY BALLS
18:43 * marcus__ hushes purl.
18:46 lb i said i might have snared in some suckers to help organize it in copenhagen
18:47 marcus Oh, that is excellent news. Please give Salve your bank account number, so we can get this rolling :)
18:47 lb probably seeing salve tomorrow
18:48 mishantil And let us coax tempire into doing more training.
18:49 lb no, we'll have tempire tied up elsewhere
18:50 marcus hogtie?
18:51 lb maybe later
18:52 mishantil I can bring a paddle or four to the party.
18:56 irq joined #mojo
18:58 sri btw. i think i might know why the /o flag made such a difference
18:59 sri perl -Mre=debug -E 'my $test = qr/foo/; "bar" =~ /$test/g for 1 .. 5'
18:59 sri this one does not recompile the regex
18:59 sri perl -Mre=debug -E 'my $test = qr/foo/; "bar" =~ /a$test/g for 1 .. 5'
18:59 sri this one does
19:00 sri looks like the optimization perl 5.6+ does only applies if the whole regex is contained in the scalar
19:00 mishantil Oh. Now _that_ is useful information.
19:01 elik joined #mojo
19:04 sri perl -Mre=debug -E 'my $x = qr/y/; "y" =~ /$x/g for 1 .. 2; "y" =~ /z$x/g for 1 .. 2'
19:04 sri little more obvious, second one gets recompiled
19:04 neyasov joined #mojo
19:10 sri haha, it's a perl bug :(
19:11 sri with older versions it is not recompiled
19:12 sri only a 5.20 thing it seems :S
19:18 mire joined #mojo
19:20 sri 5.20 output btw. http://pastie.org/9394486
19:22 sri not the first perl bug Mojo::DOM helped to detect :)
19:24 r0b3rt joined #mojo
19:32 * sri faints
19:32 sri looks like consensus is that it's a FEATURE!
19:32 disputin joined #mojo
19:32 sri so better get used to /o
19:49 lb sri: yeah, haven't had much luck arguing for problems in the regex engines
19:49 lb -s
19:53 JohnDRockefeller joined #mojo
19:58 sujithm joined #mojo
20:15 dod joined #mojo
20:16 g1tlh joined #mojo
20:17 sri trying to fit this issue into a tweet is really hard ;p
20:25 go|dfish there was also a 'regexp memory explosion' in 5.20 posted to p5p the other day
20:32 neilhwatson joined #mojo
20:32 WildPIkachu_ For authentication, I guess writing a condition, and a bridge to catch everything would be the "right" way to implement a member only app?
20:33 dod joined #mojo
20:34 Jonis girlfriend is working, so I'm mucking about with Mojo::IRC
20:34 Jonis yay
20:49 riche left #mojo
20:52 marcus jonis: Yay indeed.
20:59 WildPIkachu_ yay**yay
21:04 TenshiLyle joined #mojo
21:14 meshl joined #mojo
21:36 mattastrophe joined #mojo
21:51 WildPIkachu_ where would be the best place for me to intercept all requests if unauthenticated so I can render a login page?  before_dispatch hook maybe?
21:51 throughnothing joined #mojo
21:53 cfedde isn't that what 'under' is for?
21:55 * WildPIkachu_ reads up on under
21:57 WildPIkachu_ cfedde, I'm trying to write a module which when loaded will redirect everything to a login page, if the user is logged in allow them access as per normal
21:58 cfedde basic auth? or some kind of cookie/app level login?
21:58 WildPIkachu_ little more than just basic auth
21:58 cfedde under lets you share code across all routes.
21:58 WildPIkachu_ cfedde, my goal is absolute transparency :)
21:59 cfedde I guess I'm not getting the point.
21:59 WildPIkachu_ I'm writing an auth module to use for a few apps I'm planning, so I just want to load it and forget about it
21:59 WildPIkachu_ It add a couple of its own routes for admin pages and user profile pages
22:00 WildPIkachu_ but it needs to intercept all unauthenticated requests and send them to the login action it has, without having to make modifications to the main app
22:03 disputin joined #mojo
22:04 cfedde how will you be able to tell if a user is authenticated? what under does is gives you a place to put that test code.
22:09 * WildPIkachu_ thinks ... ok
22:10 WildPIkachu_ I will have to make a few changes to my plan then, not a train smash, let me play with under
22:10 cfedde so a plugin can load an under route.
22:11 WildPIkachu_ I just tried an under route on / and I must be doing something wrong :)
22:12 cfedde the first example in https://metacpan.org/pod/Mojolicious::Lite#Under might be close to what you want.
22:12 throughnothing joined #mojo
22:13 WildPIkachu_ exactly what I'm looking at cfedde  :)
22:13 WildPIkachu_ just need to figure out its usage that sall
22:13 cfedde it decorates all the urls in that context with the code to see if name=bender is passed.
22:14 WildPIkachu_ yea, thanks :)
22:14 cfedde does that come close or am I way off base and we're talkign about something else altogether?
22:15 WildPIkachu_ I'm not 100% sure .... I'm going to try it out and see :)
22:19 WildPIkachu_ I'm definitely doing something wrong, let me read over it a few more times, seems my under( sub { } )  for some reason isn't being called
22:30 _WildPikachu_ joined #mojo
22:31 _WildPikachu_ http://paste.linuxassist.net/view/d4c60a16 <= this is what I'm trying cfedde
22:51 D4RK-PH0ENiX joined #mojo
22:51 D4RK-PH0ENiX joined #mojo
23:00 basiliscos joined #mojo
23:20 neyasov joined #mojo
23:25 basic6_ joined #mojo
23:30 WildPikachu I really must be doing something wrong, I've been over those lines so many times :(
23:33 bpmedley WildPikachu: Try a bridge?  One sec.
23:34 bpmedley WildPikachu: https://bitbucket.org/bpmedley/sparky/src/d1c17cd2d9e5b08d1272a629668f4f13e14793ac/lib/Sparky.pm?at=master#cl-329
23:35 bpmedley Sorry, line 341
23:35 * WildPikachu studies bpmedley's paste :)
23:35 WildPikachu bpmedley, my issue seems to be I'm doing something wrong, so my under anon sub is not even being called
23:36 bpmedley Would you try the approach in my code?
23:36 WildPikachu sure thing :)
23:37 neilhwatson joined #mojo
23:38 WildPikachu bpmedley, btw, is your logged_in under being called?
23:38 bpmedley I don’t think so.  Sorry that it’s there.
23:42 WildPikachu how on earth can my $routes->under  return undef, I think this is the problem I have, hrmmmmm *investigates)
23:47 kmx joined #mojo

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