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

IRC log for #mojo, 2014-09-16

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

All times shown according to UTC.

Time Nick Message
00:02 stephan48 29
00:05 Lee joined #mojo
00:11 Averna joined #mojo
00:12 Averna joined #mojo
01:01 davido__ joined #mojo
01:25 woz joined #mojo
01:55 Akron joined #mojo
01:55 cpan_mojo Mojolicious-Plugin-JQuery 2.11000 by FERRO - http://metacpan.org/release/FERRO/Mojolicious-Plugin-JQuery-2.11000
01:55 Akron @stephan48: 29?
01:55 purl 29 is the minimal ACT score for mensa
01:58 woz joined #mojo
02:12 HtbaaPi joined #mojo
02:25 laouji joined #mojo
02:29 woz joined #mojo
02:36 woz_ joined #mojo
02:42 preaction joined #mojo
02:47 noganex joined #mojo
03:05 jwang joined #mojo
03:07 woz joined #mojo
03:10 basic6 joined #mojo
03:29 tempire Anyone heard of swagger?
03:29 tempire It seems like a thing.
03:29 tempire But it hasn't arrived in Perl, it seems.
03:29 irq joined #mojo
03:29 tempire Looks like a wsdl attempt
03:29 doublelel joined #mojo
03:38 woz joined #mojo
03:45 tempire oh, maybe just a doc format.
03:45 * tempire returns to his ios hole
04:09 jamesaxl joined #mojo
04:22 davido__ joined #mojo
04:31 woz joined #mojo
04:55 forke joined #mojo
05:08 laouji joined #mojo
05:10 ver joined #mojo
05:19 doublelel joined #mojo
05:31 woz joined #mojo
05:41 axlrose joined #mojo
05:47 denis_boyun joined #mojo
05:50 denis_boyun_ joined #mojo
05:52 denis_boyun__ joined #mojo
06:03 mr-foobar joined #mojo
06:24 Vandal joined #mojo
06:31 woz joined #mojo
06:42 KCL joined #mojo
06:49 dod joined #mojo
06:50 denis_boyun joined #mojo
07:03 Jonneh_ joined #mojo
07:10 basiliscos joined #mojo
07:31 woz joined #mojo
07:34 basiliscos joined #mojo
07:40 Jonneh joined #mojo
07:43 woz joined #mojo
07:48 arthas joined #mojo
07:58 odc https://github.com/wordnik/swagger-codegen
07:58 odc that's some serious bloat here
08:02 Nei it does look fancy http://editor.swagger.wordnik.com/
08:02 irq joined #mojo
08:03 preaction does it write automated tests too?
08:23 edestler joined #mojo
08:30 aleksey joined #mojo
08:39 dp_ joined #mojo
09:06 neyasov joined #mojo
09:10 nic joined #mojo
09:37 denis_boyun joined #mojo
09:40 Averna joined #mojo
09:47 basiliscos joined #mojo
10:00 noganex now that's very odd...
10:00 noganex i started my mojo app via plackup --enable-ssl --ssl-key-file=... --ssl-cert-file=... ../lib/ -p 3000 script/foo
10:00 noganex and it listens on http://*:3000
10:00 noganex but if i add -R lib,templates it listens on https://*:3000
10:01 noganex without -R it seems to ignore --enable-ssl o_O
10:16 d4rkie joined #mojo
10:48 _eugen joined #mojo
11:19 marcus Wish google translate could help me with http://youtu.be/rmmp5EUkJSs
11:25 lb is there a non-painful way to turn a url into a route-name (say, find the route for referrer)
11:25 lb $c->routes->match seems a little side-effect heavy
11:29 neilhwatson joined #mojo
11:30 good_news_everyon joined #mojo
11:30 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/V8Tp6w
11:30 good_news_everyon mojo/master a3f4fe7 Sebastian Riedel: link to Test::More
11:30 good_news_everyon left #mojo
11:31 d4rkie joined #mojo
11:31 doublelel joined #mojo
11:36 Jonneh_ joined #mojo
11:36 neyasov_ joined #mojo
11:36 bc547_ joined #mojo
11:37 phillipadsmith joined #mojo
11:37 bayashi joined #mojo
11:38 mattp_ joined #mojo
11:38 * lb came up with https://gist.github.com/lbalker/329c306a5f98ee32e322 which feels violator-ish
11:41 lb (our url_for handles the correct language-prefix for users preference, so this code basically translates the url you're on when you switch language)
11:46 fhelmber_ joined #mojo
11:53 basiliscos joined #mojo
11:58 jberger lb: does this help? http://mojolicio.us/perldoc/Mojolicious/Plugin/DefaultHelpers#current_route
12:01 lb no, i would be looking for previous_route (which is silly of course)
12:05 good_news_everyon joined #mojo
12:05 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/W68ICA
12:05 good_news_everyon mojo/master 50dc74d Sebastian Riedel: show directory structure of hybrid application
12:05 good_news_everyon left #mojo
12:22 Lee_ joined #mojo
12:26 Lee joined #mojo
12:37 lipizzan joined #mojo
13:03 neyasov_ joined #mojo
13:16 Akron joined #mojo
13:47 nicomen is there some way to build up a Mojo::DOM from a struct? (similar to XML::TreePP)
13:49 cpan_mojo Mojolicious-Plugin-JQuery 2.11001 by FERRO - http://metacpan.org/release/FERRO/Mojolicious-Plugin-JQuery-2.11001
14:04 odc nicomen, i asked the same question some time ago, and no, it's not possible just with mojo
14:05 odc look at XML::Quick though
14:05 batman Why isn't that possible? Can't you dump/restore the $dom object?
14:06 odc batman, how would you build a dom from a hash?
14:07 odc brb looking at restore()
14:12 Dandre joined #mojo
14:13 odc batman, can you give an example?
14:13 nicomen suddenly I also got an urge for $ mojo cmd # firing up a repl with mojo* modules loaded, and if called with script/myapp, being inside the app ;)
14:26 zackiv31 joined #mojo
14:33 sri ./myapp.pl eval 'use Reply::App; Reply::App->new->run'
14:34 sri mojo eval 'use Reply::App; Reply::App->new->run'
14:35 sri does just that
14:40 sh4 joined #mojo
14:42 sh4 joined #mojo
14:44 nicomen ah great ;)
14:44 nicomen sri++
14:52 neyasov_ joined #mojo
15:39 neyasov_ joined #mojo
15:40 mattp_ joined #mojo
15:41 woz joined #mojo
15:41 mr-foobar joined #mojo
15:42 sri glad we started encouraging Controller and Model namespaces, convos got a lot easier to read
15:45 basiliscos joined #mojo
15:48 * tempire wants to go to yapc::asia just so he can give a talk in the big room
15:51 disputin joined #mojo
15:52 tempire Yoshimitsu Torii needs more pictures.
15:52 tempire In his presentation.
15:52 tempire Some cats, AT LEAST
15:53 disputin joined #mojo
15:56 mst joined #mojo
16:03 sri MOAR MEMES
16:11 disputin joined #mojo
16:11 good_news_everyon joined #mojo
16:11 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/lQym6w
16:11 good_news_everyon mojo/master e3c44ac Sebastian Riedel: the HTML spec has a new home
16:11 good_news_everyon left #mojo
16:12 fhelmber_ joined #mojo
16:13 good_news_everyon joined #mojo
16:13 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/UPxFQg
16:13 good_news_everyon mojo/master 891f491 Sebastian Riedel: use new address in all links
16:13 good_news_everyon left #mojo
16:26 disputin joined #mojo
16:33 basiliscos joined #mojo
16:40 batman odc: a struct to me is just a data structure. I hash is... Just a hash.
16:40 batman No idea what that XML module does :/
16:41 batman sri: Mojo::EventEmitter is awesome. My JavaScript port really clean up convos.
16:42 batman I hope marcus thinks the same :)
16:50 basic6 joined #mojo
16:54 lestrrat joined #mojo
17:07 two_tired joined #mojo
17:14 disputin joined #mojo
17:28 dod joined #mojo
17:43 mst batman: AMCSS seems batshit insane to me.
17:43 batman mst: why?
17:43 batman i think it makes sense. except that the flexbox things are a bit bleeding edge
17:44 batman https://github.com/Nordaaker/convos/pull/197/files#diff-ad9c3a3ba071760556f3751b8eaa0ac1R166 # using the idea here
17:44 mst it mostly holds itself up next to bootstrap and goes "less stupid than bootstrap"
17:44 mst so's e.g. semantic-ui
17:44 batman haha
17:45 batman but i think it's clever to use context, rather than ONE MILLION classnames
17:46 mst where exactly is it using context?
17:46 mst all I can see is
17:46 mst data-foo="bar-baz" instead of class="foo-bar-baz"
17:46 mst and, like, why? that's just longer and uglier
17:47 mst actually, I'd probably use
17:47 batman uhm... let me rephrase. i'm not sure if i would use the actual AMCSS pack, but i got inspired
17:47 mst class="event nick-parted"
17:47 batman you're referring to convos now, right?
17:48 mst I'm referring the the examples in that PR
17:48 batman i think data-event="nick-parted" is a lot more descriptive, than many random class names in one attribute
17:48 batman (yeah, that's convos)
17:49 batman it's like {"whatever":"event nick-parted"} vs {"event":"nick-parted"}
17:49 batman i hope no-one goes for the first json structure.
17:49 sri those selectors look shitty
17:50 mst no, it's like
17:50 mst [ "event", "nick-parted" ]
17:50 mst vs
17:50 mst { "data-event": "nick-parted" }
17:50 batman and which
17:50 mst sri: so does the HTML, at least to me
17:50 batman oops!
17:52 sri that patch made it much worse imo
17:52 batman mst: how is "event nick-parted" the same as ["event", "nick-parted"] ?
17:53 batman sri: it will make it easier to me, when i'm moving from those templates to a pure json over ws api.
17:53 * sri shrugs
17:54 batman {"event":"nick-parted","nick":"sri","target":"#mojo","network":"magnet"} # the same as $("ul").data()
17:55 batman i won't add "class" to the json api :)
17:55 sri i don't know the convos internals, can't argue with that, just don't like the look of it
17:55 mst batman: because that's how CSS works
17:55 mst also, I'm not suggesting adding 'class' to the json API
17:56 mst I'm suggesting separating out "the json API" and "how you template the HTML"
17:56 mst unless you're *trying* to write a Model/Model/Model system
17:56 mst in which case maybe you wanted SQL on Rails?
17:57 batman mst: there's a historical reason behind the pull request
17:57 mst I have no idea how that's even relevant to the discussioin of whether the style is a good idea
17:58 mst anyway. sri thinks it's ugly, I think it's a footgun, you're welcome to try it anyway but I reserve the right to point and laugh when it goes horribly wrong :D
17:58 mst sri: is it just me, or is EventEmitter mostly the same as the jquery/angular event API? (note: I mostly like said API, so this isn't a complaint, just wondering what the key difference are
17:58 batman we started out with the event templates, since we thought it was a lot easier to test in perl, but now we discovered that we're in too deep anyway, so we want to move to a JSON over WS API instead.
17:58 mst I'd move to that API without taking a massive shit on my HTML
17:58 mst I don't really understand why you're trying to conflate the two
17:58 batman the easiest way (to me) to bridge that is by using data-foo="", since the $element.data() will be the same as the json data i will get later on
17:58 mst you shouldn't need 'class' in the JSON API
17:59 mst right, Model/Model/Model
17:59 mst I prefer separation of concerns
17:59 * batman gives up.
17:59 batman i don't have enough battery to try to make sense of this
17:59 sri mst: i stole the eventemitter design from node.js
18:01 mst batman: you're valuing simplicity of implementation, I wanted something elegant and semantic
18:01 mst I guess if you're also responsible for the CSS it doesn't matter if it makes designers choke to death on their own vomit
18:01 batman mst: don't tell me what you _think_ i value. if you do that from the PR, then you're way in deep.
18:02 mst you specifically said "the easiest way" in response to sri's arguing of "ugly" and mine of "inelegant"
18:02 mst I'm telling you what your revealed preferences are from this conversation
18:03 batman i don't value "the easiest way", but sometimes i do it anyway because i can live with it as long as it temporary.
18:03 mst then I don't understand how simplifying the JSON API should be relevant to deciding how to style your HTML
18:03 mst I'd design the two separately, then write code that connects them
18:03 mst (it's often called "a controller" :)
18:04 batman you can dissect the code again, when we move to react.js. if it still sucks, then i will pay attention.
18:05 batman in the meanwhile: i know it's messed up, but it gets the job done for now.
18:05 mst right, jquery soup happens to us all, no matter how hard we try and avoid it
18:05 mst (anybody with the urge to shout "not me" can have a free "yet" to go on the end of their sentence :)
18:06 batman we're only two people doing this, with very limited time. sometimes we decide to cut corners. that doesn't mean it's "our way of doing things"
18:07 sri what was this discussion about again?
18:07 batman sri: am-button="large"
18:07 mst I never said that it would be your way of doing things in another situation, or on another project, and if you invented such an implication then that's unfortunate but not really my fault
18:07 mst sri: at this point it's mostly about "batman's trying to parse me like a normal human and imagining subtext that doesn't exist", I suspect
18:08 mst once he remembers I'm not one, we'll go quicker
18:08 sri allright... i thought it was about using data-* attributes for styling
18:08 mst yeah
18:08 mst but then he said that a good reason for that
18:08 mst was so he could do data-${name} = json.$name
18:08 mst to simplify his JSON API
18:08 mst because the JSON API shouldn't be sending a 'class' attribute
18:08 mst that was the point at which I called it ModelModelModel
18:09 batman i have to stop talking, since i only manage to explain halves :(
18:09 mst I have the same problem every time I try to be a wit
18:12 batman i guess i have to actually explain all of this to marcus now even, since you two are running a winning argument :/
18:12 batman marcus: if so, let's do it in the same room over a beer :)
18:12 sri wait till i actually understand the topic! :)
18:13 batman haha
18:13 batman sri: pretty awesome, coming with winning arguments without even understanding the topic ;)
18:13 batman sri++
18:13 batman mst++
18:15 sri thing is, mst is not really right either i believe, because the json and data-event attributes on their own are not bad design
18:15 sri you're dealing with actual named events, and attach those events as metadata to the elements that represent them
18:16 sri what makes this ugly is that you also repurpose the metadata attributes for styling
18:16 sri https://html.spec.whatwg.org/#attr-data-*
18:16 batman yeah, i get that
18:16 marcus I agree with sri on that.
18:16 sri the html5 spec is pretty clear on the first part being good
18:17 batman marcus: so when should we meet for a beer, you say? :)
18:18 mst right, having the data-event attributes for data storage I have no objection to whatsoever
18:18 mst I'd just setup classes based on the data for styling separately to that
18:18 mst using data-event etc. for non-styling-related purposes is totally fine :)
18:18 marcus Yeah, I'm highly sceptical of using data for styling too.
18:18 * sri nods
18:19 mst esp. since I dislike the idea of tying what you can style to what data you're storing
18:19 mst seems like a separate contract to me
18:20 marcus batman: I also wonder if we really have to reimplement the event emitter given that the design comes from js in the first place.
18:20 mst I think maybe if you're already planning a switch to react
18:20 mst which has its own ways of handling and propagating events
18:20 batman marcus: the events in pure javascript is awful imo
18:20 mst it's a relatively moot point
18:20 batman *are
18:21 marcus batman: yeah, I wasn't suggesting we use those. I guess the jquery ones suck too.
18:21 batman marcus: or did i misunderstand?
18:21 nicomen I thikn you should use PHP
18:21 marcus I just wonder if we could lift them from node or if those are server side only.
18:21 marcus nicomen: wat
18:21 batman they don't suck, i just think they are clumsy in this case
18:22 batman marcus: the emit() stuff is just temporary. i don't see any reason why we want to mess with that now.
18:22 marcus https://github.com/asyncly/EventEmitter2
18:23 sri it's node core, with c++ sprinkled in
18:24 batman marcus: so you seriously want me to replace the event code that's in place and works, when it's going away anyway later on??
18:24 marcus batman: fair enough, I'll let that point rest then.
18:24 marcus batman: I was just wondering why you spent time writing your own event code.
18:25 mst probably "thinking about enough things at once that mechanically porting perl code he already understood was easier than trying a dozen libraries"
18:25 batman exactly.
18:25 batman cpan is a pretty wild place, but trying out one gazillion javascript libraries are really time consuming :(
18:25 irq joined #mojo
18:26 batman not sure how much time i've spent browsing through different jquery libraries :/
18:26 * sri doesn't like the lower level jquery apis much
18:27 mst jquery feels to me like a really useful cross-browser baseline
18:27 mst but it's not high level building blocks, and attempts to make it so seem to go horribly wrong
18:27 batman ok... so now i won't be able to complete the Mojo::Redis2 port today either :(
18:27 mst all I'm really proposing here is that you do
18:28 mst $el.class = "event "+$el.data()[event];
18:28 mst or whatever the fuck the JS syntax is
18:28 batman mst: i'm not going to change it.
18:28 batman i will however delete the whole thing on later on
18:28 batman s/on//
18:29 sri and while we are all here... someone please volunteer for turning signatures.pm into a polyfill... i really want to use it in mojolicious :)
18:30 mst sri: yeah, we need to get it to handle the rest of the syntax and then turn it into an MRO::Compat like thing
18:30 mst the problem then is that most of the compat/polyfill hackers, myself included, hate non-core XS deps if we can avoid them
18:31 marcus I hate them more when I can't avoid them.
18:32 mst :D
18:33 batman marcus: do you think anyone are running convos v0_3004...? (i want to delete the Upgrader classes)
18:34 marcus batman: I don't know and I don't see why deleting them have any benefit.
18:34 batman less to fix for Mojo::Redis2...
18:34 batman and the code is awful :(
18:35 marcus Oh right. In that case, you can probably delete them, and write a caveat about making sure to update to 0.84 before going forward
18:35 marcus in the changelog
18:35 marcus Can't be many affected users in any event
18:35 batman thanks. i'll keep the Upgrader around in a backup/upgrader branch
18:42 batman "826 deletions" feels good :)
18:42 batman and 416 deletions from removing Loopback
18:42 batman marcus: ^
18:43 KCL_ joined #mojo
18:43 marcus batman: deletions feel less good to me when they remove functionality :)
18:43 batman hehe, yeah... i somehow agree :)
18:43 marcus best deletions are DRYing up code
18:44 batman but it depends on the kind of functionality :)
18:44 marcus Yeah, removing stupid features can feel good in itself.
18:44 batman the upgrader code never felt right :(
18:45 marcus I can see that.
18:46 marcus batman: I feel like we need to build more of a model layer in convos. Too many low level redis operations with unclear purposes.
18:46 marcus or at least hard to understand 6 months after the code was written.
18:47 marcus I guess making redis optional will take care of a lot of that.
18:48 batman i agree. working on that after i manage to run all the unit tests.
18:48 batman (with redis2)
18:48 mst the last time I read the code it felt like a lot of the abstractions being used currently only existed in the authors' heads
18:49 mst and that what ended up in the .pm files was sort of one level of compilation further towards bare metal, as it were
18:49 mst (of course, premature generalisation is also evil, so I'm not saying that was the wrong choice to make to begin with)
18:50 batman mst: can't argue on that
18:50 sri i've been complaining about that too :)
18:50 sri but it's getting better
18:50 batman i really wish there could be more actual helping, than feeling though
18:50 sri actually triggered some changes in the core docs to encourage cleaner abstraction (more catalyst-ish...oh my!)
18:51 thomasoniii joined #mojo
18:52 marcus sri: core helpers even ;)
18:52 sri and better default namespaces... yea, it actually triggered a lot of changes :)
18:52 sri marcus++, batman++
18:53 batman marcus: redis_do() is going away now \o/
18:53 marcus batman: good riddance.
18:54 thomasoniii Hi all, I've got a question about under routes. I was hoping to set up a simple auth implementation as an under, and then hang other routes off of it. My issue is that apparently the parent under route cannot access route placeholders of the child routes via ->param. I suppose that may make sense, since the placeholder is defined in the child route. But it's stopped me dead in my tracks.
18:54 batman marcus: Mojo::Redis2 can do blocking, so no need for it... i would like however to get rid of all redis testing in the unit tests though :/
18:54 thomasoniii Is there any way to access a placeholder from the parent under route? Or is there a better way I should structure the routing?
18:55 mst surely if it's child-param-specific the parent route doesn't know how to do that anyway
18:55 mst why aren't you setting up the user in the parent route, and testing roles or whatever in the code that knows exactly what it's dealing with?
18:56 thomasoniii I'd been hoping to transparently drop some authentication into a few routes without rewiring them, but that seems less likely.
18:57 marty joined #mojo
18:57 thomasoniii If the user were passed in as a parameter, it'd be visible in the parent, for example. It's just the placeholder that isn't. I'm unfamiliar with the internal parse order of the routes, but it didn't seem unreasonable for it to already be parsed and available.
18:58 thomasoniii So you could have one child route that has /foo/:user_id and a different that does /bar?user_id=XXX and they'd both magically work.
18:58 thomasoniii (in a contrived example that I don't know why you'd need, admittedly)
18:59 sri making that kinda terrible design hard sounds like a feature to me :)
19:01 sri it's not done that way so you can have $r->under({action => 'foo'})->get({action => 'bar'})
19:02 sri and more such cases
19:06 mst thomasoniii: right, what I'm saying is: that indicates a design error
19:06 thomasoniii I may just need to restructure my routes. I have most of them set up of the form /:action/:id, with :id being an optional parameter. That doesn't hang nicely off off an under auth, I don't think. If I retooled it to be /:id/:action, I can tweak it further to have the parent be /auth/:id, and then various /:action child routes.
19:06 mst thomasoniii: you need to step back and find a non-stupid design
19:07 mst right, it sounds like the hierarchy is wrong here
19:07 mst at the moment, you're experiencing a stabbing pain in your right eye every time you try and drink tea
19:07 mst the answer isn't to anaesthetise your eyeball
19:07 mst instead, you should remove the spoon from the cup, THEN drink :)
19:07 sri you have a way with words
19:10 thomasoniii For example, say I have an edit route - /edit/14 edits object 14, whatever that is. /edit also works, and creates a new one. If I retooled it to /:id/edit, don't I also need to create an explicit additional /edit route to handle the creation case?
19:12 mst you're missing out half the explanation
19:13 mst mostly by saying things like 'object 14' which means we have no idea what your actual use case is
19:13 mst but also - you could use the under route to load the user initially, as I said
19:13 mst what I don't understand is - how does the 'under' route magically know how permissions work for 'edit'? isn't that specific to the 'edit' action? in which case, surely that controller should handle it
19:14 thomasoniii I don't need the under route to magically know how permissions work for 'edit', I'd just need it to access the /:id route placeholder in some manner.
19:15 cpan_mojo Mojo-Redis2 0.12 by Jan Henning Thorsen - http://metacpan.org/release/JHTHORSEN/Mojo-Redis2-0.12
19:15 thomasoniii Assume that the user is already loaded and exists, and I want the under route to check and see if I have permission to edit object 14. There's no way that I can see to hand in that '14' id to the parent under route.
19:15 thomasoniii Unless I retooled it to be under('obj/:id') and then hung an /edit action off of it.
19:16 jamesaxl joined #mojo
19:16 mst how does it know the action is an edit?
19:16 basiliscos joined #mojo
19:17 mst I really don't understand why "permissions to edit 14" isn't logically part of the "edit 14" route
19:17 mst why are you trying to move it somewhere that doesn't already know that's what's going on?
19:18 thomasoniii I'm not. I've just got 3 other actions sitting in there in addition to edit, and I need all of them to route through the same common auth controller that understands permissions on those objects.
19:19 mst assuming those actions are all in one controller
19:19 sri doing authentication based on parts of the path seems rather odd
19:19 mst I'm really not sure what's wrong with "factor it out into a method"
19:20 thomasoniii What seems odd about it? The path may conceivably contain an ID that's used to look up an object, and that object may have its actions restricted based upon the user that's logged in, right?
19:20 sri perhaps some of those rest-ful api design tutorials would help
19:20 mst and that authorization is logically the task of the controller handling that type of object, since that controller already knows that
19:20 sri http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api
19:21 mst for some reason you're trying to move it somewhere unrelated
19:21 mst and then wondering why that's hard :)
19:21 mst sub edit { if ($id) { $self->check_authz(edit => $id) } else { $self->check_authz('create') }
19:21 mst seems pretty simple and obvious to me
19:21 sri thomasoniii: credentials are usually not part of the path, but stored in a session (or some other form in a header)
19:22 mst he's talking about per-row user permissions, I think
19:22 mst i.e. he gets a user from somewhere
19:22 mst then he's trying to check authz for the particular action
19:22 mst and *that* part is best done in the controller for the particular type of model being operated on, I think
19:22 sri hmm
19:23 mst moving it somewhere else means you've now got to update two different places every time you change logic, rather than a single controller
19:25 thomasoniii Roughly, $r->under('/classroom')->to('classroom#auth')->get('/:action/:id', [action => qw(list count edit view delete)])->to(id => undef, controller => 'Classroom');
19:26 thomasoniii I really just want a transparent way to set up "do this stuff first, and if it succeeds, then carry onto the *real* action", without the real action needing to know about performing it. I thought that's what the under route would do. :-(
19:26 mst right, so surely the Classroom controller itself can handle that action
19:28 thomasoniii Yes, I can wire in the auth checking to each of the route methods, that is true. But I thought that an under route could handle it for me invisibly, hence being here asking questions.
19:30 mst like I say, extracting it into a check_authz method
19:30 mst that each of the route methods calls
19:30 mst is likely going to be more elegant anyway
19:30 mst and keeps the authorization requirement as close to the code it's protecting as possible
19:30 mst which is almost always a better design
19:30 mst 'invisible authz' tends to turn into 'shit I forgot part of the authz and now I have an exploit'
19:30 mst I like it to be visible, it means I know it's actually there :)
19:31 thomasoniii Not if the auth route is an under parent that all access routes have to hang off of to get into the site. :-)
19:31 thomasoniii It's comparably easy to remember to hang off of your pre-existing authenticating route as to add in the additional auth method to your code.
19:31 mst that makes sense for authentication but not authorization
19:31 mst actually
19:32 mst surely the Classroom controller will get instantiated with the id
19:32 mst so surely you could have a route in that controller that you call beforehand
19:32 mst sri: ?
19:32 mst basically, the equivalent of a per-controller base chained part
19:34 sri captured data is always preserved, just not merged into the stash at that point http://mojolicio.us/perldoc/Mojolicious/Controller#match
19:35 mst thomasoniii: I still think if you have per-object access permissions they should probably be ... actually per-object
19:35 mst honestly, I think I'd put this on the model itself
19:35 mst so once you've converted your $id to a $actual_thing
19:35 mst you ask $actual_thing->can_user($current_user, 'edit')
19:35 mst or similar
19:38 good_news_everyon joined #mojo
19:38 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/2MuH8Q
19:38 good_news_everyon mojo/master 0e7c031 Sebastian Riedel: better stack example
19:38 good_news_everyon left #mojo
19:38 thomasoniii heh. introspecting the results from ->match there, I see that I could just march through the stack and yank out the relevant parameter once I find it on the appropriate action in there. My gut tells me that'd be a brittle approach for my purposes, though. O:-)
19:38 mst your entire approach is brittle. you're just complaining that Mojo doesn't hide that fact from you :)
19:39 good_news_everyon joined #mojo
19:39 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/9f-w8Q
19:39 good_news_everyon mojo/master e64b093 Sebastian Riedel: better examples for the controller attribute as well
19:39 good_news_everyon left #mojo
19:40 ignacio_ joined #mojo
19:43 thomasoniii on a semi-related note, does mojo have a strong preference between routes of the form /:action/:id vs /:id/:action? I see merits to both approaches, both logically and semantically, and basically just arbitrarily picked to go /:action/:id. Would I be a much happier mojo developer in general using /:id/:action style instead?
19:44 mst you'd be a much happier web developer in general if you didn't user either of those
19:44 mst as sri said, go read a rest tutorial and stop fighting HTTP :)
19:45 thomasoniii Cool, then as per that RESTful tutorial sri linked to as well as general knowledge of the subject, then /:action/:id it is, since that's the preference in designating a resource. :-P
19:45 thomasoniii and I'll stick with my routes structured as is and ignore earlier remarks about my hierarchy being bad. :-D
19:46 mst nope, not at all
19:46 mst the preference in designating a resource is /thing/:id with no :action at all
19:47 mishantil thomasoniii: GET /thing/:id (get it), POST /thing/:id (create, perhaps update), DELETE /thing/:id (delete)
19:48 mst POST /thing # create, PUT /thing/:id # update (usually also allowing POST)
19:48 mishantil thomasoniii: using the http-methods for what they are there for == awesomesauce
19:48 mst fighting and trying to make Mojo behave like a 2005-era version of ruby on rails == not awesomesauce
19:48 mishantil mst++
19:50 cpan_mojo Rex-JobControl 0.7.0 by Jan Gehring - http://metacpan.org/release/JFRIED/Rex-JobControl-0.7.0 (depends on Mojolicious::Plugin)
19:51 mst but, yeah, if you're trying to allow for just GET+POST then the tradition is to have /:id/update or /:id/edit behave equivalently to PUT /:id
20:32 nicomen hm, in the latter example I would actually use /:thing/:action/:id - but that might be just me
20:32 mst nicomen: the idea is to have 'PUT /thing/:id' and 'POST /thing/:id/update' be the same, so you stay close to restish
20:33 mst I've always hated /thing/update/:id style URLs though, they're ... just not hierarchical in any meaningful way in terms of identifying resources
20:33 mst unless you start privileging the app's UI model over the underlying domain model, which seems like a terrible idea for a domain API
20:38 * sri agrees
20:54 mishantil Now even the alarm in my house has an app. Don't know if I like this...
21:02 forke joined #mojo
21:09 good_news_everyon joined #mojo
21:09 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/AJj5hQ
21:09 good_news_everyon mojo/master 19f19d4 Sebastian Riedel: explain how destinations work
21:09 good_news_everyon left #mojo
21:10 sri the topic has come up a few times now, i guess it needs to be mentioned
21:13 cpan_mojo Mojolicious-Plugin-BootstrapHelpers 0.0171 by CSSON - http://metacpan.org/release/CSSON/Mojolicious-Plugin-BootstrapHelpers-0.0171
21:21 punter joined #mojo
21:30 nicomen well, many times, :id is just one of many identifiers to distinguish elements I might want to operate on, but I see your point
22:03 berov joined #mojo
22:05 berov How can I have two sessions at the same time in tests. I want to emulate two users using my application and test how it behaves.
22:06 berov currently I start the application twice in my *.t file but I get warnings about redefined subroutines
22:06 berov example? ideas?
22:07 sri use two cookie jars
22:10 berov ok... will see how exactly to do it with Test::Mojo
22:10 berov thanks
22:12 berov example? :(
22:16 disputin joined #mojo
22:17 disputin joined #mojo
22:25 berov I would rather need a whole new $t->ua2
22:29 disputin joined #mojo
22:47 cfedde joined #mojo
22:51 firnsy joined #mojo
22:56 woz joined #mojo
23:04 * sri considers a new frontpage example
23:04 sri https://gist.github.com/anonymous/2e570644b9e4e3f9fed0
23:06 sri advantage, it uses many many cool features, and just works
23:06 sri downside, it shows a little less information, no post route, no params, no module use in template
23:07 d4rkie joined #mojo
23:09 sri another advantage, syntax highlighting seems to work a little better too
23:11 sweet_kid joined #mojo
23:16 sri wondering basically what the best example would be to get people hooked :)
23:16 sri i can imagine the fact that the current example doesn't really work when pasted might scare some folks
23:18 sri maybe i'll just try this one for a few days :)
23:21 disputin joined #mojo
23:28 woz joined #mojo
23:29 good_news_everyon joined #mojo
23:29 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/M1N-XA
23:29 good_news_everyon mojo/master 39e6d51 Sebastian Riedel: use a working example in README
23:29 good_news_everyon left #mojo
23:29 disputin joined #mojo
23:33 woz_ joined #mojo
23:34 good_news_everyon joined #mojo
23:34 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/u6wVpw
23:34 good_news_everyon mojo/master 56aea37 Sebastian Riedel: fixed curl example
23:34 good_news_everyon left #mojo
23:43 sri and live http://mojolicio.us/
23:43 sri tempire, jberger, marcus, batman, crab: thoughts?
23:44 tempire now it works when pasted?
23:44 sri yea
23:45 tempire then +1
23:45 tempire I never noticed before
23:45 sri shows the title of mojolicio.us
23:46 sri i've moved the unicode example to the hello world above, gives that one a little higher coolness factor as well
23:46 jnbek i never noticed that the header image moved when you mouseover'd on it
23:46 jnbek nice :)
23:46 sri :)
23:54 Lee joined #mojo

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