Skip to content

Commit 895d1b2

Browse files
authored
Merge pull request #2633 from ahornace/rename_q
Replace "q" query param name with "full"
2 parents 6dc1480 + f7af89d commit 895d1b2

File tree

14 files changed

+42
-46
lines changed

14 files changed

+42
-46
lines changed

apiary.apib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ with a colon. If the type cannot be determined "N/A" is returned.
372372
+ Request (application/json)
373373
+ Body
374374

375-
["http://localhost:8080/source/search?project=kotlin&q=text"]
375+
["http://localhost:8080/source/search?project=kotlin&full=text"]
376376

377377
+ Response 204
378378

opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/JFlexXref.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ public void linkageMatched(LinkageMatchedEvent evt) {
315315
case QUERY:
316316
out.write("<a href=\"");
317317
out.write(urlPrefix);
318-
out.write("q=");
318+
out.write("full=");
319319
Util.qurlencode(lstr, out);
320320
JFlexXrefUtils.appendProject(out, project);
321321
out.write("\">");

opengrok-indexer/src/main/java/org/opengrok/indexer/search/QueryBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright 2011 Jens Elkner.
2323
* Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
2424
*/
@@ -72,7 +72,7 @@ public class QueryBuilder {
7272
public static final String OBJSER = "objser"; // object serialized
7373
public static final String OBJVER = "objver"; // object version
7474

75-
public static final List<String> searchFields = Arrays.asList("q", DEFS, REFS, PATH, HIST);
75+
public static final List<String> searchFields = Arrays.asList(FULL, DEFS, REFS, PATH, HIST);
7676

7777
/** Used for paths, so SHA-1 is completely sufficient */
7878
private static final String DIRPATH_HASH_ALGORITHM = "SHA-1";

opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/Context.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,10 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright 2011 Jens Elkner.
2323
* Portions Copyright (c) 2018, Chris Fraire <[email protected]>.
2424
*/
25-
26-
/**
27-
* This is supposed to get the matching lines from sourcefile.
28-
* since lucene does not easily give the match context.
29-
*/
3025
package org.opengrok.indexer.search.context;
3126

3227
import java.io.IOException;
@@ -55,6 +50,10 @@
5550
import org.opengrok.indexer.util.IOUtils;
5651
import org.opengrok.indexer.web.Util;
5752

53+
/**
54+
* This is supposed to get the matching lines from sourcefile.
55+
* since lucene does not easily give the match context.
56+
*/
5857
public class Context {
5958

6059
private static final Logger LOGGER = LoggerFactory.getLogger(Context.class);
@@ -245,9 +244,6 @@ private void buildQueryAsURI(Map<String, String> subqueries) {
245244
for (Map.Entry<String, String> entry : subqueries.entrySet()) {
246245
String field = entry.getKey();
247246
String queryText = entry.getValue();
248-
if (QueryBuilder.FULL.equals(field)) {
249-
field = "q"; // bah - search query params should be consistent!
250-
}
251247
sb.append(field).append("=").append(Util.URIEncode(queryText))
252248
.append('&');
253249
}

opengrok-indexer/src/main/java/org/opengrok/indexer/web/PageConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ public List<SortOrder> getSortOrder() {
597597
*/
598598
public QueryBuilder getQueryBuilder() {
599599
if (queryBuilder == null) {
600-
queryBuilder = new QueryBuilder().setFreetext(req.getParameter("q"))
600+
queryBuilder = new QueryBuilder().setFreetext(req.getParameter(QueryBuilder.FULL))
601601
.setDefs(req.getParameter(QueryBuilder.DEFS))
602602
.setRefs(req.getParameter(QueryBuilder.REFS))
603603
.setPath(req.getParameter(QueryBuilder.PATH))
@@ -1602,8 +1602,8 @@ private String addTitleDelimiter(String title) {
16021602
public String getSearchTitle() {
16031603
String title = "";
16041604

1605-
if (req.getParameter("q") != null && !req.getParameter("q").isEmpty()) {
1606-
title += req.getParameter("q") + " (full)";
1605+
if (req.getParameter(QueryBuilder.FULL) != null && !req.getParameter(QueryBuilder.FULL).isEmpty()) {
1606+
title += req.getParameter(QueryBuilder.FULL) + " (full)";
16071607
}
16081608
if (req.getParameter(QueryBuilder.DEFS) != null && !req.getParameter(QueryBuilder.DEFS).isEmpty()) {
16091609
title = addTitleDelimiter(title);

opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/JFlexXrefTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
2323
*/
2424

@@ -434,7 +434,7 @@ public void truncatedUuencodedFile() throws IOException {
434434
assertLinesEqual("UuencodeXref truncated",
435435
"<a class=\"l\" name=\"1\" href=\"#1\">1</a>"
436436
+ "<strong>begin</strong> <em>644</em> "
437-
+ "<a href=\"/source/s?q=%22test.txt%22\">test.txt</a>"
437+
+ "<a href=\"/source/s?full=%22test.txt%22\">test.txt</a>"
438438
+ "<span class=\"c\">\n"
439439
+ "<a class=\"l\" name=\"2\" href=\"#2\">2</a></span>",
440440
out.toString());

opengrok-web/src/main/java/org/opengrok/web/api/v1/controller/SuggesterController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
2222
*/
2323
package org.opengrok.web.api.v1.controller;
2424

@@ -181,7 +181,7 @@ public void rebuild(@PathParam("project") final String project) {
181181
* Initializes the search data used by suggester to perform most popular completion. The passed {@code urls} are
182182
* decomposed into single terms which search counts are then increased by 1.
183183
* @param urls list of URLs in JSON format, e.g.
184-
* {@code ["http://demo.opengrok.org/search?project=opengrok&q=test"]}
184+
* {@code ["http://demo.opengrok.org/search?project=opengrok&full=test"]}
185185
*/
186186
@POST
187187
@Path("/init/queries")
@@ -227,7 +227,7 @@ private Query getQuery(final String field, final String value) throws ParseExcep
227227
QueryBuilder builder = new QueryBuilder();
228228

229229
switch (field) {
230-
case "q":
230+
case QueryBuilder.FULL:
231231
builder.setFreetext(value);
232232
break;
233233
case QueryBuilder.DEFS:

opengrok-web/src/main/webapp/help.jsp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ information: Portions Copyright [yyyy] [name of copyright owner]
1616
1717
CDDL HEADER END
1818
19-
Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
19+
Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
2020
Portions Copyright 2011 Jens Elkner.
2121
Portions Copyright (c) 2018, Chris Fraire <[email protected]>.
2222
@@ -61,27 +61,27 @@ include file="menu.jspf"
6161
<pre class="example">
6262

6363
To find where setResourceMonitors is defined:
64-
<a href="search?q=&amp;defs=setResourceMonitors">defs:setResourceMonitors</a>
64+
<a href="search?full=&amp;defs=setResourceMonitors">defs:setResourceMonitors</a>
6565

6666
To find files that use sprintf in usr/src/cmd/cmd-inet/usr.sbin/:
6767
<a href="search?refs=sprintf&amp;path=usr%2Fsrc%2Fcmd%2Fcmd-inet%2Fusr.sbin%2F"
6868
>refs:sprintf path:usr/src/cmd/cmd-inet/usr.sbin</a>
6969

7070
To find assignments to variable foo:
71-
<a href="search?q=%22foo+%3D%22">"foo ="</a>
71+
<a href="search?full=%22foo+%3D%22">"foo ="</a>
7272

7373
To find Makefiles where pstack binary is being built:
74-
<a href="search?q=pstack&amp;path=Makefile">pstack path:Makefile</a>
74+
<a href="search?full=pstack&amp;path=Makefile">pstack path:Makefile</a>
7575

7676
to search for phrase "Bill Joy":
77-
<a href="search?q=%22Bill+Joy%22">"Bill Joy"</a>
77+
<a href="search?full=%22Bill+Joy%22">"Bill Joy"</a>
7878

7979
To find perl files that do not use /usr/bin/perl but something else:
80-
<a href="search?q=-%22%2Fusr%2Fbin%2Fperl%22+%2B%22%2Fbin%2Fperl%22"
80+
<a href="search?full=-%22%2Fusr%2Fbin%2Fperl%22+%2B%22%2Fbin%2Fperl%22"
8181
>-"/usr/bin/perl" +"/bin/perl"</a>
8282

8383
To find all strings beginning with foo use the wildcard:
84-
<a href="search?q=foo*">foo*</a>
84+
<a href="search?full=foo*">foo*</a>
8585

8686
To find all files which have . c in their name (dot is a token!):
8787
<a href="search?path=%22. c%22">". c"</a>
@@ -90,7 +90,7 @@ To find all files which start with "ma" and then have only alphabet characters d
9090
<a href="search?path=/ma[a-zA-Z]*/">path:/ma[a-zA-Z]*/</a>
9191

9292
To find all main methods in all files analyzed by C analyzer (so .c, .h, ...) do:
93-
<a href="search?q=main&type=c">main type:c</a>
93+
<a href="search?full=main&type=c">main type:c</a>
9494
</pre>
9595

9696
<h4>More info:</h4>

opengrok-web/src/main/webapp/js/utils-0.0.28.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@
945945

946946
this.$search_defs.attr('href', this.getSearchLink('defs'));
947947
this.$search_refs.attr('href', this.getSearchLink('refs'));
948-
this.$search_full.attr('href', this.getSearchLink('q'));
948+
this.$search_full.attr('href', this.getSearchLink('full'));
949949
this.$search_files.attr('href', this.getSearchLink('path'));
950950
this.$search_google.attr('href', this.options.google_url + this.symbol)
951951
},
@@ -1745,7 +1745,7 @@ function initAutocomplete(config, minisearch) {
17451745
if (minisearch) {
17461746
initMinisearchAutocomplete(config);
17471747
} else {
1748-
initAutocompleteForField("q", "full", config);
1748+
initAutocompleteForField("full", "full", config);
17491749
initAutocompleteForField("defs", "defs", config);
17501750
initAutocompleteForField("refs", "refs", config);
17511751
initAutocompleteForField("path", "path", config);
@@ -1799,7 +1799,7 @@ function initAutocompleteForField(inputId, field, config, dataFunction, errorEle
17991799
dataFunction = getAutocompleteMenuData;
18001800
}
18011801
if (!errorElemId) {
1802-
errorElemId = 'q';
1802+
errorElemId = 'full';
18031803
}
18041804
var errorElem = $('#' + errorElemId);
18051805

@@ -1909,7 +1909,7 @@ function getAutocompleteMenuData(input, field) {
19091909
return {
19101910
projects: getSelectedProjectNames(),
19111911
field: field,
1912-
full: $('#q').val(),
1912+
full: $('#full').val(),
19131913
defs: $('#defs').val(),
19141914
refs: $('#refs').val(),
19151915
path: $('#path').val(),

opengrok-web/src/main/webapp/menu.jspf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ information: Portions Copyright [yyyy] [name of copyright owner]
1818

1919
CDDL HEADER END
2020

21-
Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
21+
Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
2222

2323
Portions Copyright 2011 Jens Elkner.
2424

@@ -156,8 +156,8 @@ document.domReady.push(function() { domReadyMenu(); });
156156
%>
157157
<tbody>
158158
<tr>
159-
<td><label for="q" title="The text token(s) or other fields to be found (lucene query, this is not full text!)">Full&nbsp;Search</label></td>
160-
<td colspan="2"><input tabindex="1" class="q" name="q" id="q" type="text" value="<%=
159+
<td><label for="full" title="The text token(s) or other fields to be found (lucene query, this is not full text!)">Full&nbsp;Search</label></td>
160+
<td colspan="2"><input tabindex="1" class="q" name="full" id="full" type="text" value="<%=
161161
Util.formQuoteEscape(queryParams.getFreetext()) %>"/></td>
162162
</tr>
163163
<tr>

0 commit comments

Comments
 (0)