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
}\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
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
}\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
--- /dev/null
+<!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
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
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
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
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
\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
\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
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
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
break;\r
}\r
}\r
- \r
+\r
@Override\r
protected void onBeforeRender() {\r
// dispose of repository object\r
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
\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
<!-- 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
<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
<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
<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
<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
<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
<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
\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
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
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
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
<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
\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
<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
<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
<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
<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
<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
+++ /dev/null
-<!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
+++ /dev/null
-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
\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
}\r
\r
span.diff.remove {\r
- color: #cc0000;\r
+ color: #FFDDDD;\r
font-family: inherit;\r
}\r
\r
}\r
\r
span.addition {\r
- background-color: #bbffbb;\r
+ background-color: #ccffcc;\r
}\r
\r
span.modification {\r
}\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
}\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