]> source.dussan.org Git - gitblit.git/commitdiff
Display tag links on indexed commits and tweaked term highlight color
authorJames Moger <james.moger@gitblit.com>
Tue, 20 Mar 2012 23:47:21 +0000 (19:47 -0400)
committerJames Moger <james.moger@gitblit.com>
Tue, 20 Mar 2012 23:47:21 +0000 (19:47 -0400)
resources/gitblit.css
src/com/gitblit/wicket/pages/LuceneSearchPage.html
src/com/gitblit/wicket/pages/LuceneSearchPage.java

index 0b285fb4fdf8ffb1feb039f6040a6c91496be8a2..14fe038266d43fdd14148d4228dd09a626388f38 100644 (file)
@@ -295,8 +295,7 @@ div.searchResult .fragment {
 }\r
 \r
 div.searchResult .highlight {\r
-       background-color: #ffffaa;      \r
-       border: 1px solid #ffcc00;\r
+       background-color: #ccff66;\r
        padding: 0 2px;\r
 }\r
 \r
index 76390589ed7e8513d29c144f7fc52569109e9054..3014bfc4f25c35237fc0cdb713fec1a946d237f7 100644 (file)
        <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><i wicket:id="type"></i><span class="summary" wicket:id="summary"></span> <span wicket:id="tags" style="padding-left:10px;"></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
+                       <span class="repository" wicket:id="repository"></span>:<span class="branch" wicket:id="branch"></span>         \r
                </div>\r
        </div>\r
 \r
 \r
        </div>  \r
 </body>\r
+\r
+       <wicket:fragment wicket:id="tagsPanel">\r
+               <span wicket:id="tag">\r
+                       <span wicket:id="tagLink">[tag]</span>\r
+               </span> \r
+       </wicket:fragment>\r
+\r
 </wicket:extend>\r
 </html>
\ No newline at end of file
index 69fb920385bb7a8ca7cb8b35acd40eaa604b66da..e43935e3aff5dab5a1df1ae67a5ae851ebf6df32 100644 (file)
@@ -19,11 +19,13 @@ import java.text.MessageFormat;
 import java.util.ArrayList;\r
 import java.util.List;\r
 \r
+import org.apache.wicket.Component;\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.html.panel.Fragment;\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
@@ -71,7 +73,7 @@ public class LuceneSearchPage extends RootPage {
                                repositories.add(repository);\r
                        }\r
 \r
-                       page = WicketUtils.getPage(params);     \r
+                       page = WicketUtils.getPage(params);\r
                        \r
                        if (params.containsKey("repositories")) {\r
                                String value = params.getString("repositories", "");\r
@@ -175,13 +177,32 @@ public class LuceneSearchPage extends RootPage {
                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
+                               final 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
+                                       // show tags\r
+                                       Fragment fragment = new Fragment("tags", "tagsPanel", LuceneSearchPage.this);\r
+                                       List<String> tags = sr.tags;\r
+                                       if (tags == null) {\r
+                                               tags = new ArrayList<String>();\r
+                                       }\r
+                                       ListDataProvider<String> tagsDp = new ListDataProvider<String>(tags);\r
+                                       final DataView<String> tagsView = new DataView<String>("tag", tagsDp) {\r
+                                               private static final long serialVersionUID = 1L;\r
+                                               public void populateItem(final Item<String> item) {\r
+                                                       String tag = item.getModelObject();\r
+                                                       Component c = new LinkPanel("tagLink", null, tag, TagPage.class,\r
+                                                                       WicketUtils.newObjectParameter(sr.repository, Constants.R_TAGS + tag));\r
+                                                       WicketUtils.setCssClass(c, "tagRef");                                                   \r
+                                                       item.add(c);\r
+                                               }\r
+                                       };\r
+                                       fragment.add(tagsView);\r
+                                       item.add(fragment);\r
                                        break;\r
                                }\r
                                case blob: {\r
@@ -189,6 +210,7 @@ public class LuceneSearchPage extends RootPage {
                                        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
+                                       item.add(new Label("tags").setVisible(false));\r
                                        break;\r
                                }\r
                                case issue: {\r
@@ -196,6 +218,7 @@ public class LuceneSearchPage extends RootPage {
                                        WicketUtils.setHtmlTooltip(icon, "issue");\r
                                        item.add(icon);\r
                                        item.add(new Label("summary", "issue: " + sr.issueId));\r
+                                       item.add(new Label("tags").setVisible(false));\r
                                        break;\r
                                }\r
                                }\r
@@ -224,51 +247,4 @@ public class LuceneSearchPage extends RootPage {
                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