summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2011-04-27 20:55:38 -0400
committerJames Moger <james.moger@gitblit.com>2011-04-27 20:55:38 -0400
commit3e087ada55f8b0e83b146578b695552db9dc8d97 (patch)
tree69b5b78421848011b95ff52527f4cf950e6d51d4
parentc1c3c6a7a2f0a2893ef36ab3dfc7b09d04a133bc (diff)
downloadgitblit-3e087ada55f8b0e83b146578b695552db9dc8d97.tar.gz
gitblit-3e087ada55f8b0e83b146578b695552db9dc8d97.zip
Integrated pagelinks into RepositoryPage. Fixed string encoding.
-rw-r--r--src/com/gitblit/utils/JGitUtils.java7
-rw-r--r--src/com/gitblit/utils/StringUtils.java26
-rw-r--r--src/com/gitblit/wicket/RepositoryPage.html30
-rw-r--r--src/com/gitblit/wicket/RepositoryPage.java149
-rw-r--r--src/com/gitblit/wicket/pages/BlobDiffPage.html3
-rw-r--r--src/com/gitblit/wicket/pages/BlobPage.html3
-rw-r--r--src/com/gitblit/wicket/pages/BranchesPage.html3
-rw-r--r--src/com/gitblit/wicket/pages/CommitDiffPage.html3
-rw-r--r--src/com/gitblit/wicket/pages/CommitPage.html3
-rw-r--r--src/com/gitblit/wicket/pages/DocsPage.html3
-rw-r--r--src/com/gitblit/wicket/pages/HistoryPage.html3
-rw-r--r--src/com/gitblit/wicket/pages/LogPage.html3
-rw-r--r--src/com/gitblit/wicket/pages/MarkdownPage.html3
-rw-r--r--src/com/gitblit/wicket/pages/MarkdownPage.java25
-rw-r--r--src/com/gitblit/wicket/pages/SearchPage.html3
-rw-r--r--src/com/gitblit/wicket/pages/SummaryPage.html3
-rw-r--r--src/com/gitblit/wicket/pages/TagPage.html3
-rw-r--r--src/com/gitblit/wicket/pages/TagsPage.html3
-rw-r--r--src/com/gitblit/wicket/pages/TicketPage.html3
-rw-r--r--src/com/gitblit/wicket/pages/TicketsPage.html3
-rw-r--r--src/com/gitblit/wicket/pages/TreePage.html3
-rw-r--r--src/com/gitblit/wicket/panels/PageLinksPanel.html21
-rw-r--r--src/com/gitblit/wicket/panels/PageLinksPanel.java150
-rw-r--r--src/com/gitblit/wicket/resources/gitblit.css18
24 files changed, 215 insertions, 259 deletions
diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java
index e5dbfd2d..8814c1f4 100644
--- a/src/com/gitblit/utils/JGitUtils.java
+++ b/src/com/gitblit/utils/JGitUtils.java
@@ -4,6 +4,7 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.Charset;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -264,12 +265,14 @@ public class JGitUtils {
}
public static String getRawContentAsString(Repository r, RevBlob blob) {
- return new String(getRawContent(r, blob));
+ byte [] content = getRawContent(r, blob);
+ return new String(content, Charset.forName("UTF-8"));
}
public static String getRawContentAsString(Repository r, RevCommit commit, String blobPath) {
RevObject obj = getRevObject(r, commit.getTree(), blobPath);
- return new String(getRawContent(r, (RevBlob) obj));
+ byte [] content = getRawContent(r, (RevBlob) obj);
+ return new String(content, Charset.forName("UTF-8"));
}
public static List<PathModel> getFilesInPath(Repository r, String basePath, String objectId) {
diff --git a/src/com/gitblit/utils/StringUtils.java b/src/com/gitblit/utils/StringUtils.java
index 6d646df8..ff9fac4f 100644
--- a/src/com/gitblit/utils/StringUtils.java
+++ b/src/com/gitblit/utils/StringUtils.java
@@ -1,12 +1,18 @@
package com.gitblit.utils;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.List;
+import org.tautua.markdownpapers.Markdown;
+import org.tautua.markdownpapers.parser.ParseException;
+
public class StringUtils {
-
+
public static boolean isEmpty(String value) {
return value == null || value.trim().length() == 0;
}
@@ -107,4 +113,22 @@ public class StringUtils {
}
}
+ public static String transformMarkdown(String markdown) throws java.text.ParseException {
+ // Read raw markdown content and transform it to html
+ StringReader reader = new StringReader(markdown);
+ StringWriter writer = new StringWriter();
+ try {
+ Markdown md = new Markdown();
+ md.transform(reader, writer);
+ return writer.toString();
+ } catch (ParseException p) {
+ throw new java.text.ParseException(p.getMessage(), 0);
+ } finally {
+ reader.close();
+ try {
+ writer.close();
+ } catch (IOException e) {
+ }
+ }
+ }
}
diff --git a/src/com/gitblit/wicket/RepositoryPage.html b/src/com/gitblit/wicket/RepositoryPage.html
new file mode 100644
index 00000000..4b3f2e78
--- /dev/null
+++ b/src/com/gitblit/wicket/RepositoryPage.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd"
+ xml:lang="en"
+ lang="en">
+
+<body>
+ <wicket:extend>
+ <!-- page header bar -->
+ <div>
+ <!-- floating search form on right -->
+ <form wicket:id="searchForm">
+ <div class="search">
+ <select wicket:id="searchType"/>
+ <input type="text" id="searchBox" wicket:id="searchBox" size="25" value=""/>
+ </div>
+ </form>
+
+ <!-- page nav links -->
+ <div class="page_nav">
+ <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>
+ </div>
+ </div>
+
+ <!-- page content -->
+ <wicket:child />
+
+ </wicket:extend>
+</body>
+</html> \ No newline at end of file
diff --git a/src/com/gitblit/wicket/RepositoryPage.java b/src/com/gitblit/wicket/RepositoryPage.java
index 30e41a5f..28cdcd03 100644
--- a/src/com/gitblit/wicket/RepositoryPage.java
+++ b/src/com/gitblit/wicket/RepositoryPage.java
@@ -1,5 +1,7 @@
package com.gitblit.wicket;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -7,7 +9,16 @@ import java.util.Map;
import org.apache.wicket.Component;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.DropDownChoice;
+import org.apache.wicket.markup.html.form.StatelessForm;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.panel.Fragment;
+import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.markup.repeater.data.DataView;
+import org.apache.wicket.markup.repeater.data.ListDataProvider;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
import org.eclipse.jgit.diff.DiffEntry.ChangeType;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.Repository;
@@ -20,9 +31,15 @@ import com.gitblit.Keys;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.JGitUtils.SearchType;
import com.gitblit.utils.StringUtils;
+import com.gitblit.wicket.pages.BranchesPage;
+import com.gitblit.wicket.pages.DocsPage;
+import com.gitblit.wicket.pages.LogPage;
import com.gitblit.wicket.pages.RepositoriesPage;
import com.gitblit.wicket.pages.SearchPage;
-import com.gitblit.wicket.panels.PageLinksPanel;
+import com.gitblit.wicket.pages.SummaryPage;
+import com.gitblit.wicket.pages.TagsPage;
+import com.gitblit.wicket.pages.TicketsPage;
+import com.gitblit.wicket.pages.TreePage;
import com.gitblit.wicket.panels.RefsPanel;
public abstract class RepositoryPage extends BasePage {
@@ -34,7 +51,21 @@ public abstract class RepositoryPage extends BasePage {
private transient Repository r = null;
private final Logger logger = LoggerFactory.getLogger(RepositoryPage.class);
-
+
+ private final Map<String, String> knownPages = new HashMap<String, String>() {
+
+ private static final long serialVersionUID = 1L;
+
+ {
+ put("summary", "gb.summary");
+ put("log", "gb.log");
+ put("branches", "gb.branches");
+ put("tags", "gb.tags");
+ put("tree", "gb.tree");
+ put("tickets", "gb.tickets");
+ }
+ };
+
public RepositoryPage(PageParameters params) {
super(params);
if (!params.containsKey("r")) {
@@ -46,14 +77,71 @@ public abstract class RepositoryPage extends BasePage {
Repository r = getRepository();
- // setup the page links and disable this page's link
- PageLinksPanel pageLinks = new PageLinksPanel("pageLinks", r, repositoryName, getPageName());
- add(pageLinks);
- pageLinks.disablePageLink(getPageName());
+ // standard page links
+ add(new BookmarkablePageLink<Void>("summary", SummaryPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
+ add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
+ add(new BookmarkablePageLink<Void>("branches", BranchesPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
+ add(new BookmarkablePageLink<Void>("tags", TagsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
+ add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils.newRepositoryParameter(repositoryName)));
+
+ // per-repository extra page links
+ List<String> extraPageLinks = new ArrayList<String>();
+
+ // Conditionally add tickets page
+ boolean checkTickets = JGitUtils.getRepositoryUseTickets(r);
+ if (checkTickets && JGitUtils.getTicketsBranch(r) != null) {
+ extraPageLinks.add("tickets");
+ }
+
+ // Conditionally add docs page
+ boolean checkDocs = JGitUtils.getRepositoryUseDocs(r);
+ if (checkDocs) {
+ extraPageLinks.add("docs");
+ }
+
+ ListDataProvider<String> extrasDp = new ListDataProvider<String>(extraPageLinks);
+ DataView<String> extrasView = new DataView<String>("extra", extrasDp) {
+ private static final long serialVersionUID = 1L;
+
+ public void populateItem(final Item<String> item) {
+ String extra = item.getModelObject();
+ if (extra.equals("tickets")) {
+ item.add(new Label("extraSeparator", " | "));
+ item.add(new LinkPanel("extraLink", null, getString("gb.tickets"), TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
+ } else if (extra.equals("docs")) {
+ item.add(new Label("extraSeparator", " | "));
+ item.add(new LinkPanel("extraLink", null, getString("gb.docs"), DocsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
+ }
+ }
+ };
+ add(extrasView);
+
+ // disable current page
+ disablePageLink(getPageName());
+ // add floating search form
+ SearchForm searchForm = new SearchForm("searchForm", repositoryName);
+ add(searchForm);
+ searchForm.setTranslatedAttributes();
+
+ // set stateless page preference
setStatelessHint(true);
}
+ public void disablePageLink(String pageName) {
+ for (String wicketId : knownPages.keySet()) {
+ String key = knownPages.get(wicketId);
+ String linkName = getString(key);
+ if (linkName.equals(pageName)) {
+ Component c = get(wicketId);
+ if (c != null) {
+ c.setEnabled(false);
+ }
+ break;
+ }
+ }
+ }
+
protected Repository getRepository() {
if (r == null) {
Repository r = GitBlit.self().getRepository(repositoryName);
@@ -108,7 +196,6 @@ public abstract class RepositoryPage extends BasePage {
protected abstract String getPageName();
-
protected Component createPersonPanel(String wicketId, PersonIdent identity, SearchType searchType) {
boolean showEmail = GitBlit.self().settings().getBoolean(Keys.web.showEmailAddresses, false);
if (!showEmail || StringUtils.isEmpty(identity.getName()) || StringUtils.isEmpty(identity.getEmailAddress())) {
@@ -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));
setPersonSearchTooltip(nameLink, identity.getName(), searchType);
fullPerson.add(nameLink);
-
+
LinkPanel addressLink = new LinkPanel("personAddress", "list", "<" + identity.getEmailAddress() + ">", SearchPage.class, WicketUtils.newSearchParameter(repositoryName, objectId, identity.getEmailAddress(), searchType));
setPersonSearchTooltip(addressLink, identity.getEmailAddress(), searchType);
fullPerson.add(addressLink);
return fullPerson;
}
}
-
+
protected void setPersonSearchTooltip(Component component, String value, SearchType searchType) {
if (searchType.equals(SearchType.AUTHOR)) {
WicketUtils.setHtmlTooltip(component, getString("gb.searchForAuthor") + " " + value);
@@ -145,7 +232,7 @@ public abstract class RepositoryPage extends BasePage {
WicketUtils.setHtmlTooltip(component, getString("gb.searchForCommitter") + " " + value);
}
}
-
+
protected void setChangeTypeTooltip(Component container, ChangeType type) {
switch (type) {
case ADD:
@@ -163,7 +250,7 @@ public abstract class RepositoryPage extends BasePage {
break;
}
}
-
+
@Override
protected void onBeforeRender() {
// dispose of repository object
@@ -191,4 +278,44 @@ public abstract class RepositoryPage extends BasePage {
protected PageParameters newPathParameter(String path) {
return WicketUtils.newPathParameter(repositoryName, objectId, path);
}
+
+ class SearchForm extends StatelessForm<Void> {
+ private static final long serialVersionUID = 1L;
+
+ private final String repositoryName;
+
+ private final IModel<String> searchBoxModel = new Model<String>("");
+
+ private final IModel<SearchType> searchTypeModel = new Model<SearchType>(SearchType.COMMIT);
+
+ public SearchForm(String id, String repositoryName) {
+ super(id);
+ this.repositoryName = repositoryName;
+ DropDownChoice<SearchType> searchType = new DropDownChoice<SearchType>("searchType", Arrays.asList(SearchType.values()));
+ searchType.setModel(searchTypeModel);
+ add(searchType.setVisible(GitBlit.self().settings().getBoolean(Keys.web.showSearchTypeSelection, false)));
+ TextField<String> searchBox = new TextField<String>("searchBox", searchBoxModel);
+ add(searchBox);
+ }
+
+ void setTranslatedAttributes() {
+ WicketUtils.setHtmlTooltip(get("searchType"), getString("gb.searchTypeTooltip"));
+ WicketUtils.setHtmlTooltip(get("searchBox"), getString("gb.searchTooltip"));
+ WicketUtils.setInputPlaceholder(get("searchBox"), getString("gb.search"));
+ }
+
+ @Override
+ public void onSubmit() {
+ SearchType searchType = searchTypeModel.getObject();
+ String searchString = searchBoxModel.getObject();
+ for (SearchType type : SearchType.values()) {
+ if (searchString.toLowerCase().startsWith(type.name().toLowerCase() + ":")) {
+ searchType = type;
+ searchString = searchString.substring(type.name().toLowerCase().length() + 1).trim();
+ break;
+ }
+ }
+ setResponsePage(SearchPage.class, WicketUtils.newSearchParameter(repositoryName, null, searchString, searchType));
+ }
+ }
}
diff --git a/src/com/gitblit/wicket/pages/BlobDiffPage.html b/src/com/gitblit/wicket/pages/BlobDiffPage.html
index 12271696..4818aa8c 100644
--- a/src/com/gitblit/wicket/pages/BlobDiffPage.html
+++ b/src/com/gitblit/wicket/pages/BlobDiffPage.html
@@ -6,9 +6,6 @@
<body>
<wicket:extend>
-
- <!-- page nav links -->
- <div wicket:id="pageLinks">[page links]</div>
<!-- blob nav links -->
<div class="page_nav2">
diff --git a/src/com/gitblit/wicket/pages/BlobPage.html b/src/com/gitblit/wicket/pages/BlobPage.html
index 80ff059d..52374437 100644
--- a/src/com/gitblit/wicket/pages/BlobPage.html
+++ b/src/com/gitblit/wicket/pages/BlobPage.html
@@ -16,9 +16,6 @@
<!-- need to specify body.onload -->
<body onload="prettyPrint()">
- <!-- page nav links -->
- <div wicket:id="pageLinks">[page links]</div>
-
<!-- blob nav links -->
<div class="page_nav2">
<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>
diff --git a/src/com/gitblit/wicket/pages/BranchesPage.html b/src/com/gitblit/wicket/pages/BranchesPage.html
index 606cbf4b..65fd9b9d 100644
--- a/src/com/gitblit/wicket/pages/BranchesPage.html
+++ b/src/com/gitblit/wicket/pages/BranchesPage.html
@@ -7,9 +7,6 @@
<body>
<wicket:extend>
- <!-- page nav links -->
- <div wicket:id="pageLinks">[page links]</div>
-
<!-- branches -->
<div style="margin-top:5px;" wicket:id="branchesPanel">[branches panel]</div>
diff --git a/src/com/gitblit/wicket/pages/CommitDiffPage.html b/src/com/gitblit/wicket/pages/CommitDiffPage.html
index 4e3a2685..50a88776 100644
--- a/src/com/gitblit/wicket/pages/CommitDiffPage.html
+++ b/src/com/gitblit/wicket/pages/CommitDiffPage.html
@@ -7,9 +7,6 @@
<body>
<wicket:extend>
- <!-- page nav links -->
- <div wicket:id="pageLinks">[page links]</div>
-
<!-- commitdiff nav links -->
<div class="page_nav2">
<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>
diff --git a/src/com/gitblit/wicket/pages/CommitPage.html b/src/com/gitblit/wicket/pages/CommitPage.html
index 26013038..059d77e4 100644
--- a/src/com/gitblit/wicket/pages/CommitPage.html
+++ b/src/com/gitblit/wicket/pages/CommitPage.html
@@ -7,9 +7,6 @@
<body>
<wicket:extend>
- <!-- page nav links -->
- <div wicket:id="pageLinks">[page links]</div>
-
<!-- commit nav links -->
<div class="page_nav2">
<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>
diff --git a/src/com/gitblit/wicket/pages/DocsPage.html b/src/com/gitblit/wicket/pages/DocsPage.html
index c098bcf8..0da4bde4 100644
--- a/src/com/gitblit/wicket/pages/DocsPage.html
+++ b/src/com/gitblit/wicket/pages/DocsPage.html
@@ -7,9 +7,6 @@
<body>
<wicket:extend>
- <!-- page nav links -->
- <div wicket:id="pageLinks">[page links]</div>
-
<!-- header -->
<div style="margin-top:5px;" class="header"><span wicket:id="header">[header]</span></div>
diff --git a/src/com/gitblit/wicket/pages/HistoryPage.html b/src/com/gitblit/wicket/pages/HistoryPage.html
index f132e599..f9bd2f69 100644
--- a/src/com/gitblit/wicket/pages/HistoryPage.html
+++ b/src/com/gitblit/wicket/pages/HistoryPage.html
@@ -7,9 +7,6 @@
<body>
<wicket:extend>
- <!-- page nav links -->
- <div wicket:id="pageLinks">[page links]</div>
-
<!-- pager links -->
<div style="padding-top:5px;">
<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>
diff --git a/src/com/gitblit/wicket/pages/LogPage.html b/src/com/gitblit/wicket/pages/LogPage.html
index ad39b779..8e5cb96a 100644
--- a/src/com/gitblit/wicket/pages/LogPage.html
+++ b/src/com/gitblit/wicket/pages/LogPage.html
@@ -7,9 +7,6 @@
<body>
<wicket:extend>
- <!-- page nav links -->
- <div wicket:id="pageLinks">[page links]</div>
-
<!-- pager links -->
<div style="padding-top:5px;">
<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>
diff --git a/src/com/gitblit/wicket/pages/MarkdownPage.html b/src/com/gitblit/wicket/pages/MarkdownPage.html
index 9b009348..b8c9cfba 100644
--- a/src/com/gitblit/wicket/pages/MarkdownPage.html
+++ b/src/com/gitblit/wicket/pages/MarkdownPage.html
@@ -13,9 +13,6 @@
<body>
<wicket:extend>
- <!-- page nav links -->
- <div wicket:id="pageLinks">[page links]</div>
-
<!-- markdown nav links -->
<div class="page_nav2">
<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>
diff --git a/src/com/gitblit/wicket/pages/MarkdownPage.java b/src/com/gitblit/wicket/pages/MarkdownPage.java
index 83083abf..64d3ce3f 100644
--- a/src/com/gitblit/wicket/pages/MarkdownPage.java
+++ b/src/com/gitblit/wicket/pages/MarkdownPage.java
@@ -1,7 +1,6 @@
package com.gitblit.wicket.pages;
-import java.io.StringReader;
-import java.io.StringWriter;
+import java.text.ParseException;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
@@ -9,19 +8,14 @@ import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.tautua.markdownpapers.Markdown;
-import org.tautua.markdownpapers.parser.ParseException;
import com.gitblit.utils.JGitUtils;
+import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.RepositoryPage;
import com.gitblit.wicket.WicketUtils;
public class MarkdownPage extends RepositoryPage {
- private final Logger logger = LoggerFactory.getLogger(MarkdownPage.class);
-
public MarkdownPage(PageParameters params) {
super(params);
@@ -36,17 +30,14 @@ public class MarkdownPage extends RepositoryPage {
add(new BookmarkablePageLink<Void>("rawLink", RawPage.class, WicketUtils.newPathParameter(repositoryName, objectId, markdownPath)));
add(new BookmarkablePageLink<Void>("headLink", MarkdownPage.class, WicketUtils.newPathParameter(repositoryName, Constants.HEAD, markdownPath)));
- // Read raw markdown content and transform it to html
- String htmlText = "";
+ // Read raw markdown content and transform it to html
+ String markdownText = JGitUtils.getRawContentAsString(r, commit, markdownPath);
+ String htmlText;
try {
- String rawText = JGitUtils.getRawContentAsString(r, commit, markdownPath);
- StringReader reader = new StringReader(rawText);
- StringWriter writer = new StringWriter();
- Markdown md = new Markdown();
- md.transform(reader, writer);
- htmlText = writer.toString();
+ htmlText = StringUtils.transformMarkdown(markdownText);
} catch (ParseException p) {
- logger.error("Failed to parse markdown text from " + markdownPath, p);
+ error(p.getMessage());
+ htmlText = markdownText;
}
// Add the html to the page
diff --git a/src/com/gitblit/wicket/pages/SearchPage.html b/src/com/gitblit/wicket/pages/SearchPage.html
index 246601a4..9bb1f418 100644
--- a/src/com/gitblit/wicket/pages/SearchPage.html
+++ b/src/com/gitblit/wicket/pages/SearchPage.html
@@ -7,9 +7,6 @@
<body>
<wicket:extend>
- <!-- page nav links -->
- <div wicket:id="pageLinks">[page links]</div>
-
<!-- pager links -->
<div style="padding-top:5px;">
<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>
diff --git a/src/com/gitblit/wicket/pages/SummaryPage.html b/src/com/gitblit/wicket/pages/SummaryPage.html
index 6abef548..6dbcfa22 100644
--- a/src/com/gitblit/wicket/pages/SummaryPage.html
+++ b/src/com/gitblit/wicket/pages/SummaryPage.html
@@ -6,9 +6,6 @@
<body>
<wicket:extend>
-
- <!-- page nav links -->
- <div wicket:id="pageLinks">[page links]</div>
<div style="clear:both;">
<!-- Repository Activity Chart -->
diff --git a/src/com/gitblit/wicket/pages/TagPage.html b/src/com/gitblit/wicket/pages/TagPage.html
index e4104628..839375bc 100644
--- a/src/com/gitblit/wicket/pages/TagPage.html
+++ b/src/com/gitblit/wicket/pages/TagPage.html
@@ -7,9 +7,6 @@
<body>
<wicket:extend>
- <!-- page nav links -->
- <div wicket:id="pageLinks">[page links]</div>
-
<!-- summary header -->
<div style="margin-top: 5px;" class="header" wicket:id="commit">[shortlog header]</div>
diff --git a/src/com/gitblit/wicket/pages/TagsPage.html b/src/com/gitblit/wicket/pages/TagsPage.html
index 3a49a745..03f1a0d7 100644
--- a/src/com/gitblit/wicket/pages/TagsPage.html
+++ b/src/com/gitblit/wicket/pages/TagsPage.html
@@ -7,9 +7,6 @@
<body>
<wicket:extend>
- <!-- page nav links -->
- <div wicket:id="pageLinks">[page links]</div>
-
<!-- tags panel -->
<div style="margin-top:5px;" wicket:id="tagsPanel">[tags panel]</div>
diff --git a/src/com/gitblit/wicket/pages/TicketPage.html b/src/com/gitblit/wicket/pages/TicketPage.html
index b61f7f95..160bc0cf 100644
--- a/src/com/gitblit/wicket/pages/TicketPage.html
+++ b/src/com/gitblit/wicket/pages/TicketPage.html
@@ -7,9 +7,6 @@
<body>
<wicket:extend>
- <!-- page nav links -->
- <div wicket:id="pageLinks">[page links]</div>
-
<!-- ticket title -->
<div style="font-size:150%;padding-top:5px;" wicket:id="ticketTitle">[ticket title]</div>
diff --git a/src/com/gitblit/wicket/pages/TicketsPage.html b/src/com/gitblit/wicket/pages/TicketsPage.html
index 0c865f33..0913dc2c 100644
--- a/src/com/gitblit/wicket/pages/TicketsPage.html
+++ b/src/com/gitblit/wicket/pages/TicketsPage.html
@@ -7,9 +7,6 @@
<body>
<wicket:extend>
- <!-- page nav links -->
- <div wicket:id="pageLinks">[page links]</div>
-
<!-- header -->
<div style="margin-top:5px;" class="header" wicket:id="header">[header]</div>
diff --git a/src/com/gitblit/wicket/pages/TreePage.html b/src/com/gitblit/wicket/pages/TreePage.html
index 90ca62bf..35eac299 100644
--- a/src/com/gitblit/wicket/pages/TreePage.html
+++ b/src/com/gitblit/wicket/pages/TreePage.html
@@ -7,9 +7,6 @@
<body>
<wicket:extend>
- <!-- page nav links -->
- <div wicket:id="pageLinks">[page links]</div>
-
<!-- blob nav links -->
<div class="page_nav2">
<a wicket:id="historyLink"><wicket:message key="gb.history"></wicket:message></a> | <a wicket:id="headLink"><wicket:message key="gb.head"></wicket:message></a>
diff --git a/src/com/gitblit/wicket/panels/PageLinksPanel.html b/src/com/gitblit/wicket/panels/PageLinksPanel.html
deleted file mode 100644
index 7cad29f0..00000000
--- a/src/com/gitblit/wicket/panels/PageLinksPanel.html
+++ /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">
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd"
- xml:lang="en"
- lang="en">
-
-<wicket:panel>
- <!-- floating search form on right -->
- <form wicket:id="searchForm">
- <div class="search">
- <select wicket:id="searchType"/>
- <input type="text" id="searchBox" wicket:id="searchBox" size="25" value=""/>
- </div>
- </form>
-
- <!-- page nav links -->
- <div class="page_nav">
- <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>
- </div>
-</wicket:panel>
-</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
index 0f335010..00000000
--- a/src/com/gitblit/wicket/panels/PageLinksPanel.java
+++ /dev/null
@@ -1,150 +0,0 @@
-package com.gitblit.wicket.panels;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.form.DropDownChoice;
-import org.apache.wicket.markup.html.form.StatelessForm;
-import org.apache.wicket.markup.html.form.TextField;
-import org.apache.wicket.markup.html.link.BookmarkablePageLink;
-import org.apache.wicket.markup.html.panel.Panel;
-import org.apache.wicket.markup.repeater.Item;
-import org.apache.wicket.markup.repeater.data.DataView;
-import org.apache.wicket.markup.repeater.data.ListDataProvider;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-import org.eclipse.jgit.lib.Repository;
-
-import com.gitblit.GitBlit;
-import com.gitblit.Keys;
-import com.gitblit.utils.JGitUtils;
-import com.gitblit.utils.JGitUtils.SearchType;
-import com.gitblit.wicket.LinkPanel;
-import com.gitblit.wicket.WicketUtils;
-import com.gitblit.wicket.pages.BranchesPage;
-import com.gitblit.wicket.pages.DocsPage;
-import com.gitblit.wicket.pages.LogPage;
-import com.gitblit.wicket.pages.SearchPage;
-import com.gitblit.wicket.pages.SummaryPage;
-import com.gitblit.wicket.pages.TagsPage;
-import com.gitblit.wicket.pages.TicketsPage;
-import com.gitblit.wicket.pages.TreePage;
-
-public class PageLinksPanel extends Panel {
-
- private static final long serialVersionUID = 1L;
-
- private final Map<String, String> knownPages = new HashMap<String, String>() {
-
- private static final long serialVersionUID = 1L;
-
- {
- put("summary", "gb.summary");
- put("log", "gb.log");
- put("branches", "gb.branches");
- put("tags", "gb.tags");
- put("tree", "gb.tree");
- put("tickets", "gb.tickets");
- }
- };
-
- public PageLinksPanel(String id, Repository r, final String repositoryName, String pageName) {
- super(id);
-
- // summary
- add(new BookmarkablePageLink<Void>("summary", SummaryPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
- add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
- add(new BookmarkablePageLink<Void>("branches", BranchesPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
- add(new BookmarkablePageLink<Void>("tags", TagsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
- add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils.newRepositoryParameter(repositoryName)));
-
- List<String> extras = new ArrayList<String>();
-
- // Get the repository tickets setting
- boolean checkTickets = JGitUtils.getRepositoryUseTickets(r);
- if (checkTickets && JGitUtils.getTicketsBranch(r) != null) {
- extras.add("tickets");
- }
-
- // Get the repository docs setting
- boolean checkDocs = JGitUtils.getRepositoryUseDocs(r);
- if (checkDocs) {
- extras.add("docs");
- }
-
- ListDataProvider<String> extrasDp = new ListDataProvider<String>(extras);
- DataView<String> extrasView = new DataView<String>("extra", extrasDp) {
- private static final long serialVersionUID = 1L;
-
- public void populateItem(final Item<String> item) {
- String extra = item.getModelObject();
- if (extra.equals("tickets")) {
- item.add(new Label("extraSeparator", " | "));
- item.add(new LinkPanel("extraLink", null, getString("gb.tickets"), TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
- } else if (extra.equals("docs")) {
- item.add(new Label("extraSeparator", " | "));
- item.add(new LinkPanel("extraLink", null, getString("gb.docs"), DocsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
- }
- }
- };
- add(extrasView);
-
- add(new SearchForm("searchForm", repositoryName));
- }
-
- public void disablePageLink(String pageName) {
- for (String wicketId : knownPages.keySet()) {
- String key = knownPages.get(wicketId);
- String linkName = getString(key);
- if (linkName.equals(pageName)) {
- Component c = get(wicketId);
- if (c != null) {
- c.setEnabled(false);
- }
- break;
- }
- }
- }
-
- class SearchForm extends StatelessForm<Void> {
- private static final long serialVersionUID = 1L;
-
- private final String repositoryName;
-
- private final IModel<String> searchBoxModel = new Model<String>("");
-
- private final IModel<SearchType> searchTypeModel = new Model<SearchType>(SearchType.COMMIT);
-
- public SearchForm(String id, String repositoryName) {
- super(id);
- this.repositoryName = repositoryName;
- DropDownChoice<SearchType> searchType = new DropDownChoice<SearchType>("searchType", Arrays.asList(SearchType.values()));
- searchType.setModel(searchTypeModel);
- WicketUtils.setHtmlTooltip(searchType, getString("gb.searchTypeTooltip"));
- add(searchType.setVisible(GitBlit.self().settings().getBoolean(Keys.web.showSearchTypeSelection, false)));
- TextField<String> searchBox = new TextField<String>("searchBox", searchBoxModel);
- add(searchBox);
- WicketUtils.setHtmlTooltip(searchBox, getString("gb.searchTooltip"));
- WicketUtils.setInputPlaceholder(searchBox, getString("gb.search"));
- }
-
- @Override
- public void onSubmit() {
- SearchType searchType = searchTypeModel.getObject();
- String searchString = searchBoxModel.getObject();
- for (SearchType type : SearchType.values()) {
- if (searchString.toLowerCase().startsWith(type.name().toLowerCase() + ":")) {
- searchType = type;
- searchString = searchString.substring(type.name().toLowerCase().length() + 1).trim();
- break;
- }
- }
- setResponsePage(SearchPage.class, WicketUtils.newSearchParameter(repositoryName, null, searchString, searchType));
- }
- }
-} \ No newline at end of file
diff --git a/src/com/gitblit/wicket/resources/gitblit.css b/src/com/gitblit/wicket/resources/gitblit.css
index ce3be676..53845466 100644
--- a/src/com/gitblit/wicket/resources/gitblit.css
+++ b/src/com/gitblit/wicket/resources/gitblit.css
@@ -32,14 +32,14 @@ pre, code, pre.prettyprint, pre.plainprint {
/* age0: age < 60*60*2 */
.age0 {
- color: #009900;
+ color: #008000;
font-style: italic;
font-weight: bold;
}
/* age1: 60*60*2 <= age < 60*60*24*2 */
.age1 {
- color: #009900;
+ color: #008000;
font-style: italic;
}
@@ -272,7 +272,7 @@ span.diff.add {
}
span.diff.remove {
- color: #cc0000;
+ color: #FFDDDD;
font-family: inherit;
}
@@ -373,7 +373,7 @@ span.addition, span.modification, span.deletion, span.rename {
}
span.addition {
- background-color: #bbffbb;
+ background-color: #ccffcc;
}
span.modification {
@@ -381,11 +381,11 @@ span.modification {
}
span.deletion {
- background-color: #ff8888;
+ background-color: #f8bbbb;
}
span.rename {
- background-color: #8888ff;
+ background-color: #cAc2f5;
}
div.commitLegend {
@@ -616,16 +616,16 @@ span .otherRef {
}
span .remoteRef {
- background-color: #aaaaff;
+ background-color: #cAc2f5;
border-color: #ccccff #0033cc #0033cc #ccccff;
}
span .tagRef {
background-color: #ffffaa;
- border-color: #ffffcc #ffee00 #ffee00 #ffffcc;
+ border-color: #ffcc00 #ffcc00 #ffcc00 #ffcc00;
}
span .headRef {
- background-color: #aaffaa;
+ background-color: #ccffcc;
border-color: #ccffcc #00cc33 #00cc33 #ccffcc;
} \ No newline at end of file