Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

First shot at actual web iface

  • Loading branch information...
commit 8da717f109860d37c9fa206e58a200667e57fe49 1 parent 7f78613
@kappa authored
Showing with 41 additions and 4 deletions.
  1. +28 −0 cpanhubble.pm
  2. +4 −4 views/index.tt
  3. +9 −0 views/serp.tt
View
28 cpanhubble.pm
@@ -1,8 +1,36 @@
package cpanhubble;
use Dancer;
+use lib './lib';
+use CpanHub;
+use AnyEvent;
+
get '/' => sub {
template 'index';
};
+get '/search' => sub {
+ my ($cpan, $gh);
+
+ my $cv = AnyEvent->condvar;
+ $cv->begin;
+ cpan_search_req(params->{q}, sub {
+ $cpan = $_[0];
+ $cv->end;
+ });
+
+ $cv->begin;
+ github_search_req(params->{q}, sub {
+ $gh = $_[0];
+ $cv->end;
+ });
+
+ $cv->recv;
+
+ my $res =
+ merge_cpan_and_github($cpan, $gh);
+
+ template 'serp', { res => $res, query => params->{q} };
+};
+
true;
View
8 views/index.tt
@@ -1,5 +1,5 @@
-<h2>It Works!</h2>
+<h2>CPAN Hubble</h2>
-<p>
-I'm in <code>/home/kappa/work/app-cpanhubble/cpanhubble/views/index.tt</code>
-</p>
+<form action="/search">
+<input name="q"><input type="submit" value="Search">
+</form>
View
9 views/serp.tt
@@ -0,0 +1,9 @@
+<h2>CPAN Hubble search for [= $query =]</h2>
+
+<?pl for my $r (@$res) { ?>
+<p>
+<a href="[= $r->{link} =]"><b>[= $r->{name} =]</b></a><br>
+[= $r->{desc} =]<br>
+<font color="green">[= $r->{date} =]</font> - <a href="[= $r->{author_link} =]">author</a>
+</p>
+<?pl } ?>
Please sign in to comment.
Something went wrong with that request. Please try again.