morphological view for testbed
diff --git a/lib/Korap.pm b/lib/Korap.pm
index 9209706..9c7ddda 100644
--- a/lib/Korap.pm
+++ b/lib/Korap.pm
@@ -1,7 +1,7 @@
 package Korap;
 use Mojo::Base 'Mojolicious';
 
-our $VERSION = '0.01';
+our $VERSION = '0.02';
 
 # This method will run once at server start
 sub startup {
@@ -43,28 +43,25 @@
     }
   );
 
-  $r->get('/')->to(
-    cb => sub {
-      my $c = shift;
-      $c->render(
-	text =>
-	  'Go to '.
-	    $c->link_to('search', '/collection/search'));
-    }
-  );
-
-
-
+  $r->get('/')->to('search#remote');
   $r->get('/util/query')->to('search#query');
 
   # Tutorial
   $r->get('/tutorial')->to('tutorial#page')->name('tutorial');
   $r->get('/tutorial/(*tutorial)')->to('tutorial#page');
 
-  my $res = $r->route('/:resource', resource => [qw/collection corpus/]);
-  $res->to('search#info');
-  $res->search;
-  $res->route('/:corpus_id')->search;
+  my $collection = $r->route('/collection');
+  $collection->to('search#info');
+  $collection->search;
+
+  my $corpus = $r->route('/corpus');
+  $corpus->search;
+  $corpus->route('/:corpus_id')->search;
+  $corpus->route('/:corpus_id/:doc_id')->search;
+  $corpus->route('/:corpus_id/#doc_id/:match_id')->to('info#about_match');
+
+
+
 #  $r->get(
 #    '/:resource/:corpus_id/#doc_id/#match_id',
 #    resource => [qw/collection corpus/])->to('search#match')->name('match');
diff --git a/lib/Korap/Info.pm b/lib/Korap/Info.pm
new file mode 100644
index 0000000..d090a88
--- /dev/null
+++ b/lib/Korap/Info.pm
@@ -0,0 +1,15 @@
+package Korap::Info;
+use Mojo::Base 'Mojolicious::Controller';
+
+sub about_match {
+  my $c = shift;
+  my $corpus_id = $c->stash('corpus_id');
+  my $doc_id = $c->stash('doc_id');
+  my $match_id = $c->stash('match_id');
+
+  return $c->render(json => $c->notifications(json => $c->match_info($corpus_id, $doc_id, $match_id)));
+};
+
+1;
+
+__END__
diff --git a/lib/Korap/Plugin/KorapInfo.pm b/lib/Korap/Plugin/KorapInfo.pm
index 77a3061..a1f3af8 100644
--- a/lib/Korap/Plugin/KorapInfo.pm
+++ b/lib/Korap/Plugin/KorapInfo.pm
@@ -1,5 +1,7 @@
 package Korap::Plugin::KorapInfo;
 use Mojo::Base 'Mojolicious::Plugin';
+use Mojo::JSON qw/decode_json/;
+use Mojo::ByteStream 'b';
 
 sub register {
   my ($plugin, $mojo, $param) = @_;
@@ -10,13 +12,23 @@
     $param = { %$param, %$config_param };
   };
 
+  state $json = decode_json(b(join('', <DATA>))->encode);
+
   my $api = $param->{api};
 
   # Todo: Make this recognize the user!
   $mojo->helper(
-    info_on => sub {
+    resource_info => sub {
       my $c = shift;
+
       my $src = shift;
+
+      if ($c->app->mode eq 'test') {
+	if ($src eq 'collection') {
+	  return $json->{collections};
+	};
+      };
+
       $src = 'VirtualCollection' if $src eq 'collection';
       $src = 'Corpus' if $src eq 'corpus';
 
@@ -35,7 +47,45 @@
       return [];
     }
   );
+
+  $mojo->helper(
+    match_info => sub {
+      my $c = shift;
+      my ($corpus, $doc, $match) = @_;
+
+      return $json->{matchInfo} if $c->app->mode eq 'test';
+
+      my $url = Mojo::URL->new($api)->path('resource/matchInfo');
+      $match = 'match-' . $corpus . '!' . $corpus . '_' . $doc . '-' . $match;
+      $url->query({
+	id => $match,
+	f => 'mate',
+	l => ''
+      });
+
+      if (my $response = $c->ua->get($url)->success) {
+	return $response->json;
+      };
+      $c->notify(error => 'Unable to retrieve resource');
+      return {};
+    }
+  );
 };
 
 
 1;
+
+__DATA__
+
+{
+"matchInfo":
+
+{"author":"Filzstift,Alexander Sommer,TheK","textClass":"freizeit-unterhaltung reisen","corpusID":"WPD","title":"Neuseeland","foundries":"xip xip/morpho xip/constituency xip/dependency corenlp corenlp/namedentities corenlp/namedentities/ne_dewac_175m_600 corenlp/namedentities corenlp/namedentities/ne_hgc_175m_600 mate mate/morpho mate/dependency connexor connexor/morpho connexor/syntax connexor/phrase treetagger treetagger/morpho base base/sentences base/paragraphs opennlp opennlp/morpho","tokenization":"opennlp#tokens","field":"tokens","startMore":false,"endMore":false,"docID":"WPD_NNN.02848","snippet":"<span class=\"context-left\"></span><span class=\"match\"><span title=\"mate/l:besonders\"><span title=\"mate/p:ADV\">Besonders</span></span> <span title=\"mate/l:auffällig\"><span title=\"mate/m:degree:pos\"><span title=\"mate/p:ADJD\">auffällig</span></span></span> <span title=\"mate/l:sein\"><span title=\"mate/m:mood:ind\"><span title=\"mate/m:number:pl\"><span title=\"mate/m:person:3\"><span title=\"mate/m:tense:pres\"><span title=\"mate/p:VAFIN\">sind</span></span></span></span></span></span> <span title=\"mate/l:schließlich\"><span title=\"mate/p:ADV\">schließlich</span></span> <span title=\"mate/l:noch\"><span title=\"mate/p:ADV\">noch</span></span> <span title=\"mate/l:der\"><span title=\"mate/m:case:nom\"><span title=\"mate/m:gender:masc\"><span title=\"mate/m:number:sg\"><span title=\"mate/p:ART\">der</span></span></span></span></span> <span title=\"mate/l:pohutukawa\"><span title=\"mate/m:case:nom\"><span title=\"mate/m:gender:masc\"><span title=\"mate/m:number:sg\"><span title=\"mate/p:NE\">Pohutukawa</span></span></span></span></span> <span title=\"mate/l:und\"><span title=\"mate/p:KON\">und</span></span> <span title=\"mate/l:der\"><span title=\"mate/m:case:nom\"><span title=\"mate/m:gender:masc\"><span title=\"mate/m:number:sg\"><span title=\"mate/p:ART\">der</span></span></span></span></span> <span title=\"mate/l:cabbage\"><span title=\"mate/m:case:nom\"><span title=\"mate/m:gender:masc\"><span title=\"mate/m:number:sg\"><span title=\"mate/p:NE\">Cabbage</span></span></span></span></span> <span title=\"mate/l:tree\"><span title=\"mate/m:gender:masc\"><span title=\"mate/m:number:sg\"><span title=\"mate/p:NE\"><span title=\"mate/m:case:nom\">Tree</span></span></span></span></span></span><span class=\"context-right\"></span>","ID":"match-WPD!WPD_NNN.02848-p1213-1224","pubDate":"2005-03-28","context":{"left":["token",0],"right":["token",0]}},
+
+
+"collections" :
+[{"shared":false,"id":1,"managed":true,"created":1401193381119,"stats":{"documents":196510,"tokens":51545081,"sentences":4116282,"paragraphs":2034752},"query":[{"@type":"korap:meta-filter","@value":{"@type":"korap:term","@field":"korap:field#corpusID","@value":"WPD"}}],"description":"Die freie Enzyklopädie","name":"Wikipedia","foundries":"base;corenlp;mate;mpt;opennlp;tt;xip"}]
+
+
+
+}
diff --git a/lib/Korap/Plugin/KorapMatchinfo.pm b/lib/Korap/Plugin/KorapMatchinfo.pm
deleted file mode 100644
index fc9ba97..0000000
--- a/lib/Korap/Plugin/KorapMatchinfo.pm
+++ /dev/null
@@ -1,44 +0,0 @@
-package Korap::Plugin::KorapMatchInfo;
-use Mojo::Base 'Mojolicious::Plugin';
-
-sub register {
-  my ($plugin, $mojo, $param) = @_;
-  $param ||= {};
-
-  # Load parameter from Config file
-  if (my $config_param = $mojo->config('KorAP')) {
-    $param = { %$param, %$config_param };
-  };
-
-  my $api = $param->{api};
-
-  # Todo: Make this recognize the user!
-  $mojo->helper(
-    info_on => sub {
-      my $c = shift;
-      my $src = shift;
-
-#/resource/matchInfo?id=match-WPD!WPD_TTT.07206-p151-152&f=treetagger&l=morpho&spans=true
-
-      $src = 'VirtualCollection' if $src eq 'collection';
-      $src = 'Corpus' if $src eq 'corpus';
-
-      my $url = Mojo::URL->new($api)->path('resource/' . $src);
-
-      my $chi = $c->chi;
-      if (my $json = $chi->get($url->to_string)) {
-	return $json;
-      }
-      elsif (my $response = $c->ua->get($url)->success) {
-	my $json = $response->json;
-	$c->chi->set($url->to_string => $json);
-	return $json;
-      };
-      $c->notify(error => 'Unable to retrieve resource');
-      return [];
-    }
-  );
-};
-
-
-1;
diff --git a/lib/Korap/Plugin/KorapSearch.pm b/lib/Korap/Plugin/KorapSearch.pm
index efe1e8b..39b5c15 100644
--- a/lib/Korap/Plugin/KorapSearch.pm
+++ b/lib/Korap/Plugin/KorapSearch.pm
@@ -32,7 +32,7 @@
       my $c = shift;
       my $match = shift;
       my $did = $match->{docID};
-      $did =~ s/^[^_]_//;
+      $did =~ s/^[^_]+_//;
       return $did // '';
     }
   );
@@ -47,21 +47,18 @@
       my %param = @_;
 
       # Test envronment
-#      if ($c->app->mode eq 'test') {
-#	my $json = b(join(' ', <DATA>))->encode;
-#	$json = decode_json($json);
-#
-#	$c->stash('search.count' => 10);
-#	$c->stash('search.startPage' => 1);
-#	$c->stash('search.totalResults' => 666);
-#	$c->stash('search.itemsPerPage' => 10);
-#	$_->{'search.bm.hit'} = 20;
-#	$_->{'search.bm.result'} = 10;
-#	$_->{'search.query'} = $json->{request}->{query};
-#	$_->{'search.hits'} = $json->{matches};
-#	return $cb->();
-#      };
-
+      if ($c->app->mode eq 'test') {
+	state $json = decode_json(join(' ', <DATA>));
+	$c->stash('search.count' => 10);
+	$c->stash('search.startPage' => 1);
+	$c->stash('search.totalResults' => 666);
+	$c->stash('search.itemsPerPage' => 10);
+	$c->stash('search.bm.hit' => 20);
+	$c->stash('search.bm.result' => 10);
+	$c->stash('search.query' => $json->{request}->{query});
+	$c->stash('search.hits' => $json->{matches});
+	return $cb->();
+      };
 
       $c->stash(
 	'search.count' =>
diff --git a/lib/Korap/Search.pm b/lib/Korap/Search.pm
index 466266b..b8972a0 100644
--- a/lib/Korap/Search.pm
+++ b/lib/Korap/Search.pm
@@ -34,18 +34,6 @@
   $c->render(template => 'search');
 };
 
-
-#sub match {
-#  my $c = shift;
-#  my $corpus_id = $c->stash('corpus_id');
-#  my $doc_id = $c->stash('doc_id');
-#  my $match_id = $c->stash('match_id');
-#  return $c->render(json => {
-#    match => 'match-' . $corpus_id . '!' . $corpus_id . '_' . $doc_id . '-' . $match_id
-#  });
-#};
-
-
 sub info {
   my $c = shift;
   my $api = $c->config('KorAP')->{api};