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

IRC log for #mojo, 2017-10-15

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

All times shown according to UTC.

Time Nick Message
00:32 simbabque_ joined #mojo
02:32 noganex_ joined #mojo
03:22 mib_1seyml joined #mojo
03:23 mib_1seyml yo
03:27 mohawk jberger, do you have a minute to help me with getting a "render" call right?
03:28 mohawk i want to have a template in __DATA__, currently just manually pulled from <DATA>, and render with $c->render(inline => $TEMPLATE, stashvar1 => ...)
03:28 mohawk that seems to not set stash vars up as $ vars though?
03:36 Grinnz you know you can automatically render templates from __DATA__ if you name them right? https://metacpan.org/pod/Mojolicious::Guides::Rendering#Renderer
03:36 mohawk yes, just had a try with that
03:36 mohawk and did push @{$app->renderer->classes}, __PACKAGE__;
03:37 mohawk seems to be working but now my browser doesn't feel like running JS
03:37 mohawk 1 step forward, 0.99999999 step back ;-)
03:38 mohawk noscript, y u no work
03:43 mohawk and with a bit of bodging of my browser: halle berry, it works!
03:55 aborazmeh joined #mojo
04:03 jberger Just saw this. Glad you got it working!
04:03 mohawk me too
04:04 mohawk the miraculous thing is, i was staring and poking at it for about 2 hours having copied it over from the Dancer2 plugin, then it worked almost first time
04:04 dboehmer joined #mojo
04:05 jberger Well if it had actually worked the first time then youd've known something was wrong
04:06 jberger You'd just have to find it
04:06 mohawk ha ha ha!
04:06 mohawk jberger, can you, in about 30s when i've put it on GH, review the plugin?
04:06 jberger Well excellent, glad it went reasonably smoothly
04:07 jberger I'll take a look, sure
04:07 jberger I'm heading towards bed (don't you Europeans sleep?) But I can give it a glance
04:08 mohawk https://github.com/graphql-perl/Mojolicious-Plugin-GraphQL
04:08 mohawk grin
04:09 mohawk there's a sample applet i'm just going to put up after i've CPAN-ed this thing
04:20 mohawk now how am i going to test this bad boy...
04:24 jberger Pretty sure mojo json always escapes slashes
04:24 mohawk i shamelessly cargo-culted that from the JS express-graphql
04:25 jberger Yes but you don't want to double escape
04:25 mohawk agreed
04:25 mohawk just testing it now :-)
04:26 jberger Or at least use a negative look behind
04:27 mohawk well, i just put "thing with /" in the # comments of default query
04:28 mohawk and it didn't seem to double-quote
04:28 mohawk double-escape
04:29 jberger Just be sure you cover it with a test case when you do those :p
04:30 mohawk grin
04:30 jberger We have some cleverer ways of checking accepts
04:30 mohawk oh?
04:31 jberger http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Content-negotiation
04:33 jberger Presumably you want a non 200 status on your error
04:33 mohawk actually, would that handle the &raw thing?
04:33 mohawk no! because it's not REST
04:34 mohawk if gql gets non-200, something went wrong in the transport
04:35 jberger You'd have to use the accepts method rather than the cuter respond_to, yeah
04:36 jberger But that's still nicer
04:36 mohawk that still wouldn't handle the &raw override thingy
04:36 mohawk i think i'm stuck with this
04:36 mohawk plus in due course i'll want to support application/graphql, which treats whole body as the "query"
04:36 mohawk that also doesn't lend itself to that scheme
04:38 jberger Yeah the checking of the raw parameter stays as you have it
04:39 jberger But the line above becomes $c->accepts('', 'html')
04:39 mohawk ahhhh
04:39 mohawk nice
04:40 jberger Where the first option of an empty string forces it to return a false on failure (which is a little odd in this use case but is more comfortable in others)
04:40 jberger also back to your safe encode
04:41 jberger Err safe serialize
04:41 jberger I didn't realize that you are inlining this to go into js in the template
04:41 mohawk mm?
04:41 jberger So two things
04:42 jberger I don't think you want the escape thing at all
04:42 mohawk the graphiql stuff does a decode i think
04:42 jberger And you actually want to use to_json rather than encode_json
04:42 mohawk i remember questioning it myself
04:43 mohawk ok
04:43 jberger Oh it wants a STRING of json?
04:43 mohawk yes
04:43 jberger Strange.
04:43 mohawk yes ;-)
04:43 jberger Ok well my point. If you were serializing to make a js object then you want to_json
04:44 mohawk gotcha
04:44 jberger Because that doesn't utf8 encode the result
04:44 mohawk uh...
04:44 mohawk oh, because it then gets encoded elsewhere?
04:45 jberger The rendered page with the html and js would be encoded when it is sent to the client
04:45 jberger Yah
04:45 jberger It's a common bug we see people make so I'm quick to call it
04:45 mohawk both pushed
04:46 jberger Indeed I'm not sure I've seen the case where someone inclines actual json into a js string
04:47 jberger I'd make some good Unicode test cases when you do them. Sprinkle in hearts and snowmen
04:47 mohawk ha ha
04:47 mohawk yes, in due course
04:48 mohawk there are things to do before that, i'd say
04:48 mohawk like making gql do promises (actually, Future)
04:48 mohawk and meeting the rest of the gql spec
04:50 mohawk https://github.com/graphql-perl/sample-mojolicious
04:51 jberger Might want to use <%== ... %> tags when in JavaScript
04:51 jberger Single = does html escaping
04:51 jberger Good in html bad in JavaScript
04:52 mohawk i think this *is* html - it's in a <script> tag and it functioned fine
04:53 jberger Ok
04:53 mohawk that's right - if we put in a snowman, we'd have utf8-encoded, html-encoded, js-encoded stuff
04:53 mohawk encodings all the way down :-)
04:53 jberger There I'm more worked about angle brackets
04:54 jberger But maybe browsers are sufficiently helpful there
04:54 mohawk sure, but they need to be html-encoded so some JS text that wants to say "</script>" doesn't cause chaos
04:54 mohawk the JS in the browser ought to get it decoded by the browser
04:55 jberger Hmm probably right. Possibly its too late at night for me to give food advice three
04:55 jberger There
04:55 mohawk grin
04:55 mohawk you've given plenty of great advice
04:55 jberger Anyway looks neat
04:56 jberger And you'll like testing with Test::Mojo
04:56 mohawk i'm about to find out
04:56 jberger Enjoy
04:56 mohawk going to cargo-cult https://github.com/kraih/mojo/blob/cf8fd092bb4bd77e9b027203f3e0a432aa3b6ccb/t/mojolicious/external_lite_app.t
04:57 jberger Give the testing guide (brand new! ) a skim
04:57 mohawk POD of Test::Mojo?
04:57 mohawk or a Guide?
04:57 jberger There's json testing built in
04:57 jberger Either
04:57 mohawk great
04:58 mohawk thanks!
04:58 jberger As usual class documentation is reference not educational
04:58 mohawk heaven forbid the docs be helpful
04:58 jberger Nope we have guides for that :D
04:58 mohawk ;'(
04:59 jberger Class docs are how does this method work again, guides are how do i
04:59 mohawk fair
05:00 jberger We have docs that most people come in and dislike at first but once you get stuck in you really like
05:01 jberger Anyway bedtime, have fun!
05:01 mohawk night!
05:35 mohawk jberger, the ->accepts('', 'html') also preferred the '' to the 'html', so i removed the '' and it worked right
05:54 mohawk the problem is this: "unspecific Accept request headers with more than one MIME type will be ignored" - well, my firefox is sending "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
06:30 mohawk anyway, there is now a blog post: http://blogs.perl.org/users/ed_j/2017/10/graphql-perl---mojoliciousplugingraphql---mojolicious-graphql-endpoint.html
06:56 sh14 joined #mojo
06:58 dotan_convos joined #mojo
07:12 Vandal joined #mojo
07:34 dod joined #mojo
07:39 dod joined #mojo
08:02 Coupon joined #mojo
08:03 CouponDC joined #mojo
08:23 petru joined #mojo
09:05 rba_ joined #mojo
09:09 sh14 joined #mojo
09:16 rba joined #mojo
09:32 rba_ joined #mojo
09:46 rba joined #mojo
10:01 rba_ joined #mojo
10:16 rba joined #mojo
10:31 rba_ joined #mojo
10:46 rba joined #mojo
11:01 rba_ joined #mojo
11:08 petru joined #mojo
11:16 margeas joined #mojo
11:17 rba joined #mojo
11:31 rba_ joined #mojo
11:46 rba joined #mojo
12:01 rba_ joined #mojo
12:16 rba joined #mojo
12:31 rba_ joined #mojo
12:31 ayrton joined #mojo
12:33 robx the mojocasts are quite useful. imho the presenter could do with a bit less theatricality, and the mojo-aggrandizement is a bit weird
12:36 robx I'm sure it's good (otherwise I wouldn't be here), and I understand the pride a developer has in good work. Maybe there's too much puritan in me, but I think the praise should be left to the users
12:41 sri robx: they were made at a time when mojo was not so mainstream
12:46 rba joined #mojo
12:54 vicash joined #mojo
13:01 rba_ joined #mojo
13:10 kaare joined #mojo
13:16 rba joined #mojo
13:31 rba_ joined #mojo
13:46 rba joined #mojo
14:01 rba_ joined #mojo
14:16 rba joined #mojo
14:31 rba_ joined #mojo
14:41 ChmEarl joined #mojo
14:46 rba joined #mojo
15:01 rba_ joined #mojo
15:10 mohawk are the mojocasts still being made?
15:12 mohawk robx, ^
15:12 mohawk (and yes, i'll also google, but i had a follow-up)
15:16 pink_mist no they aren't
15:17 mohawk was there just the 5?
15:17 pink_mist 5 or 6
15:48 trone joined #mojo
16:21 dod joined #mojo
16:22 rba joined #mojo
16:32 rba_ joined #mojo
16:34 prajith joined #mojo
17:26 rshadow joined #mojo
17:48 jberger note that there are errata on the wiki: https://github.com/kraih/mojo/wiki#screencasts
17:49 mohawk just a bit lower there, there's the databases section
17:49 mohawk do you think there's an argument for mentioning graphql there?
17:51 Grinnz it's a wiki, so feel free to add a page for it
17:52 mohawk cor
18:47 genio joined #mojo
19:22 sri the orville is great
19:39 * sjn has now seen a few episodes of the Orville too, and agrees. I didn't expect a funny show like that to take on interesting topics like that
19:47 webart everyone quit inventing new cool shit!!
19:48 mohawk webart, which new cool shit are you thinking of?
19:49 webart graphql plugin >:-|
19:49 mohawk oh, that
19:49 webart and like a whole bunch of other stuff
19:50 webart now a solar powered  bitcoin mining pool so we can errm grow money l
19:50 mohawk ha ha
19:50 webart can get behind  ...
19:51 webart leveraging chlorophyl is the key
19:51 webart so to speak
19:51 mohawk that sentence out of context sounds a bit crackers
19:51 webart true
19:52 webart almost as if I was talking on a bus and someone was recording/editing everything I said ... :-D
19:52 webart ... irc.perl.org  ++
19:54 mohawk WHY ARE YOU DROPPING MY DATA WHO WROTE THIS PIECE OF NONSENSE oh it's me
20:09 mohawk i may have edited my language there
20:39 mohawk the reason was that when you copy a hash with some keys, make sure you copy $values->{$}{thing} not $values->{thing}
20:58 robx I'm having trouble getting my head around how to implement a UI using the MVC model. Can anyone recommend resources that might help?
21:01 robx I'm quite happy to buy a book if it's good
21:03 jberger robx: are you asking about entirely front-end stuff, like Angular?
21:03 mohawk i think sawyer's description of MVC in dancer 2 was good, let me dig it out
21:04 jberger the "implement a UI" is the bit of robx's question that interests me
21:04 mohawk http://www.i-programmer.info/programming/perl/7361-all-about-dancer-an-interview-with-sawyer-x.html
21:04 mohawk ok
21:04 jberger because the front-end technologies sometimes also use the MVC model but I think that's confusing if you are used to "backend" MVC
21:04 mohawk that is interesting - robx, can you tell us more about what you're trying to achieve?
21:06 jberger then you get into stuff like this: https://stackoverflow.com/a/3540895/468327
21:07 jberger suddenly everything is semantics and you just want to forget the whole thing
21:29 rshadow joined #mojo
21:47 robx jberger, not really. I'm looking for more general help. There are some mojo examples based on MVC I was trying to understand, and I see references to the model all over the place
21:48 robx mohawk, thank you. I will have a look
21:49 mohawk robx, i see it as a pattern for separating concerns in a way that's good for UI generally - start from there and you should find it easy-peasy
21:49 robx hmm, easily said :)
21:53 mohawk i'll sweeten the offer
21:53 mohawk time estimated: 6 minutes
21:55 robx for?
21:55 mohawk understanding the whole thing
21:55 robx heh
22:11 robx does anyone here maintain mojolicious on an OpenBSD system?
22:31 zivester joined #mojo
22:44 robx the current mojolicious version offered by an OpenBSD package is 6.24. Is that hopelessly outdated and perhaps even dangerous to use?
22:45 genio 7.47 is the current version. So, there's been quite a few things that have changed.  However, you can install your own version with a local::lib somewhere if you like
22:47 pink_mist robx: yes, it's hopelessly outdated ... and I'm certain there has been a bunch of security issues fixed in later releases
22:47 pink_mist robx: but you should check the changelog to make sure
22:48 pink_mist robx: https://metacpan.org/changes/distribution/Mojolicious
23:00 robx pink_mist, thanks, but I won't bother to check the changes, I'll just install the latest version. it seems to be the best option for several reasons
23:01 robx genio, thanks for the tip
23:11 mohawk btw, on the topic of graphql: any experts here with react/relay?
23:28 jnbek joined #mojo
23:32 jnbek joined #mojo

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