Skip to content

Instantly share code, notes, and snippets.

@SebDeclercq
Created May 31, 2012 11:52
Show Gist options
  • Save SebDeclercq/2842908 to your computer and use it in GitHub Desktop.
Save SebDeclercq/2842908 to your computer and use it in GitHub Desktop.
#! /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