]> source.dussan.org Git - gitblit.git/commitdiff
Polish the Lucene search page. Integrate both search mechanisms.
authorJames Moger <james.moger@gitblit.com>
Tue, 20 Mar 2012 02:12:08 +0000 (22:12 -0400)
committerJames Moger <james.moger@gitblit.com>
Tue, 20 Mar 2012 02:12:08 +0000 (22:12 -0400)
17 files changed:
src/com/gitblit/wicket/GitBlitWebApp.java
src/com/gitblit/wicket/GitBlitWebApp.properties
src/com/gitblit/wicket/pages/GitSearchPage.html [new file with mode: 0644]
src/com/gitblit/wicket/pages/GitSearchPage.java [new file with mode: 0644]
src/com/gitblit/wicket/pages/LucenePage.html [deleted file]
src/com/gitblit/wicket/pages/LucenePage.java [deleted file]
src/com/gitblit/wicket/pages/LuceneSearchPage.html [new file with mode: 0644]
src/com/gitblit/wicket/pages/LuceneSearchPage.java [new file with mode: 0644]
src/com/gitblit/wicket/pages/RepositoryPage.java
src/com/gitblit/wicket/pages/RootPage.java
src/com/gitblit/wicket/pages/SearchPage.html [deleted file]
src/com/gitblit/wicket/pages/SearchPage.java [deleted file]
src/com/gitblit/wicket/panels/ActivityPanel.java
src/com/gitblit/wicket/panels/BranchesPanel.java
src/com/gitblit/wicket/panels/HistoryPanel.java
src/com/gitblit/wicket/panels/LogPanel.java
src/com/gitblit/wicket/panels/SearchPanel.java

index 5054afa3b67358bd657b034dec4431f49ee597c0..eea17cffc7599db574d9bc0652cff4a6a8147283 100644 (file)
@@ -26,7 +26,6 @@ import org.apache.wicket.protocol.http.WebApplication;
 import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.wicket.pages.ActivityPage;\r
-import com.gitblit.wicket.pages.BasePage;\r
 import com.gitblit.wicket.pages.BlamePage;\r
 import com.gitblit.wicket.pages.BlobDiffPage;\r
 import com.gitblit.wicket.pages.BlobPage;\r
@@ -35,16 +34,17 @@ import com.gitblit.wicket.pages.CommitDiffPage;
 import com.gitblit.wicket.pages.CommitPage;\r
 import com.gitblit.wicket.pages.DocsPage;\r
 import com.gitblit.wicket.pages.FederationRegistrationPage;\r
+import com.gitblit.wicket.pages.GitSearchPage;\r
 import com.gitblit.wicket.pages.GravatarProfilePage;\r
 import com.gitblit.wicket.pages.HistoryPage;\r
 import com.gitblit.wicket.pages.LogPage;\r
+import com.gitblit.wicket.pages.LuceneSearchPage;\r
 import com.gitblit.wicket.pages.MarkdownPage;\r
 import com.gitblit.wicket.pages.MetricsPage;\r
 import com.gitblit.wicket.pages.PatchPage;\r
 import com.gitblit.wicket.pages.RawPage;\r
 import com.gitblit.wicket.pages.RepositoriesPage;\r
 import com.gitblit.wicket.pages.ReviewProposalPage;\r
-import com.gitblit.wicket.pages.SearchPage;\r
 import com.gitblit.wicket.pages.SummaryPage;\r
 import com.gitblit.wicket.pages.TagPage;\r
 import com.gitblit.wicket.pages.TagsPage;\r
@@ -91,12 +91,7 @@ public class GitBlitWebApp extends WebApplication {
                mount("/commitdiff", CommitDiffPage.class, "r", "h");\r
                mount("/patch", PatchPage.class, "r", "h", "f");\r
                mount("/history", HistoryPage.class, "r", "h", "f");\r
-               if (GitBlit.getBoolean(Keys.lucene.enable, false)) {\r
-                       // TODO switch this to LucenePage when it is ready\r
-                       mount("/search", SearchPage.class);\r
-               } else {\r
-                       mount("/search", SearchPage.class);\r
-               }\r
+               mount("/search", GitSearchPage.class);\r
                mount("/metrics", MetricsPage.class, "r");\r
                mount("/blame", BlamePage.class, "r", "h", "f");\r
 \r
@@ -114,6 +109,7 @@ public class GitBlitWebApp extends WebApplication {
 \r
                mount("/activity", ActivityPage.class, "r", "h");\r
                mount("/gravatar", GravatarProfilePage.class, "h");\r
+               mount("/lucene", LuceneSearchPage.class);\r
        }\r
 \r
        private void mount(String location, Class<? extends WebPage> clazz, String... parameters) {\r
@@ -131,20 +127,6 @@ public class GitBlitWebApp extends WebApplication {
                return RepositoriesPage.class;\r
        }\r
        \r
-       /**\r
-        * Returns the preferred search page class.\r
-        * \r
-        * @return a Wicket class representing a search page\r
-        */\r
-       public Class<? extends BasePage> getSearchPageClass() {\r
-               if (GitBlit.getBoolean(Keys.lucene.enable, false)) {\r
-                       // TODO switch this to LucenePage when it is ready\r
-                       return SearchPage.class;//LucenePage.class;\r
-               }\r
-               return SearchPage.class;\r
-       }\r
-\r
-\r
        @Override\r
        public final Session newSession(Request request, Response response) {\r
                return new GitBlitWebSession(request);\r
index 0952b573f70eb8a1233f09e008edf2c3d85f883e..2806eee5c3cb2c9b82297e5acdfb1a471ce38c81 100644 (file)
@@ -214,11 +214,11 @@ gb.pages = pages
 gb.workingCopy = working copy\r
 gb.workingCopyWarning = this repository has a working copy and can not receive pushes\r
 gb.query = query\r
-gb.queryHelp = write brief explanation of Lucene syntax here\r
+gb.queryHelp = Standard query syntax is supported.<p/><p/>Please see <a target="_new" href="http://lucene.apache.org/core/old_versioned_docs/versions/3_5_0/queryparsersyntax.html">Lucene Query Parser Syntax</a> for details.\r
 gb.authored = authored\r
 gb.committed = committed\r
 gb.indexedBranches = indexed branches\r
 gb.indexedBranchesDescription = select the branches to include in your Lucene index\r
 gb.noIndexedRepositoriesWarning = none of your repositories are configured for Lucene indexing\r
 gb.undefinedQueryWarning = query is undefined!\r
-gb.gb.noSelectedRepositoriesWarning = please select one or more repositories!
\ No newline at end of file
+gb.noSelectedRepositoriesWarning = please select one or more repositories!
\ No newline at end of file
diff --git a/src/com/gitblit/wicket/pages/GitSearchPage.html b/src/com/gitblit/wicket/pages/GitSearchPage.html
new file mode 100644 (file)
index 0000000..9bb1f41
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
+<html xmlns="http://www.w3.org/1999/xhtml"  \r
+      xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd"  \r
+      xml:lang="en"  \r
+      lang="en"> \r
+\r
+<body>\r
+<wicket:extend>\r
+\r
+       <!-- pager links -->\r
+       <div style="padding-top:5px;">\r
+               <a wicket:id="firstPageTop"><wicket:message key="gb.pageFirst"></wicket:message></a> | <a wicket:id="prevPageTop"><wicket:message key="gb.pagePrevious"></wicket:message></a> | <a wicket:id="nextPageTop"><wicket:message key="gb.pageNext"></wicket:message></a> \r
+       </div>\r
+       \r
+       <!-- history -->\r
+       <div style="margin-top:5px;" wicket:id="searchPanel">[search panel]</div>\r
+\r
+       <!-- pager links -->\r
+       <div style="padding-bottom:5px;">\r
+               <a wicket:id="firstPageBottom"><wicket:message key="gb.pageFirst"></wicket:message></a> | <a wicket:id="prevPageBottom"><wicket:message key="gb.pagePrevious"></wicket:message></a> | <a wicket:id="nextPageBottom"><wicket:message key="gb.pageNext"></wicket:message></a> \r
+       </div>\r
+\r
+</wicket:extend>\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/src/com/gitblit/wicket/pages/GitSearchPage.java b/src/com/gitblit/wicket/pages/GitSearchPage.java
new file mode 100644 (file)
index 0000000..ca813ac
--- /dev/null
@@ -0,0 +1,69 @@
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package com.gitblit.wicket.pages;\r
+\r
+import org.apache.wicket.PageParameters;\r
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;\r
+\r
+import com.gitblit.Constants;\r
+import com.gitblit.wicket.WicketUtils;\r
+import com.gitblit.wicket.panels.SearchPanel;\r
+\r
+public class GitSearchPage extends RepositoryPage {\r
+\r
+       public GitSearchPage(PageParameters params) {\r
+               super(params);\r
+\r
+               String value = WicketUtils.getSearchString(params);\r
+               String type = WicketUtils.getSearchType(params);\r
+               Constants.SearchType searchType = Constants.SearchType.forName(type);\r
+\r
+               int pageNumber = WicketUtils.getPage(params);\r
+               int prevPage = Math.max(0, pageNumber - 1);\r
+               int nextPage = pageNumber + 1;\r
+\r
+               SearchPanel search = new SearchPanel("searchPanel", repositoryName, objectId, value,\r
+                               searchType, getRepository(), -1, pageNumber - 1);\r
+               boolean hasMore = search.hasMore();\r
+               add(search);\r
+\r
+               add(new BookmarkablePageLink<Void>("firstPageTop", GitSearchPage.class,\r
+                               WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType))\r
+                               .setEnabled(pageNumber > 1));\r
+               add(new BookmarkablePageLink<Void>("prevPageTop", GitSearchPage.class,\r
+                               WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType,\r
+                                               prevPage)).setEnabled(pageNumber > 1));\r
+               add(new BookmarkablePageLink<Void>("nextPageTop", GitSearchPage.class,\r
+                               WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType,\r
+                                               nextPage)).setEnabled(hasMore));\r
+\r
+               add(new BookmarkablePageLink<Void>("firstPageBottom", GitSearchPage.class,\r
+                               WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType))\r
+                               .setEnabled(pageNumber > 1));\r
+               add(new BookmarkablePageLink<Void>("prevPageBottom", GitSearchPage.class,\r
+                               WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType,\r
+                                               prevPage)).setEnabled(pageNumber > 1));\r
+               add(new BookmarkablePageLink<Void>("nextPageBottom", GitSearchPage.class,\r
+                               WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType,\r
+                                               nextPage)).setEnabled(hasMore));\r
+\r
+       }\r
+\r
+       @Override\r
+       protected String getPageName() {\r
+               return getString("gb.search");\r
+       }\r
+}\r
diff --git a/src/com/gitblit/wicket/pages/LucenePage.html b/src/com/gitblit/wicket/pages/LucenePage.html
deleted file mode 100644 (file)
index 75f6336..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
-<html xmlns="http://www.w3.org/1999/xhtml"  \r
-      xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd"  \r
-      xml:lang="en"  \r
-      lang="en"> \r
-\r
-<!-- contribute google-code-prettify resources to the page header -->\r
-<wicket:head>\r
-  <wicket:link>\r
-       <link href="prettify/prettify.css" type="text/css" rel="stylesheet" />\r
-       <script type="text/javascript" src="prettify/prettify.js"></script>\r
-  </wicket:link>\r
-</wicket:head>\r
-      \r
-<wicket:extend>\r
-<body onload="document.getElementById('query').focus(); prettyPrint();">\r
-       <div class="pageTitle">\r
-               <h2><wicket:message key="gb.search"></wicket:message></h2>\r
-       </div>\r
-       <form class="form-inline" style="margin:0px;" wicket:id="searchForm">\r
-               <div class="row-fluid">\r
-                       <div class="span3">\r
-                               <h3><wicket:message key="gb.repositories"></wicket:message></h3>\r
-                               <select wicket:id="repositories" ></select>\r
-                       </div>\r
-                       <div class="span9">\r
-                               <div>\r
-                                       <h3><wicket:message key="gb.query"></wicket:message></h3>\r
-                                       <input class="span8" id="query" wicket:id="query" placeholder="enter search text"></input>\r
-                                       <button class="btn btn-primary" type="submit" value="Search"><wicket:message key="gb.search"></wicket:message></button>\r
-                               </div>\r
-                               <div style="margin-top:10px;">\r
-                                       <div style="margin-left:0px;" class="span4">\r
-                                               <div class="alert alert">\r
-                                                       <b>type:</b> commit or blob<br/>\r
-                                                       <b>commit:</b> commit id<br/>\r
-                                                       <b>path:</b> blob path<br/>\r
-                                                       <b>branch:</b> refs/heads/master<br/>\r
-                                                       <b>author:</b><br/>\r
-                                                       <b>committer:</b><br/>\r
-                                                       <b>tag:</b> tag<br/>\r
-                                               </div>\r
-                                       </div>\r
-                                       <div class="span5">\r
-                                               <wicket:message key="gb.queryHelp"></wicket:message>\r
-                                       </div>\r
-                               </div>\r
-                       </div>\r
-               </div>\r
-       </form>\r
-\r
-       <div class="row-fluid"> \r
-       <!-- results header -->\r
-       <div class="span8">\r
-               <h3><span wicket:id="resultsHeader"></span> <small><span wicket:id="resultsCount"></span></small></h3>\r
-       </div>\r
-       <!-- pager links -->\r
-       <div class="span4" wicket:id="topPager"></div>\r
-       </div>\r
-       \r
-       <div class="row-fluid"> \r
-       <!--  search result repeater -->\r
-       <div class="searchResult" wicket:id="searchResults">\r
-               <div><i wicket:id="type"></i><span class="summary" wicket:id="summary"></span></div>\r
-               <div class="body">\r
-                       <div class="fragment" wicket:id="fragment"></div>\r
-                       <div><span class="author" wicket:id="author"></span> <span class="date" ><wicket:message key="gb.authored"></wicket:message> <span class="date" wicket:id="date"></span></span></div>\r
-                       <span class="repository" wicket:id="repository"></span>:<span class="branch" wicket:id="branch"></span>                 \r
-               </div>\r
-       </div>\r
-\r
-       <!-- pager links -->\r
-       <div wicket:id="bottomPager"></div>\r
-\r
-       </div>  \r
-</body>\r
-</wicket:extend>\r
-</html>
\ No newline at end of file
diff --git a/src/com/gitblit/wicket/pages/LucenePage.java b/src/com/gitblit/wicket/pages/LucenePage.java
deleted file mode 100644 (file)
index 10de0bf..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-/*\r
- * Copyright 2012 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package com.gitblit.wicket.pages;\r
-\r
-import java.text.MessageFormat;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.apache.wicket.PageParameters;\r
-import org.apache.wicket.markup.html.basic.Label;\r
-import org.apache.wicket.markup.html.form.ListMultipleChoice;\r
-import org.apache.wicket.markup.html.form.StatelessForm;\r
-import org.apache.wicket.markup.html.form.TextField;\r
-import org.apache.wicket.markup.repeater.Item;\r
-import org.apache.wicket.markup.repeater.data.DataView;\r
-import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
-import org.apache.wicket.model.Model;\r
-import org.eclipse.jgit.lib.Constants;\r
-\r
-import com.gitblit.Constants.SearchType;\r
-import com.gitblit.GitBlit;\r
-import com.gitblit.Keys;\r
-import com.gitblit.models.RepositoryModel;\r
-import com.gitblit.models.SearchResult;\r
-import com.gitblit.models.UserModel;\r
-import com.gitblit.utils.ArrayUtils;\r
-import com.gitblit.utils.StringUtils;\r
-import com.gitblit.wicket.GitBlitWebSession;\r
-import com.gitblit.wicket.StringChoiceRenderer;\r
-import com.gitblit.wicket.WicketUtils;\r
-import com.gitblit.wicket.panels.LinkPanel;\r
-import com.gitblit.wicket.panels.PagerPanel;\r
-\r
-public class LucenePage extends RootPage {\r
-\r
-       public LucenePage() {\r
-               super();\r
-               setup(null);\r
-       }\r
-\r
-       public LucenePage(PageParameters params) {\r
-               super(params);\r
-               setup(params);\r
-       }\r
-\r
-       private void setup(PageParameters params) {\r
-               setupPage("", "");\r
-               \r
-               // default values\r
-               ArrayList<String> repositories = new ArrayList<String>();                               \r
-               String query = "";\r
-               int page = 1;\r
-               int pageSize = GitBlit.getInteger(Keys.web.itemsPerPage, 50);\r
-\r
-               if (params != null) {\r
-                       String repository = WicketUtils.getRepositoryName(params);\r
-                       if (!StringUtils.isEmpty(repository)) {\r
-                               repositories.add(repository);\r
-                       }\r
-\r
-                       page = WicketUtils.getPage(params);     \r
-                       \r
-                       if (params.containsKey("repositories")) {\r
-                               String value = params.getString("repositories", "");\r
-                               List<String> list = StringUtils.getStringsFromValue(value);                     \r
-                               repositories.addAll(list);\r
-                       }\r
-\r
-                       if (params.containsKey("query")) {\r
-                               query = params.getString("query", "");  \r
-                       } else {\r
-                               String value = WicketUtils.getSearchString(params);\r
-                               String type = WicketUtils.getSearchType(params);\r
-                               com.gitblit.Constants.SearchType searchType = com.gitblit.Constants.SearchType.forName(type);\r
-                               if (!StringUtils.isEmpty(value)) {\r
-                                       if (searchType == SearchType.COMMIT) {\r
-                                               query = "type:" + searchType.name().toLowerCase() + " AND \"" + value + "\"";   \r
-                                       } else {\r
-                                               query = searchType.name().toLowerCase() + ":\"" + value + "\"";\r
-                                       }\r
-                               }\r
-                       }\r
-               }\r
-               \r
-               // display user-accessible selections\r
-               UserModel user = GitBlitWebSession.get().getUser();\r
-               List<String> availableRepositories = new ArrayList<String>();\r
-               for (RepositoryModel model : GitBlit.self().getRepositoryModels(user)) {\r
-                       if (model.hasCommits && !ArrayUtils.isEmpty(model.indexedBranches)) {\r
-                               availableRepositories.add(model.name);\r
-                       }\r
-               }\r
-               \r
-               if (availableRepositories.size() == 0) {\r
-                       info(getString("gb.noIndexedRepositoriesWarning"));\r
-               }\r
-\r
-               // enforce user-accessible repository selections\r
-               ArrayList<String> searchRepositories = new ArrayList<String>();\r
-               for (String selectedRepository : repositories) {\r
-                       if (availableRepositories.contains(selectedRepository)) {\r
-                               searchRepositories.add(selectedRepository);\r
-                       }\r
-               }\r
-               \r
-               // search form\r
-               final Model<String> queryModel = new Model<String>(query);\r
-               final Model<ArrayList<String>> repositoriesModel = new Model<ArrayList<String>>(searchRepositories);\r
-               StatelessForm<Void> form = new StatelessForm<Void>("searchForm") {\r
-                       \r
-                       private static final long serialVersionUID = 1L;\r
-\r
-                       @Override\r
-                       public void onSubmit() {\r
-                               String q = queryModel.getObject();\r
-                               if (StringUtils.isEmpty(q)) {\r
-                                       error(getString("gb.undefinedQueryWarning"));\r
-                                       return;\r
-                               }                               \r
-                               if (repositoriesModel.getObject().size() == 0) {\r
-                                       error(getString("gb.noSelectedRepositoriesWarning"));\r
-                                       return;\r
-                               }\r
-                               PageParameters params = new PageParameters();\r
-                               params.put("repositories", StringUtils.flattenStrings(repositoriesModel.getObject()));\r
-                               params.put("query", queryModel.getObject());\r
-                               setResponsePage(LucenePage.class, params);\r
-                       }\r
-               };\r
-                               \r
-               ListMultipleChoice<String> selections = new ListMultipleChoice<String>("repositories", \r
-                               repositoriesModel, availableRepositories, new StringChoiceRenderer());\r
-               selections.setMaxRows(10);\r
-               form.add(selections);\r
-               form.add(new TextField<String>("query", queryModel));\r
-               add(form);\r
-                               \r
-               // execute search\r
-               final List<SearchResult> results = new ArrayList<SearchResult>();\r
-               if (!ArrayUtils.isEmpty(searchRepositories) && !StringUtils.isEmpty(query)) {\r
-                       results.addAll(GitBlit.self().search(query, page, pageSize, searchRepositories));\r
-               }\r
-               \r
-               // results header\r
-               if (results.size() == 0) {\r
-                       add(new Label("resultsHeader").setVisible(false));\r
-                       add(new Label("resultsCount").setVisible(false));\r
-               } else {\r
-                       add(new Label("resultsHeader", query).setRenderBodyOnly(true));\r
-                       add(new Label("resultsCount", MessageFormat.format("results {0} - {1} ({2} hits)",\r
-                                       results.get(0).hitId, results.get(results.size() - 1).hitId, results.get(0).totalHits)).\r
-                                       setRenderBodyOnly(true));\r
-               }\r
-               \r
-               // search results view\r
-               ListDataProvider<SearchResult> resultsDp = new ListDataProvider<SearchResult>(results);\r
-               final DataView<SearchResult> resultsView = new DataView<SearchResult>("searchResults", resultsDp) {\r
-                       private static final long serialVersionUID = 1L;\r
-                       public void populateItem(final Item<SearchResult> item) {\r
-                               SearchResult sr = item.getModelObject();\r
-                               switch(sr.type) {\r
-                               case commit: {\r
-                                       Label icon = WicketUtils.newIcon("type", "icon-refresh");\r
-                                       WicketUtils.setHtmlTooltip(icon, "commit");\r
-                                       item.add(icon);\r
-                                       item.add(new LinkPanel("summary", null, sr.summary, CommitPage.class, WicketUtils.newObjectParameter(sr.repository, sr.commitId)));\r
-                                       break;\r
-                               }\r
-                               case blob: {\r
-                                       Label icon = WicketUtils.newIcon("type", "icon-file");\r
-                                       WicketUtils.setHtmlTooltip(icon, "blob");\r
-                                       item.add(icon);\r
-                                       item.add(new LinkPanel("summary", null, sr.path, BlobPage.class, WicketUtils.newPathParameter(sr.repository, sr.branch, sr.path)));\r
-                                       break;\r
-                               }\r
-                               case issue: {\r
-                                       Label icon = WicketUtils.newIcon("type", "icon-file");\r
-                                       WicketUtils.setHtmlTooltip(icon, "issue");\r
-                                       item.add(icon);\r
-                                       item.add(new Label("summary", "issue: " + sr.issueId));\r
-                                       break;\r
-                               }\r
-                               }\r
-                               item.add(new Label("fragment", sr.fragment).setEscapeModelStrings(false).setVisible(!StringUtils.isEmpty(sr.fragment)));\r
-                               item.add(new LinkPanel("repository", null, sr.repository, SummaryPage.class, WicketUtils.newRepositoryParameter(sr.repository)));\r
-                               if (StringUtils.isEmpty(sr.branch)) {\r
-                                       item.add(new Label("branch", "null"));\r
-                               } else {\r
-                                       item.add(new LinkPanel("branch", "branch", StringUtils.getRelativePath(Constants.R_HEADS, sr.branch), LogPage.class, WicketUtils.newObjectParameter(sr.repository, sr.branch)));\r
-                               }\r
-                               item.add(new Label("author", sr.author));\r
-                               item.add(WicketUtils.createDatestampLabel("date", sr.date, getTimeZone()));\r
-                       }\r
-               };\r
-               add(resultsView.setVisible(results.size() > 0));\r
-               \r
-               PageParameters pagerParams = new PageParameters();\r
-               pagerParams.put("repositories", StringUtils.flattenStrings(repositoriesModel.getObject()));\r
-               pagerParams.put("query", queryModel.getObject());\r
-               \r
-               int totalPages = 0;\r
-               if (results.size() > 0) {\r
-                       totalPages = (results.get(0).totalHits / pageSize) + (results.get(0).totalHits % pageSize > 0 ? 1 : 0);\r
-               }\r
-               \r
-               add(new PagerPanel("topPager", page, totalPages, LucenePage.class, pagerParams));\r
-               add(new PagerPanel("bottomPager", page, totalPages, LucenePage.class, pagerParams));\r
-       }\r
-       \r
-//     private String buildPager(int currentPage, int count, int total) {\r
-//             int pages = (total / count) + (total % count == 0 ? 0 : 1);\r
-//             \r
-//             // pages are 1-indexed\r
-//             // previous page link\r
-//             if (currentPage <= 1) {\r
-//                     sb.append(MessageFormat.format(li, "disabled", "#", "&larr;"));\r
-//             } else {\r
-//                     List<String> parameters = new ArrayList<String>();\r
-//                     if (!StringUtils.isEmpty(penString)) {\r
-//                             parameters.add(penString);\r
-//                     }\r
-//                     parameters.add(MessageFormat.format(pg, currentPage - 1));\r
-//                     sb.append(MessageFormat.format(li, "", StringUtils.flattenStrings(parameters, "&"), "&larr;"));\r
-//             }\r
-//\r
-//             // page links in middle\r
-//             int minpage = Math.max(1, currentPage - Math.min(2, 2));\r
-//             int maxpage = Math.min(pages, minpage + 4);\r
-//             for (int i = minpage; i <= maxpage; i++) {\r
-//                     String cssClass = "";\r
-//                     if (i == currentPage) {\r
-//                             cssClass = "active";\r
-//                     }\r
-//                     List<String> parameters = new ArrayList<String>();\r
-//                     if (!StringUtils.isEmpty(penString)) {\r
-//                             parameters.add(penString);\r
-//                     }\r
-//                     parameters.add(MessageFormat.format(pg, i));\r
-//                     sb.append(MessageFormat.format(li, cssClass, StringUtils.flattenStrings(parameters, "&"), i));\r
-//             }\r
-//\r
-//             // next page link\r
-//             if (currentPage == pages) {\r
-//                     sb.append(MessageFormat.format(li, "disabled", "#", "&rarr;"));\r
-//             } else {\r
-//                     List<String> parameters = new ArrayList<String>();\r
-//                     if (!StringUtils.isEmpty(penString)) {\r
-//                             parameters.add(penString);\r
-//                     }\r
-//                     parameters.add(MessageFormat.format(pg, currentPage + 1));\r
-//                     sb.append(MessageFormat.format(li, "", StringUtils.flattenStrings(parameters, "&"), "&rarr;"));\r
-//             }\r
-//             return sb.toString();\r
-//     }\r
-\r
-}\r
diff --git a/src/com/gitblit/wicket/pages/LuceneSearchPage.html b/src/com/gitblit/wicket/pages/LuceneSearchPage.html
new file mode 100644 (file)
index 0000000..7639058
--- /dev/null
@@ -0,0 +1,85 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
+<html xmlns="http://www.w3.org/1999/xhtml"  \r
+      xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd"  \r
+      xml:lang="en"  \r
+      lang="en"> \r
+\r
+<!-- contribute google-code-prettify resources to the page header -->\r
+<wicket:head>\r
+  <wicket:link>\r
+       <link href="prettify/prettify.css" type="text/css" rel="stylesheet" />\r
+       <script type="text/javascript" src="prettify/prettify.js"></script>\r
+  </wicket:link>\r
+</wicket:head>\r
+      \r
+<wicket:extend>\r
+<body onload="document.getElementById('query').focus(); prettyPrint();">\r
+       <div class="pageTitle">\r
+               <h2><wicket:message key="gb.search"></wicket:message></h2>\r
+       </div>\r
+       <form class="form-inline" style="margin:0px;" wicket:id="searchForm">\r
+               <div class="row-fluid">\r
+                       <div class="span3">\r
+                               <h3><wicket:message key="gb.repositories"></wicket:message></h3>\r
+                               <select wicket:id="repositories" ></select>\r
+                       </div>\r
+                       <div class="span9">\r
+                               <div>\r
+                                       <h3><wicket:message key="gb.query"></wicket:message></h3>\r
+                                       <input class="span8" id="query" wicket:id="query" placeholder="enter search text"></input>\r
+                                       <button class="btn btn-primary" type="submit" value="Search"><wicket:message key="gb.search"></wicket:message></button>\r
+                               </div>\r
+                               <div style="margin-top:10px;">\r
+                                       <div style="margin-left:0px;" class="span3">\r
+                                               <div class="alert alert">\r
+                                                       <b>type:</b> commit or blob<br/>\r
+                                                       <b>commit:</b> commit id<br/>\r
+                                                       <b>path:</b> path/to/blob<br/>\r
+                                                       <b>branch:</b> refs/heads/master<br/>\r
+                                                       <b>author:</b> or <b>committer:</b>                                                     \r
+                                               </div>\r
+                                       </div>\r
+                                       <div class="span4">                                             \r
+                                               <div class="alert alert-info">\r
+                                                       type:commit AND "bug fix"<br/>\r
+                                                       type:commit AND author:james*<br/>\r
+                                                       type:blob AND "int errorCode"<br/>\r
+                                                       type:blob AND test AND path:*.java<br/>\r
+                                                       commit:d91e5*\r
+                                               </div>\r
+                                       </div>\r
+                                       <div class="span2">\r
+                                               <wicket:message key="gb.queryHelp"></wicket:message>\r
+                                       </div>\r
+                               </div>\r
+                       </div>\r
+               </div>\r
+       </form>\r
+\r
+       <div class="row-fluid"> \r
+       <!-- results header -->\r
+       <div class="span8">\r
+               <h3><span wicket:id="resultsHeader"></span> <small><span wicket:id="resultsCount"></span></small></h3>\r
+       </div>\r
+       <!-- pager links -->\r
+       <div class="span4" wicket:id="topPager"></div>\r
+       </div>\r
+       \r
+       <div class="row-fluid"> \r
+       <!--  search result repeater -->\r
+       <div class="searchResult" wicket:id="searchResults">\r
+               <div><i wicket:id="type"></i><span class="summary" wicket:id="summary"></span></div>\r
+               <div class="body">\r
+                       <div class="fragment" wicket:id="fragment"></div>\r
+                       <div><span class="author" wicket:id="author"></span> <span class="date" ><wicket:message key="gb.authored"></wicket:message> <span class="date" wicket:id="date"></span></span></div>\r
+                       <span class="repository" wicket:id="repository"></span>:<span class="branch" wicket:id="branch"></span>                 \r
+               </div>\r
+       </div>\r
+\r
+       <!-- pager links -->\r
+       <div wicket:id="bottomPager"></div>\r
+\r
+       </div>  \r
+</body>\r
+</wicket:extend>\r
+</html>
\ No newline at end of file
diff --git a/src/com/gitblit/wicket/pages/LuceneSearchPage.java b/src/com/gitblit/wicket/pages/LuceneSearchPage.java
new file mode 100644 (file)
index 0000000..8e09a34
--- /dev/null
@@ -0,0 +1,269 @@
+/*\r
+ * Copyright 2012 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package com.gitblit.wicket.pages;\r
+\r
+import java.text.MessageFormat;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.apache.wicket.PageParameters;\r
+import org.apache.wicket.markup.html.basic.Label;\r
+import org.apache.wicket.markup.html.form.ListMultipleChoice;\r
+import org.apache.wicket.markup.html.form.StatelessForm;\r
+import org.apache.wicket.markup.html.form.TextField;\r
+import org.apache.wicket.markup.repeater.Item;\r
+import org.apache.wicket.markup.repeater.data.DataView;\r
+import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
+import org.apache.wicket.model.Model;\r
+import org.eclipse.jgit.lib.Constants;\r
+\r
+import com.gitblit.Constants.SearchType;\r
+import com.gitblit.GitBlit;\r
+import com.gitblit.Keys;\r
+import com.gitblit.models.RepositoryModel;\r
+import com.gitblit.models.SearchResult;\r
+import com.gitblit.models.UserModel;\r
+import com.gitblit.utils.ArrayUtils;\r
+import com.gitblit.utils.StringUtils;\r
+import com.gitblit.wicket.GitBlitWebSession;\r
+import com.gitblit.wicket.StringChoiceRenderer;\r
+import com.gitblit.wicket.WicketUtils;\r
+import com.gitblit.wicket.panels.LinkPanel;\r
+import com.gitblit.wicket.panels.PagerPanel;\r
+\r
+public class LuceneSearchPage extends RootPage {\r
+\r
+       public LuceneSearchPage() {\r
+               super();\r
+               setup(null);\r
+       }\r
+\r
+       public LuceneSearchPage(PageParameters params) {\r
+               super(params);\r
+               setup(params);\r
+       }\r
+\r
+       private void setup(PageParameters params) {\r
+               setupPage("", "");\r
+               \r
+               // default values\r
+               ArrayList<String> repositories = new ArrayList<String>();                               \r
+               String query = "";\r
+               int page = 1;\r
+               int pageSize = GitBlit.getInteger(Keys.web.itemsPerPage, 50);\r
+\r
+               if (params != null) {\r
+                       String repository = WicketUtils.getRepositoryName(params);\r
+                       if (!StringUtils.isEmpty(repository)) {\r
+                               repositories.add(repository);\r
+                       }\r
+\r
+                       page = WicketUtils.getPage(params);     \r
+                       \r
+                       if (params.containsKey("repositories")) {\r
+                               String value = params.getString("repositories", "");\r
+                               List<String> list = StringUtils.getStringsFromValue(value);                     \r
+                               repositories.addAll(list);\r
+                       }\r
+\r
+                       if (params.containsKey("query")) {\r
+                               query = params.getString("query", "");  \r
+                       } else {\r
+                               String value = WicketUtils.getSearchString(params);\r
+                               String type = WicketUtils.getSearchType(params);\r
+                               com.gitblit.Constants.SearchType searchType = com.gitblit.Constants.SearchType.forName(type);\r
+                               if (!StringUtils.isEmpty(value)) {\r
+                                       if (searchType == SearchType.COMMIT) {\r
+                                               query = "type:" + searchType.name().toLowerCase() + " AND \"" + value + "\"";   \r
+                                       } else {\r
+                                               query = searchType.name().toLowerCase() + ":\"" + value + "\"";\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+               \r
+               // display user-accessible selections\r
+               UserModel user = GitBlitWebSession.get().getUser();\r
+               List<String> availableRepositories = new ArrayList<String>();\r
+               for (RepositoryModel model : GitBlit.self().getRepositoryModels(user)) {\r
+                       if (model.hasCommits && !ArrayUtils.isEmpty(model.indexedBranches)) {\r
+                               availableRepositories.add(model.name);\r
+                       }\r
+               }\r
+               \r
+               if (availableRepositories.size() == 0) {\r
+                       info(getString("gb.noIndexedRepositoriesWarning"));\r
+               }\r
+\r
+               // enforce user-accessible repository selections\r
+               ArrayList<String> searchRepositories = new ArrayList<String>();\r
+               for (String selectedRepository : repositories) {\r
+                       if (availableRepositories.contains(selectedRepository)) {\r
+                               searchRepositories.add(selectedRepository);\r
+                       }\r
+               }\r
+               \r
+               // search form\r
+               final Model<String> queryModel = new Model<String>(query);\r
+               final Model<ArrayList<String>> repositoriesModel = new Model<ArrayList<String>>(searchRepositories);\r
+               StatelessForm<Void> form = new StatelessForm<Void>("searchForm") {\r
+                       \r
+                       private static final long serialVersionUID = 1L;\r
+\r
+                       @Override\r
+                       public void onSubmit() {\r
+                               String q = queryModel.getObject();\r
+                               if (StringUtils.isEmpty(q)) {\r
+                                       error(getString("gb.undefinedQueryWarning"));\r
+                                       return;\r
+                               }                               \r
+                               if (repositoriesModel.getObject().size() == 0) {\r
+                                       error(getString("gb.noSelectedRepositoriesWarning"));\r
+                                       return;\r
+                               }\r
+                               PageParameters params = new PageParameters();\r
+                               params.put("repositories", StringUtils.flattenStrings(repositoriesModel.getObject()));\r
+                               params.put("query", queryModel.getObject());\r
+                               setResponsePage(LuceneSearchPage.class, params);\r
+                       }\r
+               };\r
+                               \r
+               ListMultipleChoice<String> selections = new ListMultipleChoice<String>("repositories", \r
+                               repositoriesModel, availableRepositories, new StringChoiceRenderer());\r
+               selections.setMaxRows(8);\r
+               form.add(selections);\r
+               form.add(new TextField<String>("query", queryModel));\r
+               add(form);\r
+                               \r
+               // execute search\r
+               final List<SearchResult> results = new ArrayList<SearchResult>();\r
+               if (!ArrayUtils.isEmpty(searchRepositories) && !StringUtils.isEmpty(query)) {\r
+                       results.addAll(GitBlit.self().search(query, page, pageSize, searchRepositories));\r
+               }\r
+               \r
+               // results header\r
+               if (results.size() == 0) {\r
+                       add(new Label("resultsHeader").setVisible(false));\r
+                       add(new Label("resultsCount").setVisible(false));\r
+               } else {\r
+                       add(new Label("resultsHeader", query).setRenderBodyOnly(true));\r
+                       add(new Label("resultsCount", MessageFormat.format("results {0} - {1} ({2} hits)",\r
+                                       results.get(0).hitId, results.get(results.size() - 1).hitId, results.get(0).totalHits)).\r
+                                       setRenderBodyOnly(true));\r
+               }\r
+               \r
+               // search results view\r
+               ListDataProvider<SearchResult> resultsDp = new ListDataProvider<SearchResult>(results);\r
+               final DataView<SearchResult> resultsView = new DataView<SearchResult>("searchResults", resultsDp) {\r
+                       private static final long serialVersionUID = 1L;\r
+                       public void populateItem(final Item<SearchResult> item) {\r
+                               SearchResult sr = item.getModelObject();\r
+                               switch(sr.type) {\r
+                               case commit: {\r
+                                       Label icon = WicketUtils.newIcon("type", "icon-refresh");\r
+                                       WicketUtils.setHtmlTooltip(icon, "commit");\r
+                                       item.add(icon);\r
+                                       item.add(new LinkPanel("summary", null, sr.summary, CommitPage.class, WicketUtils.newObjectParameter(sr.repository, sr.commitId)));\r
+                                       break;\r
+                               }\r
+                               case blob: {\r
+                                       Label icon = WicketUtils.newIcon("type", "icon-file");\r
+                                       WicketUtils.setHtmlTooltip(icon, "blob");\r
+                                       item.add(icon);\r
+                                       item.add(new LinkPanel("summary", null, sr.path, BlobPage.class, WicketUtils.newPathParameter(sr.repository, sr.branch, sr.path)));\r
+                                       break;\r
+                               }\r
+                               case issue: {\r
+                                       Label icon = WicketUtils.newIcon("type", "icon-file");\r
+                                       WicketUtils.setHtmlTooltip(icon, "issue");\r
+                                       item.add(icon);\r
+                                       item.add(new Label("summary", "issue: " + sr.issueId));\r
+                                       break;\r
+                               }\r
+                               }\r
+                               item.add(new Label("fragment", sr.fragment).setEscapeModelStrings(false).setVisible(!StringUtils.isEmpty(sr.fragment)));\r
+                               item.add(new LinkPanel("repository", null, sr.repository, SummaryPage.class, WicketUtils.newRepositoryParameter(sr.repository)));\r
+                               if (StringUtils.isEmpty(sr.branch)) {\r
+                                       item.add(new Label("branch", "null"));\r
+                               } else {\r
+                                       item.add(new LinkPanel("branch", "branch", StringUtils.getRelativePath(Constants.R_HEADS, sr.branch), LogPage.class, WicketUtils.newObjectParameter(sr.repository, sr.branch)));\r
+                               }\r
+                               item.add(new Label("author", sr.author));\r
+                               item.add(WicketUtils.createDatestampLabel("date", sr.date, getTimeZone()));\r
+                       }\r
+               };\r
+               add(resultsView.setVisible(results.size() > 0));\r
+               \r
+               PageParameters pagerParams = new PageParameters();\r
+               pagerParams.put("repositories", StringUtils.flattenStrings(repositoriesModel.getObject()));\r
+               pagerParams.put("query", queryModel.getObject());\r
+               \r
+               int totalPages = 0;\r
+               if (results.size() > 0) {\r
+                       totalPages = (results.get(0).totalHits / pageSize) + (results.get(0).totalHits % pageSize > 0 ? 1 : 0);\r
+               }\r
+               \r
+               add(new PagerPanel("topPager", page, totalPages, LuceneSearchPage.class, pagerParams));\r
+               add(new PagerPanel("bottomPager", page, totalPages, LuceneSearchPage.class, pagerParams));\r
+       }\r
+       \r
+//     private String buildPager(int currentPage, int count, int total) {\r
+//             int pages = (total / count) + (total % count == 0 ? 0 : 1);\r
+//             \r
+//             // pages are 1-indexed\r
+//             // previous page link\r
+//             if (currentPage <= 1) {\r
+//                     sb.append(MessageFormat.format(li, "disabled", "#", "&larr;"));\r
+//             } else {\r
+//                     List<String> parameters = new ArrayList<String>();\r
+//                     if (!StringUtils.isEmpty(penString)) {\r
+//                             parameters.add(penString);\r
+//                     }\r
+//                     parameters.add(MessageFormat.format(pg, currentPage - 1));\r
+//                     sb.append(MessageFormat.format(li, "", StringUtils.flattenStrings(parameters, "&"), "&larr;"));\r
+//             }\r
+//\r
+//             // page links in middle\r
+//             int minpage = Math.max(1, currentPage - Math.min(2, 2));\r
+//             int maxpage = Math.min(pages, minpage + 4);\r
+//             for (int i = minpage; i <= maxpage; i++) {\r
+//                     String cssClass = "";\r
+//                     if (i == currentPage) {\r
+//                             cssClass = "active";\r
+//                     }\r
+//                     List<String> parameters = new ArrayList<String>();\r
+//                     if (!StringUtils.isEmpty(penString)) {\r
+//                             parameters.add(penString);\r
+//                     }\r
+//                     parameters.add(MessageFormat.format(pg, i));\r
+//                     sb.append(MessageFormat.format(li, cssClass, StringUtils.flattenStrings(parameters, "&"), i));\r
+//             }\r
+//\r
+//             // next page link\r
+//             if (currentPage == pages) {\r
+//                     sb.append(MessageFormat.format(li, "disabled", "#", "&rarr;"));\r
+//             } else {\r
+//                     List<String> parameters = new ArrayList<String>();\r
+//                     if (!StringUtils.isEmpty(penString)) {\r
+//                             parameters.add(penString);\r
+//                     }\r
+//                     parameters.add(MessageFormat.format(pg, currentPage + 1));\r
+//                     sb.append(MessageFormat.format(li, "", StringUtils.flattenStrings(parameters, "&"), "&rarr;"));\r
+//             }\r
+//             return sb.toString();\r
+//     }\r
+\r
+}\r
index 4a83b876054e0be4e53884a322df0af3a90c8d35..cd3c8a2e86c11d6a2125a23d82d3665968cfb6dd 100644 (file)
@@ -44,10 +44,10 @@ import com.gitblit.Keys;
 import com.gitblit.PagesServlet;\r
 import com.gitblit.SyndicationServlet;\r
 import com.gitblit.models.RepositoryModel;\r
+import com.gitblit.utils.ArrayUtils;\r
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.StringUtils;\r
 import com.gitblit.utils.TicgitUtils;\r
-import com.gitblit.wicket.GitBlitWebApp;\r
 import com.gitblit.wicket.GitBlitWebSession;\r
 import com.gitblit.wicket.PageRegistration;\r
 import com.gitblit.wicket.PageRegistration.OtherPageLink;\r
@@ -229,8 +229,6 @@ public abstract class RepositoryPage extends BasePage {
 \r
        protected Component createPersonPanel(String wicketId, PersonIdent identity,\r
                        Constants.SearchType searchType) {\r
-               GitBlitWebApp app = (GitBlitWebApp) GitBlitWebSession.get().getApplication();\r
-               final Class<? extends BasePage> searchPageClass = app.getSearchPageClass();\r
                String name = identity == null ? "" : identity.getName();\r
                String address = identity == null ? "" : identity.getEmailAddress();\r
                boolean showEmail = GitBlit.getBoolean(Keys.web.showEmailAddresses, false);\r
@@ -244,20 +242,20 @@ public abstract class RepositoryPage extends BasePage {
                                }\r
                        }\r
                        Fragment partial = new Fragment(wicketId, "partialPersonIdent", this);\r
-                       LinkPanel link = new LinkPanel("personName", "list", value, searchPageClass,\r
+                       LinkPanel link = new LinkPanel("personName", "list", value, GitSearchPage.class,\r
                                        WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType));\r
                        setPersonSearchTooltip(link, value, searchType);\r
                        partial.add(link);\r
                        return partial;\r
                } else {\r
                        Fragment fullPerson = new Fragment(wicketId, "fullPersonIdent", this);\r
-                       LinkPanel nameLink = new LinkPanel("personName", "list", name, searchPageClass,\r
+                       LinkPanel nameLink = new LinkPanel("personName", "list", name, GitSearchPage.class,\r
                                        WicketUtils.newSearchParameter(repositoryName, objectId, name, searchType));\r
                        setPersonSearchTooltip(nameLink, name, searchType);\r
                        fullPerson.add(nameLink);\r
 \r
                        LinkPanel addressLink = new LinkPanel("personAddress", "list", "<" + address + ">",\r
-                                       searchPageClass, WicketUtils.newSearchParameter(repositoryName, objectId,\r
+                                       GitSearchPage.class, WicketUtils.newSearchParameter(repositoryName, objectId,\r
                                                        address, searchType));\r
                        setPersonSearchTooltip(addressLink, address, searchType);\r
                        fullPerson.add(addressLink);\r
@@ -360,8 +358,13 @@ public abstract class RepositoryPage extends BasePage {
                                        break;\r
                                }\r
                        }\r
-                       GitBlitWebApp app = (GitBlitWebApp) GitBlitWebSession.get().getApplication();\r
-                       setResponsePage(app.getSearchPageClass(),\r
+                       Class<? extends BasePage> searchPageClass = GitSearchPage.class;\r
+                       RepositoryModel model = GitBlit.self().getRepositoryModel(repositoryName);\r
+                       if (!ArrayUtils.isEmpty(model.indexedBranches)) {\r
+                               // this repository is Lucene-indexed\r
+                               searchPageClass = LuceneSearchPage.class;\r
+                       }\r
+                       setResponsePage(searchPageClass,\r
                                        WicketUtils.newSearchParameter(repositoryName, null, searchString, searchType));\r
                }\r
        }\r
index d81fae1bb59c49a901fe7847f79b8ef043a41b11..f110cb317cd6b5f3be7466fba24dc2a3667cee01 100644 (file)
@@ -102,7 +102,7 @@ public abstract class RootPage extends BasePage {
                                getRootPageParameters()));\r
                pages.add(new PageRegistration("gb.activity", ActivityPage.class, getRootPageParameters()));\r
                if (GitBlit.getBoolean(Keys.lucene.enable, false)) {\r
-                       pages.add(new PageRegistration("gb.search", LucenePage.class));\r
+                       pages.add(new PageRegistration("gb.search", LuceneSearchPage.class));\r
                }\r
                if (showAdmin) {\r
                        pages.add(new PageRegistration("gb.users", UsersPage.class));\r
diff --git a/src/com/gitblit/wicket/pages/SearchPage.html b/src/com/gitblit/wicket/pages/SearchPage.html
deleted file mode 100644 (file)
index 9bb1f41..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
-<html xmlns="http://www.w3.org/1999/xhtml"  \r
-      xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd"  \r
-      xml:lang="en"  \r
-      lang="en"> \r
-\r
-<body>\r
-<wicket:extend>\r
-\r
-       <!-- pager links -->\r
-       <div style="padding-top:5px;">\r
-               <a wicket:id="firstPageTop"><wicket:message key="gb.pageFirst"></wicket:message></a> | <a wicket:id="prevPageTop"><wicket:message key="gb.pagePrevious"></wicket:message></a> | <a wicket:id="nextPageTop"><wicket:message key="gb.pageNext"></wicket:message></a> \r
-       </div>\r
-       \r
-       <!-- history -->\r
-       <div style="margin-top:5px;" wicket:id="searchPanel">[search panel]</div>\r
-\r
-       <!-- pager links -->\r
-       <div style="padding-bottom:5px;">\r
-               <a wicket:id="firstPageBottom"><wicket:message key="gb.pageFirst"></wicket:message></a> | <a wicket:id="prevPageBottom"><wicket:message key="gb.pagePrevious"></wicket:message></a> | <a wicket:id="nextPageBottom"><wicket:message key="gb.pageNext"></wicket:message></a> \r
-       </div>\r
-\r
-</wicket:extend>\r
-</body>\r
-</html>
\ No newline at end of file
diff --git a/src/com/gitblit/wicket/pages/SearchPage.java b/src/com/gitblit/wicket/pages/SearchPage.java
deleted file mode 100644 (file)
index d4728d7..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package com.gitblit.wicket.pages;\r
-\r
-import org.apache.wicket.PageParameters;\r
-import org.apache.wicket.markup.html.link.BookmarkablePageLink;\r
-\r
-import com.gitblit.Constants;\r
-import com.gitblit.wicket.WicketUtils;\r
-import com.gitblit.wicket.panels.SearchPanel;\r
-\r
-public class SearchPage extends RepositoryPage {\r
-\r
-       public SearchPage(PageParameters params) {\r
-               super(params);\r
-\r
-               String value = WicketUtils.getSearchString(params);\r
-               String type = WicketUtils.getSearchType(params);\r
-               Constants.SearchType searchType = Constants.SearchType.forName(type);\r
-\r
-               int pageNumber = WicketUtils.getPage(params);\r
-               int prevPage = Math.max(0, pageNumber - 1);\r
-               int nextPage = pageNumber + 1;\r
-\r
-               SearchPanel search = new SearchPanel("searchPanel", repositoryName, objectId, value,\r
-                               searchType, getRepository(), -1, pageNumber - 1);\r
-               boolean hasMore = search.hasMore();\r
-               add(search);\r
-\r
-               add(new BookmarkablePageLink<Void>("firstPageTop", SearchPage.class,\r
-                               WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType))\r
-                               .setEnabled(pageNumber > 1));\r
-               add(new BookmarkablePageLink<Void>("prevPageTop", SearchPage.class,\r
-                               WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType,\r
-                                               prevPage)).setEnabled(pageNumber > 1));\r
-               add(new BookmarkablePageLink<Void>("nextPageTop", SearchPage.class,\r
-                               WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType,\r
-                                               nextPage)).setEnabled(hasMore));\r
-\r
-               add(new BookmarkablePageLink<Void>("firstPageBottom", SearchPage.class,\r
-                               WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType))\r
-                               .setEnabled(pageNumber > 1));\r
-               add(new BookmarkablePageLink<Void>("prevPageBottom", SearchPage.class,\r
-                               WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType,\r
-                                               prevPage)).setEnabled(pageNumber > 1));\r
-               add(new BookmarkablePageLink<Void>("nextPageBottom", SearchPage.class,\r
-                               WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType,\r
-                                               nextPage)).setEnabled(hasMore));\r
-\r
-       }\r
-\r
-       @Override\r
-       protected String getPageName() {\r
-               return getString("gb.search");\r
-       }\r
-}\r
index 37ab9f0ca45c15886f28bbc2a90aa67da92de728..a7e68d86b60f51a42f2844fa55afaa43b177c9aa 100644 (file)
@@ -28,14 +28,11 @@ import com.gitblit.Constants;
 import com.gitblit.models.Activity;\r
 import com.gitblit.models.Activity.RepositoryCommit;\r
 import com.gitblit.utils.StringUtils;\r
-import com.gitblit.wicket.GitBlitWebApp;\r
-import com.gitblit.wicket.GitBlitWebSession;\r
 import com.gitblit.wicket.WicketUtils;\r
-import com.gitblit.wicket.pages.BasePage;\r
 import com.gitblit.wicket.pages.CommitDiffPage;\r
 import com.gitblit.wicket.pages.CommitPage;\r
 import com.gitblit.wicket.pages.LogPage;\r
-import com.gitblit.wicket.pages.SearchPage;\r
+import com.gitblit.wicket.pages.GitSearchPage;\r
 import com.gitblit.wicket.pages.SummaryPage;\r
 import com.gitblit.wicket.pages.TreePage;\r
 \r
@@ -54,9 +51,6 @@ public class ActivityPanel extends BasePanel {
 \r
                Collections.sort(recentActivity);\r
                \r
-               GitBlitWebApp app = (GitBlitWebApp) GitBlitWebSession.get().getApplication();\r
-               final Class<? extends BasePage> searchPageClass = app.getSearchPageClass();\r
-\r
                DataView<Activity> activityView = new DataView<Activity>("activity",\r
                                new ListDataProvider<Activity>(recentActivity)) {\r
                        private static final long serialVersionUID = 1L;\r
@@ -92,7 +86,7 @@ public class ActivityPanel extends BasePanel {
                                                // author search link\r
                                                String author = commit.getAuthorIdent().getName();\r
                                                LinkPanel authorLink = new LinkPanel("author", "list", author,\r
-                                                               searchPageClass, WicketUtils.newSearchParameter(commit.repository,\r
+                                                               GitSearchPage.class, WicketUtils.newSearchParameter(commit.repository,\r
                                                                                commit.getName(), author, Constants.SearchType.AUTHOR), true);\r
                                                setPersonSearchTooltip(authorLink, author, Constants.SearchType.AUTHOR);\r
                                                fragment.add(authorLink);\r
index 58862095a2badb468da9b688974d59ca0cff1844..5f1b0588224544d3ec975a212ff20d0d4fe99225 100644 (file)
@@ -35,15 +35,12 @@ import com.gitblit.models.RefModel;
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.StringUtils;\r
-import com.gitblit.wicket.GitBlitWebApp;\r
-import com.gitblit.wicket.GitBlitWebSession;\r
 import com.gitblit.wicket.WicketUtils;\r
-import com.gitblit.wicket.pages.BasePage;\r
 import com.gitblit.wicket.pages.BranchesPage;\r
 import com.gitblit.wicket.pages.CommitPage;\r
 import com.gitblit.wicket.pages.LogPage;\r
 import com.gitblit.wicket.pages.MetricsPage;\r
-import com.gitblit.wicket.pages.SearchPage;\r
+import com.gitblit.wicket.pages.GitSearchPage;\r
 import com.gitblit.wicket.pages.TreePage;\r
 \r
 public class BranchesPanel extends BasePanel {\r
@@ -78,9 +75,6 @@ public class BranchesPanel extends BasePanel {
                        add(new Label("branches", new StringResourceModel("gb.branches", this, null)));\r
                }\r
 \r
-               GitBlitWebApp app = (GitBlitWebApp) GitBlitWebSession.get().getApplication();\r
-               final Class<? extends BasePage> searchPageClass = app.getSearchPageClass();\r
-\r
                ListDataProvider<RefModel> branchesDp = new ListDataProvider<RefModel>(branches);\r
                DataView<RefModel> branchesView = new DataView<RefModel>("branch", branchesDp) {\r
                        private static final long serialVersionUID = 1L;\r
@@ -97,7 +91,7 @@ public class BranchesPanel extends BasePanel {
 \r
                                String author = entry.getAuthorIdent().getName();\r
                                LinkPanel authorLink = new LinkPanel("branchAuthor", "list", author,\r
-                                               searchPageClass, WicketUtils.newSearchParameter(model.name,\r
+                                               GitSearchPage.class, WicketUtils.newSearchParameter(model.name,\r
                                                                entry.getName(), author, Constants.SearchType.AUTHOR));\r
                                setPersonSearchTooltip(authorLink, author, Constants.SearchType.AUTHOR);\r
                                item.add(authorLink);\r
index 23eb2b3f3744c1d421482aef79cc3a64fc8c9ca7..15a4aa276acc8a7986d64f38864c860e2f5aa163 100644 (file)
@@ -38,16 +38,13 @@ import com.gitblit.models.PathModel.PathChangeModel;
 import com.gitblit.models.RefModel;\r
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.StringUtils;\r
-import com.gitblit.wicket.GitBlitWebApp;\r
-import com.gitblit.wicket.GitBlitWebSession;\r
 import com.gitblit.wicket.WicketUtils;\r
-import com.gitblit.wicket.pages.BasePage;\r
 import com.gitblit.wicket.pages.BlobDiffPage;\r
 import com.gitblit.wicket.pages.BlobPage;\r
 import com.gitblit.wicket.pages.CommitDiffPage;\r
 import com.gitblit.wicket.pages.CommitPage;\r
 import com.gitblit.wicket.pages.HistoryPage;\r
-import com.gitblit.wicket.pages.SearchPage;\r
+import com.gitblit.wicket.pages.GitSearchPage;\r
 import com.gitblit.wicket.pages.TreePage;\r
 \r
 public class HistoryPanel extends BasePanel {\r
@@ -97,9 +94,6 @@ public class HistoryPanel extends BasePanel {
                // breadcrumbs\r
                add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, path, objectId));\r
 \r
-               GitBlitWebApp app = (GitBlitWebApp) GitBlitWebSession.get().getApplication();\r
-               final Class<? extends BasePage> searchPageClass = app.getSearchPageClass();\r
-\r
                ListDataProvider<RevCommit> dp = new ListDataProvider<RevCommit>(commits);\r
                DataView<RevCommit> logView = new DataView<RevCommit>("commit", dp) {\r
                        private static final long serialVersionUID = 1L;\r
@@ -114,7 +108,8 @@ public class HistoryPanel extends BasePanel {
                                // author search link\r
                                String author = entry.getAuthorIdent().getName();\r
                                LinkPanel authorLink = new LinkPanel("commitAuthor", "list", author,\r
-                                               searchPageClass, WicketUtils.newSearchParameter(repositoryName, objectId,\r
+                                               GitSearchPage.class,\r
+                                               WicketUtils.newSearchParameter(repositoryName, objectId,\r
                                                                author, Constants.SearchType.AUTHOR));\r
                                setPersonSearchTooltip(authorLink, author, Constants.SearchType.AUTHOR);\r
                                item.add(authorLink);\r
index 380cc31507c992dc6d8f07d561ef11ad38983dd1..5ced2f6f5cdd5cfd76a7cbde67220cd3b0fc57af 100644 (file)
@@ -35,14 +35,11 @@ import com.gitblit.Keys;
 import com.gitblit.models.RefModel;\r
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.StringUtils;\r
-import com.gitblit.wicket.GitBlitWebApp;\r
-import com.gitblit.wicket.GitBlitWebSession;\r
 import com.gitblit.wicket.WicketUtils;\r
-import com.gitblit.wicket.pages.BasePage;\r
 import com.gitblit.wicket.pages.CommitDiffPage;\r
 import com.gitblit.wicket.pages.CommitPage;\r
 import com.gitblit.wicket.pages.LogPage;\r
-import com.gitblit.wicket.pages.SearchPage;\r
+import com.gitblit.wicket.pages.GitSearchPage;\r
 import com.gitblit.wicket.pages.TreePage;\r
 \r
 public class LogPanel extends BasePanel {\r
@@ -85,9 +82,6 @@ public class LogPanel extends BasePanel {
                                        WicketUtils.newRepositoryParameter(repositoryName)));\r
                }\r
 \r
-               GitBlitWebApp app = (GitBlitWebApp) GitBlitWebSession.get().getApplication();\r
-               final Class<? extends BasePage> searchPageClass = app.getSearchPageClass();\r
-\r
                ListDataProvider<RevCommit> dp = new ListDataProvider<RevCommit>(commits);\r
                DataView<RevCommit> logView = new DataView<RevCommit>("commit", dp) {\r
                        private static final long serialVersionUID = 1L;\r
@@ -102,8 +96,8 @@ public class LogPanel extends BasePanel {
                                // author search link\r
                                String author = entry.getAuthorIdent().getName();\r
                                LinkPanel authorLink = new LinkPanel("commitAuthor", "list", author,\r
-                                               searchPageClass, WicketUtils.newSearchParameter(repositoryName, objectId,\r
-                                                               author, Constants.SearchType.AUTHOR));\r
+                                               GitSearchPage.class, WicketUtils.newSearchParameter(repositoryName,\r
+                                                               objectId, author, Constants.SearchType.AUTHOR));\r
                                setPersonSearchTooltip(authorLink, author, Constants.SearchType.AUTHOR);\r
                                item.add(authorLink);\r
 \r
index b9b13a50cbaad6bdfc307ea377d1695df3e58248..4d195c52d0e663aa17ffd9f15482410481fb87f1 100644 (file)
@@ -37,7 +37,7 @@ import com.gitblit.utils.StringUtils;
 import com.gitblit.wicket.WicketUtils;\r
 import com.gitblit.wicket.pages.CommitDiffPage;\r
 import com.gitblit.wicket.pages.CommitPage;\r
-import com.gitblit.wicket.pages.SearchPage;\r
+import com.gitblit.wicket.pages.GitSearchPage;\r
 import com.gitblit.wicket.pages.TreePage;\r
 \r
 public class SearchPanel extends BasePanel {\r
@@ -92,7 +92,7 @@ public class SearchPanel extends BasePanel {
                                // author search link\r
                                String author = entry.getAuthorIdent().getName();\r
                                LinkPanel authorLink = new LinkPanel("commitAuthor", "list", author,\r
-                                               SearchPage.class, WicketUtils.newSearchParameter(repositoryName, objectId,\r
+                                               GitSearchPage.class, WicketUtils.newSearchParameter(repositoryName, objectId,\r
                                                                author, Constants.SearchType.AUTHOR));\r
                                setPersonSearchTooltip(authorLink, author, Constants.SearchType.AUTHOR);\r
                                item.add(authorLink);\r