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

IRC log for #mojo, 2017-07-15

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

All times shown according to UTC.

Time Nick Message
00:08 kgoess is it possible to use Test::Mojo to test a mojo app that itself does an async Mojo::UserAgent call?
00:09 kgoess it looks like maybe the test exists without waiting for the $ua to finish its business
00:13 kgoess s/exists/exits/
00:19 marty joined #mojo
00:39 karjala_ joined #mojo
01:15 genio sri: It's getting closer: https://github.com/genio/p5-UV  all tests passing
01:49 jberger CandyAngel mostly, assuming this makes any sense, the TO_JSON method is used for serialization
02:05 noganex joined #mojo
04:04 kaare joined #mojo
05:11 marcus genio++
06:01 cng joined #mojo
06:04 karjala_ joined #mojo
06:08 cng joined #mojo
06:17 zivester joined #mojo
06:24 Lee_ joined #mojo
06:29 Lee[home] joined #mojo
07:18 yukikimoto joined #mojo
07:23 schelcj joined #mojo
07:36 Vandal joined #mojo
07:41 petru joined #mojo
08:02 itaipu joined #mojo
08:05 bianca joined #mojo
08:29 stryx` joined #mojo
08:29 bianca joined #mojo
08:29 kiwiroy joined #mojo
08:32 irqq joined #mojo
08:34 trone joined #mojo
09:27 bianca joined #mojo
10:52 Lee[home] joined #mojo
10:53 Lee_ joined #mojo
10:59 bianca joined #mojo
11:07 zerah joined #mojo
11:46 yukikimoto joined #mojo
11:47 sri genio++ # can't wait to try it
11:48 VVelox joined #mojo
11:57 karjala__ joined #mojo
12:26 VVelox joined #mojo
12:39 Vandal wich hook can I use to access placeholders before they get to controller?
12:40 Vandal it seems that before_routes doesn't have them and around_action has scary warning and would be overkill for me I think
13:00 petru joined #mojo
13:00 bianca joined #mojo
13:11 gizmomathboy joined #mojo
13:19 bianca joined #mojo
13:20 someguy Vandal: might as well try it, and if it turns out there's a less "over kill" way to do it, you can always change it
13:22 someguy It might turn out that an under was all you needed though
13:24 Lee_ joined #mojo
13:29 Lee[home] joined #mojo
13:41 mib_5vk6fr joined #mojo
13:45 Vandal someguy, nope, under isn't working
14:01 jberger Vandal: what are you trying to do?
14:04 Vandal jberger, nvm, I'll use around_action
14:06 PryMar56 joined #mojo
14:36 bianca joined #mojo
14:40 kaare joined #mojo
14:46 kaare_ joined #mojo
14:52 Lee[home] joined #mojo
14:53 Lee_ joined #mojo
14:53 gordonfish joined #mojo
14:55 gordonfish I was looking at the code under http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Reusable-template-blocks, underneath "A naive translation"..., specifically the "xml_escape scalar + $block->('Wolfgang')" part of the pseudo/equivilancy code.
14:55 gordonfish I'm wondering why the + in "scalar +" was chosen there. When I try a similar example the + cuases a warning to be issued.
14:56 gordonfish "Warning: Use of "scalar" without parentheses is ambiguous"
14:56 gordonfish (It makes me wonder if that pseudo/equivilancy code should maybe be ammended?)
14:57 gordonfish eval: sub foo { @_ } my $bar = sub { qw(x y z) }; [ foo scalar + $bar->('foo') ] # generates that warning.
14:57 pink_mist no perlbot in here
14:57 gordonfish eval: sub foo { @_ } my $bar = sub { qw(x y z) }; [ foo scalar $bar->('foo') ]; # does not
14:57 gordonfish Oh, right (and shoulda written sweval not eval)
15:04 kaare_ joined #mojo
15:11 dod joined #mojo
15:16 dod joined #mojo
15:29 karjala_ joined #mojo
15:33 sri anyone got a good ctags config for perl?
15:53 sri tried to use this https://github.com/atom/symbols-view/blob/master/lib/ctags-config#L109
15:54 sri turns out it's borked and \w+ doesn't work
16:05 dod joined #mojo
16:16 petru joined #mojo
16:23 iamb joined #mojo
16:34 bianca joined #mojo
16:46 kaare_ joined #mojo
17:44 bianca joined #mojo
17:59 bianca joined #mojo
18:00 petru joined #mojo
18:02 zivester joined #mojo
18:32 bianca hi, I am trying to write tests in mojolicious for checking if an image was sent correctly from a form. In the controller I am checking if $image_file->headers->content_type =~ /image/. The tests, on the other side, send the image file as image_upl => { content => 'abc', filename => 'x.png' }. But the check fails, I don't really understand how those headers are set, so that I can send a mock image. Any thoughts?
18:41 Lee[home] joined #mojo
18:46 Lee_ joined #mojo
19:00 dod joined #mojo
19:23 gordonfish bianca: It might be better to send an actual test image, so it's a more real world test
19:24 zach is there an easy way to make a password change form with mojo, where I can say new password and repeat new password fields must match on the front end through helpers or something?
19:24 zach I don't really want to have to do more JS right now
19:25 zach I'm fine with containing it on the backend, but I feel like the front end should also tell you you screwed up if possible
19:25 pink_mist zach: frontend code only works with JS
19:26 bianca gordonfish: hm do you know how I can do that? From what I saw the way to send files is to specify the content and filename, I tried creating a Mojo::Upload object and sending it as {image_file => $mojo_upload} but it crashes inside the tests and I actually don't know where I can see why, it just returns 500
19:26 pink_mist bianca: the way to send files is with a $c->asset->static()
19:27 pink_mist unless you mean upload to a server
19:27 zach pink_mist: I know, but I was hoping for a mojo generator for it :(
19:27 zach pink_mist: I already do tag helpers :P
19:27 pink_mist zach: no such thing, sorry
19:28 zach need mojo js helpers lol
19:28 bianca pink_mist: I just want to send it through a post request. In your example, what is $c?
19:28 bianca is it the mojo::upload object?
19:28 pink_mist bianca: the controller
19:28 purl the controller is, like, all fine until someone writes another app that uses the same db/model
19:28 bianca ah ok, checking it out
19:29 pink_mist bianca: so you do mean upload to a server then
19:29 pink_mist ?
19:29 bianca hm well yeah, what is the other way?
19:30 pink_mist the controller is on the server side. as is a Mojo::Upload object
19:30 pink_mist not on the user agent side
19:30 pink_mist which seems to be what you're talking about
19:30 bianca ok, I have a form on the user agent side, yes
19:30 bianca and sending a request to the server
19:31 pink_mist so how are you sending the request?
19:32 bianca so I have <input type="file" name="image_upload" accept="image/*"> inside a form, which is grabbed in the controller through $self->req->upload('image_upload')
19:32 bianca and that is treated as a Mojo::Upload from what I understood
19:32 pink_mist so how are you sending the request?
19:32 bianca hm I'm using templates?
19:33 pink_mist what
19:33 pink_mist I think I am not able to help you =(
19:33 pink_mist I don't think we're on the same page at all
19:33 bianca <%= form_for 'on_attachment_add' => (method => 'POST') => (enctype => "multipart/form-data") => begin %>
19:34 bianca I'm referring to mojolicious templates
19:34 preaction they could show us the code and it might be easier
19:35 bianca :( ok, I'll try to come back with a clearer question
19:36 brunoramos joined #mojo
19:41 bianca pink_mist: I believe the answer to this question summarizes what I am doing https://stackoverflow.com/questions/10152973/how-upload-file-using-mojolicious Now I want to write the tests and send an image in the form as I said earlier
19:46 bianca Here is the problematic code: http://ideone.com/vM565G
19:50 preaction bianca: my guess is your test doesn't set the content-type header. at the bottom of this section of the docs, it shows how to post files http://mojolicious.org/perldoc/Mojo/UserAgent/Transactor#tx
20:05 bianca preaction thanks! adding 'Content-Type' => 'image/png' inside the hash reference as specified in the link did the trick :)
20:07 depesz joined #mojo
20:07 depesz hi. i have a problem - I have an array, with strings. the strings contain polish accents, and as far as I can tell, these are recognized correctly as wide-characters.
20:08 depesz in Mojo, I then convert it to json, using: Mojo::JSON 'encode_json'
20:08 depesz and it looks that it encodes it again to utf8, basically changing my data.
20:08 depesz not sure if my description is clear
20:10 depesz it looks that after encode_json, the data is still correct. so only after including it in template, using <%== stash 'roles_list' %>, it gets re-encoded.
20:20 pink_mist depesz: encode_json take characters, that is decoded characters, not utf-8 encoded bytes. if what you have is utf-8 encoded bytes you may need to use to_json instead
20:20 depesz ah, thanks a lot
20:21 pink_mist of course, if the problem occurs when you get it from the stash the problem might be different and I misunderstood you
20:36 sri it's a bit ugly though, to use to_json with already encoded bytes
20:36 sri generally you should decode data to characters when it enters perl space
20:37 sri (textual data)
20:54 Grinnz he doesn't have utf-8 encoded bytes, but the template will encode to UTF-8, so you want to use to_json so the resulting json is characters
20:54 warrior98 joined #mojo
20:57 sri oh, i misunderstood, carry on then :)
21:24 warrior98 Hello! I want to implement a form for a project of mine, and I want it to be pre-completed with the info I already have about the logged user in my database so he knows if he wants to change that data
21:25 warrior98 How can i do that?
21:28 warrior98 Oh, never mind, it was easier than i thought :D
21:41 pink_mist Grinnz: oh, then I actually misunderstood but mistakenly gave the right answer :P
21:52 Grinnz "mistaken right answer" is a common solution to encoding issues
21:53 Grinnz warrior98: the value attribute of form elements will let you prefill a value, so set that in the template
22:00 ptolemarch joined #mojo
22:11 Lee[home] joined #mojo
22:11 warrior98 joined #mojo
22:19 Lee[home] joined #mojo
22:20 Lee_ joined #mojo

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