[Bps-public-commit] RT-BugTracker-Public branch, rt4, updated. f09ecb95990e329f9c927511512f9019bcec5581
Thomas Sibley
trs at bestpractical.com
Fri Mar 1 22:06:17 EST 2013
The branch, rt4 has been updated
via f09ecb95990e329f9c927511512f9019bcec5581 (commit)
from 124a09343fdc056a2ad51812a33de70dfb874704 (commit)
Summary of changes:
.../BugTracker-Public/Search/Results.html/Initial | 9 ++
.../BugTracker-Public/autohandler/Default | 10 +-
html/Public/Search/Elements/Results | 134 ---------------------
html/Public/Search/Results.html | 13 ++
html/Public/Search/Simple.html | 61 +---------
5 files changed, 29 insertions(+), 198 deletions(-)
create mode 100644 html/Callbacks/BugTracker-Public/Search/Results.html/Initial
delete mode 100755 html/Public/Search/Elements/Results
create mode 100644 html/Public/Search/Results.html
- Log -----------------------------------------------------------------
commit f09ecb95990e329f9c927511512f9019bcec5581
Author: Thomas Sibley <trs at bestpractical.com>
Date: Fri Mar 1 19:04:48 2013 -0800
Turn /Public/Search/Simple.html into a proxy for the standard endpoint
Using a callback, we inject our own public search results page. This
lets us avoid duplicating the extra simple search logic that
RT::BugTracker provides. Less overriding FTW.
diff --git a/html/Callbacks/BugTracker-Public/Search/Results.html/Initial b/html/Callbacks/BugTracker-Public/Search/Results.html/Initial
new file mode 100644
index 0000000..ef17dcf
--- /dev/null
+++ b/html/Callbacks/BugTracker-Public/Search/Results.html/Initial
@@ -0,0 +1,9 @@
+<%args>
+$ARGSRef => {}
+</%args>
+<%init>
+return unless RT::BugTracker::Public->IsPublicUser;
+$m->comp("/Public/Search/Results.html", %$ARGSRef);
+$m->comp("/Elements/Footer");
+$m->abort;
+</%init>
diff --git a/html/Callbacks/BugTracker-Public/autohandler/Default b/html/Callbacks/BugTracker-Public/autohandler/Default
index 2f92dad..ecc083d 100644
--- a/html/Callbacks/BugTracker-Public/autohandler/Default
+++ b/html/Callbacks/BugTracker-Public/autohandler/Default
@@ -59,12 +59,14 @@ if ( $path =~ '^(/+)Ticket/Display.html'
{
$m->redirect($RT::WebPath . "/Public/Bug/Display.html?id="
. $m->interp->apply_escapes($ARGS{'id'}, 'u'));
- $m->abort();
}
-
-elsif ( $path =~ '^(/+)Dist/Display.html' and $ARGS{'Queue'} ) {
+elsif ( $path =~ '^(/+)Dist/Display.html' and ($ARGS{'Name'} or $ARGS{'Queue'}) ) {
$m->redirect($RT::WebPath . "/Public/Dist/Display.html?Name="
- . $m->interp->apply_escapes($ARGS{'Queue'}, 'u'));
+ . $m->interp->apply_escapes($ARGS{'Name'} || $ARGS{'Queue'}, 'u'));
+}
+elsif ( $path =~ '^(/+)Dist/ByMaintainer.html' and $ARGS{'Name'} ) {
+ $m->redirect($RT::WebPath . "/Public/Dist/ByMaintainer.html?Name="
+ . $m->interp->apply_escapes($ARGS{'Name'}, 'u'));
}
# otherwise, drop the user at the Public default page
diff --git a/html/Public/Search/Elements/Results b/html/Public/Search/Elements/Results
deleted file mode 100755
index b94eee1..0000000
--- a/html/Public/Search/Elements/Results
+++ /dev/null
@@ -1,134 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
-%# <jesse at bestpractical.com>
-%#
-%# (Except where explicitly superseded by other copyright notices)
-%#
-%#
-%# LICENSE:
-%#
-%# This work is made available to you under the terms of Version 2 of
-%# the GNU General Public License. A copy of that license should have
-%# been provided with this software, but in any event can be snarfed
-%# from www.gnu.org.
-%#
-%# This work is distributed in the hope that it will be useful, but
-%# WITHOUT ANY WARRANTY; without even the implied warranty of
-%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-%# General Public License for more details.
-%#
-%# You should have received a copy of the GNU General Public License
-%# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-%# 02110-1301 or visit their web page on the internet at
-%# http://www.gnu.org/copyleft/gpl.html.
-%#
-%#
-%# CONTRIBUTION SUBMISSION POLICY:
-%#
-%# (The following paragraph is not intended to limit the rights granted
-%# to you to modify and distribute this software under the terms of
-%# the GNU General Public License and is only of importance to you if
-%# you choose to contribute your changes and enhancements to the
-%# community by submitting them to Best Practical Solutions, LLC.)
-%#
-%# By intentionally submitting any modifications, corrections or
-%# derivatives to this work, or any other work intended for use with
-%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-%# you are the copyright holder for those contributions and you grant
-%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
-%# royalty-free, perpetual, license to use, copy, create derivative
-%# works based on those contributions, and sublicense and distribute
-%# those contributions and any derivatives thereof.
-%#
-%# END BPS TAGGED BLOCK }}}
-%# TMP: We'll disable sorting for now since it doesn't work right
-%
-<& /Elements/TicketList,
- Query => $Query,
- AllowSorting => 0,
- OrderBy => $OrderBy,
- Order => $Order,
- Rows => $Rows,
- Page => $Page,
- Format => $Format,
- BaseURL => $BaseURL,
- %ARGS
- &>
-% $m->callback(CallbackName => 'SearchActions', QueryString => $QueryString);
-<%INIT>
-# Read from user preferences
-my $prefs = $session{'CurrentUser'}->UserObj->Preferences("SearchDisplay") || {};
-
-# These variables are what define a search_hash; this is also
-# where we give sane defaults.
-$Format ||= $prefs->{'Format'};
-$Order ||= $prefs->{'Order'} || 'ASC';
-$OrderBy ||= $prefs->{'OrderBy'} || 'id';
-
-# Some forms pass in "RowsPerPage" rather than "Rows"
-# We call it RowsPerPage everywhere else.
-if ( !$Rows && $ARGS{'RowsPerPage'} ) {
- $Rows = $ARGS{'RowsPerPage'};
-}
-elsif ( !$Rows && defined $prefs->{'RowsPerPage'} ) {
- $Rows = $prefs->{'RowsPerPage'};
-}
-else {
- $Rows = 50;
-}
-
-
-my ($title, $ticketcount);
-$session{'i'}++;
-$session{'tickets'} = RT::Tickets->new($session{'CurrentUser'}) ;
-$session{'tickets'}->FromSQL($Query) if ($Query);
-$session{'tickets'}->OrderBy(FIELD => $OrderBy, ORDER => $Order);
-
-
-$session{'CurrentSearchHash'} = {
- Format => $Format,
- Query => $Query,
- Page => $Page,
- Order => $Order,
- OrderBy => $OrderBy,
- RowsPerPage => $Rows
- };
-
-
-
-if ( $session{'tickets'}->Query()) {
- $ticketcount = $session{tickets}->CountAll();
- $title = loc('Found [quant,_1,bug report]', $ticketcount);
-} else {
- $title = loc("Find tickets");
-}
-
-my $QueryString = "?".$m->comp('/Elements/QueryString',
- Query => $Query,
- Format => $Format,
- Rows => $Rows,
- OrderBy => $OrderBy,
- Order => $Order,
- Page => $Page);
-
-# TODO: This works, but how to get the required params each page needs?
-my ($BaseURL) = ($m->request_comp->path =~ m|/([^/]+?\.html)$|);
-$BaseURL .= '?';
-
-</%INIT>
-<%CLEANUP>
-$session{'tickets'}->PrepForSerialization();
-</%CLEANUP>
-<%ARGS>
-$Query => undef
-$Format => undef
-$HideResults => 0
-$Rows => undef
-$Page => 1
-$OrderBy => undef
-$Order => undef
-</%ARGS>
diff --git a/html/Public/Search/Results.html b/html/Public/Search/Results.html
new file mode 100644
index 0000000..ebf98eb
--- /dev/null
+++ b/html/Public/Search/Results.html
@@ -0,0 +1,13 @@
+<& /Elements/Header, Title => loc("Search results") &>
+<& /Elements/Tabs &>
+<& /Elements/CollectionList,
+ Query => $ARGS{Query},
+ AllowSorting => 0,
+ OrderBy => 'id',
+ Order => 'ASC',
+ Rows => 50,
+ Page => ($ARGS{Page} || 1),
+ Format => RT->Config->Get("DefaultSearchResultFormat"),
+ Class => 'RT::Tickets',
+ BaseURL => RT->Config->Get("WebPath") . "/Public/Search/Results.html?"
+ &>
diff --git a/html/Public/Search/Simple.html b/html/Public/Search/Simple.html
index 3f39920..3677467 100644
--- a/html/Public/Search/Simple.html
+++ b/html/Public/Search/Simple.html
@@ -45,63 +45,4 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-<& /Elements/Header, Title => $title &>
-<& /Elements/Tabs &>
-
-% if (not $q and not $ARGS{Query}) {
-<div id="SimpleSearchForm">
-<form action="Simple.html" method="get">
-
-<p><&|/l&>Search for bug reports. Enter <strong>id</strong> numbers, <strong>distributions</strong> by name,
-Owners by <strong>username</strong> and Requestors by <strong>email address</strong>.
-RT will look for anything else you enter in ticket bodies and attachments.</&></p>
-
-<p><&|/l&>Searching the full text of every ticket can take a long time, but if you need to do it, you can search for any word in full ticket history for any word by typing <b>fulltext:<i>word</i></b>.</&></p>
-<p><&|/l&>RT will look for anything else you enter in ticket subjects.</&></p>
-
-<div align="center">
-<input name="q" size="60" /><input type="submit" class="button" value="<&|/l&>Search</&>" />
-</div>
-% }
-% else {
-<& /Public/Search/Elements/Results, Query => ($search ? $search->QueryToSQL() : undef), Format => RT->Config->Get('DefaultSearchResultFormat'), %ARGS &>
-% }
-
-<%INIT>
-my $title = loc("Simple Search");
-use RT::Search::Googleish;
-
-my $search;
-
-if ($q) {
- my $tickets = new RT::Tickets( $session{'CurrentUser'} );
-
- $m->callback( %ARGS, CallbackName => 'ModifyQuery', query => \$q);
-
- # try to load a queue or a user; if found, redirect to the distribution page
- # instead of the search page
- if ($q !~ /^\d+$/) {
- my $queue = RT::Queue->new( $session{'CurrentUser'} );
- $queue->Load($q);
- if ($queue->id) {
- $m->redirect( $RT::WebPath .'/Public/Dist/Display.html?Name=' . $m->interp->apply_escapes($q, 'u') );
- $m->abort();
- }
-
- my $user = RT::User->new( $session{'CurrentUser'} );
- $user->Load($q);
- if ($user->id) {
- $m->redirect( $RT::WebPath .'/Public/Dist/ByMaintainer.html?Name=' . $m->interp->apply_escapes($q, 'u') );
- $m->abort();
- }
- }
-
- $search = RT::Search::Googleish->new(Argument => $q,
- TicketsObj => $tickets);
-}
-</%INIT>
-
-<%ARGS>
-$q => undef
-</%ARGS>
-
+% $m->comp("/Search/Simple.html", %ARGS);
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list