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

IRC log for #mojo, 2015-09-19

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

All times shown according to UTC.

Time Nick Message
00:01 ZoffixWork Ahhh... Found it! I need to set app->mode *before* I load the plugin. Never mind me. :)
00:01 jabberwok asking the question alone often reveals the answer
00:02 ZoffixWork :)
00:11 genio joined #mojo
00:12 ZoffixWork .oO( I wonder if ->purge can combine with some static asset names )
00:13 ZoffixWork Was planning to have X page retrieve asset-packed resources from my app, but I've just realized they don't have static names :/
00:28 ZoffixWork AssetPack has trouble minifying JS it seems. I had trouble before with bluipm gallery plugin and now having trouble twice again. First, if file 1 ends with '//' comment and file 2 begins with /* comment, this ends up in error... I
00:28 ZoffixWork And I've come across another minifier error again after fixing the comment one (not sure what causes this one).
00:28 ZoffixWork I'll take a look at this when I get some time.
00:45 PryMar56 joined #mojo
00:46 theo joined #mojo
00:52 bpmedley https://github.com/brianmed/Mojo-IOLoop-Tail <-- Thoughts on new approach?
00:54 bpmedley Thanks for looking at my code, I really appreciate it.  Hopefully something useful can make its way to CPAN.
00:57 Grinnz looks better. you need some tests :)
00:59 bpmedley I agree about tests.  I'll have to think of a way to do that.
01:03 cpan_mojo Mojo-IOLoop-Tail-0.01 by BPMEDLEY https://metacpan.org/release/BPMEDLEY/Mojo-IOLoop-Tail-0.01
02:17 asarch joined #mojo
02:39 SmokeMachine hi! good night!
02:39 SmokeMachine how can I test a long polling?
02:48 noganex_ joined #mojo
05:13 dustinm joined #mojo
05:50 irqq joined #mojo
06:02 dod joined #mojo
06:03 irqq_ joined #mojo
06:08 dod joined #mojo
06:42 jb360 joined #mojo
07:34 asm35 joined #mojo
07:38 asm35 joined #mojo
07:43 bpmedley SmokeMachine: Did you get your long polling stuff tested?
08:17 Vandal joined #mojo
08:25 melo joined #mojo
08:26 cpan_mojo Mojo-IOLoop-Tail-0.02 by BPMEDLEY https://metacpan.org/release/BPMEDLEY/Mojo-IOLoop-Tail-0.02
08:31 sue joined #mojo
08:45 cpan_mojo Mojolicious-Plugin-BModel-0.07 by BCDE https://metacpan.org/release/BCDE/Mojolicious-Plugin-BModel-0.07
08:57 batman ZoffixWork: Provide a failing test, and I'll fix it.
08:58 batman The only case I've seen where minifying fails is when the source code is already minified
08:58 pink_mist fail('This is a failing test');
08:58 pink_mist :P
08:59 batman Not sure why, but double minifying seems to not work
09:00 pink_mist fix: s/fail/pass/g
09:07 batman Grinnz: Yes. cpanfile is the source
10:22 sue hello batman
10:22 sue didn't get to say hi at yapc
10:24 batman sue: I think we did at the bar the first night, but that was about it :/
10:24 sue boo
10:25 batman But... We'll meet again! :)
10:26 * batman is so hung over today :/
10:26 batman Having guests over later. Going to be awful :(
10:26 sue i'm doing something mildly risky today (re hangover)
10:27 sue riding on a steam train which is an excuse for drinking beer
10:27 batman Yesterday I thought that "future batman" will manage, but now "present batman" hates "past batman"
10:27 sue good luck with your guests
10:27 bpmedley Just make your guests drink, as well.
10:27 sue drunk me always thinks that the future will be wonderful. drunk me is happy but somewhat deluded
10:27 trone joined #mojo
10:28 batman sue: Haha! Good luck with the train.
10:28 sue i'm sure it will be fun
10:29 sue http://www.watercressline.co.uk/product.php/10/real-ale-train-r-a-t
10:29 batman Five people from Iceland, I've never met before... Yeah, it could be fun :)
10:29 * sue apologises for briefly hijacking #mojo
10:30 batman Yeah. Me too.
10:40 * sue has a go at installing convos on a server as penance
10:58 marcus sue: All is forgiven.
11:11 meshl joined #mojo
11:45 sh4 joined #mojo
12:07 Zoffix batman, ah, that's probably it. Some of my JS files are already minified.
12:15 kanishka joined #mojo
12:22 SmokeMachine bpmedley: not yet
12:27 stephen joined #mojo
12:30 batman Zoffix: Just call them .min.js and they won't get minified again
12:34 Zoffix batman++ didn't know that :)
12:41 sue joined #mojo
12:53 asarch joined #mojo
13:01 xenv joined #mojo
13:13 mudpit joined #mojo
13:43 bpmedley SmokeMachine: https://github.com/kraih/mojo/blob/master/t/mojolicious/longpolling_lite_app.t <-- This may help?
13:54 gryphon joined #mojo
14:02 SmokeMachine bpmedley: yes, i think that could help
14:03 bpmedley The Mojolicious tests are a treasure trove of fun.. :)
14:05 SmokeMachine Another question: I have a route for a action that renders a json, but I want to if I receive a message on my web socket to run that action, get that rendered json and message it back... Is that possible?
14:08 SmokeMachine Or will I have to split that action in a method that do everything but render and a action that call that method and render the result?
14:08 bpmedley Do you want to lookup the action dynamically, call the action via Mojo::UserAgent, or call the sub in the package directly?
14:09 SmokeMachine I would prefer call the package (but discover witch package dynamically if possible)
14:10 batman SmokeMachine: You should probably factor out the code in a model and then call the model method from both places.
14:11 bpmedley batman's response makes more sense
14:12 SmokeMachine That would be perfect if I could: $ws->send({action => "bla", controller => "ble")... But I don't think that would be possible...
14:13 batman SmokeMachine: sorry. i don't understand that last part
14:13 sri use mvc
14:17 SmokeMachine Because I want to receive a "command" from ws, ant that command do the same of a already existing route (with a lot of under, sub routes Etc) and return (message) exactly the same thing I would return if I did accessed that route...
14:18 bpmedley SmokeMachine: Can you use use the UserAgent?
14:18 SmokeMachine But ua will not be fast, or it will?
14:19 bpmedley Not as fast, no; however, you can use localhost.
14:19 batman SmokeMachine: but... calling the same method that generates the same data _is_ the same thing
14:19 mattastrophe joined #mojo
14:20 sri bpmedley: that's not good advice
14:20 batman SmokeMachine: i think you're take on this issue is all wrong. sorry :(
14:20 bpmedley sri: Understood, I won't mention it again.
14:20 sri proper abstraction would be so much better
14:20 SmokeMachine Any way to use the same thing of the get command, and not going to the network?
14:21 bpmedley SmokeMachine: I think the guidance is to structure your app in a way that you can call your methods in the various places that needs the data.
14:22 sri there's so much overhead when you use the user agent with your own app
14:24 sri put as much code as possible into the model, and use helpers for repetitive action code
14:24 SmokeMachine Let's say I have a route that has a under that verify the api key, another one that from a token put a dbic obj with the user, etc,etc... And the action itself only goes to database and render the result...
14:25 SmokeMachine I want to do every step of that on a ws "command"
14:26 SmokeMachine If I have that logic on my route, why should I do the same logic outside that again?
14:27 SmokeMachine Made I myself clear.
14:27 SmokeMachine .
14:27 SmokeMachine ?
14:27 SmokeMachine Sorry
14:27 PryMar56 joined #mojo
14:27 pink_mist factor the logic out to a helper and have the under or your route call the helper instead?
14:28 sri in general, there should be very little code in actions, they only glue things together
14:29 SmokeMachine pink_mist: that way I would have put the logic of witch helpers call for every route in 2 places...
14:30 pink_mist why would you do that?
14:30 SmokeMachine sri: there is very little code on the action... The problem is the chain of actions on the route
14:32 bpmedley SmokeMachine: Perhaps you could put together a small Mojolicious::Lite app that demonstrates the issue so we can banter with code?
14:32 SmokeMachine pink_mist: I am not trying to do that for one route... My plan is to every endpoint on my api have a equivalent command by ws
14:33 SmokeMachine I'm on a iPad now... :(
14:33 SmokeMachine bpmedley: ^
14:33 pink_mist we'll be here when you get to a real machine
14:33 pink_mist (maybe) :P
15:24 SmokeMachine pink_mist, bpmedley, sri: I hope this can help https://www.irccloud.com/pastebin/P7a0by7g/
15:24 SmokeMachine I forgot the response!
15:27 ajr_ joined #mojo
15:27 SmokeMachine I tryed to edit to add the response, did it work?
15:29 bpmedley $tx->send($response)
15:29 SmokeMachine yes
15:38 SmokeMachine understandable?
15:39 bpmedley SmokeMachine: One sec
15:46 bpmedley SmokeMachine: https://bitbucket.org/snippets/bpmedley/7RxGE <-- Is this an accurate reflection of the routes?
16:25 disputin joined #mojo
17:11 ZoffixWork joined #mojo
17:15 ZoffixWork batman, curious, what is the purpose of this while(){} loop? http://bit.ly/1KplgE8
17:15 ZoffixWork It does have a bug in it, but I'm curious why it's there from the start.
17:16 SmokeMachine bpmedley: looks good
17:17 ZoffixWork I haven't made a testcase yet, but I see that I get this output (notice the // comment blocking out the start of /* comment): http://fpaste.scsys.co.uk/498935  If I comment out that while(){} loop, the issue goes away
17:23 ZoffixWork Ah, a heuristic to detect minified files?
17:27 ZoffixWork batman, this fixes the issue I was having: https://github.com/jhthorsen/mojolicious-plugin-assetpack/commit/76bb6a2d3e711017d2a1cf4123706cbddfbf536a
17:27 ZoffixWork Cheers! :)
17:31 bpmedley SmokeMachine: https://bitbucket.org/snippets/bpmedley/7RxGE <-- How does this strike you?
17:31 bpmedley There's basically only psudeocode for get_obj.
18:37 asarch joined #mojo
19:02 asm35 joined #mojo
19:16 kaare joined #mojo
19:23 Adurah joined #mojo
19:42 ajr_ joined #mojo
20:06 SmokeMachine bpmedley: sotty, I didn't get it...
20:07 bpmedley SmokeMachine: So, my example doesn't make sense?
20:08 SmokeMachine bpmedley: it is running only the data() for any "command"...
20:10 SmokeMachine bpmedley: and I didn't get what id the api, the admin and the slash inside the eval...
20:10 bpmedley Do you see how get_obj has the authentication/authorizaiton and data access abstracted out?
20:10 SmokeMachine bpmedley: and I didn't get what is the api, the admin and the slash inside the eval...
20:14 SmokeMachine yes... the routes part is ok...
20:16 bpmedley In the websocket the access_api, access_admin, and access_flash helpers are used to authorize the websocket against the same code that would authorize a route.
20:16 SmokeMachine bpmedley: but, if the api means access_api, the admin means access_admin and the slash means access_slash, so the problem is that every "command" on ws is testing those 3 tests, what should not be true
20:17 bpmedley You'll need someway to determine which access sub to call for a give route passed into the websocket.
20:17 SmokeMachine yes, thats my problem!
20:18 bpmedley You have the route name, right?
20:18 SmokeMachine Id like to use the route for that! Or ill have to duplicate that logic...
20:19 SmokeMachine on my example the $msg->{route} is the route name...
20:19 SmokeMachine sri, pink_mist, batman: any help?
20:24 SmokeMachine bpmedley: did you understand the problem?
20:24 bpmedley Moment
20:28 bpmedley https://bitbucket.org/snippets/bpmedley/7RxGE <-- Is this better?
20:28 ZoffixWork joined #mojo
20:40 abra joined #mojo
20:45 SmokeMachine bpmedley: I steel don get why do the data() for every command, but the validation is almost there... probably it should be a hash of arrays... but thats the problem... the logic is in 2 places...
20:46 SmokeMachine if I change the route Ill have to remember to change the hash...
20:50 sri bpmedley: why not a plugin for the helpers?
20:50 bpmedley SmokeMachine: my $name = $c->current_route; <-- Will this help?
20:50 bpmedley sri: I hadn't thought of that.. hrmm
20:51 bpmedley I was thinking of using a package; however, a plugin probably would be better..
20:51 sri http://mojolicio.us/perldoc/Mojolicious/Guides/Cookbook#Adding-a-plugin-to-your-application
20:51 SmokeMachine bpmedley: i don't think so... the current route will probably be the web socket one...
20:53 bpmedley SmokeMachine: So, basically, you want one data structure to define everything?  Or, at least one place to goto for configuration of everything?
20:56 SmokeMachine bpmedley: I'd prefer use the already existent routes...
20:57 SmokeMachine but if its not possible, yes, Id like to do every think in one place...
21:00 sri bpmedley: i doubt it all has to be helpers though
21:00 sri authentication almost always fits well into a model
21:07 sri oh, doctor who is back \o/
21:20 jb360 joined #mojo
21:25 bpmedley https://bitbucket.org/snippets/bpmedley/7RxGE <-- SmokeMachine (thoughts)
21:30 meshl joined #mojo
21:53 sri honestly, the whole thing smells of terrible design
21:53 sri tunneling http through websockets
21:53 sri it's like you just want to tick off a box on the feature list
21:55 sri there are many sensible use cases for websockets, but this just doesn't make sense
21:58 sri don't do REST over wbesockets
22:02 sri just in case nobody has told you that yet :)
22:10 SmokeMachine sri, I don't know yet (IMHO) if it is a bad idea... I was trying to figure how to do this: https://mmikowski.github.io/json-pure/ once done, see what I think about that...
22:28 preaction joined #mojo
22:36 njlg joined #mojo
22:46 till joined #mojo
22:48 Dada joined #mojo
23:17 njlg joined #mojo
23:22 Dada Hi. I'm developping a website with mojo, and I was wondering how to handle the possibility to change the language : I  thought about storing the language in the session cookie, and before rendering every page, I check the cookie to know what language to use.. any suggestions?
23:23 pink_mist web browsers usually send headers telling you which language to use ... but yes, storing an overrideable value in a cookie is definitely a plus
23:25 sri there's an i18n plugin on cpan that used to be in core
23:25 sri https://metacpan.org/pod/Mojolicious::Plugin::I18N
23:31 Dada @pink_mist : oh right, I forgot about headers...
23:31 Dada @sri : yea, nice plugin, indeed. I might just be perfect, thanks!
23:33 Dada s/I/It/
23:34 pink_mist nice typo :P

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