Created
May 31, 2012 11:52
-
-
Save SebDeclercq/2842908 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/perl -w | |
use strict; | |
use warnings; | |
package main; | |
use Dancer ':syntax'; | |
use Dancer::Plugin::DBIC; | |
use Template; | |
package My::LawDB::Schema; | |
use base qw(DBIx::Class::Schema::Loader); | |
my $schema = My::LawDB::Schema->connect('dbi:SQLite:dbname=LawDB.db'); | |
### ... ### | |
get '/websearch' => sub { | |
template 'websearch'; | |
}; | |
post '/webresults' => sub { | |
my $query = params->{query}; | |
my @links = schema->resultset('LinkIdx')->search({content => {match => $query}}); | |
my @snippets = schema->dbh_do("SELECT id,snippet(Link_idx) AS content FROM Link_idx WHERE content MATCH $query;"); | |
template 'webresults', {links => \@links,snippets => \@snippets,query => $query}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment