Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 48 lines (35 sloc) 0.92 kb
ff7a10de »
2010-03-31 Import Dancer skeleton
1 package cpanhubble;
2 use Dancer;
3
8da717f1 »
2010-04-02 First shot at actual web iface
4 use lib './lib';
5 use CpanHub;
6 use AnyEvent;
8f3a3348 »
2010-04-03 Implement cacheing
7 use Encode;
8 use CHI;
9
10 my $cache = CHI->new(driver => 'FastMmap', root_dir => '/tmp/hubble-cache', cache_size => '10m');
8da717f1 »
2010-04-02 First shot at actual web iface
11
ff7a10de »
2010-03-31 Import Dancer skeleton
12 get '/' => sub {
4dea552a »
2010-04-03 Implement sane index
13 template 'index';
ff7a10de »
2010-03-31 Import Dancer skeleton
14 };
15
8da717f1 »
2010-04-02 First shot at actual web iface
16 get '/search' => sub {
17 my ($cpan, $gh);
18
8f3a3348 »
2010-04-03 Implement cacheing
19 my $cache_miss;
20 my $res = $cache->get(params->{q});
21 unless ($res) {
22 $cache_miss = 1;
23
24 my $cv = AnyEvent->condvar;
25 $cv->begin;
26 cpan_search_req(params->{q}, sub {
27 $cpan = $_[0];
28 $cv->end;
29 });
30
31 $cv->begin;
32 github_search_req(params->{q}, sub {
33 $gh = $_[0];
34 $cv->end;
35 });
8da717f1 »
2010-04-02 First shot at actual web iface
36
8f3a3348 »
2010-04-03 Implement cacheing
37 $cv->recv;
8da717f1 »
2010-04-02 First shot at actual web iface
38
8f3a3348 »
2010-04-03 Implement cacheing
39 $res = merge_cpan_and_github($cpan, $gh, params->{q});
8da717f1 »
2010-04-02 First shot at actual web iface
40
8f3a3348 »
2010-04-03 Implement cacheing
41 $cache->set(params->{q}, $res, '2 days');
42 }
8da717f1 »
2010-04-02 First shot at actual web iface
43
8f3a3348 »
2010-04-03 Implement cacheing
44 template 'serp', { res => $res, cache_miss => $cache_miss };
8da717f1 »
2010-04-02 First shot at actual web iface
45 };
46
ff7a10de »
2010-03-31 Import Dancer skeleton
47 true;
Something went wrong with that request. Please try again.