]> source.dussan.org Git - gitblit.git/commitdiff
Add search form to the page nav links panel within a repository.
authorJames Moger <james.moger@gitblit.com>
Mon, 18 Apr 2011 21:50:31 +0000 (17:50 -0400)
committerJames Moger <james.moger@gitblit.com>
Mon, 18 Apr 2011 21:50:31 +0000 (17:50 -0400)
src/com/gitblit/utils/JGitUtils.java
src/com/gitblit/wicket/GitBlitWebApp.java
src/com/gitblit/wicket/pages/SummaryPage.html
src/com/gitblit/wicket/panels/PageLinksPanel.html
src/com/gitblit/wicket/panels/PageLinksPanel.java
src/com/gitblit/wicket/resources/gitblit.css

index 3b69c2258449c90ccd5683b3434b8a3a43a5d715..49fbf1ef89d475cb34d878f65338e43fff74c829 100644 (file)
@@ -519,6 +519,10 @@ public class JGitUtils {
                        }\r
                        return null;\r
                }\r
+               \r
+               public String toString() {\r
+                       return name().toLowerCase();\r
+               }\r
        }\r
 \r
        public static List<RevCommit> searchRevlogs(Repository r, String objectId, String value, final SearchType type, int offset, int maxCount) {\r
index dc1e2c9ce1ef3186af85dc97a1322fbe657c558e..106981e3b9431c373f1549ae6244f8b2c2cebe03 100644 (file)
@@ -6,8 +6,6 @@ import org.apache.wicket.Request;
 import org.apache.wicket.Response;\r
 import org.apache.wicket.Session;\r
 import org.apache.wicket.protocol.http.WebApplication;\r
-import org.apache.wicket.protocol.http.request.urlcompressing.UrlCompressingWebRequestProcessor;\r
-import org.apache.wicket.request.IRequestCycleProcessor;\r
 import org.apache.wicket.request.target.coding.MixedParamUrlCodingStrategy;\r
 \r
 import com.gitblit.GitBlit;\r
@@ -86,11 +84,6 @@ public class GitBlitWebApp extends WebApplication {
                return new GitBlitWebSession(request);\r
        }\r
 \r
-       @Override\r
-       protected final IRequestCycleProcessor newRequestCycleProcessor() {\r
-               return new UrlCompressingWebRequestProcessor();\r
-       }\r
-\r
        @Override\r
        public final String getConfigurationType() {\r
                if (GitBlit.self().isDebugMode())\r
index 7075bd2ccadd7cabb66cc083f7f2f3242cda52b8..47c10b317d0c8ed24c12d366ffd8044f459d4c13 100644 (file)
@@ -10,7 +10,7 @@
        <!-- page nav links --> \r
        <div wicket:id="pageLinks">[page links]</div>\r
        \r
-       <div>\r
+       <div style="clear:both;">\r
                <!-- Repository Activity Chart -->      \r
                <div style="width:400px;float:right;">\r
                        <img class="activityGraph" wicket:id="commitsChart" />\r
index f2e4d316faaedb8cef536b415036a0e3e8aa7efe..40ec634f04d775ea97b3f69a16576500c6eefc97 100644 (file)
@@ -5,9 +5,20 @@
       lang="en"> \r
 \r
 <wicket:panel>\r
-       <!-- page nav links --> \r
-       <div class="page_nav">\r
-               <a wicket:id="summary"><wicket:message key="gb.summary"></wicket:message></a> | <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a> | <a wicket:id="branches"><wicket:message key="gb.branches"></wicket:message></a> | <a wicket:id="tags"><wicket:message key="gb.tags"></wicket:message></a> | <a wicket:id="tree"><wicket:message key="gb.tree"></wicket:message></a> <span wicket:id="extra"><span wicket:id="extraSeparator"></span><span wicket:id="extraLink"></span></span>\r
+       <!-- floating search form on right -->\r
+       <form wicket:id="searchForm">\r
+               <div class="search">\r
+                       <select wicket:id="searchType"/>\r
+                       <wicket:message key="gb.search"></wicket:message>:\r
+                       <input type="text" id="searchBox" wicket:id="searchBox" value=""/>\r
+               </div>\r
+       </form>\r
+               \r
+       <!-- page nav links -->\r
+       <div class="page_nav">          \r
+               <div>\r
+                       <a wicket:id="summary"><wicket:message key="gb.summary"></wicket:message></a> | <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a> | <a wicket:id="branches"><wicket:message key="gb.branches"></wicket:message></a> | <a wicket:id="tags"><wicket:message key="gb.tags"></wicket:message></a> | <a wicket:id="tree"><wicket:message key="gb.tree"></wicket:message></a> <span wicket:id="extra"><span wicket:id="extraSeparator"></span><span wicket:id="extraLink"></span></span>\r
+               </div>\r
        </div>  \r
 </wicket:panel>\r
 </html>
\ No newline at end of file
index f8824db56ebda74c36bbb4ec42be88a1a2e47ad9..65034051337d6d76d73269c4e289d6c315fdf1df 100644 (file)
@@ -2,26 +2,34 @@ package com.gitblit.wicket.panels;
 \r
 import java.text.MessageFormat;\r
 import java.util.ArrayList;\r
+import java.util.Arrays;\r
 import java.util.HashMap;\r
 import java.util.List;\r
 import java.util.Map;\r
 \r
 import org.apache.wicket.Component;\r
 import org.apache.wicket.markup.html.basic.Label;\r
+import org.apache.wicket.markup.html.form.DropDownChoice;\r
+import org.apache.wicket.markup.html.form.StatelessForm;\r
+import org.apache.wicket.markup.html.form.TextField;\r
 import org.apache.wicket.markup.html.link.BookmarkablePageLink;\r
 import org.apache.wicket.markup.html.panel.Panel;\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.IModel;\r
+import org.apache.wicket.model.Model;\r
 import org.eclipse.jgit.lib.Repository;\r
 \r
 import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.utils.JGitUtils;\r
+import com.gitblit.utils.JGitUtils.SearchType;\r
 import com.gitblit.wicket.LinkPanel;\r
 import com.gitblit.wicket.WicketUtils;\r
 import com.gitblit.wicket.pages.BranchesPage;\r
 import com.gitblit.wicket.pages.LogPage;\r
+import com.gitblit.wicket.pages.SearchPage;\r
 import com.gitblit.wicket.pages.SummaryPage;\r
 import com.gitblit.wicket.pages.TagsPage;\r
 import com.gitblit.wicket.pages.TicketsPage;\r
@@ -78,6 +86,8 @@ public class PageLinksPanel extends Panel {
                        }\r
                };\r
                add(extrasView);\r
+\r
+               add(new SearchForm("searchForm", repositoryName));\r
        }\r
 \r
        public void disablePageLink(String pageName) {\r
@@ -93,4 +103,30 @@ public class PageLinksPanel extends Panel {
                        }\r
                }\r
        }\r
+\r
+       class SearchForm extends StatelessForm<Void> {\r
+               private static final long serialVersionUID = 1L;\r
+\r
+               private final String repositoryName;\r
+\r
+               private final IModel<String> searchBoxModel = new Model<String>("");\r
+               \r
+               private final IModel<SearchType> searchTypeModel = new Model<SearchType>(SearchType.COMMIT);\r
+\r
+               public SearchForm(String id, String repositoryName) {\r
+                       super(id);\r
+                       this.repositoryName = repositoryName;\r
+                       DropDownChoice<SearchType> searchType = new DropDownChoice<SearchType>("searchType", Arrays.asList(SearchType.values()));\r
+                       searchType.setModel(searchTypeModel);\r
+                       add(searchType);\r
+                       add(new TextField<String>("searchBox", searchBoxModel));\r
+               }\r
+\r
+               @Override\r
+               public void onSubmit() {\r
+                       SearchType searchType = searchTypeModel.getObject();\r
+                       String searchString = searchBoxModel.getObject();\r
+                       setResponsePage(SearchPage.class, WicketUtils.newSearchParameter(repositoryName, null, searchString, searchType));\r
+               }\r
+       }\r
 }
\ No newline at end of file
index 736dbb3644d74b27c10fb27d95937af76d37546f..8264cbb5958d9ae76e9dc316d0f6145908bddfcb 100644 (file)
@@ -5,6 +5,10 @@ html, body, table, dl, dt, dd, ol, ul, li, form, a, span, tr, th, td, div, em {
        font-family: verdana, sans-serif;\r
        font-size: 12px;\r
        line-height: 15px;\r
+       margin: 0;\r
+       padding: 0;\r
+       border: 0;\r
+       outline: 0;\r
 }\r
 \r
 body {\r
@@ -141,7 +145,7 @@ div.page_footer {
 div.page_nav {\r
        color: #ddd;\r
        background-color: #000070;\r
-       padding: 5px;\r
+       padding: 7px;\r
 }\r
 \r
 div.page_nav a {\r
@@ -161,6 +165,13 @@ div.page_nav2 {
        padding: 2px 5px 7px 5px;       \r
 }\r
 \r
+div.search {\r
+       color:yellow;\r
+       text-align:right;\r
+       float:right;\r
+       padding:3px;\r
+}\r
+\r
 .repositories_message {\r
        border: solid #bbb;\r
        border-width: 0px 0px 1px;\r