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

IRC log for #mojo, 2016-05-01

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

All times shown according to UTC.

Time Nick Message
00:08 Lee joined #mojo
00:31 dvinciguerra joined #mojo
01:20 asarch joined #mojo
01:38 ivi joined #mojo
02:21 noganex joined #mojo
02:47 Kripton joined #mojo
03:13 kaare joined #mojo
04:09 Lee joined #mojo
05:13 Kripton joined #mojo
06:04 punter joined #mojo
06:10 Lee joined #mojo
06:52 salva joined #mojo
07:09 Lee joined #mojo
07:32 dod joined #mojo
07:37 dod joined #mojo
08:20 Vandal joined #mojo
08:28 punter joined #mojo
08:28 punter I'm having difficulty setting up my routes.
08:29 punter I want to have a parent route called $api (where all URLs under /api will go), and another parent one called $pages (where all the other URLs will go)
08:31 punter Here it is: http://paste.scsys.co.uk/512060?ln=on&hl=on&submit=Format+it!
08:31 punter Am I doing it wrongly?
08:32 punter Under this setup, /browse and /health do not map to the corresponding subroutines for some reason, only to the template (which doesn't find the variables in the stash, because the subroutine has not been executed, and so crashes)
08:33 punter What am I doing wrong? How can I fix it?
08:33 punter /index runs though
08:37 punter I mean, when I point the browser to /browse, I get an error displaying the template lines, and saying that a template variable is missing
08:56 HtbaaPi joined #mojo
09:10 Lee joined #mojo
09:26 henq joined #mojo
09:49 punter someone, help
10:00 basic6_ joined #mojo
10:33 henq joined #mojo
11:11 Lee joined #mojo
11:28 batman joined #mojo
11:35 punter joined #mojo
11:36 punter I solved my problem by setting $pages->any('/pages')->to('pages#');
11:36 punter and then mapping / to /pages on nginx
11:58 punter NEW QUESTION: What does one have to do to enable postderef syntax in templates?
11:58 pink_mist surely % use feature 'postderef';
11:58 pink_mist should be enough?
11:59 pink_mist possibly also disabling experimental warnings for it
11:59 punter aha, thanks!
11:59 punter use experimental 'postderef' then
12:00 pink_mist note: I've not tried it; it's just what I assume would work
12:04 punter it works
12:05 punter but also this works (one-time solution for all your templates): http://stackoverflow.com/questions/24855798/how-to-use-new-syntax-features-in-mojolicious-templates
12:07 punter What's better: Template::Toolkit or .ep files?
12:07 batman joined #mojo
12:09 pink_mist I prefer .ep files because I can just use perl in them. I don't need to learn a specific templating language.
12:09 pink_mist but whether one is "better" than the other? no clue.
12:09 pink_mist I don't think the question makes sense
12:10 punter Possible answers are: one is always better than the other, or that both each have their advantages
12:12 punter ok, I'll use .ep for the first time in my life, then
12:18 batman joined #mojo
12:24 jberger punter: couldn't you also do $pages->any('/')->to('pages#')
12:24 jberger ?
12:27 jberger punter: if you are already comfortable with TT (and assuming the TtRenderer plugin is any good, I haven't tried) then go ahead and use it
12:27 jberger I'm like pink_mist I don't want to have to learn another "language" to do my templates
12:28 jberger but there are people who argue that not having the full power of perl in templates is good because it keeps you from doing anything too clever there
12:31 * sri was about to tell punter about ->any('/') too
12:33 punter jberger: Are you sure you mean $pages->any('/'), or did you mean my $pages = $r->any('/')->to('pages#') ?
12:33 jberger punter: yes $r
12:34 punter jberger: but then, you won't be able to do $pages->get('/about') because that will map to //about
12:34 jberger punter: nope
12:34 jberger give it a try
12:34 punter ok
12:39 punter indeed, jberger, it worked!
12:39 punter thanks
12:39 jberger np
12:39 punter so does ///// get simplified to / ?
12:40 jberger canonical path resolution does that usually yes
12:40 punter it seems it does
12:40 jberger try it in your terminal
12:40 jberger cd .//SomeFolder
12:41 punter yes
12:41 sri for the record, even $r->any->to(...) works
12:41 sri internally slash is just a noop
12:43 punter but a web-browser will send all its slashes to the server
12:45 jberger sri: that I hadn't tried, though it makes sense
12:45 jberger TIL
12:47 pink_mist punter: why would the browser have all those slashes in the first place?
12:47 pink_mist punter: the browser will follow the links on webpages; if you write those to have an inordinate amount of slashes ... don't
12:55 bobkare joined #mojo
12:59 meshl joined #mojo
12:59 jberger pink_mist: I think you missed the point, punter was worried about it in the router
12:59 jberger but path canonicalization works at each of these levels, that's all
13:00 asarch joined #mojo
13:18 Kripton joined #mojo
13:31 Kripton joined #mojo
13:32 * sri hadn't realized that the 13" mbp and 12" rmb share the same screen resolutions
13:34 sri 1280x800 native and 1440x900 scaled down
13:38 sri s/mbp/rmbp/
13:55 sri somehow i expected the 13" to have more screen real estate
14:00 jberger under Jobs it would have
14:34 sri to be fair, the 13" does have a 3rd scaled resolution of 1680x1050
14:35 sri but at that point, why have a retina display at all if you want blurry text
14:42 henq joined #mojo
15:02 lluad joined #mojo
15:09 trwww joined #mojo
15:12 Lee joined #mojo
16:20 marty joined #mojo
17:11 PryMar56 joined #mojo
17:14 Lee joined #mojo
18:03 henq joined #mojo
18:21 punter joined #mojo
18:23 punter joined #mojo
18:31 asarch joined #mojo
18:42 Kripton joined #mojo
19:04 kaare_ joined #mojo
19:18 henq joined #mojo
19:19 kaare_ joined #mojo
21:05 meshl joined #mojo
21:15 Lee joined #mojo
21:15 punter joined #mojo
21:25 bpmedley punter: May I see what you ended up doing for your $api and $pages routes?  Also, did you decide on Template Toolkit or Embedded Perl?
21:34 sugar joined #mojo
21:44 kwa On the question of which is better, I prefer EP, but I've seen talks where companies have gone with Template Toolkit in case they want to move away from Mojo, and they seem to think it's less dangerous for designers to play around with TT templates.
21:44 sri reasonable argument
21:46 sri you're paying a steep price in performance though
21:47 * sri actually always wondered why TT has to be so slow
21:47 sri you'd think the templates could be compiled to optimized perl code
21:48 mmp sri: I think Template::Alloy was supposed to be a dropin fast replacement for TT
21:48 kwa I've not looked at the guts of it. But if it's anything like the first "template langugage" I wrote, I would say it was screwed trying to maintain backwards compatibility.
21:48 Grinnz Text::Xslate seems to be a decent choice for performance
21:49 sri Text::Xslate is cool but scary imo
21:49 sri you're pulling another complicated bytecode interpreter into your stack
21:51 kwa I suppose when you're already losing performance using databases to generate your pages, a little extra TT overhead doesn't really matter to most.
21:52 punter bpmedley: Here's how I solved my routing problems: http://paste.scsys.co.uk/512070?ln=on&hl=on&submit=Format+it!
21:53 kwa Despite TT being a simple enough language, I'd always have to refer to a cheatsheet if I'd not hacked in it for a few weeks.
21:53 bpmedley punter: Looks very succinct.  Does that work well for you?
21:53 kwa EP allows me to pick up where I left off, so I have no reason to go back.
21:54 punter bpmedley: yes
21:54 bpmedley Are you gonna need any authorization or authentication for your routes?
21:55 punter bpmedley: I decided to go with .ep files, for reasons I dont remember. TT has the useful "IF LAST THEN ..." condition you can place in loops. But .ep is cool as well.
21:55 sri kwa: actually, TT is one of the few template systems that always became a bottleneck in catalyst apps back in the days
21:55 punter bpmedley: I was slightly disappointed by the fact that mojo.vim doesn't do perfect syntax highlighting in .ep files. But I got over it.
21:56 bpmedley punter: Why not fix mojo.vim?
21:56 punter bpmedley: I'm not that good of a programmer.
21:56 bpmedley Only way to get better is failure..
21:56 punter bpmedley: I have a very good and mature authentication plugin I use in all my sites.
21:57 bpmedley punter: Cool, may I ask which plugin?
21:57 punter bpmedley: It's homebrewn, I haven't published it
21:57 kwa sri: Worrying as it was so prevelant back that. Was that a driving force behind EP?
21:57 kwa *then
21:57 punter bpmedley: I can show it to you if you want.
21:57 sri kwa: no
21:57 bpmedley punter: Please!
21:57 punter bpmedley: if you tell me who you are (on CPAN)
21:58 sri EP exists because i wanted to experiment
21:58 kwa punter: Why do you post to /addsubject_submit rather than /addsubject
21:58 kwa You can use the same _submit method.
21:59 punter kwa: addsubject just displays the form. The code would be too convoluted if I added "if param('body')" to have it do something else depending on whether it's the first or second time running
21:59 punter don't you think?
22:00 kwa punter: You're routing /addsubject GETs to create_topic. You can route /addsubject POSTs to create_topic_submit still.
22:01 punter kwa: You are right. i didn't think of that (was thinking in terms of an older framework that didn't do this trick - CGI::Application)
22:01 kwa I remember CGI::Application. :)
22:02 sri here's an example for a default REST app naming scheme https://github.com/kraih/mojo-pg/blob/master/examples/blog/lib/Blog.pm#L23
22:03 sri create is the form, store the form submit
22:05 sri (yes, PUT/DELETE just work with the form_for helper)
22:06 kwa I always thought /posts/:id/edit was a practical solution for returning a form to edit a resource, but it didn't feel very "RESTy".
22:07 sri it's the industry standard now, so... meh :)
22:07 kwa Is it? Shit. I best update ma plugin. :p
22:08 sri the /posts/create is not amazing either
22:08 sri but that's how every framework does it now
22:09 kwa Yeah. My solution was to embed it in the collection or resource endpoint themselves.
22:10 kwa But that was straightforward because I was using knockoutjs and sammyjs.
22:10 kwa Not everyone would be using things like that, so having a specific route to create/update makes sense. Just feels dirty.
22:56 punter joined #mojo
22:57 nicomen joined #mojo
23:16 Lee joined #mojo
23:42 henq joined #mojo

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