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

IRC log for #mojo, 2017-11-10

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

All times shown according to UTC.

Time Nick Message
00:19 genio joined #mojo
00:24 namotco joined #mojo
00:48 marty joined #mojo
01:31 haarg joined #mojo
01:32 haarg joined #mojo
01:35 Seth joined #mojo
01:41 aborazmeh joined #mojo
02:12 kaare_ joined #mojo
02:23 bret joined #mojo
02:28 bret hello, I've been trying to wrap my head around semantics for utf8 encoding in Mojolicious, trying to figure out how paranoid I should be about when writing validators.
02:29 Grinnz most input is decoded from utf-8 before it reaches you
02:29 Grinnz so you shouldn't have to care
02:32 bret Right, I agree in the end I probably don't need to worry about it, but I like to understand the mechanism just for some peace of mind. I see in Mojo::Parameters that the decode calling context is: $value = decode($charset,$value) // $value if $charset
02:32 Grinnz for URL or body parameters, yes, Mojo::Parameters decodes them
02:33 bret It seems to me the input from the UA will get pass through un-decoded if if the decode subroutine in Mojo::Util croaks
02:33 Grinnz that means it was not valid UTF-8
02:34 bret Agreed
02:34 bret I don't know that I would want to do further processing on invalid UTF-8 though
02:35 Grinnz so yes, you could potentially get either decoded characters or random bytes
02:35 Grinnz however, it's impossible to tell the difference, so there's not really anything to do about it
02:35 Grinnz except your normal validation that you receive what you expect
02:37 bret Right, in this case I'm expecting a firstname. I think in some cases it's possible to detect data that gets passed through un-decoded with perl's utf8::is_utf8
02:37 nicomen AFAIR, mojo tries to decode as utf-8 first, and if not you get the bytes
02:37 nicomen sorry
02:37 Grinnz no. never use is_utf8
02:37 nicomen AFAIR, mojo tries to decode as the announced charset first, and if not you get the bytes
02:37 pink_mist bret: NEVER EVER use is_utf8
02:38 bret Point taken, but what's the issue with using is_utf8 ?
02:38 Grinnz it does not tell if you if it's utf-8
02:38 nicomen mostly that it doesn't mean what you think it means
02:38 Grinnz it also does not tell you if it was once utf-8, or if it's supposed to be utf-8
02:38 Grinnz the only thing it tells you is how perl is currently internally representing that value
02:38 pink_mist relying on is_utf8 has caused bugs in many many perl programs
02:38 Grinnz which is useless for user code
02:39 pink_mist I consider it a bug that it's a public api
02:39 nicomen (I use it when something has told perl the wrong thing, and I need to do manual hacks)
02:39 nicomen but don't use it, if you have to, something is wrong in the first place
02:39 Grinnz nicomen: i consider that out of the scope of user code :)
02:40 nicomen and Mojo::Parameters does the rightest thing
02:40 Grinnz bret: basically, if you end up getting bytes because it isn't valid UTF-8, they'll still appear to be valid characters between codepoints 0 and 255
02:41 nicomen maybe a real example might help in guiding you in the right direction
02:41 Grinnz so just assume that's what the user meant to send, and you'll probably end up either failing validation or the user will get garbage for their garbage input
02:41 bret Gotcha
02:50 marty joined #mojo
02:54 bret ricomen do you happen to have an example you could point me to ?
02:56 ilbot2 joined #mojo
02:56 Topic for #mojo is now 🍩 nom nom | http://mojolicious.org | http://irclog.mojolicious.org | http://code-of-conduct.mojolicious.org
03:06 bret I guess I'm sort of trying to account for the case where the UA has told perl the wrong thing through the announced charset. I want to stop processing the form at that point because of the implied error in not being able to decode the garbage input. Thanks for responding and clarifying the best practice for the user code.
03:18 noganex_ joined #mojo
04:11 dugword joined #mojo
04:12 kiwiroy joined #mojo
04:15 kiwiroy Does Mojo::File->to_abs() need to pass @_ to File::Spec::Functions::rel2abs()?
04:44 karjala_ joined #mojo
04:52 marty joined #mojo
05:04 dboehmer joined #mojo
05:21 ghenry joined #mojo
06:06 inokenty-w joined #mojo
06:47 kiwiroy joined #mojo
06:58 dod joined #mojo
07:02 marty joined #mojo
07:04 Vandal joined #mojo
07:04 dod joined #mojo
07:12 geospeck joined #mojo
07:24 kaare_ joined #mojo
07:35 dugword joined #mojo
07:42 AndrewIsh joined #mojo
07:59 karjala_ joined #mojo
08:37 trone joined #mojo
08:40 kiwiroy joined #mojo
08:41 mtths joined #mojo
09:27 tlatelolco joined #mojo
09:29 tlatelolco Hello! My photo template just contains <img src="img/<%= $fic %>">. But when I run it, I get a 404, even though the file path exists. How come?
09:30 tlatelolco (a 404 error on the image only)
09:31 CandyAngel tlatelolco: You might find using the image tag helper makes the template tidier
09:31 CandyAngel %= image $fic
09:34 tlatelolco without the img tag?
09:34 CandyAngel Yeah
09:36 tlatelolco but then where to add the directory img/ ? %= image "img/$fic" doesn't make it
09:37 CandyAngel There are a bunch of tag helpers you can use so you don't have to write out the HTML
09:37 CandyAngel http://mojolicious.org/perldoc/Mojolicious/Plugin/TagHelpers
09:38 CandyAngel You could concatenate it: %= image 'img/' . $fic
09:38 CandyAngel Or write your own helper which adds that prefix
09:38 CandyAngel Or prefix it to $fic in the controller
09:39 tlatelolco yes. But the fact is that the html code is correct but the mojo server doesn't serve the file from this location. Is there a reason for that?
09:40 CandyAngel Static files are served from public/
09:40 CandyAngel So if you have
09:40 CandyAngel app_dir/public/someimage.jpg
09:41 CandyAngel Mojolicious will serve that if you request http://app/someimage.jpg
09:41 CandyAngel So you want it like.. app_dir/public/img/someimage.jpg
09:41 CandyAngel I think :P
09:41 CHYC_ tlatelolco: The src looks to be relative to the current file, which changes depending on if the current page has a slash appended. What's the page location, and how does it relate to the img directory?
09:42 tlatelolco putting img in public works
09:42 tlatelolco thank you
10:03 sri http://mojolicious.org/perldoc/Mojolicious/Guides/Tutorial#Static-files
10:04 marty joined #mojo
10:14 tlatelolco How to handle with Mojo::SQLite when the query has no answer? After that I need an if condition...
10:34 CandyAngel Hm.. it kind of sounds like you are trying to put too much logic in the template, rather than the controller..?
10:34 CandyAngel In the template, is should be like
10:35 CandyAngel % if (my $results = stash 'sqlite_results') {
10:38 tlatelolco it's not in the template, but in the app
10:41 gregf_ joined #mojo
10:42 CandyAngel You can do an early render if there are no results
10:42 CandyAngel So like..
10:43 CandyAngel return $self->stash(results => [])->render if $query->rows == 0;
10:44 CandyAngel No idea if that is suitable for what you are doing though so..
10:45 tchaves joined #mojo
11:04 tlatelolco hmm i don't think so. If there are results, it renders the photo template. If not an error template is rendered
11:12 che joined #mojo
11:15 che hi, sorry at all but better for me correct the Mojolicious.pm line 122 to the my $path   = $req->url->path->to_route;
11:17 CandyAngel tlatelolco: The Mojolicious one, where it gives you a bunch of information?
12:06 marty joined #mojo
12:56 kaare_ joined #mojo
13:40 dugword joined #mojo
13:59 Pyritic joined #mojo
14:00 maschine joined #mojo
14:08 perlpilot joined #mojo
14:16 garo left #mojo
14:16 aborazmeh joined #mojo
14:29 Pyritic joined #mojo
14:34 gryphon joined #mojo
14:41 jberger api design question for anyone
14:42 jberger I've been working on batman's suggestion for Mojo::Chrome to drive the configuration from a url
14:42 jberger this branch is the current state of the result: https://github.com/jberger/Mojo-Chrome/tree/url
14:42 jberger so things like cli switches are query parameters
14:43 jberger but then there's the chrome_executable which might be a path (if not just a name meaning the executable is in the $PATH)
14:44 jberger so there's a question on how I could include at option into the url
14:44 jberger it could (a) stay a separate option (which might get awkward if ->new eventually takes a url directly as other modules do)
14:45 jberger (b) be a special query parameter that is extracted before the others are interpreted as cli args
14:45 jberger (c) abuse(?) the path part of the url which is currently unused but feels kinda strange
14:46 jberger oh and if (b) it means that there is going to need to be lots of url escaping if a path is given
14:46 mohawk not c
14:46 mohawk a feels wrong
14:46 mohawk re b - does it really need to be special?
14:46 jberger mohawk: do you still feel that about (c) if the proto isn't http://
14:47 jberger say it was chrome:// or, since that is actually a thing in chrome itself, some other proto
14:47 mohawk mojochrome://usr/bin/chrome
14:47 mohawk still doesn't feel good
14:47 mohawk it's a configuration-ish thing, really
14:47 sri comparable to http+unix://? http://mojolicious.org/perldoc/Mojo/Server/Daemon#listen
14:48 jberger sri: interesting comparison, but seeing those examples reminds me that we already have lots of query parameters that are path-like
14:48 mohawk it is comparable to that
14:48 jberger for say certs
14:49 mohawk my gut doesn't really like it, but it also doesn't have any better suggestions
14:49 sri yea, the question is if it's essential like http+unix://, or just another parameter like cert=...
14:49 jberger it is certainly not essential
14:50 sri then you got your answer
14:50 jberger most users will just use the default of google-chrome or the odd path that is hard-coded for mac
14:50 jberger yeah
14:51 jberger thanks! sri++ mohawk++
14:52 jberger mohawk: all I meant by "special" is that all other query params are interpreted as cli switches so it is "special" in that sense
14:53 mohawk gotcha
14:57 bjakubski joined #mojo
14:58 mohawk mohawk now as karma of: 1
15:00 jberger karma mohawh
15:00 jberger err
15:00 jberger karma mohawk
15:00 jberger awww, ENOPURL again
15:01 mohawk quelle fromage
15:03 pink_mist omelette du fromage
15:12 gizmomathboy joined #mojo
15:18 dod joined #mojo
16:09 marty joined #mojo
16:14 gregf_ joined #mojo
16:46 sh14 joined #mojo
16:51 ChmEarl joined #mojo
16:53 jberger hmmmmm, I'm not sure Iove the notion of using a url for all this
16:53 jberger like if I want to change just the port I have to remember to use all the other stuff
16:55 jberger I guess rather than Mojo::Chome->new('http://127.0.0.1:4000/?headless') to use port 4000 I could do my $chrome = Mojo::Chrome->new; $chrome->url->port(4000);
16:55 jberger s/;//
16:55 Grinnz in the end its just a way of text encoding a bunch of parameters
16:58 jberger hmmmm, now I'm looking at Mojo::Pg and realizing that probably I should keep the properties themselves separate but offer a new_from_string
16:59 Grinnz yea no need to keep a url as an attribute unless you plan to use it as one
17:04 sh14|2 joined #mojo
17:04 sri yea, url should be an option, not a requirement
17:05 sri it's not always more convenient
17:06 * Grinnz tends to prefer ->from_filename for Mojo::SQLite
17:06 rickbol_ joined #mojo
17:31 disputin joined #mojo
17:35 kaare_ joined #mojo
17:37 jberger further, I think I'll invent a no-headless option, you get --headless unless you specifically ask not to
17:37 jberger I think from Mojo::Chrome's perspective that's the more likely option
17:37 jberger and always having to include ?headless as part of a url is silly
17:38 Grinnz supporting both --headless and --no-headless would be consistent with how boolean switches usually work
17:38 jberger chrome of course doesn't have no-headless, but I can emulate it
17:38 dod joined #mojo
17:43 kaare joined #mojo
17:52 disputin joined #mojo
18:08 kaare joined #mojo
18:21 trone joined #mojo
18:26 Pyritic joined #mojo
18:51 karjala_ joined #mojo
18:55 brunoramos joined #mojo
18:57 geospeck joined #mojo
19:17 disputin joined #mojo
19:43 Seth joined #mojo
19:43 gizmomathboy joined #mojo
20:29 sri bit of a bummer that epoch.js is dead
20:30 sri you'd think fastly would take better care of a popular project
21:10 jberger sri: how goes the hackathon?
21:11 sri first day was quite productive, but i got stuck on realtime charts
21:11 sri looks like all the libraries are unmaintained
21:11 sri as is tradition with js
21:15 gryphon joined #mojo
21:27 purl joined #mojo
21:29 disputin joined #mojo
21:46 jberger indeed
21:46 jberger it can't be highcharts?
21:46 jberger licensing?
21:46 purl licensing is probably evil...the only time i've seen jarkko seriously pissed what when RMS started poking at cpan
21:53 pink_mist purl is back!
21:54 jberger I know who to poke :-P
21:55 pink_mist also, RMS poking at cpan 0_o
22:05 sri jberger: i didn't know about highcharts so far
22:05 sri this does look neat https://www.highcharts.com/studies/live-server.htm
22:07 sri but yea, the license seems to make it unusable
22:07 jberger :(
22:14 sri i do have epoch.js kinda working now though
22:21 [0xAF] FWIW, i've been using chart.js few times for realtime data charting (once per second, if that counts as realtime)
22:22 [0xAF] sorry to stick into the middle of the talk...
22:23 pink_mist and it has an MIT license?
22:23 pink_mist cool
22:25 sri chart.js looks very hard to use for realtime charts
22:30 [0xAF] sri, I don't know what you're looking for... but here is a simple page i've created when I learned mojo and chart.js, for my home server http://home.0xAF.org/ (once loaded, press ENTER key, it will show the charts)... it will load new data with ajax on every 1 sec.
22:30 [0xAF] don't shoot me for not rewriting it later... ;)
22:33 kaare_ joined #mojo
22:40 sri yea, i don't like the stutter
22:42 [0xAF] there was stuttering, but after digging a bit, i've found a way to handle it... if you take a look at the JS code, i'm not adding new values to the js array, i'm replacing the js array and this trick made it... IIRC
22:43 sri your example stutters for me
22:43 sri look at epoch http://epochjs.github.io/epoch/real-time/
22:43 [0xAF] i see... but this is the best you can get from chart.js i guess...
22:44 [0xAF] ok, now i see... but i'm not sure you can get that with chart.js
22:45 sri my point
22:45 purl sri, your point is probably that you can use a non-multipart request
22:46 [0xAF] i've managed to get animation between the frames at least... but this is still not what you need.
22:57 [0xAF] how about Flot: http://www.flotcharts.org/flot/examples/realtime/index.html    (it's MIT)
22:58 [0xAF] hmz convos rewrited the url     http://www.flotcharts.org/flot/examples/realtime/index.html
23:02 pink_mist that's the same url
23:02 [0xAF] so it seems convos is rewriting it for me only :) sorry...
23:08 sri a little preview https://i.imgur.com/8kaBfXG.png
23:09 sri numbers are polled every few seconds
23:12 maschine that looks awesome - also this is relevant to the project I've been working on for a year now, I've been thinking about how to do graphs and real time logging for a while
23:13 maschine there's so many different frameworks to choose from
23:13 sri the graph still needs a pretty theme
23:14 [0xAF] what is showing this graph?
23:14 [0xAF] sorry for my ignorance...
23:14 sri job backlog
23:14 sri inactive jobs that are not delayed
23:15 sri so you see spikes for tons of new jobs immediately
23:15 [0xAF] ahh, i see...
23:16 jberger purl, forget my point
23:16 purl jberger, I didn't have anything matching my point
23:16 sri or you see all blue when there is no progress
23:16 sri i found that one to be the most useful graph
23:16 sri tried a few
23:18 [0xAF] sri, are you going to make such graphs available for everyone using minion or it's a private project? this seems to be very useful, to get visuals on minion
23:21 sri it's part of the admin ui i'm making for minion
23:21 sri https://twitter.com/kraih/status/928605001689202688
23:23 [0xAF] that's cool. thanks a lot for this. and for everything you've been making for us.  thanks to everyone evolved and contributing to mojo.  i'm glad i've stuck on this framework.  there are no words to express my gratitude. thanks to all of you!
23:23 sri :D
23:47 mohawk purl, forget your point
23:47 purl mohawk, I didn't have anything matching your point
23:48 mohawk my point
23:48 mohawk your point
23:48 mohawk ok then

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