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

IRC log for #mojo, 2014-12-07

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

All times shown according to UTC.

Time Nick Message
00:25 KCL joined #mojo
00:57 Grinnz joined #mojo
01:11 atom sri:  thanks... so stupid... I had index.html.eb  not .ep
01:30 akhasanov joined #mojo
01:39 atom I'm making the authentication system like here:  http://mojolicio.us/perldoc/Mojolicious/Guides/Growing#toc
01:39 atom My app is not "Lite"
01:39 atom do I put "helper users => sub { state $users = MyApp::Model::Users->new };"  outside the startup block?
01:39 atom I'm thinking yes
01:47 meredith nah, in the startup method. just switch it to $self->helper( users => sub { ... } );
01:49 jberger for all intents and purposes, you can think of the body of a lite app as the body of a full app's startup method, with functions chanced to appropriate methods
01:49 jberger that'll get you 90% there at least
01:50 meredith your app is a plain perl class that allows defining methods like any other, and -that- happens outside startup if it's ever what you want
01:50 jberger s/chanced/changed/
01:51 jberger meredith: sure, but in Lite you couldn't do that, so those were helpers and that translates as mentioned
01:51 jberger right, the reverse is not necessarily true
01:52 meredith we're on the same page
01:53 * jberger high fives meredith
02:34 woz joined #mojo
02:42 atom jberger & meredith:  thx... I think I understand
02:55 klapperl_ joined #mojo
03:15 atom in the helper for why do we use 'state' and not 'my' for:  state $users = MyApp::Model::Users->new
03:16 atom is that so we're using the same object every time we grab the helper?
03:16 noganex joined #mojo
03:19 jberger atom: exactly
03:38 atom does that "static" object persist between requests and lives for a long as the server is up?
03:38 atom or is it generated each time a request is made and if it is called multi times it's the same object each time?
03:49 sri http://mojolicio.us/perldoc/Mojolicious#static
03:49 sri it's an attribute of the application instance
03:54 Grinnz sri, referring to "state" not "static"
03:55 atom ahh yeah should have said "state" and not "static"
03:55 atom more clear:  does that "state" object persist between requests and lives for a long as the server is up?
04:22 jberger atom: state behaves exactly analogous to having a my variable in the immediately outer scope, with the exception that that variable is not actually visible in that outer scope
04:23 jberger does that help?
04:27 * sri misses Mojo::DOM::val
04:30 jberger I still think that val and every_val are an option
04:31 * sri thinks that looks terrible
04:31 atom jberger:  so like a closure
04:31 jberger we have precedent all over the place now
04:31 jberger atom: yep
04:31 * Grinnz just put a my var in the outer scope... no big deal
04:32 sri how is val/every_val better than keeping val as is?
04:32 jberger Grinnz: yeah, except you have now polluted the variable space or added extra curly braces, each of which clutters things up
04:33 Grinnz jberger, except that scope is just the register function of my plugin... nothing else happens there :P
04:33 jberger my @uniq = grep { state %seen; !$seen{$_}++; } @elems;
04:33 Grinnz how recent is the state feature anyway?
04:33 jberger 5.10
04:34 Grinnz ah not bad
04:34 jberger Mojo::Base enables all 5.10 features
04:34 Grinnz does that include say?
04:34 jberger sure does
04:34 Grinnz hmm i might bother using that then
04:35 jberger and //
04:35 Grinnz / always works...
04:35 Grinnz // even
04:35 jberger though that technically doesn't need the feature pragma
04:35 Grinnz kind of annoying you have to declare something for say and state etc to work...
04:35 Grinnz which is probably why i dont usually bother
04:35 Grinnz // on the other hand... saves quite a bit of typing
04:36 atom state is core with 5.16+
04:41 atom <- remembers @ YAPC jberger reads perldoc on the train
04:46 sri jberger: i almost applied this patch before you brought up every_val again ;p https://gist.github.com/anonymous/d2b2bf98f2b9e1b56b2f
05:12 sri i think it's the only solution that makes sense
05:15 sri TIL <input type="email" multiple> exists
05:16 sri that allows you to enter a comma separated list of email addresses which become multiple key/value pairs
05:18 sri or actually, it seems ambiguous what's supposed to happen
05:18 zivester joined #mojo
05:21 sri oh, but the html5 spec actually defines a regex for validating email addresses Oo
05:21 sri /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
05:22 sri /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
05:22 sri so yea, that solves that once and for all ;p
05:23 preaction wait, what?
05:23 purl yeah, seriously
05:23 preaction ... wtf...
05:23 preaction what. the. actual. fuck. is. the. whatwg. doing?
05:23 sri https://html.spec.whatwg.org/multipage/forms.html#valid-e-mail-address-list
05:23 sri scroll a little up
05:25 preaction https://html.spec.whatwg.org/multipage/introduction.html#willful-violation <- so, the whatwg feel they can just ignore any other spec they feel like
05:25 preaction because they're right and everyone else is wrong
05:26 preaction and the w3 allows this shit to continue, because whatever
05:28 sri he who controls the spice^Wbrowsers...
05:29 sri honestly, i trust whatwg more than w3... they have pulled too much shit
05:29 sri whatwg is just pragmatic, documenting how the real world works, without idealism
05:30 preaction okay, but they appear to be building short-term solutions, which will cause long-term disasters
05:30 preaction i mean, yes, w3 sat on their hands for a _long_ time before whatwg came along to cure them of their malaise
05:31 sri you don't like your XHTML?
05:32 preaction now that i've seen what an unpruned HTML looks like, no, i think XHTML (module-based web content, like CSS modules) would have been a better choice
05:33 * sri faints
05:33 preaction HTML5 modules then? instead of a massive spec, a modular one
05:34 woz joined #mojo
05:38 * sri wants someone to tell him to apply https://gist.github.com/anonymous/d2b2bf98f2b9e1b56b2f
05:38 * sri pokes marcus, tempire, batman and crab
05:40 franzkafka joined #mojo
05:55 rem_lex|pivo joined #mojo
06:55 irq joined #mojo
07:18 da5id joined #mojo
07:21 johnnydepp joined #mojo
07:22 woz joined #mojo
07:30 PotatoGim^Home joined #mojo
07:34 Vandal joined #mojo
07:39 jamesaxl joined #mojo
07:54 dod joined #mojo
07:58 Lee joined #mojo
08:07 da5id joined #mojo
08:39 atom joined #mojo
08:52 amon joined #mojo
09:11 woz joined #mojo
09:14 Eke- joined #mojo
09:26 basiliscos joined #mojo
09:33 berov joined #mojo
09:57 punter joined #mojo
10:17 sh4 joined #mojo
10:25 Eke- joined #mojo
11:00 woz joined #mojo
11:19 neyasov__ joined #mojo
11:36 dod joined #mojo
11:44 denis_boyun joined #mojo
11:46 basiliscos joined #mojo
11:50 basiliscos joined #mojo
11:59 woz joined #mojo
12:15 basiliscos joined #mojo
12:26 KCL_ joined #mojo
12:57 trone joined #mojo
13:11 jamesaxl joined #mojo
13:15 punter joined #mojo
13:19 KCL_ joined #mojo
14:17 Eke- joined #mojo
14:19 neyasov__ joined #mojo
14:37 phillipadsmith joined #mojo
14:43 da5id joined #mojo
14:47 sri *crickets*
14:49 lipizzan joined #mojo
14:49 * jberger makes cricket stew
14:51 wim joined #mojo
14:51 jberger sri: oh that's the patch to make all of them return a collection?
14:51 jberger I'm +1 on that, always have been
14:51 sri :o
14:51 jberger you were the one opposed to that!
14:52 johnnydepp joined #mojo
14:59 jberger sri: have we tried the new Test::Simple release against Test::Mojo yet?
14:59 * jberger spins up a perl-blead
15:02 sri i benchmarked per-blead against mojolicious like 3 days ago
15:03 sri s/per/perl/
15:03 jberger k
15:05 * sri wonders if this should be fixed https://groups.google.com/forum/#!topic/mojolicious/IdbGHgZ_duk
15:08 jberger personally, I'm indifferent
15:09 jberger it seems like if you ask for an endpoint with a query parameter and then add a form, that sounds like a merge
15:09 zivester joined #mojo
15:09 sri it is true that browsers do replace all query parameters
15:10 jberger sri: here's an off the wall proposal
15:11 jberger string urls get there query parameters replaced, Mojo::URL objects get merged. I have my reasoning ...
15:11 jberger strings are likely to have come from other sources, say scraped from another site
15:11 sri lets not do that
15:12 jberger but if its a Mojo::URL object, it means that something has post-processed the object
15:12 jberger and the precedent is Mojo::ByteStream not being escaped in templates
15:12 sri -1 on special cases without very good reasons
15:13 jberger that's fine, as I said I'm actually relatively indifferent, and doing what the browsers do is probably the best default (assuming the browsers all agree)
15:13 jberger I was just offering a possible compromise, devils advocate style
15:14 sri browsers do agree
15:14 sri perl -Mojo -E 'a({inline => q{<%= form_for "/?bar=baz" => begin%><%= text_field "foo" %><%= submit_button %><% end %>}})->start' daemon
15:15 jberger <3 one-liners
15:15 jberger ojo++
15:15 jberger purl karma ojo
15:15 purl ojo has karma of 2
15:15 sri ojo++
15:15 good_news_everyon joined #mojo
15:15 good_news_everyon [mojo] kraih pushed 2 new commits to master: http://git.io/SO1gIA
15:15 good_news_everyon mojo/master b1b87ff Sebastian Riedel: reverted deprecation of Mojo::DOM::val
15:15 good_news_everyon mojo/master 1bcd622 Sebastian Riedel: fixed Mojo::UserAgent::Transactor to handle query parameters more like most common browsers
15:15 good_news_everyon left #mojo
15:17 * jberger misses cpan_mojo
15:17 jberger batman, where oh where has my mojo bot gone, oh where oh where can she beeeeeeee
15:18 sri this is only the second time a deprecation has been reverted :o
15:18 jberger what was the first, I can almost recall it happening before
15:18 jberger ?
15:19 sri perl 5.8.x support back in the days ;p
15:19 jberger oh, nope
15:19 jberger maybe I remember reverting features that never got released
15:19 jberger s/features/deprecations/
15:20 jberger on another topic, I do like my new mac, I wish that the keyboard was more standard
15:20 jberger but I guess I will figure that out with time
15:21 jberger (my fingers hate command+[xcv] for copypasta)
15:21 jberger and the inconsistency in how terminals/etc treat home/end behavior
15:21 jberger also, I wish homebrew was standard, like apt
15:22 jberger though in the end, having the package manager be third party probably helps break the tendency to trust the packagers over upstream authors
15:22 asarch joined #mojo
15:23 jberger mst: I'm really enjoying the mstpan series, keep it up!
15:23 jberger mst++
15:28 jberger sri: as you suspected, Mojolicious installs just fine on blead with $Test::Simple::VERSION == 1.301001079
15:30 jberger these last few years working mostly in python, everything I've been doing in Perl space has been modules for CPAN,
15:30 jberger now working on a Perl code-base its kinda nice to be able to use the features of the Perl you are using
15:30 jberger my project is on 5.16.3 atm
15:42 sri i'm still surprised by the performance gain with perl-blead
15:43 sri 23% for something as simple as examples/hello-template.pl
15:45 sri oooh, this new optimization looks interesting too http://code.activestate.com/lists/perl5-porters/215282/
15:46 sri time to benchmark again!
15:47 jberger sri: yeah I just saw that one /r/perl
15:47 jberger s/one/on/
16:04 good_news_everyon joined #mojo
16:04 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/jl7P-Q
16:04 good_news_everyon mojo/master fc0f89b Sebastian Riedel: fixed val example
16:04 good_news_everyon left #mojo
16:08 sri wow, perl-blead got quite a bit faster
16:09 jberger \o/
16:10 sri examples/hello-template.pl went from 1512 rps to 1934 rps
16:10 sri (both have all optional modules installed)
16:12 sri even Mojo::DOM gained a little performance
16:12 sri parsing the html5 spec went from 5.42s to 5.32s
16:16 sri "mojo generate lite_app" went from 1427 rps to 1791 rps
16:17 jberger haha, I had never thought to profile generating a lite app :_)
16:17 sri no
16:17 sri i mean the resulting app
16:18 sri and i run "wrk -c 100 -d 10s http://127.0.0.1:8080/" against them
16:18 sri that's a gain of 26% i believe
16:19 sri examples/hello-template.pl gained 28%
16:20 jberger ah ok
16:20 jberger I was imaging you filling up your hd with piles of lite apps :-P
16:21 punter joined #mojo
16:33 sri Oo
16:35 Eke- joined #mojo
16:47 inokenty joined #mojo
16:48 sri btw. Mojo::Base attribute accessors got about 20% faster
16:56 jberger nice!
16:56 btyler wow, that's awesome
17:12 trone_ joined #mojo
17:16 akhasanov joined #mojo
17:37 KCL_ joined #mojo
18:08 akhasanov joined #mojo
18:13 sri marcus, tempire, batman, crab: any other opinions on http://mojolicio.us/perldoc/Mojo/DOM#val
18:13 sri ?
18:35 denis_boyun joined #mojo
18:48 sugar joined #mojo
18:50 woz joined #mojo
18:52 bobkare joined #mojo
19:23 trone_ joined #mojo
19:36 marty joined #mojo
19:37 Eke- joined #mojo
19:41 dod joined #mojo
19:49 sri *crickets*
19:50 sri this channel might need an exterminator
19:50 preaction I'll be back
19:51 preaction Your code. Give them to me.
20:09 akhasanov joined #mojo
20:22 tempire seems a little weird
20:22 tempire but I don't have any better ideas
20:22 sri I'm back
20:25 mst actually, ->val->[0] is almost clearer to me
20:36 cfedde why a special method for the value attribute? and then why abbreviate it?
20:40 franzkafka does attr->{value} not work on inputs?
20:42 good_news_everyon joined #mojo
20:42 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/dHAJmg
20:42 good_news_everyon mojo/master 54517db Sebastian Riedel: stringify for better performance when passing Mojo::DOM objects to Mojo::DOM
20:42 good_news_everyon left #mojo
20:42 sri did you two read the description?
20:42 sri http://mojolicio.us/perldoc/Mojo/DOM#val
20:47 mst I did!
20:47 mst I actually read the POD instead of the source for once ;P
20:47 sri and you're the 3rd ;p
20:48 sri i mean franzkafka and cfedde
20:49 franzkafka I did not read the POD, was just following up on what cfedde had said. Sorry about that. Back to what I was doing :D
20:49 franzkafka Btw, I like shortened val.
20:50 franzkafka And I get it why you have val method.
20:51 sri every now and then i want to extract form values without thinking about the specifics of the input element... but at the same time i don't like any of the possible apis much :S
20:51 sri what makes it complicated is the <select>, which may have more than one value
20:52 mst make it list context sensitive!
20:52 sri the whole thing originates from jquery, which has a terrrible api too http://api.jquery.com/val/
20:52 * sri sets mst on fire
20:52 * mst lights a joint off his hair
20:54 * jberger warms himself by the fire
20:55 sri i still kinda just want to get rid of it... and wait until we find a good api... but all evidence suggests that there is no better api :S
20:58 cfedde The hierarchical structure available in HTML 4 select optgroup seems interesting to consider.
20:58 sri ?
21:01 sri like https://github.com/kraih/mojo/blob/master/t/mojo/dom.t#L2297-L2304
21:02 sri for the record, we don't care about the html4 spec, just the living standard
21:03 * cfedde crawls back under his rock.
21:06 sri i take that as a yes ;p
21:07 sri btw. looking at the source is actually not too bad https://github.com/kraih/mojo/blob/master/lib/Mojo/DOM.pm#L183-L200
21:08 sri that's the stuff you would have to know and do manually
21:08 cfedde it is a pain to muck about with forms in the dom.  and it does not seem like we can reverse the mistakes made in the early form specs where there are several different grouping abstractions.
21:10 cfedde if my vote counts at all I say that it is convenient to have this feature. regardless of the name.
21:11 sri i don't think anyone minds the name, it's about returning collections
21:12 sri only <select> can actually have more than one value
21:12 Eke- joined #mojo
21:12 sri so for all the other elements you always get a collection with one or no values
21:13 sri when the method was added collections did stringify
21:13 sri so you could just do say $dom->at("input")->val
21:14 sri after the deprecation of stringify in collections, you now have to use say $dom->at("input")->val->first
21:14 mst um
21:14 mst so why not have 'values' that always returns a collection
21:15 mst and 'val' that throws a fat exception if you get more than one result
21:15 sri i don't want to split up the feature into multiple methods
21:15 mst k
21:17 cfedde a select that contains multiple optgroup would return a complex collection?
21:17 sri ->values would get so little use
21:17 sri cfedde: wat?
21:17 purl Watt?  Watt?  I can't hear you, there's this buzzing noise where my brain should be. or https://www.destroyallsoftware.com/talks/wat
21:18 sri what's a complex collection?
21:18 cfedde I guess I'm asking if the returned collection would represent the tree structure of the optgroups some how.
21:19 cfedde I should test and see.
21:19 sri why do you care about the strucutre?
21:20 cfedde My values have to be properly encoded so I don't.
21:21 sri how does the encoding relate to structure?
21:21 * sri is a bit confused
21:22 cfedde I should have stayed under my rock.
21:22 * cfedde goes away again
21:24 * jberger looks under cfedde's rock
21:24 jberger looks comfy enough
21:29 good_news_everyon joined #mojo
21:29 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/b880RA
21:29 good_news_everyon mojo/master f3248d6 Sebastian Riedel: added textarea example too
21:29 good_news_everyon left #mojo
21:31 sri well, worst case would be if Mojo::DOM::val actually confused people
21:36 alnewkirk joined #mojo
21:44 denis_boyun joined #mojo
21:50 woz joined #mojo
21:52 franzkafka Hi all, I feel pretty damned good about my UserAgent skills at this point. The only think I know I am probably still doing wrong is testing for the existence of something in DOM before calling methods on it.
21:52 franzkafka Here's an example: http://paste.scsys.co.uk/451299
21:53 good_news_everyon joined #mojo
21:53 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/cOb-8A
21:53 good_news_everyon mojo/master 09a549a Sebastian Riedel: stringify closer to the regex
21:53 good_news_everyon left #mojo
21:54 sri franzkafka: if (my $e = $dom->find(...)) { ... = $e->text; ... }
21:55 sri oops
21:55 sri s/find/at/
21:55 franzkafka Ah ha! Thanks sri!
21:57 mib_bg89hg joined #mojo
22:20 neyasov__ joined #mojo
22:24 Averna joined #mojo
22:35 sri ->val->first does not look that bad in oneliners
22:35 sri perl -Mojo -E 'say r g("www.github.com")->dom->at("form")->find("button, input, select, textarea")->reduce(sub { $a->{$b->{name}} = $b->val->first; $a }, {})'
22:38 sri i guess ->val->to_array is nicer for building Mojo::UserAgent forms
22:48 sri this one is better
22:48 sri perl -Mojo -E 'say r g("https://www.google.com/advanced_search?hl=en&amp;fg=1")->dom->at("form")->find("[name]")->reduce(sub { $a->{$b->{name}} = $b->val->to_array; $a }, {})'
22:56 davido__ joined #mojo
23:13 punter joined #mojo
23:17 absolut_todd joined #mojo
23:39 woz joined #mojo
23:49 good_news_everyon joined #mojo
23:49 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/HFdQtA
23:49 good_news_everyon mojo/master a5801d5 Sebastian Riedel: keep Mojo::DOM::val deprecated
23:49 good_news_everyon left #mojo
23:49 sri oh well
23:58 * sri just realized that ->val was actually the first truly html specific method in Mojo::DOM
23:59 crab short for valerie?

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