]> source.dussan.org Git - gitblit.git/commitdiff
Integrated pagelinks into RepositoryPage. Fixed string encoding.
authorJames Moger <james.moger@gitblit.com>
Thu, 28 Apr 2011 00:55:38 +0000 (20:55 -0400)
committerJames Moger <james.moger@gitblit.com>
Thu, 28 Apr 2011 00:55:38 +0000 (20:55 -0400)
24 files changed:
src/com/gitblit/utils/JGitUtils.java
src/com/gitblit/utils/StringUtils.java
src/com/gitblit/wicket/RepositoryPage.html [new file with mode: 0644]
src/com/gitblit/wicket/RepositoryPage.java
src/com/gitblit/wicket/pages/BlobDiffPage.html
src/com/gitblit/wicket/pages/BlobPage.html
src/com/gitblit/wicket/pages/BranchesPage.html
src/com/gitblit/wicket/pages/CommitDiffPage.html
src/com/gitblit/wicket/pages/CommitPage.html
src/com/gitblit/wicket/pages/DocsPage.html
src/com/gitblit/wicket/pages/HistoryPage.html
src/com/gitblit/wicket/pages/LogPage.html
src/com/gitblit/wicket/pages/MarkdownPage.html
src/com/gitblit/wicket/pages/MarkdownPage.java
src/com/gitblit/wicket/pages/SearchPage.html
src/com/gitblit/wicket/pages/SummaryPage.html
src/com/gitblit/wicket/pages/TagPage.html
src/com/gitblit/wicket/pages/TagsPage.html
src/com/gitblit/wicket/pages/TicketPage.html
src/com/gitblit/wicket/pages/TicketsPage.html
src/com/gitblit/wicket/pages/TreePage.html
src/com/gitblit/wicket/panels/PageLinksPanel.html [deleted file]
src/com/gitblit/wicket/panels/PageLinksPanel.java [deleted file]
src/com/gitblit/wicket/resources/gitblit.css

index e5dbfd2d85a56308606af81578ccd18306fe859b..8814c1f4ccdf62b2fca741c37307e2d39f33bd99 100644 (file)
@@ -4,6 +4,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.File;\r
 import java.io.IOException;\r
 import java.io.InputStream;\r
+import java.nio.charset.Charset;\r
 import java.text.DateFormat;\r
 import java.text.ParseException;\r
 import java.text.SimpleDateFormat;\r
@@ -264,12 +265,14 @@ public class JGitUtils {
        }\r
 \r
        public static String getRawContentAsString(Repository r, RevBlob blob) {\r
-               return new String(getRawContent(r, blob));\r
+               byte [] content = getRawContent(r, blob);\r
+               return new String(content, Charset.forName("UTF-8"));\r
        }\r
 \r
        public static String getRawContentAsString(Repository r, RevCommit commit, String blobPath) {\r
                RevObject obj = getRevObject(r, commit.getTree(), blobPath);\r
-               return new String(getRawContent(r, (RevBlob) obj));\r
+               byte [] content = getRawContent(r, (RevBlob) obj);\r
+               return new String(content, Charset.forName("UTF-8"));\r
        }\r
 \r
        public static List<PathModel> getFilesInPath(Repository r, String basePath, String objectId) {\r
index 6d646df89db5607fb6c81aa9c1a9e2b35662784e..ff9fac4ff6a355c3f71a21ead3138ca612d1bb65 100644 (file)
@@ -1,12 +1,18 @@
 package com.gitblit.utils;\r
 \r
+import java.io.IOException;\r
+import java.io.StringReader;\r
+import java.io.StringWriter;\r
 import java.io.UnsupportedEncodingException;\r
 import java.security.MessageDigest;\r
 import java.security.NoSuchAlgorithmException;\r
 import java.util.List;\r
 \r
+import org.tautua.markdownpapers.Markdown;\r
+import org.tautua.markdownpapers.parser.ParseException;\r
+\r
 public class StringUtils {\r
-       \r
+\r
        public static boolean isEmpty(String value) {\r
                return value == null || value.trim().length() == 0;\r
        }\r
@@ -107,4 +113,22 @@ public class StringUtils {
                }\r
        }\r
 \r
+       public static String transformMarkdown(String markdown) throws java.text.ParseException {\r
+               // Read raw markdown content and transform it to html           \r
+               StringReader reader = new StringReader(markdown);\r
+               StringWriter writer = new StringWriter();\r
+               try {\r
+                       Markdown md = new Markdown();\r
+                       md.transform(reader, writer);\r
+                       return writer.toString();\r
+               } catch (ParseException p) {                    \r
+                       throw new java.text.ParseException(p.getMessage(), 0);\r
+               } finally {\r
+                       reader.close();\r
+                       try {\r
+                               writer.close();\r
+                       } catch (IOException e) {\r
+                       }\r
+               }\r
+       }\r
 }\r
diff --git a/src/com/gitblit/wicket/RepositoryPage.html b/src/com/gitblit/wicket/RepositoryPage.html
new file mode 100644 (file)
index 0000000..4b3f2e7
--- /dev/null
@@ -0,0 +1,30 @@
+<!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
+               <!-- page header bar -->        \r
+               <div>\r
+                       <!-- floating search form on right -->\r
+                       <form wicket:id="searchForm">\r
+                               <div class="search">\r
+                                       <select wicket:id="searchType"/>                        \r
+                                       <input type="text" id="searchBox" wicket:id="searchBox" size="25" value=""/>\r
+                               </div>\r
+                       </form>\r
+               \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
+                       </div>\r
+               </div>\r
+       \r
+               <!-- page content -->\r
+               <wicket:child />\r
+               \r
+       </wicket:extend>\r
+</body>\r
+</html>
\ No newline at end of file
index 30e41a5fa19f879a363cff4004d364ef696c1ed7..28cdcd037cf1dde6285ed06ecdf118c6a3fda6a7 100644 (file)
@@ -1,5 +1,7 @@
 package com.gitblit.wicket;\r
 \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
@@ -7,7 +9,16 @@ import java.util.Map;
 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.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.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
+import org.apache.wicket.model.IModel;\r
+import org.apache.wicket.model.Model;\r
 import org.eclipse.jgit.diff.DiffEntry.ChangeType;\r
 import org.eclipse.jgit.lib.PersonIdent;\r
 import org.eclipse.jgit.lib.Repository;\r
@@ -20,9 +31,15 @@ import com.gitblit.Keys;
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.JGitUtils.SearchType;\r
 import com.gitblit.utils.StringUtils;\r
+import com.gitblit.wicket.pages.BranchesPage;\r
+import com.gitblit.wicket.pages.DocsPage;\r
+import com.gitblit.wicket.pages.LogPage;\r
 import com.gitblit.wicket.pages.RepositoriesPage;\r
 import com.gitblit.wicket.pages.SearchPage;\r
-import com.gitblit.wicket.panels.PageLinksPanel;\r
+import com.gitblit.wicket.pages.SummaryPage;\r
+import com.gitblit.wicket.pages.TagsPage;\r
+import com.gitblit.wicket.pages.TicketsPage;\r
+import com.gitblit.wicket.pages.TreePage;\r
 import com.gitblit.wicket.panels.RefsPanel;\r
 \r
 public abstract class RepositoryPage extends BasePage {\r
@@ -34,7 +51,21 @@ public abstract class RepositoryPage extends BasePage {
        private transient Repository r = null;\r
 \r
        private final Logger logger = LoggerFactory.getLogger(RepositoryPage.class);\r
-       \r
+\r
+       private final Map<String, String> knownPages = new HashMap<String, String>() {\r
+\r
+               private static final long serialVersionUID = 1L;\r
+\r
+               {\r
+                       put("summary", "gb.summary");\r
+                       put("log", "gb.log");\r
+                       put("branches", "gb.branches");\r
+                       put("tags", "gb.tags");\r
+                       put("tree", "gb.tree");\r
+                       put("tickets", "gb.tickets");\r
+               }\r
+       };\r
+\r
        public RepositoryPage(PageParameters params) {\r
                super(params);\r
                if (!params.containsKey("r")) {\r
@@ -46,14 +77,71 @@ public abstract class RepositoryPage extends BasePage {
 \r
                Repository r = getRepository();\r
 \r
-               // setup the page links and disable this page's link\r
-               PageLinksPanel pageLinks = new PageLinksPanel("pageLinks", r, repositoryName, getPageName());\r
-               add(pageLinks);\r
-               pageLinks.disablePageLink(getPageName());\r
+               // standard page links\r
+               add(new BookmarkablePageLink<Void>("summary", SummaryPage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
+               add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
+               add(new BookmarkablePageLink<Void>("branches", BranchesPage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
+               add(new BookmarkablePageLink<Void>("tags", TagsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
+               add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
+\r
+               // per-repository extra page links \r
+               List<String> extraPageLinks = new ArrayList<String>();\r
+\r
+               // Conditionally add tickets page\r
+               boolean checkTickets = JGitUtils.getRepositoryUseTickets(r);\r
+               if (checkTickets && JGitUtils.getTicketsBranch(r) != null) {\r
+                       extraPageLinks.add("tickets");\r
+               }\r
+\r
+               // Conditionally add docs page\r
+               boolean checkDocs = JGitUtils.getRepositoryUseDocs(r);\r
+               if (checkDocs) {\r
+                       extraPageLinks.add("docs");\r
+               }\r
+\r
+               ListDataProvider<String> extrasDp = new ListDataProvider<String>(extraPageLinks);\r
+               DataView<String> extrasView = new DataView<String>("extra", extrasDp) {\r
+                       private static final long serialVersionUID = 1L;\r
+\r
+                       public void populateItem(final Item<String> item) {\r
+                               String extra = item.getModelObject();\r
+                               if (extra.equals("tickets")) {\r
+                                       item.add(new Label("extraSeparator", " | "));\r
+                                       item.add(new LinkPanel("extraLink", null, getString("gb.tickets"), TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
+                               } else if (extra.equals("docs")) {\r
+                                       item.add(new Label("extraSeparator", " | "));\r
+                                       item.add(new LinkPanel("extraLink", null, getString("gb.docs"), DocsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
+                               }\r
+                       }\r
+               };\r
+               add(extrasView);\r
+               \r
+               // disable current page\r
+               disablePageLink(getPageName());\r
 \r
+               // add floating search form\r
+               SearchForm searchForm = new SearchForm("searchForm", repositoryName);\r
+               add(searchForm);\r
+               searchForm.setTranslatedAttributes();\r
+               \r
+               // set stateless page preference\r
                setStatelessHint(true);\r
        }\r
 \r
+       public void disablePageLink(String pageName) {\r
+               for (String wicketId : knownPages.keySet()) {\r
+                       String key = knownPages.get(wicketId);\r
+                       String linkName = getString(key);\r
+                       if (linkName.equals(pageName)) {\r
+                               Component c = get(wicketId);\r
+                               if (c != null) {\r
+                                       c.setEnabled(false);\r
+                               }\r
+                               break;\r
+                       }\r
+               }\r
+       }\r
+\r
        protected Repository getRepository() {\r
                if (r == null) {\r
                        Repository r = GitBlit.self().getRepository(repositoryName);\r
@@ -108,7 +196,6 @@ public abstract class RepositoryPage extends BasePage {
 \r
        protected abstract String getPageName();\r
 \r
-       \r
        protected Component createPersonPanel(String wicketId, PersonIdent identity, SearchType searchType) {\r
                boolean showEmail = GitBlit.self().settings().getBoolean(Keys.web.showEmailAddresses, false);\r
                if (!showEmail || StringUtils.isEmpty(identity.getName()) || StringUtils.isEmpty(identity.getEmailAddress())) {\r
@@ -130,14 +217,14 @@ public abstract class RepositoryPage extends BasePage {
                        LinkPanel nameLink = new LinkPanel("personName", "list", identity.getName(), SearchPage.class, WicketUtils.newSearchParameter(repositoryName, objectId, identity.getName(), searchType));\r
                        setPersonSearchTooltip(nameLink, identity.getName(), searchType);\r
                        fullPerson.add(nameLink);\r
-                       \r
+\r
                        LinkPanel addressLink = new LinkPanel("personAddress", "list", "<" + identity.getEmailAddress() + ">", SearchPage.class, WicketUtils.newSearchParameter(repositoryName, objectId, identity.getEmailAddress(), searchType));\r
                        setPersonSearchTooltip(addressLink, identity.getEmailAddress(), searchType);\r
                        fullPerson.add(addressLink);\r
                        return fullPerson;\r
                }\r
        }\r
-       \r
+\r
        protected void setPersonSearchTooltip(Component component, String value, SearchType searchType) {\r
                if (searchType.equals(SearchType.AUTHOR)) {\r
                        WicketUtils.setHtmlTooltip(component, getString("gb.searchForAuthor") + " " + value);\r
@@ -145,7 +232,7 @@ public abstract class RepositoryPage extends BasePage {
                        WicketUtils.setHtmlTooltip(component, getString("gb.searchForCommitter") + " " + value);\r
                }\r
        }\r
-       \r
+\r
        protected void setChangeTypeTooltip(Component container, ChangeType type) {\r
                switch (type) {\r
                case ADD:\r
@@ -163,7 +250,7 @@ public abstract class RepositoryPage extends BasePage {
                        break;\r
                }\r
        }\r
-       \r
+\r
        @Override\r
        protected void onBeforeRender() {\r
                // dispose of repository object\r
@@ -191,4 +278,44 @@ public abstract class RepositoryPage extends BasePage {
        protected PageParameters newPathParameter(String path) {\r
                return WicketUtils.newPathParameter(repositoryName, objectId, path);\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.setVisible(GitBlit.self().settings().getBoolean(Keys.web.showSearchTypeSelection, false)));\r
+                       TextField<String> searchBox = new TextField<String>("searchBox", searchBoxModel);\r
+                       add(searchBox);\r
+               }\r
+               \r
+               void setTranslatedAttributes() {                        \r
+                       WicketUtils.setHtmlTooltip(get("searchType"), getString("gb.searchTypeTooltip"));\r
+                       WicketUtils.setHtmlTooltip(get("searchBox"), getString("gb.searchTooltip"));\r
+                       WicketUtils.setInputPlaceholder(get("searchBox"), getString("gb.search"));                      \r
+               }\r
+\r
+               @Override\r
+               public void onSubmit() {\r
+                       SearchType searchType = searchTypeModel.getObject();\r
+                       String searchString = searchBoxModel.getObject();\r
+                       for (SearchType type : SearchType.values()) {\r
+                               if (searchString.toLowerCase().startsWith(type.name().toLowerCase() + ":")) {\r
+                                       searchType = type;\r
+                                       searchString = searchString.substring(type.name().toLowerCase().length() + 1).trim();\r
+                                       break;\r
+                               }\r
+                       }\r
+                       setResponsePage(SearchPage.class, WicketUtils.newSearchParameter(repositoryName, null, searchString, searchType));\r
+               }\r
+       }\r
 }\r
index 12271696a3b1cc3bb1fea0c1fec97acdb9c163ae..4818aa8c096beb4c914d9075b91d68560c5e0cdf 100644 (file)
@@ -6,9 +6,6 @@
 \r
 <body>\r
 <wicket:extend>\r
-\r
-       <!-- page nav links --> \r
-       <div wicket:id="pageLinks">[page links]</div>\r
        \r
        <!-- blob nav links --> \r
        <div class="page_nav2">\r
index 80ff059dc219aa103136dce562048da65f2a35bc..523744375d2a7bf66443012c2df438cacb337879 100644 (file)
@@ -16,9 +16,6 @@
 <!-- need to specify body.onload -->\r
 <body onload="prettyPrint()">\r
 \r
-               <!-- page nav links --> \r
-               <div wicket:id="pageLinks">[page links]</div>\r
-       \r
                <!-- blob nav links --> \r
                <div class="page_nav2">\r
                        <span wicket:id="blameLink">[blame link]</span> | <a wicket:id="historyLink"><wicket:message key="gb.history"></wicket:message></a> | <a wicket:id="rawLink"><wicket:message key="gb.raw"></wicket:message></a> | <a wicket:id="headLink"><wicket:message key="gb.head"></wicket:message></a>\r
index 606cbf4be667cabd7fcbc3bf811d58c4aa5846f8..65fd9b9d682196cebd9da7df835eef38e8cd096f 100644 (file)
@@ -7,9 +7,6 @@
 <body>\r
 <wicket:extend>\r
 \r
-       <!-- page nav links --> \r
-       <div wicket:id="pageLinks">[page links]</div>\r
-\r
        <!-- branches -->       \r
        <div style="margin-top:5px;" wicket:id="branchesPanel">[branches panel]</div>\r
        \r
index 4e3a26855427cf5dc08438683db7877e278c145f..50a88776eed16adcc0d3b740591623917f4e4dd4 100644 (file)
@@ -7,9 +7,6 @@
 <body>\r
 <wicket:extend>\r
 \r
-       <!-- page nav links --> \r
-       <div wicket:id="pageLinks">[page links]</div>\r
-       \r
        <!-- commitdiff nav links -->   \r
        <div class="page_nav2">\r
                <wicket:message key="gb.parent"></wicket:message>: <span wicket:id="parentLink">[parent link]</span> | <a wicket:id="patchLink"><wicket:message key="gb.patch"></wicket:message></a> | <a wicket:id="commitLink"><wicket:message key="gb.commit"></wicket:message></a>\r
index 26013038e334ad9f0eada5535c61faf7ef354788..059d77e499b6464039ad3d743dacdb46d55ef913 100644 (file)
@@ -7,9 +7,6 @@
 <body>\r
 <wicket:extend>\r
 \r
-       <!-- page nav links --> \r
-       <div wicket:id="pageLinks">[page links]</div>\r
-       \r
        <!-- commit nav links -->       \r
        <div class="page_nav2">\r
                <wicket:message key="gb.parent"></wicket:message>: <span wicket:id="parentLink">[parent link]</span> | <a wicket:id="patchLink"><wicket:message key="gb.patch"></wicket:message></a> | <span wicket:id="commitdiffLink">[commitdiff link]</span>\r
index c098bcf8ee436cecb8f8483019f3cb80d31c32b9..0da4bde44d99de51ab2d8032bf41009271ea79fa 100644 (file)
@@ -7,9 +7,6 @@
 <body>\r
 <wicket:extend>\r
        \r
-       <!-- page nav links --> \r
-       <div wicket:id="pageLinks">[page links]</div>\r
-       \r
        <!-- header -->\r
        <div style="margin-top:5px;" class="header"><span wicket:id="header">[header]</span></div>\r
        \r
index f132e5994a8a6905968e49e81aa1627cb1147e47..f9bd2f6991da839862ea5055d5479e61bed9966a 100644 (file)
@@ -7,9 +7,6 @@
 <body>\r
 <wicket:extend>\r
 \r
-       <!-- page nav links --> \r
-       <div wicket:id="pageLinks">[page links]</div>\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
index ad39b779a60e09be442a3e11aff05042a4ef3294..8e5cb96a4176bd55cf8f35baba247058cabf6a88 100644 (file)
@@ -7,9 +7,6 @@
 <body>\r
 <wicket:extend>\r
 \r
-       <!-- page nav links --> \r
-       <div wicket:id="pageLinks">[page links]</div>\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
index 9b00934888f597bc0c136930c2a9ea6f6e7c58a6..b8c9cfba92d9ed6f2b0bceec72c294e0d5e8ae0c 100644 (file)
@@ -13,9 +13,6 @@
 \r
 <body>\r
 <wicket:extend>\r
-               <!-- page nav links --> \r
-               <div wicket:id="pageLinks">[page links]</div>\r
-       \r
                <!-- markdown nav links -->     \r
                <div class="page_nav2">\r
                        <span wicket:id="blameLink">[blame link]</span> | <a wicket:id="historyLink"><wicket:message key="gb.history"></wicket:message></a> | <a wicket:id="rawLink"><wicket:message key="gb.raw"></wicket:message></a> | <a wicket:id="headLink"><wicket:message key="gb.head"></wicket:message></a>\r
index 83083abfbd34d7203a520c93535e5cf2e840a889..64d3ce3fa4a14311d93d904136ad2df0b47c93ed 100644 (file)
@@ -1,7 +1,6 @@
 package com.gitblit.wicket.pages;\r
 \r
-import java.io.StringReader;\r
-import java.io.StringWriter;\r
+import java.text.ParseException;\r
 \r
 import org.apache.wicket.PageParameters;\r
 import org.apache.wicket.markup.html.basic.Label;\r
@@ -9,19 +8,14 @@ import org.apache.wicket.markup.html.link.BookmarkablePageLink;
 import org.eclipse.jgit.lib.Constants;\r
 import org.eclipse.jgit.lib.Repository;\r
 import org.eclipse.jgit.revwalk.RevCommit;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-import org.tautua.markdownpapers.Markdown;\r
-import org.tautua.markdownpapers.parser.ParseException;\r
 \r
 import com.gitblit.utils.JGitUtils;\r
+import com.gitblit.utils.StringUtils;\r
 import com.gitblit.wicket.RepositoryPage;\r
 import com.gitblit.wicket.WicketUtils;\r
 \r
 public class MarkdownPage extends RepositoryPage {\r
        \r
-       private final Logger logger = LoggerFactory.getLogger(MarkdownPage.class);\r
-\r
        public MarkdownPage(PageParameters params) {\r
                super(params);\r
 \r
@@ -36,17 +30,14 @@ public class MarkdownPage extends RepositoryPage {
                add(new BookmarkablePageLink<Void>("rawLink", RawPage.class, WicketUtils.newPathParameter(repositoryName, objectId, markdownPath)));\r
                add(new BookmarkablePageLink<Void>("headLink", MarkdownPage.class, WicketUtils.newPathParameter(repositoryName, Constants.HEAD, markdownPath)));\r
 \r
-               // Read raw markdown content and transform it to html\r
-               String htmlText = "";\r
+               // Read raw markdown content and transform it to html           \r
+               String markdownText = JGitUtils.getRawContentAsString(r, commit, markdownPath);\r
+               String htmlText;\r
                try {\r
-                       String rawText = JGitUtils.getRawContentAsString(r, commit, markdownPath);\r
-                       StringReader reader = new StringReader(rawText);\r
-                       StringWriter writer = new StringWriter();\r
-                       Markdown md = new Markdown();\r
-                       md.transform(reader, writer);\r
-                       htmlText = writer.toString();\r
+                       htmlText = StringUtils.transformMarkdown(markdownText);\r
                } catch (ParseException p) {\r
-                       logger.error("Failed to parse markdown text from " + markdownPath, p);\r
+                       error(p.getMessage());\r
+                       htmlText = markdownText;\r
                }\r
                \r
                // Add the html to the page\r
index 246601a4b7bd853e65802b8a97cc6a73763a0926..9bb1f418a332418aa05a9ab6a8755865edbc4348 100644 (file)
@@ -7,9 +7,6 @@
 <body>\r
 <wicket:extend>\r
 \r
-       <!-- page nav links --> \r
-       <div wicket:id="pageLinks">[page links]</div>\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
index 6abef54867fec416854a0ff6596404d41770e573..6dbcfa225744ce1315ad408569f3648defde12d6 100644 (file)
@@ -6,9 +6,6 @@
 \r
 <body>\r
 <wicket:extend>\r
-\r
-       <!-- page nav links --> \r
-       <div wicket:id="pageLinks">[page links]</div>\r
        \r
        <div style="clear:both;">\r
                <!-- Repository Activity Chart -->      \r
index e41046283091c124a745e3b2f05cc4c98bb1ac9d..839375bce0dc8e8baec74f5d080d2ddf3122153f 100644 (file)
@@ -7,9 +7,6 @@
 <body>\r
 <wicket:extend>\r
        \r
-       <!-- page nav links --> \r
-       <div wicket:id="pageLinks">[page links]</div>\r
-\r
        <!-- summary header -->\r
        <div style="margin-top: 5px;" class="header" wicket:id="commit">[shortlog header]</div>\r
        \r
index 3a49a745ed1dcf4c6637670af73a489ae18698e2..03f1a0d7a78ad4caa44a8abb1db54e4efcf25b5b 100644 (file)
@@ -7,9 +7,6 @@
 <body>\r
 <wicket:extend>\r
 \r
-       <!-- page nav links --> \r
-       <div wicket:id="pageLinks">[page links]</div>\r
-\r
        <!-- tags panel -->\r
        <div style="margin-top:5px;" wicket:id="tagsPanel">[tags panel]</div>\r
        \r
index b61f7f95c208200d5ac8c1b499efbbd37367b567..160bc0cf17e5c7fc23ab6c231893eebd8c26a97a 100644 (file)
@@ -7,9 +7,6 @@
 <body>\r
 <wicket:extend>\r
 \r
-       <!-- page nav links --> \r
-       <div wicket:id="pageLinks">[page links]</div>\r
-       \r
        <!-- ticket title -->\r
        <div style="font-size:150%;padding-top:5px;" wicket:id="ticketTitle">[ticket title]</div>\r
                \r
index 0c865f33c81ed65f479910adf3f986d556978dd2..0913dc2c2abc12a5da33a18ff611d0f40eb26e98 100644 (file)
@@ -7,9 +7,6 @@
 <body>\r
 <wicket:extend>\r
 \r
-       <!-- page nav links --> \r
-       <div wicket:id="pageLinks">[page links]</div>\r
-\r
        <!-- header --> \r
        <div style="margin-top:5px;" class="header" wicket:id="header">[header]</div>\r
        \r
index 90ca62bffd0528ce7f384c1c6a6b3939fcd7fe4e..35eac299fb78ef1855d46df5080b69c1bea86d43 100644 (file)
@@ -7,9 +7,6 @@
 <body>\r
 <wicket:extend>\r
 \r
-       <!-- page nav links --> \r
-       <div wicket:id="pageLinks">[page links]</div>\r
-       \r
        <!-- blob nav links --> \r
        <div class="page_nav2">\r
                <a wicket:id="historyLink"><wicket:message key="gb.history"></wicket:message></a> | <a wicket:id="headLink"><wicket:message key="gb.head"></wicket:message></a>\r
diff --git a/src/com/gitblit/wicket/panels/PageLinksPanel.html b/src/com/gitblit/wicket/panels/PageLinksPanel.html
deleted file mode 100644 (file)
index 7cad29f..0000000
+++ /dev/null
@@ -1,21 +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
-<wicket:panel>\r
-       <!-- floating search form on right -->\r
-       <form wicket:id="searchForm">\r
-               <div class="search">\r
-                       <select wicket:id="searchType"/>                        \r
-                       <input type="text" id="searchBox" wicket:id="searchBox" size="25" value=""/>\r
-               </div>\r
-       </form>\r
-               \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
-       </div>  \r
-</wicket:panel>\r
-</html>
\ No newline at end of file
diff --git a/src/com/gitblit/wicket/panels/PageLinksPanel.java b/src/com/gitblit/wicket/panels/PageLinksPanel.java
deleted file mode 100644 (file)
index 0f33501..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-package com.gitblit.wicket.panels;\r
-\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.DocsPage;\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
-import com.gitblit.wicket.pages.TreePage;\r
-\r
-public class PageLinksPanel extends Panel {\r
-\r
-       private static final long serialVersionUID = 1L;\r
-\r
-       private final Map<String, String> knownPages = new HashMap<String, String>() {\r
-\r
-               private static final long serialVersionUID = 1L;\r
-\r
-               {\r
-                       put("summary", "gb.summary");\r
-                       put("log", "gb.log");\r
-                       put("branches", "gb.branches");\r
-                       put("tags", "gb.tags");\r
-                       put("tree", "gb.tree");\r
-                       put("tickets", "gb.tickets");\r
-               }\r
-       };\r
-\r
-       public PageLinksPanel(String id, Repository r, final String repositoryName, String pageName) {\r
-               super(id);\r
-\r
-               // summary\r
-               add(new BookmarkablePageLink<Void>("summary", SummaryPage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
-               add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
-               add(new BookmarkablePageLink<Void>("branches", BranchesPage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
-               add(new BookmarkablePageLink<Void>("tags", TagsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
-               add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
-\r
-               List<String> extras = new ArrayList<String>();\r
-\r
-               // Get the repository tickets setting\r
-               boolean checkTickets = JGitUtils.getRepositoryUseTickets(r);\r
-               if (checkTickets && JGitUtils.getTicketsBranch(r) != null) {\r
-                       extras.add("tickets");\r
-               }\r
-\r
-               // Get the repository docs setting\r
-               boolean checkDocs = JGitUtils.getRepositoryUseDocs(r);\r
-               if (checkDocs) {\r
-                       extras.add("docs");\r
-               }\r
-\r
-               ListDataProvider<String> extrasDp = new ListDataProvider<String>(extras);\r
-               DataView<String> extrasView = new DataView<String>("extra", extrasDp) {\r
-                       private static final long serialVersionUID = 1L;\r
-\r
-                       public void populateItem(final Item<String> item) {\r
-                               String extra = item.getModelObject();\r
-                               if (extra.equals("tickets")) {\r
-                                       item.add(new Label("extraSeparator", " | "));\r
-                                       item.add(new LinkPanel("extraLink", null, getString("gb.tickets"), TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
-                               } else if (extra.equals("docs")) {\r
-                                       item.add(new Label("extraSeparator", " | "));\r
-                                       item.add(new LinkPanel("extraLink", null, getString("gb.docs"), DocsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
-                               }\r
-                       }\r
-               };\r
-               add(extrasView);\r
-\r
-               add(new SearchForm("searchForm", repositoryName));\r
-       }\r
-\r
-       public void disablePageLink(String pageName) {\r
-               for (String wicketId : knownPages.keySet()) {\r
-                       String key = knownPages.get(wicketId);\r
-                       String linkName = getString(key);\r
-                       if (linkName.equals(pageName)) {\r
-                               Component c = get(wicketId);\r
-                               if (c != null) {\r
-                                       c.setEnabled(false);\r
-                               }\r
-                               break;\r
-                       }\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
-                       WicketUtils.setHtmlTooltip(searchType, getString("gb.searchTypeTooltip"));\r
-                       add(searchType.setVisible(GitBlit.self().settings().getBoolean(Keys.web.showSearchTypeSelection, false)));\r
-                       TextField<String> searchBox = new TextField<String>("searchBox", searchBoxModel);\r
-                       add(searchBox);\r
-                       WicketUtils.setHtmlTooltip(searchBox, getString("gb.searchTooltip"));\r
-                       WicketUtils.setInputPlaceholder(searchBox, getString("gb.search"));\r
-               }\r
-\r
-               @Override\r
-               public void onSubmit() {\r
-                       SearchType searchType = searchTypeModel.getObject();\r
-                       String searchString = searchBoxModel.getObject();\r
-                       for (SearchType type : SearchType.values()) {\r
-                               if (searchString.toLowerCase().startsWith(type.name().toLowerCase() + ":")) {\r
-                                       searchType = type;\r
-                                       searchString = searchString.substring(type.name().toLowerCase().length() + 1).trim();\r
-                                       break;\r
-                               }\r
-                       }\r
-                       setResponsePage(SearchPage.class, WicketUtils.newSearchParameter(repositoryName, null, searchString, searchType));\r
-               }\r
-       }\r
-}
\ No newline at end of file
index ce3be676c440fbd8d15b2c6e23ae145acf273e8c..53845466545c674a3ce65743c3e9a50dd59dde80 100644 (file)
@@ -32,14 +32,14 @@ pre, code, pre.prettyprint, pre.plainprint {
 \r
 /* age0: age < 60*60*2 */\r
 .age0 {\r
-       color: #009900;\r
+       color: #008000;\r
        font-style: italic;\r
        font-weight: bold;\r
 }\r
 \r
 /* age1: 60*60*2 <= age < 60*60*24*2 */\r
 .age1 {\r
-       color: #009900;\r
+       color: #008000;\r
        font-style: italic;\r
 }\r
 \r
@@ -272,7 +272,7 @@ span.diff.add {
 }\r
 \r
 span.diff.remove {\r
-       color: #cc0000;\r
+       color: #FFDDDD;\r
        font-family: inherit;\r
 }\r
 \r
@@ -373,7 +373,7 @@ span.addition, span.modification, span.deletion, span.rename {
 }\r
 \r
 span.addition {\r
-       background-color: #bbffbb;\r
+       background-color: #ccffcc;\r
 }\r
 \r
 span.modification {\r
@@ -381,11 +381,11 @@ span.modification {
 }\r
 \r
 span.deletion {\r
-       background-color: #ff8888;\r
+       background-color: #f8bbbb;\r
 }\r
 \r
 span.rename {\r
-       background-color: #8888ff;\r
+       background-color: #cAc2f5;\r
 }\r
 \r
 div.commitLegend {\r
@@ -616,16 +616,16 @@ span .otherRef {
 }\r
 \r
 span .remoteRef {\r
-       background-color: #aaaaff;\r
+       background-color: #cAc2f5;\r
        border-color: #ccccff #0033cc #0033cc #ccccff;\r
 }\r
 \r
 span .tagRef {\r
        background-color: #ffffaa;\r
-       border-color: #ffffcc #ffee00 #ffee00 #ffffcc;\r
+       border-color: #ffcc00 #ffcc00 #ffcc00 #ffcc00;\r
 }\r
 \r
 span .headRef {\r
-       background-color: #aaffaa;\r
+       background-color: #ccffcc;\r
        border-color: #ccffcc #00cc33 #00cc33 #ccffcc;\r
 }
\ No newline at end of file