--- /dev/null
+package NDWeb::Controller::Quotes;
+
+use strict;
+use warnings;
+use parent 'Catalyst::Controller';
+
+=head1 NAME
+
+NDWeb::Controller::Quotes - Catalyst Controller
+
+=head1 DESCRIPTION
+
+Catalyst Controller.
+
+=head1 METHODS
+
+=cut
+
+
+=head2 index
+
+=cut
+
+sub index :Path :Args(0) {
+ my ( $self, $c ) = @_;
+
+ $c->assert_user_roles(qw//);
+
+ my $search = $c->req->param('search');
+ $search =~ s/^\s+|\s+$//g if $search;
+ if ($search) {
+ $c->stash(search => $search);
+ my $dbh = $c->model;
+ my $query = $dbh->prepare(q{
+SELECT qid,quote FROM quotes
+WHERE quote ILIKE '%' || $1 || '%' ORDER BY qid ASC
+ });
+
+ $query->execute($search);
+
+ $c->stash(quotes => $query->fetchall_arrayref({}));
+ }
+}
+
+=head1 AUTHOR
+
+Michael Andreen (harv@ruin.nu)
+
+=head1 LICENSE
+
+GPL 2.0, or later
+
+=cut
+
+1;
$c->stash->{template} = 'access_denied.tt2';
$c->res->status(403);
$c->clear_errors;
+ }elsif ($c->error->[0] =~ m/No logged in user, and none supplied as argument/){
+ $c->stash->{template} = 'access_denied.tt2';
+ $c->res->status(403);
+ $c->clear_errors;
}
}
[% IF user %]
<li><a href="/forum/allUnread">New posts [% IF user.unreadposts %](<span class="[% IF user.newposts %]newposts[% ELSE %]unreadposts[% END %]">[% user.unreadposts %]</span>)[% END %]</a></li>
<li><a href="/forum/privmsg">Priv msg</a></li>
+ <li><a href="/quotes">Quotes</a></li>
<li><a href="/settings">Settings</a></li>
<li><a href="/logout">Log out ([% c.user.username %])</a></li>
[% ELSE %]
--- /dev/null
+[% META title = 'Quotes' %]
+<form action="[% c.uri_for('') %]" method="post"><fieldset> <legend>Search term</legend>
+ <input type="text" name="search" value="[% search | html %]" class="search">
+ <input type="submit" value="Search">
+</fieldset></form>
+
+<table>
+ <tr>
+ <th>Id</th><th>Quote</th>
+ </tr>
+
+[% debug(quotes.size) %]
+[% FOR q IN quotes %]
+ <tr align="center" class="[% loop.count % 2 == 0 ? 'even' : 'odd' %]">
+ <td align="right">[% q.qid %]</td>
+ <td align="left">[% q.quote | html %]</td>
+ </tr>
+[% END %]
+</table>