Perl 6 - the future is here, just unevenly distributed

IRC log for #metacpan, 2014-03-24

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

All times shown according to UTC.

Time Nick Message
00:40 ether_ joined #metacpan
01:55 oiami joined #metacpan
02:14 oiami joined #metacpan
02:42 klapperl_ joined #metacpan
05:44 alnewkirk joined #metacpan
05:52 ether_ joined #metacpan
06:00 mport left #metacpan
06:39 [Sno] joined #metacpan
07:10 dpetrov_ joined #metacpan
07:16 nbezzala joined #metacpan
07:33 ribasushi joined #metacpan
07:44 bjakubski joined #metacpan
08:13 DerAlex joined #metacpan
08:37 nado joined #metacpan
09:21 neilb joined #metacpan
13:01 timbunce_ joined #metacpan
13:25 [Sno] joined #metacpan
13:26 [Sno] left #metacpan
13:28 oiami joined #metacpan
14:07 talina_ joined #metacpan
14:36 talina_ joined #metacpan
14:46 talina_ joined #metacpan
14:52 mport joined #metacpan
15:27 jwang joined #metacpan
15:50 talina_ joined #metacpan
16:06 rashi joined #metacpan
17:41 nbezzala joined #metacpan
17:48 neilb joined #metacpan
18:01 punter joined #metacpan
20:17 neilb joined #metacpan
20:36 punter Help, where can I find out how to do the API query that's useful for autocompletion
20:36 punter ?
20:36 punter the one where you type in only half the module's name, and you get a list of modules that have the same substring?
20:37 punter it's not here: https://github.com/CPAN-API/cpan-api/wiki/API-docs
20:37 dipsy [ API docs · CPAN-API/cpan-api Wiki · GitHub ]
20:42 punter Found this in the slides of a presentation. Can I make it return distributions rather than modules? http://api.metacpan.org/v0/search/autocomplete?q=Moose
20:44 jibsheet rt.cpan.org does this to get dists https://github.com/bestpractical/rt-extension-rt_cpan_org/blob/master/html/NoAuth/js/rt.cpan.org.js#L48
20:44 dipsy [ rt-extension-rt_cpan_org/html/NoAuth/js/rt.cpan.org.js at master · bestpractical/rt-extension-rt_cpan_org · GitHub ]
20:45 punter thanks (though it looks the same as the Moose example above)
20:45 punter that returns dists as well, but the search is done on the Module names
20:45 punter it's ok, not so important. Thanks
21:03 trs punter: you can certainly do an api query for dist name prefixes
21:06 punter trs: hm. What would such a query look like?
21:07 punter shall I google for "elasticsearch autocomplete"?
21:07 timbunce joined #metacpan
21:08 trs punter: http://explorer.metacpan.org/#/9749197
21:08 punter thanks
21:09 punter great
21:09 trs you'd google for "elasticsearch prefix"
21:09 trs there's a reason I used the term "prefix" ;)
21:09 trs BUT: the metacpan autocompleter is doing a much more complex query
21:09 trs to restrict to non-dev releases, authorized releases, etc.
21:10 punter so, modules never contain minus sign, and distros never contain colon, is that right?
21:10 punter (so I know what to search each time)
21:10 punter trs, ok, I'll restrict
21:11 trs you can see it in the metacpan code: https://github.com/CPAN-API/cpan-api/blob/2aba91d/lib/MetaCPAN/Document/File.pm#L928-L959
21:11 dipsy [ cpan-api/lib/MetaCPAN/Document/File.pm at 2aba91d4f72d3c14797f1baf465116e9035d560c · CPAN-API/cpan-api · GitHub ]
21:12 trs adjusting is left as an exercise for the reader.
21:12 trs that's convention, but I'm not sure it's a totally hard and fast rule (at least for dists not containing a colon)
21:17 punter trs: when Firefox tries to POST that query, it first does a pre-flight OPTIONS query, which apparently fails.
21:18 punter trs: I'll have the server do the query, doesn't matter.
21:18 punter I think it fails because (even though the status is 200) metacpan doesn't mention that the content-type header is allowed
21:19 punter I do'nt know, sorry
21:19 punter for some reason only the OPTIONS query is done, not the post
21:22 trs punter: how are you doing the query? metacpan won't send CORS headers unless you send some requesting CORS in your request
21:22 trs IIRC
21:22 punter The browser is doing the query, with AngularJS's $http object
21:22 punter service
21:23 punter I bet CORS is what the browser is requesting
21:23 trs why don't you check that?
21:23 trs because I'm pretty sure this works :)
21:23 punter the request is OPTIONS, with this header: Access-Control-Request-Headers: content-type
21:24 punter that's CORS isn't it?
21:24 punter and this header, too;
21:24 punter Access-Control-Request-Method: POST
21:25 punter the response of metacpan is 200, with allow-origin, but no allow-header or allow-request-method
21:25 punter I'll check the CORS specs
21:25 trs hmm.
21:26 punter this here is missing: http://www.w3.org/TR/cors/#access-control-allow-headers-response-header
21:26 dipsy [ Cross-Origin Resource Sharing ]
21:28 trs yes, and what I was saying is that I was pretty sure those headers normally got sent if the request contained a CORS header.
21:28 trs that it isn't is strange
21:28 punter If each of the header field-names is a simple header and none is Content-Type, this step may be skipped.
21:28 punter Add one or more Access-Control-Allow-Headers headers consisting of (a subset of) the list of headers.
21:28 punter (from the spec)
21:28 haarg https://metacpan.org/pod/Plack::Middleware::CrossOrigin
21:28 dipsy [ Plack::Middleware::CrossOrigin - Adds headers to allow Cross-Origin Resource Sharing - metacpan.org ]
21:30 punter I think we found a small bug
21:30 trs haarg: yeah, I thought metacpan was using that. but it isn't!
21:30 trs punter: yes, metacpan's cors support is incomplete.
21:31 trs thanks for pointing ths out
21:31 punter :-)
21:31 haarg https://github.com/CPAN-API/cpan-api/blob/master/lib/MetaCPAN/Server/Controller/Root.pm#L55
21:31 dipsy [ cpan-api/lib/MetaCPAN/Server/Controller/Root.pm at master · CPAN-API/cpan-api · GitHub ]
21:31 haarg yeah, it should be adapted to use that middleware
21:31 trs not sufficient: https://github.com/CPAN-API/cpan-api/blob/master/lib/MetaCPAN/Server/Controller/Root.pm#L54-L57
21:31 dipsy [ cpan-api/lib/MetaCPAN/Server/Controller/Root.pm at master · CPAN-API/cpan-api · GitHub ]
21:31 trs haarg: hah, beat me to it
21:31 trs haarg: yes, that middleware is ++
21:32 trs although, the $c->controller->does('...') may be tricky
21:33 punter I'll do it server-side until this gets fixed
21:33 trs and probably means an ugly hack like setting a response flag in the controller that the middleware picks up
21:34 haarg i've added it to my todo list.  not sure the best way to tie it into the does check.
21:34 haarg but i'm open to extending the middleware if it is helpful for cases like this
21:41 neilb joined #metacpan
21:44 nbezzala joined #metacpan
23:04 jabowery joined #metacpan

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