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

IRC log for #mojo, 2016-10-12

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

All times shown according to UTC.

Time Nick Message
00:16 tchaves joined #mojo
00:19 jabberwok joined #mojo
00:53 bpmedley sri : use constant HAS_AF_INET6 => defined eval { Socket::AF_INET6() }  <-- would this do well for IPv6 support detection
00:58 suede ʰᵉʸ
00:59 Janos joined #mojo
01:28 tchaves joined #mojo
01:30 zivester joined #mojo
01:44 trwww left #mojo
02:19 Janos joined #mojo
02:49 noganex_ joined #mojo
03:05 Sebbe joined #mojo
03:30 Sebbe joined #mojo
04:12 polettix joined #mojo
04:26 Sebbe joined #mojo
04:33 Sebbe joined #mojo
05:19 inokenty-w joined #mojo
05:24 dod joined #mojo
05:29 dod joined #mojo
05:35 Adura_ joined #mojo
05:53 dod joined #mojo
06:08 khfeng joined #mojo
06:17 Lee joined #mojo
06:34 Vandal joined #mojo
06:36 trone joined #mojo
06:38 Lee joined #mojo
06:48 juikuen joined #mojo
07:03 mbudde joined #mojo
07:04 suede joined #mojo
07:21 martin joined #mojo
07:32 trone joined #mojo
07:45 aborazmeh joined #mojo
07:46 martin joined #mojo
08:09 martin joined #mojo
08:16 osfabibisi joined #mojo
08:21 polettix joined #mojo
08:24 rshadow joined #mojo
08:54 martin joined #mojo
09:14 lluad joined #mojo
10:02 trone joined #mojo
10:34 lluad joined #mojo
10:47 martin joined #mojo
11:07 trone joined #mojo
11:15 polettix joined #mojo
12:00 pink_mist jberger: you about?
12:01 pink_mist (or some other op who feels like they have a say about a code of conduct question)
12:03 * marcus hides
12:03 * pink_mist pounces
12:06 tchaves joined #mojo
12:07 pink_mist well, that was fruitless, guess I'll wait for the next op that comes around :P
12:27 asarch joined #mojo
12:29 jberger pink_mist: Hi
12:29 pink_mist ah, there you are =) I'll PM =)
12:30 jberger Ok
12:31 trone joined #mojo
12:38 jberger pink_mist++ # thoughtfulness
12:42 gizmomathboy joined #mojo
12:49 tchaves joined #mojo
12:51 Sebbe joined #mojo
12:51 tchaves joined #mojo
12:56 martin joined #mojo
12:56 tchaves1 joined #mojo
13:01 zivester joined #mojo
13:03 Lee batman: can i use toadfarm to run multiple instances of the same mojo app with different configs?
13:04 Lee i'm assuming yes from the docs but haven't got as far as testing yet
13:08 batman Lee: yes.
13:08 batman the only reason why that wouldn't work, is if the app use global data.
13:08 Lee great, ta!
13:09 batman like `$main::config = app->config;` or something other weirdness :)
13:09 batman *some
13:09 batman but you can't run different versions of the same app. (that's a limitation in perl)
13:09 Lee that's fine
13:16 tchaves joined #mojo
13:33 martin joined #mojo
13:40 lluad joined #mojo
13:41 tchaves joined #mojo
13:44 stephan48 joined #mojo
13:46 tchaves joined #mojo
14:02 tchaves1 joined #mojo
14:19 gregf_ joined #mojo
14:56 marty joined #mojo
15:11 zivester joined #mojo
15:12 tchaves joined #mojo
15:37 tchaves1 joined #mojo
15:41 dod joined #mojo
16:09 disputin joined #mojo
16:16 thowe_work joined #mojo
17:14 dave joined #mojo
17:27 harleypig joined #mojo
17:35 marty joined #mojo
17:49 disputin joined #mojo
19:00 ramortegui joined #mojo
19:11 rshadow joined #mojo
19:44 PryMar56 joined #mojo
19:59 jacoby joined #mojo
20:00 jacoby joined #mojo
20:17 polettix joined #mojo
20:22 * sri just ordered 1000 mojolicious stickers :)
20:23 sri jberger will be the one handing them out, so be nice to him!
20:27 genio http://i.imgur.com/n8AFqr7.gifv
20:29 jberger I'm much more likely to give several to someone who is going somewhere where they can hand them out ... :-P
20:30 jberger and if one accidentally goes "missing" ... well who am I to say
20:30 sri heh
20:31 jberger Hover getting ddos-ed
20:31 jberger luckily I can edit the hosts file on my mac
20:32 jberger not sure if you can do that on android, guess I can only irc from my mac today
20:43 juikuen joined #mojo
20:51 rshadow joined #mojo
21:10 mib_m1111 joined #mojo
21:11 mib_m1111 Hi All
21:11 mib_m1111 having a problem redendering JSON
21:11 mib_m1111 e.g $self->render(json => {'true'} blar..
21:12 mib_m1111 results in looking for a HTML template
21:13 mib_m1111 I would have thought that render(json) would result in a Content-Type: text/javascript; text;json or whatever
21:13 mib_m1111 I notice in the after_render the format is HTML not JSON
21:14 mib_m1111 I thought maybe this is because I was not setting the status code, but that makes no difference
21:14 mib_m1111 the upshot is its redering my default ep template
21:15 sri http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Rendering-JSON
21:15 mib_m1111 also what is the difference between render JSON and Encode_JSON
21:16 mib_m1111 yes, I've read those docs
21:17 mib_m1111 ok, maybe I have to specify the format ?
21:17 mib_m1111 I assumed that was implied by the use of the keyword json
21:17 sri perl -Mojo -E 'get "/" => sub { shift->render(json => {it => pp->start' get -v /
21:18 sri oops
21:18 jberger mib_m1111: that json is invalid
21:18 sri perl -Mojo -E 'get "/" => sub { shift->render(json => {it => "works!"}) }; app->start' get -v /
21:18 jberger in fact, it isn't valid perl either
21:19 mib_m1111 Yes that works
21:19 jberger (unless it is and that block is being interpreted as a block ...)
21:21 pink_mist jberger: it's valid but causes a warning to make a hash from a list with an odd number of elements
21:21 jberger yeah, just got there myself
21:21 jberger mib_m1111: I confirm with sri, I have no problems getting the correct type
21:22 jberger can you reduce your case to a minimal example?
21:23 mib_m1111 just working on it
21:28 mib_m1111 God Damn It, its working now
21:28 pink_mist that sounds like a good thing :P
21:30 mib_m1111 basically, I;m implementing https://jqueryvalidation.org/remote-method/
21:31 mib_m1111 its a bit strange because the docs say "The serverside resource is called via jQuery.ajax (XMLHttpRequest) and gets a key/value pair corresponding to the name of the validated element and its value as a GET parameter. The serverside response must be a JSON string that must be "true" for valid elements, and can be "false", undefined, or null for invalid eleme"
21:31 mib_m1111 So if I send username: blah
21:32 mib_m1111 I would interpret the above to mean send a response string somthing like username: "true"
21:32 mib_m1111 however, that does not work, you have to send back only a raw text string "your username ..."
21:32 Grinnz the string 'true' is not the same as JSON true
21:32 pink_mist javascript has a boolean true value as well, which you can get at via Mojo::JSON::true
21:33 pink_mist (I think it is)
21:33 mib_m1111 maybe so, but that's not the problem, the string sent back gets displayed and interpreted as an error if its not true,
21:34 pink_mist and "true" is different to the boolean value true
21:34 mib_m1111 I got the impression that it was testing for the string "true"
21:35 Grinnz thats what it sounds like it's saying, but it's unclear
21:35 mib_m1111 because any other string results in false
21:35 mib_m1111 so anyway
21:35 purl well, so is Ah, so!
21:35 jnbek joined #mojo
21:35 mib_m1111 in my controller I've got something like
21:35 mib_m1111 return $self->render(json => ("Your email is already registered."));
21:36 pink_mist that certainly doesn't look like valid json
21:36 mib_m1111 but until now it was tring to redener the HTML default template
21:36 mib_m1111 I agree, there is no key
21:36 Grinnz the inner parentheses aren't needed, but that should be fine for the "If the serverside response is a string" case
21:36 Grinnz a string is a JSON document
21:37 pink_mist thought it needed to be encapsulated in an object
21:37 Grinnz if you want keys, you need a hash which gets translated to a JSON object
21:37 Grinnz but these docs don't mention any JSON objects, so that would probably be invalid
21:38 Grinnz https://tools.ietf.org/html/rfc7159 allows the highest level of a JSON document to be an object, array, number, string, false, true, or null
21:39 pink_mist oh, huh
21:41 jberger 7159 fills me with hate
21:41 Grinnz what can men do, against such reckless hate
21:42 mishanti1 Suicide.
21:42 purl Through early morning fog I see // visions of the things to be // the pains that are withheld for me // I realize and I can see // that suicide is painless // It brings on many changes // and I can take or leave it if I please.
21:42 jberger He piled upon the whale's white hump the sum of all the general rage and hate felt by his whole race from Adam down; and then, as if his chest had been a mortar, he burst his hot heart's shell upon it. Read more at: http://www.brainyquote.com/quotes/quotes/h/hermanmelv130583.html
21:42 jberger ugh I hate when sites add crap to copypasta
21:42 * Grinnz thinks these quotes are each somewhat unrelated
21:43 Grinnz it's also curious that those docs mention undefined as a value, when it's not valid in JSON
21:44 mib_m1111 Actually, it is transmitted as the string "undefined" to the server in cases
21:44 Grinnz as a string? wouldn't that be considered true?
21:44 Grinnz or rather
21:44 Grinnz as an "other string"
21:44 mib_m1111 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17   $( "#myform" ).validate({ rules: { email: { required: true, email: true, remote: { url: "check-email.php", type: "post", data: { username: function() { return $( "#username" ).val(); } } } } } });
21:44 mib_m1111 "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17   $( "#myform" ).validate({ rules: { email: { required: true, email: true, remote: { url: "check-email.php", type: "post", data: { username: function() { return $( "#username" ).val(); } } } } } }); "
21:45 jberger mib_m1111: please don't paste into the channel
21:45 mib_m1111 well that did not work
21:45 mib_m1111 ok sorry
21:45 mib_m1111 see last example here: https://jqueryvalidation.org/remote-method/
21:45 * jberger recommends gist.github.com
21:45 mib_m1111 the will transmit string "undefined" if for example "username" is not defined and you are sending a different field
21:46 Grinnz isn't that up to the serverside script, not that javascript?
21:46 mib_m1111 So, why would I use use Mojo::JSON 'encode_json';
21:46 Grinnz you wouldn't, render(json => $foo) does already
21:47 mib_m1111 instead of render(json =>"")
21:47 jberger that document doesn't tell us what the server should return
21:47 Grinnz Mojo::JSON is usable more generally, when not rendering a response
21:48 jberger or rather that example doesn't, the text above does, but man is it badly defined
21:49 mib_m1111 ok
21:49 mib_m1111 think I found the problem
21:49 Grinnz the main confusion is: JSON string that must be "true" for valid elements, and can be "false", undefined, or null for invalid elements
21:50 mib_m1111 I assumed the following: $self->render(data => encode_json("email already registered"));
21:50 Grinnz the choice of quoting suggests that "true" and "false" are actual strings, not the booleans, while null and undefined are the actual javascript values
21:50 mib_m1111 would render json, but it does not, it renders HTML
21:50 Grinnz however, "JSON string of "true"" could refer to a JSON document containing the boolean true, serialized as a string
21:50 pink_mist I find it curious that they make a distinction between null and undefined
21:50 Grinnz I find a lot of this curious :P
21:51 Grinnz mib_m1111: that renders data, defaulting to the HTML content type IIRC
21:51 jberger read the source of the example: https://jqueryvalidation.org/files/demo/milk/
21:51 Grinnz mib_m1111: in addition to encoding the argument to JSON, the "json =>" formatter also sets the JSON content type header
21:51 jberger especially the mock responses
21:52 Grinnz thats why it's easier to use that
21:52 jberger I think I'm noping out of this validator :-P
21:52 mib_m1111 I had another example, without using data, which caused me to use data
21:52 Grinnz jberger: i couldn't even get that demo to work, nothing seems to happen
21:52 jberger oh heh, I didn't even try it
21:52 jberger I just read the code
21:52 Grinnz the jquery seems to be throwing an exception
21:53 mib_m1111 Grimz: most examples online simply return text string
21:53 mib_m1111 not realizing that the client hash specifically ACCEPT javascript only
21:54 jberger mib_m1111: just render(text => 'true', format => 'json') and see if that works for you
21:54 jberger (gods I hate so much about that previous message I just sent)
21:55 Grinnz (json => Mojo::JSON::true) should be the same as that
21:55 mib_m1111 its not to bad
21:55 mib_m1111 at first I was sending text send changing the header :*
21:56 mib_m1111 in this example "$self->render(data => encode_json("email already registered"));" what does data mean?
21:56 Grinnz it means the following is binary data (so don't encode it to UTF-8 when rendering)
21:56 mib_m1111 is it just data, i.e. has no impact on the content-type
21:56 Grinnz which is correct, but won't set your content-type
21:56 jberger use format => 'json'
21:57 mib_m1111 when I first started using "$self->render(json => " I was getting HTML output
21:57 mib_m1111 which cause me to look for another solution, but I've lost that example now
21:57 Grinnz something else must have been different
21:58 mib_m1111 trying to replicate it
22:01 jberger I wouldn't spend too much time on that
22:01 jberger make the thing work that you need working
22:01 jberger I mean if it happens again, and if it is a bug in mojo then please report it
22:01 mib_m1111 I think I was doing something like "return $self->render(json => {"Your email is already registered."});|
22:02 mib_m1111 which cause an error (odd number of entries in hash), which caused an error
22:02 Grinnz that should still work, but wouldn't give you what you expect
22:02 Grinnz it's not an error, just a warning
22:02 mib_m1111 correct, which is why I said something
22:03 Grinnz it would result in the JSON document: {"Your email is already registered.": null}
22:05 mib_m1111 found it
22:05 mib_m1111 this causes the error
22:05 mib_m1111 return $self->render(json("blah"));
22:06 Grinnz yes, that would blow up since json isn't a defined function (probably)
22:06 Grinnz so the HTML you got was the exception page, probably
22:06 mib_m1111 correct
22:07 mib_m1111 but the jjquery does validate on that error
22:07 mib_m1111 i.e. does not bork
22:08 mib_m1111 the field is then excepted without error
22:08 Grinnz how strange
22:08 mib_m1111 well, it was expecting JSON and got HTML content-type, so maybe it ignored the entire thing and got null
22:09 Grinnz could be
22:09 purl somebody said could be was not sufficient! I want fatal or nothing.
22:20 mib_m1111 I didn't say thank you, so thank you :)
22:23 mib_m1111 Guys,
22:23 mib_m1111 do any of you know of a utility that does HTML type for snippets
22:23 mib_m1111 type=tidy
22:25 mib_m1111 preferably one that could skip over all the <%== include type stuff
22:27 Grinnz https://metacpan.org/pod/XML::LibXML::PrettyPrint ?
22:28 Grinnz comes with the https://metacpan.org/pod/distribution/XML-LibXML-PrettyPrint/bin/xml-pretty script
22:28 Grinnz no idea how it would handle EP templates
22:28 mib_m1111 Sure I tried that, will give it a go
22:38 mib_m1111 it does not like %==
22:38 mib_m1111 says "Could not parse XML: :1: parser error : Start tag expected, '<' not found"
23:22 disputin joined #mojo

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