Commit f4966aeb authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 70907: QuickSearch: port the JS code to perl (make it server-side) - Patch…

Bug 70907: QuickSearch: port the JS code to perl (make it server-side) - Patch by Marc Schumann <wurblzap@gmail.com> r=wicked a=myk
parent d055246d
......@@ -30,10 +30,6 @@ of the Bugzilla Guide in the docs/ directory.
If you want to change platforms, operating systems, severities and
priorities, this can also be done in localconfig at this time.
You should also update localconfig.js to reflect these changes. This
includes setting the URL you chose in step 1 as the 'bugzilla' JS
variable.
5. Using the name you provided as $db_name above, create a MySQL database
for Bugzilla. You should also create a user permission for the name
supplied as $db_user with read/write access to that database.
......
......@@ -38,6 +38,7 @@ use vars qw($template $vars);
use Bugzilla;
use Bugzilla::Search;
use Bugzilla::Search::Quicksearch;
use Bugzilla::Constants;
use Bugzilla::User;
......@@ -65,6 +66,15 @@ if (length($buffer) == 0) {
ThrowUserError("buglist_parameters_required");
}
# Determine whether this is a quicksearch query.
my $searchstring = $cgi->param('quicksearch');
if (defined($searchstring)) {
$buffer = quicksearch($searchstring);
# Quicksearch may do a redirect, in which case it does not return.
# If it does return, it has modified $cgi->params so we can use them here
# as if this had been a normal query from the beginning.
}
################################################################################
# Data and Security Validation
################################################################################
......
......@@ -1015,9 +1015,6 @@ if ($my_create_htaccess) {
<FilesMatch ^(.*\.pl|.*localconfig.*)$>
deny from all
</FilesMatch>
<FilesMatch ^(localconfig.js|localconfig.rdf)$>
allow from all
</FilesMatch>
END
close HTACCESS;
chmod $fileperm, ".htaccess";
......@@ -1033,11 +1030,6 @@ END
print "Repairing .htaccess...\n";
open HTACCESS, '>', '.htaccess';
print HTACCESS $oldaccess;
print HTACCESS <<'END';
<FilesMatch ^(localconfig.js|localconfig.rdf)$>
allow from all
</FilesMatch>
END
close HTACCESS;
}
......
......@@ -1424,6 +1424,17 @@ Reason: %reason%
default => 1,
},
{
name => 'quicksearch_comment_cutoff',
desc => q{The maximum number of search terms for a QuickSearch to search
comments.
If the QuickSearch query contains more terms than this value,
QuickSearch will not search comments.},
type => 't',
default => '4',
checker => \&check_numeric
},
# Added for Patch Viewer stuff (attachment.cgi?action=diff)
{
name => 'cvsroot',
......
<!-- <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"> -->
<!-- $Id: security.xml,v 1.6 2005/06/29 23:43:33 zach%zachlipton.com Exp $ -->
<!-- $Id: security.xml,v 1.7 2005/08/21 18:16:41 lpsolit%gmail.com Exp $ -->
<chapter id="security">
<title>Bugzilla Security</title>
......@@ -207,14 +207,6 @@ skip-networking
</simplelist>
</para>
</listitem>
<listitem>
<para>But allow:
<simplelist type="inline">
<member><filename>localconfig.js</filename></member>
<member><filename>localconfig.rdf</filename></member>
</simplelist>
</para>
</listitem>
</itemizedlist>
</listitem>
......
......@@ -725,11 +725,12 @@
summary and status whiteboard of a bug; adding
"<filename>:BazProduct</filename>" would
search only in that product.
You can use it to find a bug by its number or its alias, too.
</para>
<para>You'll find the Quicksearch box on Bugzilla's
front page, along with a
<ulink url="../../quicksearch.html">Help</ulink>
<para>You'll find the Quicksearch box in Bugzilla's footer area.
On Bugzilla's front page, there is an additional
<ulink url="../../page.cgi?id=quicksearch.html">Help</ulink>
link which details how to use it.</para>
</section>
......
//
// This file contains the installation specific values for QuickSearch.
// See quicksearch.js for more details.
//
// the global bugzilla url
var bugzilla = "";
//var bugzilla = "http://bugzilla.mozilla.org/";
// Status and Resolution
// ---------------------
var statuses_open = new Array("UNCONFIRMED","NEW","ASSIGNED","REOPENED");
var statuses_resolved = new Array("RESOLVED","VERIFIED","CLOSED");
var resolutions = new Array("FIXED","INVALID","WONTFIX","LATER",
"REMIND","DUPLICATE","WORKSFORME","MOVED");
// Keywords
// --------
//
// Enumerate all your keywords here. This is necessary to avoid
// "foo is not a legal keyword" errors. This makes it possible
// to include the keywords field in the search by default.
var keywords = new Array(
// "foo", "bar", "baz"
);
// Platforms
// ---------
//
// A list of words <w> (substrings of platform values)
// that will automatically be translated to "platform:<w>"
// E.g. if "mac" is defined as a platform, then searching
// for it will find all bugs with platform="Macintosh",
// but no other bugs with e.g. "mac" in the summary.
var platforms = new Array(
"pc","sun","macintosh","mac" //shortcut added
//,"dec","hp","sgi"
//,"all" //this is a legal value for OpSys, too :(
//,"other"
);
// Severities
// ----------
//
// A list of words <w> (substrings of severity values)
// that will automatically be translated to "severity:<w>"
// E.g with this default set of severities, searching for
// "blo,cri,maj" will find all severe bugs.
var severities = new Array("blo","cri","maj","nor","min","tri","enh");
// Products and Components
// -----------------------
//
// It is not necessary to list all products and components here.
// Instead, you can define a "blacklist" for some commonly used
// words or word fragments that occur in a product or component name
// but should _not_ trigger product/component search.
var product_exceptions = new Array(
"row" // [Browser]
// ^^^
,"new" // [MailNews]
// ^^^
);
var component_exceptions = new Array(
"hang" // [mozilla.org] Bugzilla: Component/Keyword Changes
// ^^^^
);
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Bugzilla QuickSearch</title>
</head>
<body bgcolor="#ffffff">
<p>
<small>If you are already familiar with the original
<a href="query.cgi">Bugzilla Query Form</a>,
you may prefer <a href="quicksearchhack.html">this form</a>.
</small>
</p>
<script src="localconfig.js" type="text/javascript"></script>
<script src="quicksearch.js" type="text/javascript"></script>
<h1>Bugzilla QuickSearch</h1>
<p>
Type in one or more words (or word fragments) to search for:
</p>
<form name="f" action="show_bug.cgi" method="get"
onsubmit="QuickSearch(f.id.value); return false;">
<table>
<tr>
<td><input type="text" size="40" name="id"></td>
<td align="left"><input type="submit" value="Search"></td>
<!-- <td><a href="javascript:QuickSearch_Help();">[Help]</a></td> -->
</tr>
</table>
</form>
<script type="text/javascript">
<!--
document.forms['f'].id.focus();
//-->
</script>
<h2>Getting Started</h2>
<ul>
<li> This is <b>case-insensitive</b> search.
<ul>
<li> &nbsp;<tt>table</tt>&nbsp;, &nbsp;<tt>Table</tt>&nbsp;
and &nbsp;<tt>TABLE</tt>&nbsp; are all the same.</li>
</ul>
</li>
<li> This is <b>all words as substrings</b> search.<br>
Therefore you should <b>use stems</b> to get better results:
<ul>
<li> Use <tt>localiz</tt> instead of <tt>localize</tt> or
<tt>localization</tt>.</li>
<li> Use <tt>bookmark</tt> instead of <tt>bookmarks</tt> or
<tt>bookmarking</tt>.</li>
</ul>
</li>
</ul>
<h2><a name="features">Features</a></h2>
<ul>
<li> Boolean operations: ``<tt>-foo</tt>''(NOT), ``<tt>foo bar</tt>''(AND),
``<tt>foo|bar</tt>''(OR).
<ul>
<li> <b>NOT</b>: Use &nbsp;<tt><b>-</b><i>foo</i></tt>&nbsp; to exclude bugs
with &nbsp;<tt><i>foo</i></tt>&nbsp; in the summary.</li>
<li> <b>AND</b>: Space-separated words are treated as a conjunction.</li>
<li> <b>OR</b>: Within a word, "|"-separated parts denote alternatives. </li>
<li> Besides "|", a comma can be used to separate alternatives.</li>
<li> OR has higher precedence than AND; AND is the top level operation</li>
</ul>
<i>Example:</i> &nbsp;<tt>url,location bar,field -focus</tt>&nbsp;
means
(<tt>url</tt> OR <tt>location</tt>) AND (<tt>bar</tt> OR <tt>field</tt>) AND (NOT <tt>focus</tt>)
<p>
</li>
<li>Use &nbsp;<tt>+foo</tt>&nbsp; to search for bugs where the <b>summary</b> contains &nbsp;<tt>foo</tt>&nbsp; as a <b>substring</b>.<br>
Use &nbsp;<tt>#foo</tt>&nbsp; to search for bugs where the <b>summary</b> contains the <b>word</b> &nbsp;<tt>foo</tt>&nbsp;
<ul>
<li> &nbsp;<tt>+brow</tt>&nbsp; does not find all bugs in the &nbsp;<tt>Browser</tt>&nbsp; product</li>
<li> &nbsp;<tt>#title</tt>&nbsp; does not find bugs bugs with &nbsp;<tt>titlebar</tt>&nbsp; or &nbsp;<tt>titled</tt>&nbsp;</li>
</ul>
Phrases with special chars (space, comma, +, -, #, ...) can be <b>quoted</b>:
<ul>
<li> &nbsp;<tt>"lock icon"</tt>&nbsp;</li>
</ul>
<p>
</li>
<li> <b>Open vs. Resolved Bugs</b>:<br>
By default, only open (i.e. unresolved) bugs are shown.
Use &nbsp;<tt>+DUP</tt>&nbsp; as first word in your query
to include duplicate bugs in your search,
&nbsp;<tt>FIXED</tt>&nbsp; to search for fixed bugs only,
or &nbsp;<tt>ALL</tt>&nbsp; to search all bugs,
regardless of status or resolution. Searching for duplicates is
recommended if you can't find an open bug directly.
<ul>
<li> &nbsp;<tt>+DUP,FIXED table border</tt>&nbsp;</li>
<li> &nbsp;<tt>ALL mouse wheel</tt>&nbsp;</li>
</ul>
<p></li>
<li> <b>Focus the Search with Products &amp; Components</b>:<br>
To search for bugs in product "Foo Bar" only, add
&nbsp;<tt>:foo</tt>&nbsp; or &nbsp;<tt>:bar</tt>&nbsp; or both
to your query.
You can do this with any substring of a
<a href="describecomponents.cgi">product or component</a>
to focus the search.
</li>
</ul>
<h2>More Tips</h2>
<ul>
<li> You can also use this tool to <b>lookup</b> a bug by its number.
<ul>
<li> &nbsp;<tt>12345</tt>&nbsp;</li>
</ul>
</li>
<li> A comma-separated list of bug numbers gives you a list of these bugs.
<ul>
<li> &nbsp;<tt>12345,23456,34567</tt>&nbsp;</li>
</ul>
</li>
</ul>
<p>
By default, the following fields are searched: Summary, Keywords, Product,
Component, Status Whiteboard. If a word looks like a part of a URL, that field
is included in the search, too.
</p>
<!--
<small>For further details, see
<a href="http://bugzilla.mozilla.org/show_bug.cgi?id=61561">Bug 61561</a> and
<a href="http://bugzilla.mozilla.org/show_bug.cgi?id=69793">Bug 69793</a>.
</small>
-->
<hr>
<p>
Use the powerful
<a href="query.cgi">Bugzilla Query Form</a>
for advanced queries.
</p>
</body>
</html>
......@@ -176,13 +176,14 @@ body
margin-top: 5px;
width: 100%;
font-family: sans-serif;
background: #edf2f2;
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
}
#footer form
{
background: #edf2f2;
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
display: inline;
}
#footer span
......
......@@ -19,8 +19,7 @@
# Contributor(s): Myk Melez <myk@mozilla.org>
#%]
//
// This file contains the installation specific values for QuickSearch
// and other Bugzilla clients. See quicksearch.js for more details.
// This file contains installation specific values for third-party clients.
//
// Note: this interface is experimental and under development.
// We may and probably will make breaking changes to it in the future.
......
......@@ -25,7 +25,6 @@
[% PROCESS global/variables.none.tmpl %]
<form method="get" action="show_bug.cgi">
<div id="useful-links">
<div id="links-actions">
<div class="label">Actions:</div>
......@@ -34,8 +33,13 @@
<a href="enter_bug.cgi">New</a> |
<a href="query.cgi">Search</a> |
[% terms.bug %] # <input class="txt" name="id" size="6">
<input class="btn" type="submit" value="Find"> |
<form action="buglist.cgi" method="get"
onsubmit="if (this.quicksearch.value == '')
{ alert('Please enter one or more search terms first.');
return false; } return true;">
<input class="txt" type="text" name="quicksearch">
<input class="btn" type="submit" value="Find">
</form> |
<a href="report.cgi">Reports</a>
......@@ -127,4 +131,3 @@
[%# Sections of links to more things users can do on this installation. %]
[% Hook.process("end") %]
</div>
</form>
......@@ -28,11 +28,12 @@
[% PROCESS global/variables.none.tmpl %]
[% title = BLOCK %]
[% terms.Bugzilla %] Main Page
[% END %]
[% style_urls = [ "skins/standard/index.css" ] %]
[% PROCESS global/header.html.tmpl %]
[% PROCESS global/header.html.tmpl
title = "$terms.Bugzilla Main Page"
style_urls = [ 'skins/standard/index.css' ]
onload = 'document.forms[\'f\'].quicksearch.focus();'
%]
<script type="text/javascript">
......@@ -84,25 +85,19 @@ function addSidebar() {
</ul>
<form id="show-bug" name="f" action="show_bug.cgi" method="get"
onsubmit="QuickSearch(f.id.value); return false;">
<form id="show-bug" name="f" action="buglist.cgi" method="get"
onsubmit="if (this.quicksearch.value == '')
{ alert('Please enter one or more search terms first.');
return false; } return true;">
<div>
<p>Enter [% terms.abug %] # or some search terms:</p>
<input id="text" type="text" name="id">
<input id="show" type="submit" value="Show">
<a href="quicksearch.html">[Help]</a>
<input id="quicksearch" type="text" name="quicksearch">
<input id="find" type="submit" value="Find">
<a href="page.cgi?id=quicksearch.html">[Help]</a>
</div>
</form>
<div class="outro"></div>
</div>
<script type="text/javascript" src="localconfig.js"></script>
<script type="text/javascript" src="quicksearch.js"></script>
<script type="text/javascript">
<!--
document.forms['f'].id.focus();
//-->
</script>
[% PROCESS global/footer.html.tmpl %]
[%# 1.0@bugzilla.org %]
[%# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# Contributor(s): N.N.
# Marc Schumann <wurblzap@gmail.com>
#%]
[% PROCESS global/variables.none.tmpl %]
[% INCLUDE global/header.html.tmpl
title = "$terms.Bugzilla QuickSearch",
style = 'ul {margin-bottom: 2ex}
ul li {margin-top: 2ex}
ul li ul li {margin-top: 0}'
onload = 'document.forms[\'f\'].quicksearch.focus()'
%]
<p style="font-size: 80%">
If you are already familiar with the original
<a href="query.cgi">[% terms.Bugzilla %] Search Form</a>,
you may prefer <a href="page.cgi?id=quicksearchhack.html">this form</a>.
</p>
<p>
Type in one or more words (or word fragments) to search for:
</p>
<form name="f" action="buglist.cgi" method="get"
onsubmit="if (this.quicksearch.value == '')
{ alert('Please enter one or more search terms first.');
return false; } return true;">
<input type="text" size="40" name="quicksearch">
<input type="submit" value="Find">
</form>
<h2>Getting Started</h2>
<ul>
<li>
This is <strong>case-insensitive</strong> search:<br />
<ul>
<li><tt>table</tt>, <tt>Table</tt> and <tt>TABLE</tt> are all the same.</li>
</ul>
</li>
<li>
This is <strong>all words as substrings</strong>
search.<br />
Therefore you should <strong>use stems</strong> to get better results:
<ul>
<li>
Use <tt>localiz</tt> instead of <tt>localize</tt> or
<tt>localization</tt>.
</li>
<li>
Use <tt>bookmark</tt> instead of <tt>bookmarks</tt> or
<tt>bookmarking</tt>.
</li>
</ul>
</li>
</ul>
<h2><a name="features">Features</a></h2>
<ul>
<li>
Boolean operations: &ldquo;<tt>-foo</tt>&rdquo;&nbsp;(NOT),
&ldquo;<tt>foo&nbsp;bar</tt>&rdquo;&nbsp;(AND),
&ldquo;<tt>foo|bar</tt>&rdquo;&nbsp;(OR).
<ul>
<li>
<strong>NOT</strong>:<br />
Use <tt><b>-</b><i>foo</i></tt> to exclude [% terms.bugs %]
with <tt><i>foo</i></tt> in the summary.
</li>
<li>
<strong>AND</strong>:<br />
Space-separated words are treated as a conjunction.
</li>
<li>
<strong>OR</strong>:<br />
Within a word, "|"-separated parts denote alternatives.
</li>
<li>
Besides "|", a comma can be used to separate alternatives.
</li>
<li>
OR has higher precedence than AND; AND is the top level operation.
</li>
</ul>
<i>Example:</i>
<tt>url,location bar,field -focus</tt> means
(<tt>url</tt> OR <tt>location</tt>) AND (<tt>bar</tt> OR <tt>field</tt>)
AND (NOT <tt>focus</tt>)
</li>
<li>
Use <tt>+foo</tt> to search for [% terms.bugs %] where the
<strong>summary</strong> contains <tt>foo</tt> as a
<strong>substring</strong>.<br/>
Use <tt>#foo</tt> to search for [% terms.bugs %] where the
<strong>summary</strong> contains the <strong>word</strong> <tt>foo</tt>.
<ul>
<li>
<tt>+brow</tt> does not find all [% terms.bugs %] in the
<tt>Browser</tt> product.
</li>
<li>
<tt>#title</tt> does not find [% terms.bugs %] with <tt>titlebar</tt>
or <tt>titled</tt>.
</li>
</ul>
Phrases with special chars (space, comma, +, -, #, &hellip;) can be
<strong>quoted</strong>:
<ul>
<li>
<tt>"lock icon"</tt>
</li>
</ul>
</li>
<li>
<strong>Open vs. Resolved [% terms.Bugs %]</strong>:<br />
By default, only open (i.e. unresolved) [% terms.bugs %] are shown.
Use <tt>+DUP</tt> as first word in your search to include duplicate
[%+ terms.bugs %] in your search,
<tt>FIXED</tt> to search for fixed [%+ terms.bugs %] only,
or <tt>ALL</tt> to search all [% terms.bugs %],
regardless of status or resolution.
Searching for duplicates is recommended if you can't find an open
[%+ terms.bug %] directly.
<ul>
<li>
<tt>+DUP,FIXED table border</tt>
</li>
<li>
<tt>ALL mouse wheel</tt>
</li>
</ul>
</li>
<li>
<strong>Focus the Search with Products &amp;
Components</strong>:<br />
To search for [% terms.bugs %] in product "Foo Bar" only, add
<tt>:foo</tt> or <tt>:bar</tt> or both to your search.
You can do this with any substring of a
<a href="describecomponents.cgi">product or component</a> to focus the
search.
</li>
</ul>
<h2>More Tips</h2>
<ul>
<li>
You can also use this tool to <strong>lookup</strong> a [% terms.bug %] by
its number:<br />
<ul>
<li><tt>12345</tt></li>
</ul>
</li>
<li>
A comma-separated list of [% terms.bug %] numbers gives you a list of these
[%+ terms.bugs %]:<br />
<ul>
<li><tt>12345,23456,34567</tt></li>
</ul>
</li>
</ul>
<p>
By default, the following fields are searched: Summary, Keywords, Product,
Component, Status Whiteboard. If a word looks like a part of a URL, that field
is included in the search, too.
</p>
<hr>
<p>
Use the powerful <a href="query.cgi">[% terms.Bugzilla %] Search Form</a>
for advanced queries.
</p>
[% PROCESS global/footer.html.tmpl %]
......@@ -34,14 +34,8 @@
orient="vertical"
onload="document.getElementById('query-field').addEventListener('keypress', initial_keypress_handler, true)">
<!-- Load QuickSearch libraries -->
<script type="application/x-javascript" src="localconfig.js"/>
<script type="application/x-javascript" src="quicksearch.js"/>
<script type="application/x-javascript"><![CDATA[
// Tell QuickSearch that the source of this is the sidebar
var sidebar = 1;
function load_absolute_url( aAbsoluteURL ) {
content.location = aAbsoluteURL;
}
......@@ -59,7 +53,7 @@ function initial_keypress_handler( aEvent ) {
function normal_keypress_handler( aEvent ) {
if ( aEvent.keyCode == 13 )
QuickSearch(this.value);
load_relative_url('buglist.cgi?quicksearch=' + this.value);
}
]]></script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment