diff options
author | James Moger <james.moger@gitblit.com> | 2011-04-04 09:10:51 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2011-04-04 09:10:51 -0400 |
commit | 5fe7df81eb38dc66f2cfc4bf1973863a19f55cf2 (patch) | |
tree | 3f1b1b3f953aa8a5ed60e149043598fbdaf4d42f /src/com/gitblit/wicket | |
download | gitblit-5fe7df81eb38dc66f2cfc4bf1973863a19f55cf2.tar.gz gitblit-5fe7df81eb38dc66f2cfc4bf1973863a19f55cf2.zip |
Initial import of Git:Blit.
Change-Id: Ifce000c85c8947c3a768e782c841e41a8953d314
Diffstat (limited to 'src/com/gitblit/wicket')
51 files changed, 2374 insertions, 0 deletions
diff --git a/src/com/gitblit/wicket/BasePage.java b/src/com/gitblit/wicket/BasePage.java new file mode 100644 index 00000000..5d8176a2 --- /dev/null +++ b/src/com/gitblit/wicket/BasePage.java @@ -0,0 +1,69 @@ +package com.gitblit.wicket;
+
+import java.util.Date;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.gitblit.utils.Utils;
+
+
+public abstract class BasePage extends WebPage {
+
+ Logger logger = LoggerFactory.getLogger(BasePage.class);
+
+ public BasePage() {
+ super();
+ }
+
+ public BasePage(PageParameters params) {
+ super(params);
+ }
+
+ protected Label createAuthorLabel(String wicketId, String author) {
+ Label label = new Label(wicketId, author);
+ WicketUtils.setHtmlTitle(label, author);
+ return label;
+ }
+
+ protected Label createDateLabel(String wicketId, Date date) {
+ Label label = new Label(wicketId, GitBlitWebSession.get().formatDate(date));
+ WicketUtils.setCssClass(label, Utils.timeAgoCss(date));
+ WicketUtils.setHtmlTitle(label, Utils.timeAgo(date));
+ return label;
+ }
+
+ protected Label createShortlogDateLabel(String wicketId, Date date) {
+ String dateString = GitBlitWebSession.get().formatDate(date);
+ String title = Utils.timeAgo(date);
+ if ((System.currentTimeMillis() - date.getTime()) < 10 * 24 * 60 * 60 * 1000l) {
+ dateString = title;
+ title = GitBlitWebSession.get().formatDate(date);
+ }
+ Label label = new Label(wicketId, dateString);
+ WicketUtils.setCssClass(label, Utils.timeAgoCss(date));
+ WicketUtils.setHtmlTitle(label, title);
+ return label;
+ }
+
+ protected void setAlternatingBackground(Component c, int i) {
+ String clazz = i % 2 == 0 ? "dark" : "light";
+ WicketUtils.setCssClass(c, clazz);
+ }
+
+ protected String trimShortLog(String string) {
+ if (string.length() > 60) {
+ return string.substring(0, 60) + "...";
+ }
+ return string;
+ }
+
+ public void error(String message, Throwable t) {
+ super.error(message);
+ logger.error(message, t);
+ }
+}
diff --git a/src/com/gitblit/wicket/GitBlitWebApp.java b/src/com/gitblit/wicket/GitBlitWebApp.java new file mode 100644 index 00000000..2a245fa8 --- /dev/null +++ b/src/com/gitblit/wicket/GitBlitWebApp.java @@ -0,0 +1,143 @@ +package com.gitblit.wicket;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.wicket.Application;
+import org.apache.wicket.Page;
+import org.apache.wicket.Request;
+import org.apache.wicket.Response;
+import org.apache.wicket.Session;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.protocol.http.request.urlcompressing.UrlCompressingWebRequestProcessor;
+import org.apache.wicket.protocol.http.servlet.ServletWebRequest;
+import org.apache.wicket.request.IRequestCycleProcessor;
+import org.apache.wicket.request.target.coding.MixedParamUrlCodingStrategy;
+import org.eclipse.jgit.errors.RepositoryNotFoundException;
+import org.eclipse.jgit.http.server.resolver.FileResolver;
+import org.eclipse.jgit.http.server.resolver.ServiceNotEnabledException;
+import org.eclipse.jgit.lib.Repository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.gitblit.GitBlitServer;
+import com.gitblit.StoredSettings;
+import com.gitblit.utils.JGitUtils;
+import com.gitblit.wicket.models.RepositoryModel;
+import com.gitblit.wicket.pages.BlobPage;
+import com.gitblit.wicket.pages.CommitPage;
+import com.gitblit.wicket.pages.HeadsPage;
+import com.gitblit.wicket.pages.LogPage;
+import com.gitblit.wicket.pages.RepositoriesPage;
+import com.gitblit.wicket.pages.ShortLogPage;
+import com.gitblit.wicket.pages.SummaryPage;
+import com.gitblit.wicket.pages.TagPage;
+import com.gitblit.wicket.pages.TagsPage;
+import com.gitblit.wicket.pages.TreePage;
+
+
+public class GitBlitWebApp extends WebApplication {
+
+ public static int PAGING_ITEM_COUNT = 50;
+
+ Logger logger = LoggerFactory.getLogger(GitBlitWebApp.class);
+
+ FileResolver repositoryResolver;
+
+ private File repositories;
+
+ private boolean exportAll;
+
+ @Override
+ public void init() {
+ super.init();
+
+ // Grab Browser info (like timezone, etc)
+ getRequestCycleSettings().setGatherExtendedBrowserInfo(true);
+
+ // setup the url paths
+ mount(new MixedParamUrlCodingStrategy("/summary", SummaryPage.class, new String[] { "p" }));
+ mount(new MixedParamUrlCodingStrategy("/shortlog", ShortLogPage.class, new String[] { "p", "h" }));
+ mount(new MixedParamUrlCodingStrategy("/log", LogPage.class, new String[] { "p", "h" }));
+ mount(new MixedParamUrlCodingStrategy("/tags", TagsPage.class, new String[] { "p" }));
+ mount(new MixedParamUrlCodingStrategy("/heads", HeadsPage.class, new String[] { "p" }));
+ mount(new MixedParamUrlCodingStrategy("/commit", CommitPage.class, new String[] { "p", "h" }));
+ mount(new MixedParamUrlCodingStrategy("/tag", TagPage.class, new String[] { "p", "h" }));
+ mount(new MixedParamUrlCodingStrategy("/tree", TreePage.class, new String[] { "p", "h", "f" }));
+ mount(new MixedParamUrlCodingStrategy("/blob", BlobPage.class, new String[] { "p", "h", "f" }));
+
+ repositories = new File(StoredSettings.getString("repositoriesFolder", "repos"));
+ exportAll = StoredSettings.getBoolean("exportAll", true);
+ repositoryResolver = new FileResolver(repositories, exportAll);
+ }
+
+ @Override
+ public Class<? extends Page> getHomePage() {
+ return RepositoriesPage.class;
+ }
+
+ @Override
+ public final Session newSession(Request request, Response response) {
+ return new GitBlitWebSession(request);
+ }
+
+ @Override
+ protected final IRequestCycleProcessor newRequestCycleProcessor() {
+ return new UrlCompressingWebRequestProcessor();
+ }
+
+ @Override
+ public final String getConfigurationType() {
+ if (GitBlitServer.isDebugMode())
+ return Application.DEVELOPMENT;
+ return Application.DEPLOYMENT;
+ }
+
+ public List<String> getRepositoryList() {
+ return JGitUtils.getRepositoryList(repositories, exportAll, StoredSettings.getBoolean("nestedRepositories", true));
+ }
+
+ public List<RepositoryModel> getRepositories(Request request) {
+ List<String> list = getRepositoryList();
+ ServletWebRequest servletWebRequest = (ServletWebRequest) request;
+ HttpServletRequest req = servletWebRequest.getHttpServletRequest();
+
+ List<RepositoryModel> repositories = new ArrayList<RepositoryModel>();
+ for (String repo : list) {
+ Repository r = getRepository(req, repo);
+ String description = JGitUtils.getRepositoryDescription(r);
+ String owner = JGitUtils.getRepositoryOwner(r);
+ Date lastchange = JGitUtils.getLastChange(r);
+ r.close();
+ repositories.add(new RepositoryModel(repo, description, owner, lastchange));
+ }
+ return repositories;
+ }
+
+ public Repository getRepository(HttpServletRequest req, String repositoryName) {
+ Repository r = null;
+ try {
+ r = repositoryResolver.open(req, repositoryName);
+ } catch (RepositoryNotFoundException e) {
+ r = null;
+ logger.error("Failed to find repository " + repositoryName);
+ e.printStackTrace();
+ } catch (ServiceNotEnabledException e) {
+ r = null;
+ e.printStackTrace();
+ }
+ return r;
+ }
+
+ public String getCloneUrl(String repositoryName) {
+ return StoredSettings.getString("cloneUrl", "https://localhost/git/") + repositoryName;
+ }
+
+ public static GitBlitWebApp get() {
+ return (GitBlitWebApp) WebApplication.get();
+ }
+}
diff --git a/src/com/gitblit/wicket/GitBlitWebSession.java b/src/com/gitblit/wicket/GitBlitWebSession.java new file mode 100644 index 00000000..1eccb702 --- /dev/null +++ b/src/com/gitblit/wicket/GitBlitWebSession.java @@ -0,0 +1,74 @@ +package com.gitblit.wicket;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+import org.apache.wicket.Request;
+import org.apache.wicket.Session;
+import org.apache.wicket.protocol.http.WebSession;
+import org.apache.wicket.protocol.http.request.WebClientInfo;
+
+import com.gitblit.StoredSettings;
+
+
+public final class GitBlitWebSession extends WebSession {
+
+ private static final long serialVersionUID = 1L;
+
+ protected TimeZone timezone = null;
+
+ public GitBlitWebSession(Request request) {
+ super(request);
+ }
+
+ public void invalidate() {
+ super.invalidate();
+ }
+
+ public TimeZone getTimezone() {
+ if (timezone == null) {
+ timezone = ((WebClientInfo) getClientInfo()).getProperties().getTimeZone();
+ }
+ // use server timezone if we can't determine the client timezone
+ if (timezone == null) {
+ timezone = TimeZone.getDefault();
+ }
+ return timezone;
+ }
+
+ public String formatTime(Date date) {
+ DateFormat df = new SimpleDateFormat(StoredSettings.getString("timestampFormat", "h:mm a"));
+ df.setTimeZone(getTimezone());
+ return df.format(date);
+ }
+
+ public String formatDate(Date date) {
+ DateFormat df = new SimpleDateFormat(StoredSettings.getString("datestampShortFormat", "MM/dd/yy"));
+ df.setTimeZone(getTimezone());
+ return df.format(date);
+ }
+
+ public String formatDateLong(Date date) {
+ DateFormat df = new SimpleDateFormat(StoredSettings.getString("datestampLongFormat", "EEEE, MMMM d, yyyy"));
+ df.setTimeZone(getTimezone());
+ return df.format(date);
+ }
+
+ public String formatDateTime(Date date) {
+ DateFormat df = new SimpleDateFormat(StoredSettings.getString("datetimestampShortFormat", "MM/dd/yy h:mm a"));
+ df.setTimeZone(getTimezone());
+ return df.format(date);
+ }
+
+ public String formatDateTimeLong(Date date) {
+ DateFormat df = new SimpleDateFormat(StoredSettings.getString("datetimestampLongFormat", "EEEE, MMMM d, yyyy h:mm a"));
+ df.setTimeZone(getTimezone());
+ return df.format(date);
+ }
+
+ public static GitBlitWebSession get() {
+ return (GitBlitWebSession) Session.get();
+ }
+}
\ No newline at end of file diff --git a/src/com/gitblit/wicket/LinkPanel.html b/src/com/gitblit/wicket/LinkPanel.html new file mode 100644 index 00000000..7abf14ce --- /dev/null +++ b/src/com/gitblit/wicket/LinkPanel.html @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+<wicket:panel>
+<a href="#" wicket:id="link"><span wicket:id="label">link</span></a>
+</wicket:panel>
+</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/LinkPanel.java b/src/com/gitblit/wicket/LinkPanel.java new file mode 100644 index 00000000..afa2647b --- /dev/null +++ b/src/com/gitblit/wicket/LinkPanel.java @@ -0,0 +1,44 @@ +package com.gitblit.wicket;
+
+import org.apache.wicket.AttributeModifier;
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.AbstractReadOnlyModel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+
+public class LinkPanel extends Panel {
+
+ private static final long serialVersionUID = 1L;
+
+ private IModel<String> labelModel = new Model<String>();
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public LinkPanel(String wicketId, final String linkCssClass, String label, Class<? extends WebPage> clazz, PageParameters parameters) {
+ super(wicketId);
+ Link<?> link = null;
+ if (parameters == null) {
+ link = new BookmarkablePageLink("link", clazz);
+ } else {
+ link = new BookmarkablePageLink("link", clazz, parameters);
+ }
+ if (linkCssClass != null) {
+ link.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getObject() {
+ return linkCssClass;
+ }
+ }));
+ }
+ labelModel.setObject(label);
+ link.add(new Label("label", labelModel));
+ add(link);
+ }
+
+}
diff --git a/src/com/gitblit/wicket/RepositoryPage.java b/src/com/gitblit/wicket/RepositoryPage.java new file mode 100644 index 00000000..4371052b --- /dev/null +++ b/src/com/gitblit/wicket/RepositoryPage.java @@ -0,0 +1,118 @@ +package com.gitblit.wicket;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.protocol.http.servlet.ServletWebRequest;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+
+import com.gitblit.StoredSettings;
+import com.gitblit.utils.JGitUtils;
+import com.gitblit.wicket.pages.RepositoriesPage;
+import com.gitblit.wicket.panels.PageFooter;
+import com.gitblit.wicket.panels.PageHeader;
+import com.gitblit.wicket.panels.PageLinksPanel;
+import com.gitblit.wicket.panels.RefsPanel;
+
+
+public abstract class RepositoryPage extends BasePage {
+
+ protected final String repositoryName;
+ protected final String commitId;
+ protected String description;
+
+ public RepositoryPage(PageParameters params, String pageName) {
+ super(params);
+ if (!params.containsKey("p")) {
+ error("Repository not specified!");
+ redirectToInterceptPage(new RepositoriesPage());
+ }
+ repositoryName = params.getString("p", "");
+ commitId = params.getString("h", "");
+
+ add(new PageHeader("pageHeader", repositoryName, "/ " + pageName));
+ add(new PageLinksPanel("pageLinks", repositoryName, pageName));
+ setStatelessHint(true);
+ }
+
+ protected Repository getRepository() {
+ ServletWebRequest servletWebRequest = (ServletWebRequest) getRequest();
+ HttpServletRequest req = servletWebRequest.getHttpServletRequest();
+ req.getServerName();
+
+ Repository r = GitBlitWebApp.get().getRepository(req, repositoryName);
+ if (r == null) {
+ error("Can not load repository " + repositoryName);
+ redirectToInterceptPage(new RepositoriesPage());
+ return null;
+ }
+ description = JGitUtils.getRepositoryDescription(r);
+ return r;
+ }
+
+ protected void addRefs(Repository r, RevCommit c) {
+ add(new RefsPanel("refsPanel", r, c));
+ }
+
+ protected void addFullText(String wicketId, String text, boolean substituteRegex) {
+ String html = WicketUtils.breakLines(text);
+ if (substituteRegex) {
+ Map<String, String> map = new HashMap<String, String>();
+ // global regex keys
+ for (String key : StoredSettings.getAllKeys("regex.global")) {
+ String subKey = key.substring(key.lastIndexOf('.') + 1);
+ map.put(subKey, StoredSettings.getString(key, ""));
+ }
+
+ // repository-specific regex keys
+ List<String> keys = StoredSettings.getAllKeys("regex." + repositoryName.toLowerCase());
+ for (String key : keys) {
+ String subKey = key.substring(key.lastIndexOf('.') + 1);
+ map.put(subKey, StoredSettings.getString(key, ""));
+ }
+
+ for (String key : map.keySet()) {
+ String definition = map.get(key).trim();
+ String [] chunks = definition.split("!!!");
+ if (chunks.length == 2) {
+ html = html.replaceAll(chunks[0], chunks[1]);
+ } else {
+ logger.warn(key + " improperly formatted. Use !!! to separate match from replacement: " + definition);
+ }
+ }
+ }
+ add(new Label(wicketId, html).setEscapeModelStrings(false));
+ }
+
+ protected void addFooter() {
+ add(new PageFooter("pageFooter", description));
+ }
+
+ protected PageParameters newRepositoryParameter() {
+ return new PageParameters("p=" + repositoryName);
+ }
+
+ protected PageParameters newCommitParameter() {
+ return newCommitParameter(commitId);
+ }
+
+ protected PageParameters newCommitParameter(String commitId) {
+ if (commitId == null || commitId.trim().length() == 0) {
+ return newRepositoryParameter();
+ }
+ return new PageParameters("p=" + repositoryName + ",h=" + commitId);
+ }
+
+ protected PageParameters newPathParameter(String path) {
+ if (path == null || path.trim().length() == 0) {
+ return newCommitParameter();
+ }
+ return new PageParameters("p=" + repositoryName + ",h=" + commitId + ",f=" + path);
+ }
+}
diff --git a/src/com/gitblit/wicket/SecuredPage.java b/src/com/gitblit/wicket/SecuredPage.java new file mode 100644 index 00000000..c3153a67 --- /dev/null +++ b/src/com/gitblit/wicket/SecuredPage.java @@ -0,0 +1,11 @@ +package com.gitblit.wicket;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface SecuredPage {
+}
diff --git a/src/com/gitblit/wicket/WicketUtils.java b/src/com/gitblit/wicket/WicketUtils.java new file mode 100644 index 00000000..1d85a80b --- /dev/null +++ b/src/com/gitblit/wicket/WicketUtils.java @@ -0,0 +1,35 @@ +package com.gitblit.wicket;
+
+import org.apache.wicket.AttributeModifier;
+import org.apache.wicket.Component;
+import org.apache.wicket.model.AbstractReadOnlyModel;
+
+public class WicketUtils {
+
+ public static void setCssClass(Component container, String value) {
+ container.add(newAttributeModifier("class", value));
+ }
+
+ public static void setCssStyle(Component container, String value) {
+ container.add(newAttributeModifier("style", value));
+ }
+
+ public static void setHtmlTitle(Component container, String value) {
+ container.add(newAttributeModifier("title", value));
+ }
+
+ private static AttributeModifier newAttributeModifier(String attrib, final String value) {
+ return new AttributeModifier(attrib, true, new AbstractReadOnlyModel<String>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getObject() {
+ return value;
+ }
+ });
+ }
+
+ public static String breakLines(String string) {
+ return string.replace("\r", "<br/>").replace("\n", "<br/>");
+ }
+}
diff --git a/src/com/gitblit/wicket/models/PathModel.java b/src/com/gitblit/wicket/models/PathModel.java new file mode 100644 index 00000000..3fa0f633 --- /dev/null +++ b/src/com/gitblit/wicket/models/PathModel.java @@ -0,0 +1,45 @@ +package com.gitblit.wicket.models;
+
+import java.io.Serializable;
+
+import com.gitblit.utils.JGitUtils;
+
+
+public class PathModel implements Serializable, Comparable<PathModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public final String name;
+ public final String path;
+ public final long size;
+ public final int mode;
+ public final String commitId;
+ public boolean isParentPath;
+
+ public PathModel(String name, String path, long size, int mode, String commitId) {
+ this.name = name;
+ this.path = path;
+ this.size = size;
+ this.mode = mode;
+ this.commitId = commitId;
+ }
+
+ public boolean isTree() {
+ return JGitUtils.isTreeFromMode(mode);
+ }
+
+ public static PathModel getParentPath(String basePath, String commitId) {
+ String parentPath = null;
+ if (basePath.lastIndexOf('/') > -1) {
+ parentPath = basePath.substring(0, basePath.lastIndexOf('/'));
+ }
+ PathModel model = new PathModel("..", parentPath, 0, 0040000, commitId);
+ model.isParentPath = true;
+ return model;
+ }
+
+ @Override
+ public int compareTo(PathModel o) {
+ return path.compareTo(o.path);
+ }
+}
diff --git a/src/com/gitblit/wicket/models/RefModel.java b/src/com/gitblit/wicket/models/RefModel.java new file mode 100644 index 00000000..e76b489d --- /dev/null +++ b/src/com/gitblit/wicket/models/RefModel.java @@ -0,0 +1,54 @@ +package com.gitblit.wicket.models;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import org.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.lib.Ref;
+import org.eclipse.jgit.revwalk.RevCommit;
+
+import com.gitblit.utils.JGitUtils;
+
+
+public class RefModel implements Serializable, Comparable<RefModel> {
+
+ private static final long serialVersionUID = 1L;
+ final String displayName;
+ transient Ref ref;
+ final RevCommit commit;
+
+ public RefModel(String displayName, Ref ref, RevCommit commit) {
+ this.displayName = displayName;
+ this.ref = ref;
+ this.commit = commit;
+ }
+
+ public Date getDate() {
+ return JGitUtils.getCommitDate(commit);
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public String getName() {
+ return ref.getName();
+ }
+
+ public ObjectId getCommitId() {
+ return commit.getId();
+ }
+
+ public String getShortLog() {
+ return commit.getShortMessage();
+ }
+
+ public ObjectId getObjectId() {
+ return ref.getObjectId();
+ }
+
+ @Override
+ public int compareTo(RefModel o) {
+ return getDate().compareTo(o.getDate());
+ }
+}
\ No newline at end of file diff --git a/src/com/gitblit/wicket/models/RepositoryModel.java b/src/com/gitblit/wicket/models/RepositoryModel.java new file mode 100644 index 00000000..7ce98e0c --- /dev/null +++ b/src/com/gitblit/wicket/models/RepositoryModel.java @@ -0,0 +1,20 @@ +package com.gitblit.wicket.models;
+
+import java.io.Serializable;
+import java.util.Date;
+
+public class RepositoryModel implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ public final String name;
+ public final String description;
+ public final String owner;
+ public final Date lastChange;
+
+ public RepositoryModel(String name, String description, String owner, Date lastchange) {
+ this.name = name;
+ this.description = description;
+ this.owner = owner;
+ this.lastChange = lastchange;
+ }
+}
\ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/BlobPage.html b/src/com/gitblit/wicket/pages/BlobPage.html new file mode 100644 index 00000000..6d04e180 --- /dev/null +++ b/src/com/gitblit/wicket/pages/BlobPage.html @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<head>
+ <link href="prettify/prettify.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="prettify/prettify.js"></script>
+</head>
+<body onload="prettyPrint()">
+ <!-- page header -->
+ <div wicket:id="pageHeader"></div>
+
+ <!-- page nav links -->
+ <div wicket:id="pageLinks"></div>
+
+ <!-- blob nav links -->
+ <div class="page_nav2">
+ <span wicket:id="historyLink"></span> | <span wicket:id="rawLink"></span> | <span wicket:id="headLink"></span>
+ </div>
+
+ <!-- shortlog header -->
+ <div class="header" wicket:id="shortlog"></div>
+
+ <!-- breadcrumbs -->
+ <div wicket:id="breadcrumbs"></div>
+
+ <!-- blob content -->
+ <pre wicket:id="blobText"></pre>
+
+ <!-- footer -->
+ <div wicket:id="pageFooter"></div>
+</body>
+</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/BlobPage.java b/src/com/gitblit/wicket/pages/BlobPage.java new file mode 100644 index 00000000..979bb261 --- /dev/null +++ b/src/com/gitblit/wicket/pages/BlobPage.java @@ -0,0 +1,94 @@ +package com.gitblit.wicket.pages;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.basic.Label;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+
+import com.gitblit.StoredSettings;
+import com.gitblit.utils.JGitUtils;
+import com.gitblit.wicket.LinkPanel;
+import com.gitblit.wicket.RepositoryPage;
+import com.gitblit.wicket.WicketUtils;
+import com.gitblit.wicket.panels.PathBreadcrumbsPanel;
+
+
+public class BlobPage extends RepositoryPage {
+
+ public BlobPage(PageParameters params) {
+ super(params, "blob");
+
+ final String blobPath = params.getString("f", null);
+
+ Repository r = getRepository();
+ RevCommit commit = JGitUtils.getCommit(r, commitId);
+
+ // blob page links
+ add(new Label("historyLink", "history"));
+ add(new Label("rawLink", "raw"));
+ add(new Label("headLink", "HEAD"));
+
+ add(new LinkPanel("shortlog", "title", commit.getShortMessage(), CommitPage.class, newCommitParameter()));
+
+ add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, blobPath, commitId));
+ String extension = null;
+ if (blobPath.lastIndexOf('.') > -1) {
+ extension = blobPath.substring(blobPath.lastIndexOf('.') + 1);
+ }
+
+ // Map the extensions to types
+ Map<String, Integer> map = new HashMap<String, Integer>();
+ for (String ext : StoredSettings.getStrings("prettyPrintExtensions")) {
+ map.put(ext.toLowerCase(), 1);
+ }
+ for (String ext : StoredSettings.getStrings("imageExtensions")) {
+ map.put(ext.toLowerCase(), 2);
+ }
+ for (String ext : StoredSettings.getStrings("binaryExtensions")) {
+ map.put(ext.toLowerCase(), 3);
+ }
+
+ if (extension != null) {
+ int type = 0;
+ if (map.containsKey(extension)) {
+ type = map.get(extension);
+ }
+ Component c = null;
+ switch (type) {
+ case 1:
+ // PrettyPrint blob text
+ c = new Label("blobText", JGitUtils.getRawContentAsString(r, commit, blobPath));
+ WicketUtils.setCssClass(c, "prettyprint");
+ break;
+ case 2:
+ // TODO image blobs
+ c = new Label("blobText", "Image File");
+ break;
+ case 3:
+ // TODO binary blobs
+ c = new Label("blobText", "Binary File");
+ break;
+ default:
+ // plain text
+ c = new Label("blobText", JGitUtils.getRawContentAsString(r, commit, blobPath));
+ WicketUtils.setCssClass(c, "plainprint");
+ }
+ add(c);
+ } else {
+ // plain text
+ Label blobLabel = new Label("blobText", JGitUtils.getRawContentAsString(r, commit, blobPath));
+ WicketUtils.setCssClass(blobLabel, "plainprint");
+ add(blobLabel);
+ }
+
+ // close repository
+ r.close();
+
+ // footer
+ addFooter();
+ }
+}
diff --git a/src/com/gitblit/wicket/pages/CommitPage.html b/src/com/gitblit/wicket/pages/CommitPage.html new file mode 100644 index 00000000..a493e047 --- /dev/null +++ b/src/com/gitblit/wicket/pages/CommitPage.html @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<body>
+ <!-- page header -->
+ <div wicket:id="pageHeader"></div>
+
+ <!-- page nav links -->
+ <div wicket:id="pageLinks"></div>
+
+ <!-- commit nav links -->
+ <div class="page_nav2">
+ (parent: <span wicket:id="parentLink"></span>) | <span wicket:id="patchLink"></span>
+ </div>
+
+ <!-- shortlog header -->
+ <div class="header" wicket:id="shortlog"></div>
+
+ <!-- Refs -->
+ <div wicket:id="refsPanel"></div>
+
+ <!-- commit info -->
+ <div class="title_text">
+ <table class="object_header">
+ <tr><td>author</td><td><span wicket:id="commitAuthor">Message goes here</span></td></tr>
+ <tr><td></td><td><span wicket:id="commitAuthorDate">Message goes here</span></td></tr>
+ <tr><td>committer</td><td><span wicket:id="commitCommitter">Message goes here</span></td></tr>
+ <tr><td></td><td><span wicket:id="commitCommitterDate">Message goes here</span></td></tr>
+ <tr><td>commit</td><td class="sha1"><span wicket:id="commitId">Message goes here</span></td></tr>
+ <tr><td>tree</td><td class="sha1"><span wicket:id="commitTree">Message goes here</span></td></tr>
+ <tr><td>parent</td><td class="sha1"><span wicket:id="commitParents">
+ <div wicket:id="commitParent">Message goes here</div></span></td></tr>
+ </table>
+ </div>
+
+ <!-- full message -->
+ <div class="page_body" wicket:id="fullMessage"></div>
+
+ <!-- changed paths -->
+ <div class="list_head"></div>
+ <table class="diff_tree">
+ <tr wicket:id="changedPath">
+ <td class="path"><span wicket:id="pathName"></span></td>
+ <td></td>
+ <td><span wicket:id="pathLinks"></span></td>
+ </tr>
+ </table>
+
+ <!-- footer -->
+ <div wicket:id="pageFooter"></div>
+</body>
+</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/CommitPage.java b/src/com/gitblit/wicket/pages/CommitPage.java new file mode 100644 index 00000000..ad1fce06 --- /dev/null +++ b/src/com/gitblit/wicket/pages/CommitPage.java @@ -0,0 +1,106 @@ +package com.gitblit.wicket.pages;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.basic.Label;
+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.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+
+import com.gitblit.utils.JGitUtils;
+import com.gitblit.wicket.GitBlitWebSession;
+import com.gitblit.wicket.LinkPanel;
+import com.gitblit.wicket.RepositoryPage;
+import com.gitblit.wicket.WicketUtils;
+import com.gitblit.wicket.models.PathModel;
+import com.gitblit.wicket.panels.PathLinksPanel;
+
+
+public class CommitPage extends RepositoryPage {
+
+ public CommitPage(PageParameters params) {
+ super(params, "commit");
+
+ final String commitId = params.getString("h", "");
+
+ Repository r = getRepository();
+ RevCommit c = JGitUtils.getCommit(r, commitId);
+
+ List<String> parents = new ArrayList<String>();
+ if (c.getParentCount() > 0) {
+ for (RevCommit parent : c.getParents()) {
+ parents.add(parent.name());
+ }
+ }
+
+ // commit page links
+ if (parents.size() == 0) {
+ add(new Label("parentLink", "none"));
+ } else {
+ add(new LinkPanel("parentLink", null, parents.get(0).substring(0, 8), CommitPage.class, newCommitParameter(parents.get(0))));
+ }
+ add(new Label("patchLink", "patch"));
+
+ add(new LinkPanel("shortlog", "title", c.getShortMessage(), ShortLogPage.class, newRepositoryParameter()));
+
+ addRefs(r, c);
+
+ add(new Label("commitAuthor", JGitUtils.getDisplayName(c.getAuthorIdent())));
+ String authorDate = GitBlitWebSession.get().formatDateTimeLong(c.getAuthorIdent().getWhen());
+ add(new Label("commitAuthorDate", authorDate));
+
+ add(new Label("commitCommitter", JGitUtils.getDisplayName(c.getCommitterIdent())));
+ String comitterDate = GitBlitWebSession.get().formatDateTimeLong(c.getCommitterIdent().getWhen());
+ add(new Label("commitCommitterDate", comitterDate));
+
+ add(new Label("commitId", c.getName()));
+
+ add(new LinkPanel("commitTree", "list", c.getTree().getName(), TreePage.class, newCommitParameter()));
+
+ // Parent Commits
+ ListDataProvider<String> parentsDp = new ListDataProvider<String>(parents);
+ DataView<String> parentsView = new DataView<String>("commitParents", parentsDp) {
+ private static final long serialVersionUID = 1L;
+
+ public void populateItem(final Item<String> item) {
+ String entry = item.getModelObject();
+ item.add(new LinkPanel("commitParent", "list", entry, CommitPage.class, newCommitParameter(entry)));
+ }
+ };
+ add(parentsView);
+
+ addFullText("fullMessage", c.getFullMessage(), true);
+
+ // changed paths list
+ List<PathModel> paths = JGitUtils.getCommitChangedPaths(r, c);
+ ListDataProvider<PathModel> pathsDp = new ListDataProvider<PathModel>(paths);
+ DataView<PathModel> pathsView = new DataView<PathModel>("changedPath", pathsDp) {
+ private static final long serialVersionUID = 1L;
+ int counter = 0;
+
+ public void populateItem(final Item<PathModel> item) {
+ final PathModel entry = item.getModelObject();
+ if (entry.isTree()) {
+ item.add(new LinkPanel("pathName", null, entry.path, TreePage.class, newPathParameter(entry.path)));
+ } else {
+ item.add(new LinkPanel("pathName", "list", entry.path, BlobPage.class, newPathParameter(entry.path)));
+ }
+ item.add(new PathLinksPanel("pathLinks", repositoryName, entry));
+ String clazz = counter % 2 == 0 ? "dark" : "light";
+ WicketUtils.setCssClass(item, clazz);
+ counter++;
+ }
+ };
+ add(pathsView);
+
+ // close repository
+ r.close();
+
+ // footer
+ addFooter();
+ }
+}
diff --git a/src/com/gitblit/wicket/pages/HeadsPage.html b/src/com/gitblit/wicket/pages/HeadsPage.html new file mode 100644 index 00000000..cd914363 --- /dev/null +++ b/src/com/gitblit/wicket/pages/HeadsPage.html @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<body>
+ <!-- page header -->
+ <div wicket:id="pageHeader"></div>
+
+ <!-- page nav links -->
+ <div wicket:id="pageLinks"></div>
+
+ <!-- shortlog -->
+ <div class="header" wicket:id="summary"></div>
+
+ <table class="heads">
+ <tbody>
+ <tr wicket:id="head">
+ <td><i><span wicket:id="headDate"></span></i></td>
+ <td><div wicket:id="headName"></div></td>
+ <td></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <!-- footer -->
+ <div wicket:id="pageFooter"></div>
+</body>
+</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/HeadsPage.java b/src/com/gitblit/wicket/pages/HeadsPage.java new file mode 100644 index 00000000..df5e00f0 --- /dev/null +++ b/src/com/gitblit/wicket/pages/HeadsPage.java @@ -0,0 +1,63 @@ +package com.gitblit.wicket.pages;
+
+import java.util.List;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.basic.Label;
+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.eclipse.jgit.lib.Repository;
+
+import com.gitblit.utils.JGitUtils;
+import com.gitblit.utils.Utils;
+import com.gitblit.wicket.GitBlitWebApp;
+import com.gitblit.wicket.LinkPanel;
+import com.gitblit.wicket.RepositoryPage;
+import com.gitblit.wicket.WicketUtils;
+import com.gitblit.wicket.models.RefModel;
+
+
+public class HeadsPage extends RepositoryPage {
+
+ public HeadsPage(PageParameters params) {
+ super(params, "heads");
+
+ Repository r = getRepository();
+ List<RefModel> tags = JGitUtils.getHeads(r, -1);
+ r.close();
+
+ // shortlog
+ add(new LinkPanel("summary", "title", repositoryName, SummaryPage.class, newRepositoryParameter()));
+
+ ListDataProvider<RefModel> tagsDp = new ListDataProvider<RefModel>(tags);
+ DataView<RefModel> tagView = new DataView<RefModel>("head", tagsDp) {
+ private static final long serialVersionUID = 1L;
+ int counter = 0;
+
+ public void populateItem(final Item<RefModel> item) {
+ final RefModel entry = item.getModelObject();
+ String date;
+ if (entry.getDate() != null) {
+ date = Utils.timeAgo(entry.getDate());
+ } else {
+ date = "";
+ }
+ Label headDateLabel = new Label("headDate", date);
+ item.add(headDateLabel);
+ WicketUtils.setCssClass(headDateLabel, Utils.timeAgoCss(entry.getDate()));
+
+ item.add(new LinkPanel("headName", "list name", entry.getDisplayName(), ShortLogPage.class, newCommitParameter(entry.getName())));
+
+ String clazz = counter % 2 == 0 ? "dark" : "light";
+ WicketUtils.setCssClass(item, clazz);
+ counter++;
+ }
+ };
+ tagView.setItemsPerPage(GitBlitWebApp.PAGING_ITEM_COUNT);
+ add(tagView);
+
+ // footer
+ addFooter();
+ }
+}
diff --git a/src/com/gitblit/wicket/pages/LogPage.html b/src/com/gitblit/wicket/pages/LogPage.html new file mode 100644 index 00000000..3c1b54b9 --- /dev/null +++ b/src/com/gitblit/wicket/pages/LogPage.html @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<body>
+ <!-- page header -->
+ <div wicket:id="pageHeader"></div>
+
+ <!-- page nav links -->
+ <div wicket:id="pageLinks"></div>
+
+ <!-- summary header -->
+ <div class="header" wicket:id="summary"></div>
+
+ <!-- log -->
+ <div wicket:id="commit">
+ <div class="header">
+ <b><span class="age" wicket:id="timeAgo"></span></b>
+ <span wicket:id="link"></span>
+ </div>
+ <div wicket:id="commitRefs"></div>
+ <div class="title_text">
+ <div class="log_link">commit | commitdiff | tree</div>
+ <span wicket:id="commitAuthor"></span>
+ <span wicket:id="commitDate"></span>
+ </div>
+ <div class="log_body" wicket:id="fullMessage"></div>
+ </div>
+
+ <div wicket:id="navigator"></div>
+
+ <!-- footer -->
+ <div wicket:id="pageFooter"></div>
+</body>
+</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/LogPage.java b/src/com/gitblit/wicket/pages/LogPage.java new file mode 100644 index 00000000..325596ab --- /dev/null +++ b/src/com/gitblit/wicket/pages/LogPage.java @@ -0,0 +1,69 @@ +package com.gitblit.wicket.pages;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
+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.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+
+import com.gitblit.utils.JGitUtils;
+import com.gitblit.utils.Utils;
+import com.gitblit.wicket.GitBlitWebApp;
+import com.gitblit.wicket.GitBlitWebSession;
+import com.gitblit.wicket.LinkPanel;
+import com.gitblit.wicket.RepositoryPage;
+import com.gitblit.wicket.WicketUtils;
+import com.gitblit.wicket.panels.RefsPanel;
+
+
+public class LogPage extends RepositoryPage {
+
+ public LogPage(PageParameters params) {
+ super(params, "log");
+
+ Repository r = getRepository();
+ final Map<ObjectId, List<String>> allRefs = JGitUtils.getAllRefs(r);
+ List<RevCommit> commits = JGitUtils.getRevLog(r, 100);
+ r.close();
+
+ add(new LinkPanel("summary", "title", repositoryName, SummaryPage.class, newRepositoryParameter()));
+
+ // log
+ ListDataProvider<RevCommit> dp = new ListDataProvider<RevCommit>(commits);
+ DataView<RevCommit> logView = new DataView<RevCommit>("commit", dp) {
+ private static final long serialVersionUID = 1L;
+
+ public void populateItem(final Item<RevCommit> item) {
+ final RevCommit entry = item.getModelObject();
+ final Date date = JGitUtils.getCommitDate(entry);
+
+ item.add(new Label("timeAgo", Utils.timeAgo(date)));
+
+ item.add(new LinkPanel("link", "title", entry.getShortMessage(), CommitPage.class, newCommitParameter(entry.getName())));
+
+ item.add(new RefsPanel("commitRefs", entry, allRefs));
+
+ String author = entry.getAuthorIdent().getName();
+ item.add(createAuthorLabel("commitAuthor", author));
+
+ item.add(new Label("commitDate", GitBlitWebSession.get().formatDateTimeLong(date)));
+
+ item.add(new Label("fullMessage", WicketUtils.breakLines(entry.getFullMessage())).setEscapeModelStrings(false));
+ }
+ };
+ logView.setItemsPerPage(GitBlitWebApp.PAGING_ITEM_COUNT);
+ add(logView);
+ add(new PagingNavigator("navigator", logView));
+
+ // footer
+ addFooter();
+ }
+}
diff --git a/src/com/gitblit/wicket/pages/RepositoriesPage.html b/src/com/gitblit/wicket/pages/RepositoriesPage.html new file mode 100644 index 00000000..6a3054f1 --- /dev/null +++ b/src/com/gitblit/wicket/pages/RepositoriesPage.html @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<body>
+ <div wicket:id="pageHeader"></div>
+ <div class="index_include" wicket:id="indexInclude"></div>
+
+ <table class="project_list">
+ <tr>
+ <th wicket:id="orderByRepository">Repository</th>
+ <th wicket:id="orderByDescription">Description</th>
+ <th wicket:id="orderByOwner">Owner</th>
+ <th wicket:id="orderByDate">Last Change</th>
+ <th></th>
+ </tr>
+ <tbody>
+ <tr wicket:id="repository">
+ <td><div class="list" wicket:id="repositoryName"></div></td>
+ <td><div class="list" wicket:id="repositoryDescription"></div></td>
+ <td><i><span wicket:id="repositoryOwner"></span></i></td>
+ <td><span wicket:id="repositoryLastChange"></span></td>
+ <td></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <!-- footer -->
+ <div wicket:id="pageFooter"></div>
+</body>
+</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/RepositoriesPage.java b/src/com/gitblit/wicket/pages/RepositoriesPage.java new file mode 100644 index 00000000..1c880d9f --- /dev/null +++ b/src/com/gitblit/wicket/pages/RepositoriesPage.java @@ -0,0 +1,151 @@ +package com.gitblit.wicket.pages;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.extensions.markup.html.repeater.data.sort.OrderByBorder;
+import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
+import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.markup.repeater.data.DataView;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+
+import com.gitblit.StoredSettings;
+import com.gitblit.utils.Utils;
+import com.gitblit.wicket.BasePage;
+import com.gitblit.wicket.GitBlitWebApp;
+import com.gitblit.wicket.LinkPanel;
+import com.gitblit.wicket.WicketUtils;
+import com.gitblit.wicket.models.RepositoryModel;
+import com.gitblit.wicket.panels.PageFooter;
+import com.gitblit.wicket.panels.PageHeader;
+
+
+public class RepositoriesPage extends BasePage {
+
+ public RepositoriesPage() {
+ add(new PageHeader("pageHeader"));
+
+ add(new Label("indexInclude", StoredSettings.getString("indexMessage", "")).setEscapeModelStrings(false));
+
+ List<RepositoryModel> rows = GitBlitWebApp.get().getRepositories(getRequest());
+ DataProvider dp = new DataProvider(rows);
+ DataView<RepositoryModel> dataView = new DataView<RepositoryModel>("repository", dp) {
+ private static final long serialVersionUID = 1L;
+ int counter = 0;
+
+ public void populateItem(final Item<RepositoryModel> item) {
+ final RepositoryModel entry = item.getModelObject();
+ PageParameters pp = new PageParameters("p=" + entry.name);
+ item.add(new LinkPanel("repositoryName", "list", entry.name, SummaryPage.class, pp));
+ item.add(new LinkPanel("repositoryDescription", "list", entry.description, SummaryPage.class, pp));
+ item.add(new Label("repositoryOwner", entry.owner));
+
+ String lastChange = Utils.timeAgo(entry.lastChange);
+ Label lastChangeLabel = new Label("repositoryLastChange", lastChange);
+ item.add(lastChangeLabel);
+ WicketUtils.setCssClass(lastChangeLabel, Utils.timeAgoCss(entry.lastChange));
+
+ String clazz = counter % 2 == 0 ? "dark" : "light";
+ WicketUtils.setCssClass(item, clazz);
+ counter++;
+ }
+ };
+ add(dataView);
+
+ add(newSort("orderByRepository", SortBy.repository, dp, dataView));
+ add(newSort("orderByDescription", SortBy.description, dp, dataView));
+ add(newSort("orderByOwner", SortBy.owner, dp, dataView));
+ add(newSort("orderByDate", SortBy.date, dp, dataView));
+
+ add(new PageFooter("pageFooter"));
+ }
+
+ protected enum SortBy {
+ repository, description, owner, date;
+ }
+
+ protected OrderByBorder newSort(String wicketId, SortBy field, SortableDataProvider<?> dp, final DataView<?> dataView) {
+ return new OrderByBorder(wicketId, field.name(), dp) {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void onSortChanged() {
+ dataView.setCurrentPage(0);
+ }
+ };
+ }
+
+ private class DataProvider extends SortableDataProvider<RepositoryModel> {
+ private static final long serialVersionUID = 1L;
+ private List<RepositoryModel> list = null;
+
+ protected DataProvider(List<RepositoryModel> list) {
+ this.list = list;
+ setSort(SortBy.date.name(), false);
+ }
+
+ @Override
+ public int size() {
+ if (list == null)
+ return 0;
+ return list.size();
+ }
+
+ @Override
+ public IModel<RepositoryModel> model(RepositoryModel header) {
+ return new Model<RepositoryModel>(header);
+ }
+
+ @Override
+ public Iterator<RepositoryModel> iterator(int first, int count) {
+ SortParam sp = getSort();
+ String prop = sp.getProperty();
+ final boolean asc = sp.isAscending();
+
+ if (prop == null || prop.equals(SortBy.date.name())) {
+ Collections.sort(list, new Comparator<RepositoryModel>() {
+ @Override
+ public int compare(RepositoryModel o1, RepositoryModel o2) {
+ if (asc)
+ return o1.lastChange.compareTo(o2.lastChange);
+ return o2.lastChange.compareTo(o1.lastChange);
+ }
+ });
+ } else if (prop.equals(SortBy.repository.name())) {
+ Collections.sort(list, new Comparator<RepositoryModel>() {
+ @Override
+ public int compare(RepositoryModel o1, RepositoryModel o2) {
+ if (asc)
+ return o1.name.compareTo(o2.name);
+ return o2.name.compareTo(o1.name);
+ }
+ });
+ } else if (prop.equals(SortBy.owner.name())) {
+ Collections.sort(list, new Comparator<RepositoryModel>() {
+ @Override
+ public int compare(RepositoryModel o1, RepositoryModel o2) {
+ if (asc)
+ return o1.owner.compareTo(o2.owner);
+ return o2.owner.compareTo(o1.owner);
+ }
+ });
+ } else if (prop.equals(SortBy.description.name())) {
+ Collections.sort(list, new Comparator<RepositoryModel>() {
+ @Override
+ public int compare(RepositoryModel o1, RepositoryModel o2) {
+ if (asc)
+ return o1.description.compareTo(o2.description);
+ return o2.description.compareTo(o1.description);
+ }
+ });
+ }
+ return list.subList(first, first + count).iterator();
+ }
+ }
+}
diff --git a/src/com/gitblit/wicket/pages/ShortLogPage.html b/src/com/gitblit/wicket/pages/ShortLogPage.html new file mode 100644 index 00000000..b10e90d6 --- /dev/null +++ b/src/com/gitblit/wicket/pages/ShortLogPage.html @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<body>
+ <!-- page header -->
+ <div wicket:id="pageHeader"></div>
+
+ <!-- page nav links -->
+ <div wicket:id="pageLinks"></div>
+
+ <!-- shortlog -->
+ <div class="header" wicket:id="summary"></div>
+
+ <table class="project_list">
+ <tbody>
+ <tr wicket:id="commit">
+ <td><span wicket:id="commitDate"></span></td>
+ <td><i><span wicket:id="commitAuthor"></span></i></td>
+ <td><div wicket:id="commitShortMessage"></div></td>
+ <td><div wicket:id="commitRefs"></div></td>
+ <td><span wicket:id="commitLinks"></span></td>
+ </tr>
+ <tr>
+ <td colspan="4"><div wicket:id="navigator"></div></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <!-- footer -->
+ <div wicket:id="pageFooter"></div>
+</body>
+</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/ShortLogPage.java b/src/com/gitblit/wicket/pages/ShortLogPage.java new file mode 100644 index 00000000..220874e8 --- /dev/null +++ b/src/com/gitblit/wicket/pages/ShortLogPage.java @@ -0,0 +1,76 @@ +package com.gitblit.wicket.pages;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
+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.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+
+import com.gitblit.utils.JGitUtils;
+import com.gitblit.wicket.GitBlitWebApp;
+import com.gitblit.wicket.LinkPanel;
+import com.gitblit.wicket.RepositoryPage;
+import com.gitblit.wicket.WicketUtils;
+import com.gitblit.wicket.panels.RefsPanel;
+import com.gitblit.wicket.panels.ShortLogLinksPanel;
+
+
+public class ShortLogPage extends RepositoryPage {
+
+ public ShortLogPage(PageParameters params) {
+ super(params, "shortlog");
+
+ Repository r = getRepository();
+ final Map<ObjectId, List<String>> allRefs = JGitUtils.getAllRefs(r);
+ List<RevCommit> commits = JGitUtils.getRevLog(r, 100);
+ r.close();
+
+ // shortlog
+ add(new LinkPanel("summary", "title", repositoryName, SummaryPage.class, newRepositoryParameter()));
+
+ ListDataProvider<RevCommit> dp = new ListDataProvider<RevCommit>(commits);
+ DataView<RevCommit> shortlogView = new DataView<RevCommit>("commit", dp) {
+ private static final long serialVersionUID = 1L;
+ int counter = 0;
+
+ public void populateItem(final Item<RevCommit> item) {
+ final RevCommit entry = item.getModelObject();
+ final Date date = JGitUtils.getCommitDate(entry);
+
+ item.add(createShortlogDateLabel("commitDate", date));
+
+ String author = entry.getAuthorIdent().getName();
+ item.add(createAuthorLabel("commitAuthor", author));
+
+ String shortMessage = entry.getShortMessage();
+ String trimmedMessage = trimShortLog(shortMessage);
+ LinkPanel shortlog = new LinkPanel("commitShortMessage", "list subject", trimmedMessage, CommitPage.class, newCommitParameter(entry.getName()));
+ if (!shortMessage.equals(trimmedMessage)) {
+ WicketUtils.setHtmlTitle(shortlog, shortMessage);
+ }
+ item.add(shortlog);
+
+ item.add(new RefsPanel("commitRefs", entry, allRefs));
+
+ item.add(new ShortLogLinksPanel("commitLinks", repositoryName, entry.getName()));
+
+ String clazz = counter % 2 == 0 ? "dark" : "light";
+ WicketUtils.setCssClass(item, clazz);
+ counter++;
+ }
+ };
+ shortlogView.setItemsPerPage(GitBlitWebApp.PAGING_ITEM_COUNT);
+ add(shortlogView);
+ add(new PagingNavigator("navigator", shortlogView));
+
+ // footer
+ addFooter();
+ }
+}
diff --git a/src/com/gitblit/wicket/pages/SummaryPage.html b/src/com/gitblit/wicket/pages/SummaryPage.html new file mode 100644 index 00000000..3eab0a1e --- /dev/null +++ b/src/com/gitblit/wicket/pages/SummaryPage.html @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<body>
+ <!-- page header -->
+ <div wicket:id="pageHeader"></div>
+
+ <!-- page nav links -->
+ <div wicket:id="pageLinks"></div>
+
+ <!-- repository info -->
+ <div class="title"> </div>
+ <table class="projects_list">
+ <tr id="metadata_desc"><td>description</td><td><span wicket:id="repositoryDescription">Message goes here</span></td></tr>
+ <tr id="metadata_owner"><td>owner</td><td><span wicket:id="repositoryOwner">Message goes here</span></td></tr>
+ <tr id="metadata_lchange"><td>last change</td><td><span wicket:id="repositoryLastChange">Message goes here</span></td></tr>
+ <tr class="metadata_url"><td>URL</td><td><span wicket:id="repositoryCloneUrl">Message goes here</span></td></tr>
+ </table>
+
+
+ <!-- shortlog -->
+ <div class="header" wicket:id="shortlog"></div>
+
+ <table class="project_list">
+ <tbody>
+ <tr wicket:id="commit">
+ <td><span wicket:id="commitDate"></span></td>
+ <td><i><span wicket:id="commitAuthor"></span></i></td>
+ <td><div wicket:id="commitShortMessage"></div></td>
+ <td><div wicket:id="commitRefs"></div></td>
+ <td><span wicket:id="commitLinks"></span></td>
+ </tr>
+
+ <tr>
+ <td colspan="4"><div wicket:id="shortlogMore"></div></td>
+ </tr>
+ </tbody>
+ </table>
+
+
+ <!-- tags -->
+ <div class="header" wicket:id="tags"></div>
+
+ <table class="project_list">
+ <tbody>
+ <tr wicket:id="tag">
+ <td><i><span wicket:id="tagDate"></span></i></td>
+ <td><div wicket:id="tagName"></div></td>
+ <td><div wicket:id="tagDescription"></div></td>
+ <td><span wicket:id="tagLinks"></span></td>
+ </tr>
+
+ <tr>
+ <td colspan="4"><div wicket:id="tagsMore"></div></td>
+ </tr>
+ </tbody>
+ </table>
+
+
+ <!-- heads -->
+ <div class="header" wicket:id="heads"></div>
+
+ <table class="heads">
+ <tbody>
+ <tr wicket:id="head">
+ <td><i><span wicket:id="headDate"></span></i></td>
+ <td><div wicket:id="headName"></div></td>
+ <td><span wicket:id="headLinks"></span></td>
+ </tr>
+ </tbody>
+ </table>
+
+
+ <!-- footer -->
+ <div wicket:id="pageFooter"></div>
+</body>
+</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/SummaryPage.java b/src/com/gitblit/wicket/pages/SummaryPage.java new file mode 100644 index 00000000..84e78b4e --- /dev/null +++ b/src/com/gitblit/wicket/pages/SummaryPage.java @@ -0,0 +1,149 @@ +package com.gitblit.wicket.pages;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.basic.Label;
+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.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+
+import com.gitblit.utils.JGitUtils;
+import com.gitblit.wicket.GitBlitWebApp;
+import com.gitblit.wicket.GitBlitWebSession;
+import com.gitblit.wicket.LinkPanel;
+import com.gitblit.wicket.RepositoryPage;
+import com.gitblit.wicket.WicketUtils;
+import com.gitblit.wicket.models.RefModel;
+import com.gitblit.wicket.panels.HeadLinksPanel;
+import com.gitblit.wicket.panels.RefsPanel;
+import com.gitblit.wicket.panels.ShortLogLinksPanel;
+import com.gitblit.wicket.panels.TagLinksPanel;
+
+
+public class SummaryPage extends RepositoryPage {
+
+ public SummaryPage(PageParameters params) {
+ super(params, "summary");
+
+ Repository r = getRepository();
+ final Map<ObjectId, List<String>> allRefs = JGitUtils.getAllRefs(r);
+
+ String owner = JGitUtils.getRepositoryOwner(r);
+ GitBlitWebSession session = GitBlitWebSession.get();
+ String lastchange = session.formatDateTimeLong(JGitUtils.getLastChange(r));
+ String cloneurl = GitBlitWebApp.get().getCloneUrl(repositoryName);
+
+ // repository description
+ add(new Label("repositoryDescription", description));
+ add(new Label("repositoryOwner", owner));
+ add(new Label("repositoryLastChange", lastchange));
+ add(new Label("repositoryCloneUrl", cloneurl));
+
+ int summaryCount = 16;
+
+ // shortlog
+ add(new LinkPanel("shortlog", "title", "shortlog", ShortLogPage.class, newRepositoryParameter()));
+
+ List<RevCommit> commits = JGitUtils.getRevLog(r, summaryCount);
+ ListDataProvider<RevCommit> dp = new ListDataProvider<RevCommit>(commits);
+ DataView<RevCommit> shortlogView = new DataView<RevCommit>("commit", dp) {
+ private static final long serialVersionUID = 1L;
+ int counter = 0;
+
+ public void populateItem(final Item<RevCommit> item) {
+ RevCommit entry = item.getModelObject();
+ Date date = JGitUtils.getCommitDate(entry);
+
+ item.add(createShortlogDateLabel("commitDate", date));
+
+ String author = entry.getAuthorIdent().getName();
+ item.add(createAuthorLabel("commitAuthor", author));
+
+ String shortMessage = entry.getShortMessage();
+ String trimmedMessage = trimShortLog(shortMessage);
+ LinkPanel shortlog = new LinkPanel("commitShortMessage", "list subject", trimmedMessage, CommitPage.class, newCommitParameter(entry.getName()));
+ if (!shortMessage.equals(trimmedMessage)) {
+ WicketUtils.setHtmlTitle(shortlog, shortMessage);
+ }
+ item.add(shortlog);
+
+ item.add(new RefsPanel("commitRefs", entry, allRefs));
+
+ item.add(new ShortLogLinksPanel("commitLinks", repositoryName, entry.getName()));
+
+ setAlternatingBackground(item, counter);
+ counter++;
+ }
+ };
+ add(shortlogView);
+ add(new LinkPanel("shortlogMore", "link", "...", ShortLogPage.class, newRepositoryParameter()));
+
+ // tags
+ List<RefModel> tags = JGitUtils.getTags(r, summaryCount);
+ add(new LinkPanel("tags", "title", "tags", TagsPage.class, newRepositoryParameter()));
+
+ ListDataProvider<RefModel> tagsDp = new ListDataProvider<RefModel>(tags);
+ DataView<RefModel> tagView = new DataView<RefModel>("tag", tagsDp) {
+ private static final long serialVersionUID = 1L;
+ int counter = 0;
+
+ public void populateItem(final Item<RefModel> item) {
+ final RefModel entry = item.getModelObject();
+
+ item.add(createDateLabel("tagDate", entry.getDate()));
+
+ item.add(new LinkPanel("tagName", "list name", entry.getDisplayName(), CommitPage.class, newCommitParameter(entry.getCommitId().getName())));
+
+ if (entry.getCommitId().equals(entry.getObjectId())) {
+ // lightweight tag on commit object
+ item.add(new Label("tagDescription", ""));
+ } else {
+ // tag object
+ item.add(new LinkPanel("tagDescription", "list subject", entry.getShortLog(), TagPage.class, newCommitParameter(entry.getObjectId().getName())));
+ }
+
+ item.add(new TagLinksPanel("tagLinks", repositoryName, entry));
+
+ setAlternatingBackground(item, counter);
+ counter++;
+ }
+ };
+ add(tagView);
+ add(new LinkPanel("tagsMore", "link", "...", TagsPage.class, newRepositoryParameter()));
+ // heads
+ List<RefModel> heads = JGitUtils.getHeads(r, summaryCount);
+ add(new LinkPanel("heads", "title", "heads", HeadsPage.class, newRepositoryParameter()));
+
+ ListDataProvider<RefModel> headsDp = new ListDataProvider<RefModel>(heads);
+ DataView<RefModel> headsView = new DataView<RefModel>("head", headsDp) {
+ private static final long serialVersionUID = 1L;
+ int counter = 0;
+
+ public void populateItem(final Item<RefModel> item) {
+ final RefModel entry = item.getModelObject();
+
+ item.add(createDateLabel("headDate", entry.getDate()));
+
+ item.add(new LinkPanel("headName", "list name", entry.getDisplayName(), ShortLogPage.class, newCommitParameter(entry.getName())));
+
+ item.add(new HeadLinksPanel("headLinks", repositoryName, entry));
+
+ setAlternatingBackground(item, counter);
+ counter++;
+ }
+ };
+ add(headsView);
+
+ // close the repository
+ r.close();
+
+ // footer
+ addFooter();
+ }
+}
diff --git a/src/com/gitblit/wicket/pages/TagPage.html b/src/com/gitblit/wicket/pages/TagPage.html new file mode 100644 index 00000000..ae2c99c2 --- /dev/null +++ b/src/com/gitblit/wicket/pages/TagPage.html @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<body>
+ <!-- page header -->
+ <div wicket:id="pageHeader"></div>
+
+ <!-- page nav links -->
+ <div wicket:id="pageLinks"></div>
+
+ <!-- summary header -->
+ <div class="header" wicket:id="commit"></div>
+
+ <!-- commit info -->
+ <div class="title_text">
+ <table class="object_header">
+ <tr><td>object</td><td><span wicket:id="tagId">Message goes here</span></td></tr>
+ <tr><td>author</td><td><span wicket:id="tagAuthor">Message goes here</span></td></tr>
+ <tr><td></td><td><span wicket:id="tagDate">Message goes here</span></td></tr>
+ </table>
+ </div>
+
+ <!-- full message -->
+ <div class="page_body" wicket:id="fullMessage"></div>
+
+ <!-- footer -->
+ <div wicket:id="pageFooter"></div>
+</body>
+</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/TagPage.java b/src/com/gitblit/wicket/pages/TagPage.java new file mode 100644 index 00000000..f098c1e3 --- /dev/null +++ b/src/com/gitblit/wicket/pages/TagPage.java @@ -0,0 +1,36 @@ +package com.gitblit.wicket.pages;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.basic.Label;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+
+import com.gitblit.utils.JGitUtils;
+import com.gitblit.wicket.GitBlitWebSession;
+import com.gitblit.wicket.LinkPanel;
+import com.gitblit.wicket.RepositoryPage;
+
+
+public class TagPage extends RepositoryPage {
+
+ public TagPage(PageParameters params) {
+ super(params, "tag");
+
+ Repository r = getRepository();
+ RevCommit c = JGitUtils.getCommit(r, commitId);
+
+ add(new LinkPanel("commit", "title", c.getName(), CommitPage.class, newCommitParameter()));
+
+ add(new LinkPanel("tagId", "list", c.getName(), CommitPage.class, newCommitParameter(c.getName())));
+ add(new Label("tagAuthor", JGitUtils.getDisplayName(c.getAuthorIdent())));
+ String authorDate = GitBlitWebSession.get().formatDateTimeLong(c.getAuthorIdent().getWhen());
+ add(new Label("tagDate", authorDate));
+
+ addFullText("fullMessage", c.getFullMessage(), true);
+
+ r.close();
+
+ // footer
+ addFooter();
+ }
+}
diff --git a/src/com/gitblit/wicket/pages/TagsPage.html b/src/com/gitblit/wicket/pages/TagsPage.html new file mode 100644 index 00000000..314eec77 --- /dev/null +++ b/src/com/gitblit/wicket/pages/TagsPage.html @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<body>
+ <!-- page header -->
+ <div wicket:id="pageHeader"></div>
+
+ <!-- page nav links -->
+ <div wicket:id="pageLinks"></div>
+
+ <!-- shortlog -->
+ <div class="header" wicket:id="summary"></div>
+
+ <table class="tags">
+ <tbody>
+ <tr wicket:id="tag">
+ <td><i><span wicket:id="tagDate"></span></i></td>
+ <td><div wicket:id="tagName"></div></td>
+ <td><div wicket:id="tagDescription"></div></td>
+ <td><span wicket:id="tagLinks"></span></td>
+ </tr>
+ <tr>
+ <td colspan="4"><div wicket:id="navigator"></div></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <!-- footer -->
+ <div wicket:id="pageFooter"></div>
+</body>
+</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/TagsPage.java b/src/com/gitblit/wicket/pages/TagsPage.java new file mode 100644 index 00000000..85c0455c --- /dev/null +++ b/src/com/gitblit/wicket/pages/TagsPage.java @@ -0,0 +1,64 @@ +package com.gitblit.wicket.pages;
+
+import java.util.List;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
+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.eclipse.jgit.lib.Repository;
+
+import com.gitblit.utils.JGitUtils;
+import com.gitblit.wicket.GitBlitWebApp;
+import com.gitblit.wicket.LinkPanel;
+import com.gitblit.wicket.RepositoryPage;
+import com.gitblit.wicket.models.RefModel;
+import com.gitblit.wicket.panels.TagLinksPanel;
+
+
+public class TagsPage extends RepositoryPage {
+
+ public TagsPage(PageParameters params) {
+ super(params, "tags");
+ Repository r = getRepository();
+ List<RefModel> tags = JGitUtils.getTags(r, -1);
+ r.close();
+
+ // shortlog
+ add(new LinkPanel("summary", "title", repositoryName, SummaryPage.class, newRepositoryParameter()));
+
+ ListDataProvider<RefModel> tagsDp = new ListDataProvider<RefModel>(tags);
+ DataView<RefModel> tagView = new DataView<RefModel>("tag", tagsDp) {
+ private static final long serialVersionUID = 1L;
+ int counter = 0;
+
+ public void populateItem(final Item<RefModel> item) {
+ final RefModel entry = item.getModelObject();
+ item.add(createDateLabel("tagDate", entry.getDate()));
+
+ item.add(new LinkPanel("tagName", "list name", entry.getDisplayName(), CommitPage.class, newCommitParameter(entry.getObjectId().getName())));
+
+ if (entry.getCommitId().equals(entry.getObjectId())) {
+ // lightweight tag on commit object
+ item.add(new Label("tagDescription", ""));
+ } else {
+ // tag object
+ item.add(new LinkPanel("tagDescription", "list subject", entry.getShortLog(), TagPage.class, newCommitParameter(entry.getObjectId().getName())));
+ }
+
+ item.add(new TagLinksPanel("tagLinks", repositoryName, entry));
+
+ setAlternatingBackground(item, counter);
+ counter++;
+ }
+ };
+ tagView.setItemsPerPage(GitBlitWebApp.PAGING_ITEM_COUNT);
+ add(tagView);
+ add(new PagingNavigator("navigator", tagView));
+
+ // footer
+ addFooter();
+ }
+}
diff --git a/src/com/gitblit/wicket/pages/TreePage.html b/src/com/gitblit/wicket/pages/TreePage.html new file mode 100644 index 00000000..e01049c6 --- /dev/null +++ b/src/com/gitblit/wicket/pages/TreePage.html @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<body>
+ <!-- page header -->
+ <div wicket:id="pageHeader"></div>
+
+ <!-- page nav links -->
+ <div wicket:id="pageLinks"></div>
+
+ <!-- blob nav links -->
+ <div class="page_nav2">
+ <span wicket:id="historyLink"></span> | <span wicket:id="headLink"></span>
+ </div>
+
+ <!-- shortlog header -->
+ <div class="header" wicket:id="shortlog"></div>
+
+ <!-- breadcrumbs -->
+ <div wicket:id="breadcrumbs"></div>
+
+ <!-- changed paths -->
+ <div class="list_head"></div>
+ <table class="diff_tree">
+ <tr wicket:id="changedPath">
+ <td class="mode"><span wicket:id="pathPermissions"></span></td>
+ <td class="size"><span wicket:id="pathSize"></span></td>
+ <td><span wicket:id="pathName"></span></td>
+ <td><span wicket:id="treeLinks"></span></td>
+ </tr>
+ </table>
+
+ <!-- footer -->
+ <div wicket:id="pageFooter"></div>
+</body>
+</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/TreePage.java b/src/com/gitblit/wicket/pages/TreePage.java new file mode 100644 index 00000000..a608bdda --- /dev/null +++ b/src/com/gitblit/wicket/pages/TreePage.java @@ -0,0 +1,89 @@ +package com.gitblit.wicket.pages;
+
+import java.util.List;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.basic.Label;
+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.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+
+import com.gitblit.utils.ByteFormat;
+import com.gitblit.utils.JGitUtils;
+import com.gitblit.wicket.LinkPanel;
+import com.gitblit.wicket.RepositoryPage;
+import com.gitblit.wicket.WicketUtils;
+import com.gitblit.wicket.models.PathModel;
+import com.gitblit.wicket.panels.PathBreadcrumbsPanel;
+import com.gitblit.wicket.panels.TreeLinksPanel;
+
+
+public class TreePage extends RepositoryPage {
+
+ public TreePage(PageParameters params) {
+ super(params, "tree");
+
+ final String basePath = params.getString("f", null);
+
+ Repository r = getRepository();
+ RevCommit commit = JGitUtils.getCommit(r, commitId);
+ List<PathModel> paths = JGitUtils.getFilesInPath(r, basePath, commit);
+
+ // tree page links
+ add(new Label("historyLink", "history"));
+ add(new Label("headLink", "HEAD"));
+
+ add(new LinkPanel("shortlog", "title", commit.getShortMessage(), CommitPage.class, newCommitParameter()));
+
+ // breadcrumbs
+ if (basePath == null || basePath.trim().length() == 0) {
+ add(new Label("breadcrumbs", "").setVisible(false));
+ } else {
+ add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, basePath, commitId));
+ paths.add(0, PathModel.getParentPath(basePath, commitId));
+ }
+
+ final ByteFormat byteFormat = new ByteFormat();
+
+ // changed paths list
+ ListDataProvider<PathModel> pathsDp = new ListDataProvider<PathModel>(paths);
+ DataView<PathModel> pathsView = new DataView<PathModel>("changedPath", pathsDp) {
+ private static final long serialVersionUID = 1L;
+ int counter = 0;
+
+ public void populateItem(final Item<PathModel> item) {
+ PathModel entry = item.getModelObject();
+ item.add(new Label("pathPermissions", JGitUtils.getPermissionsFromMode(entry.mode)));
+ if (entry.isParentPath) {
+ // parent .. path
+ item.add(new Label("pathSize", "").setVisible(false));
+ item.add(new LinkPanel("pathName", null, entry.name, TreePage.class, newPathParameter(entry.path)));
+ item.add(new Label("treeLinks", "").setVisible(false));
+ } else {
+ if (entry.isTree()) {
+ // folder/tree link
+ item.add(new Label("pathSize", "-"));
+ item.add(new LinkPanel("pathName", null, entry.name, TreePage.class, newPathParameter(entry.path)));
+ } else {
+ // blob link
+ item.add(new Label("pathSize", byteFormat.format(entry.size)));
+ item.add(new LinkPanel("pathName", "list", entry.name, BlobPage.class, newPathParameter(entry.path)));
+ }
+ item.add(new TreeLinksPanel("treeLinks", repositoryName, entry));
+ }
+ String clazz = counter % 2 == 0 ? "dark" : "light";
+ WicketUtils.setCssClass(item, clazz);
+ counter++;
+ }
+ };
+ add(pathsView);
+
+ // close repository
+ r.close();
+
+ // footer
+ addFooter();
+ }
+}
diff --git a/src/com/gitblit/wicket/panels/HeadLinksPanel.html b/src/com/gitblit/wicket/panels/HeadLinksPanel.html new file mode 100644 index 00000000..4849e8e2 --- /dev/null +++ b/src/com/gitblit/wicket/panels/HeadLinksPanel.html @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+<wicket:panel>
+ <div class="link">
+ <span wicket:id="shortlog"></span> | <span wicket:id="log"></span> | <span wicket:id="tree"></span>
+ </div>
+</wicket:panel>
+</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/HeadLinksPanel.java b/src/com/gitblit/wicket/panels/HeadLinksPanel.java new file mode 100644 index 00000000..4f4c9d7e --- /dev/null +++ b/src/com/gitblit/wicket/panels/HeadLinksPanel.java @@ -0,0 +1,23 @@ +package com.gitblit.wicket.panels;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.panel.Panel;
+
+import com.gitblit.wicket.LinkPanel;
+import com.gitblit.wicket.models.RefModel;
+import com.gitblit.wicket.pages.LogPage;
+import com.gitblit.wicket.pages.ShortLogPage;
+
+
+public class HeadLinksPanel extends Panel {
+
+ private static final long serialVersionUID = 1L;
+
+ public HeadLinksPanel(String id, String repositoryName, RefModel tag) {
+ super(id);
+ add(new LinkPanel("shortlog", null, "shortlog", ShortLogPage.class, new PageParameters("p=" + repositoryName + ",h=" + tag.getName())));
+ add(new LinkPanel("log", null, "log", LogPage.class, new PageParameters("p=" + repositoryName + ",h=" + tag.getName())));
+ add(new Label("tree", "tree"));
+ }
+}
\ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/PageFooter.html b/src/com/gitblit/wicket/panels/PageFooter.html new file mode 100644 index 00000000..6eed4b3c --- /dev/null +++ b/src/com/gitblit/wicket/panels/PageFooter.html @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+<wicket:panel>
+ <div class="page_footer">
+ <div class="cachetime"><span wicket:id="cacheTime"></span></div>
+ <div class="page_footer_text"><span wicket:id="footerText"></span></div>
+ <a title="git homepage" href="http://git-scm.com/">Git</a>
+ </div>
+</wicket:panel>
+</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/PageFooter.java b/src/com/gitblit/wicket/panels/PageFooter.java new file mode 100644 index 00000000..91a1f57c --- /dev/null +++ b/src/com/gitblit/wicket/panels/PageFooter.java @@ -0,0 +1,28 @@ +package com.gitblit.wicket.panels;
+
+import java.util.Date;
+
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.panel.Panel;
+
+import com.gitblit.StoredSettings;
+import com.gitblit.wicket.GitBlitWebSession;
+
+
+public class PageFooter extends Panel {
+
+ private static final long serialVersionUID = 1L;
+
+ public PageFooter(String id) {
+ this(id, "");
+ }
+
+ public PageFooter(String id, String description) {
+ super(id);
+ add(new Label("cacheTime", "Page Last Updated: " + GitBlitWebSession.get().formatDateTimeLong(new Date())));
+ add(new Label("footerText", description));
+ if (StoredSettings.getBoolean("aggressiveGC", false)) {
+ System.gc();
+ }
+ }
+}
\ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/PageHeader.html b/src/com/gitblit/wicket/panels/PageHeader.html new file mode 100644 index 00000000..83edb994 --- /dev/null +++ b/src/com/gitblit/wicket/panels/PageHeader.html @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+<wicket:panel>
+ <head>
+ <title wicket:id="title">Message goes here</title>
+ <link rel="stylesheet" type="text/css" href="gitblit.css"/>
+ <link rel="stylesheet" type="text/css" href="gitweb.css"/>
+ <link rel="shortcut icon" href="git-favicon.png" type="image/png" />
+ </head>
+
+ <div class="page_header">
+ <a title="gitblit homepage" href="http://gitblit.com/"><img src="gitblt-logo.png" width="91" height="31" alt="gitblit" class="logo"/></a><a href="/"><span wicket:id="siteName">name</span></a> / <span wicket:id="repositoryName">name</span> <span wicket:id="pageName">name</span>
+ </div>
+</wicket:panel>
+</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/PageHeader.java b/src/com/gitblit/wicket/panels/PageHeader.java new file mode 100644 index 00000000..c375758c --- /dev/null +++ b/src/com/gitblit/wicket/panels/PageHeader.java @@ -0,0 +1,41 @@ +package com.gitblit.wicket.panels;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.protocol.http.servlet.ServletWebRequest;
+
+import com.gitblit.Constants;
+import com.gitblit.StoredSettings;
+import com.gitblit.wicket.LinkPanel;
+import com.gitblit.wicket.pages.SummaryPage;
+
+
+public class PageHeader extends Panel {
+
+ private static final long serialVersionUID = 1L;
+
+ public PageHeader(String id) {
+ this(id, "", "");
+ }
+
+ public PageHeader(String id, String repositoryName, String page) {
+ super(id);
+ if (repositoryName != null && repositoryName.trim().length() > 0) {
+ add(new Label("title", getServerName() + " - " + repositoryName));
+ } else {
+ add(new Label("title", getServerName()));
+ }
+ add(new Label("siteName", StoredSettings.getString("siteName", Constants.NAME)));
+ add(new LinkPanel("repositoryName", null, repositoryName, SummaryPage.class, new PageParameters("p=" + repositoryName)));
+ add(new Label("pageName", page));
+ }
+
+ protected String getServerName() {
+ ServletWebRequest servletWebRequest = (ServletWebRequest) getRequest();
+ HttpServletRequest req = servletWebRequest.getHttpServletRequest();
+ return req.getServerName();
+ }
+}
\ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/PageLinksPanel.html b/src/com/gitblit/wicket/panels/PageLinksPanel.html new file mode 100644 index 00000000..66c3ce7a --- /dev/null +++ b/src/com/gitblit/wicket/panels/PageLinksPanel.html @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+<wicket:panel>
+ <!-- page nav links -->
+ <div class="page_nav">
+ <span wicket:id="summary"></span> | <span wicket:id="shortlog"></span> | <span wicket:id="log"></span> | <span wicket:id="commit"></span> | <span wicket:id="commitdiff"></span> | <span wicket:id="tree"></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 new file mode 100644 index 00000000..f72b8800 --- /dev/null +++ b/src/com/gitblit/wicket/panels/PageLinksPanel.java @@ -0,0 +1,61 @@ +package com.gitblit.wicket.panels;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.panel.Panel;
+
+import com.gitblit.wicket.LinkPanel;
+import com.gitblit.wicket.pages.CommitPage;
+import com.gitblit.wicket.pages.LogPage;
+import com.gitblit.wicket.pages.ShortLogPage;
+import com.gitblit.wicket.pages.SummaryPage;
+import com.gitblit.wicket.pages.TreePage;
+
+
+public class PageLinksPanel extends Panel {
+
+ private static final long serialVersionUID = 1L;
+
+ public PageLinksPanel(String id, String repositoryName, String pageName) {
+ super(id);
+ // summary
+ if (pageName.equals("summary")) {
+ add(new Label("summary", pageName));
+ } else {
+ add(new LinkPanel("summary", null, "summary", SummaryPage.class, new PageParameters("p=" + repositoryName)));
+ }
+
+ // shortlog
+ if (pageName.equals("shortlog")) {
+ add(new Label("shortlog", pageName));
+ } else {
+ add(new LinkPanel("shortlog", null, "shortlog", ShortLogPage.class, new PageParameters("p=" + repositoryName)));
+ }
+
+ // log
+ if (pageName.equals("log")) {
+ add(new Label("log", pageName));
+ } else {
+ add(new LinkPanel("log", null, "log", LogPage.class, new PageParameters("p=" + repositoryName)));
+ }
+
+ // commit
+ if (pageName.equals("commit")) {
+ add(new Label("commit", pageName));
+ } else {
+ add(new LinkPanel("commit", null, "commit", CommitPage.class, new PageParameters("p=" + repositoryName + ",h=HEAD")));
+ }
+ // commitdiff
+ if (pageName.equals("commitdiff")) {
+ add(new Label("commitdiff", pageName));
+ } else {
+ add(new Label("commitdiff", "commitdiff"));
+ }
+ // tree
+ if (pageName.equals("tree")) {
+ add(new Label("tree", pageName));
+ } else {
+ add(new LinkPanel("tree", null, "tree", TreePage.class, new PageParameters("p=" + repositoryName + ",h=HEAD")));
+ }
+ }
+}
\ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/PathBreadcrumbsPanel.html b/src/com/gitblit/wicket/panels/PathBreadcrumbsPanel.html new file mode 100644 index 00000000..ee8bca22 --- /dev/null +++ b/src/com/gitblit/wicket/panels/PathBreadcrumbsPanel.html @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+<wicket:panel>
+ <!-- page path links -->
+ <div class="page_path">
+ <span wicket:id="path">
+ <span wicket:id="pathLink"></span> <span wicket:id="pathSeparator"></span>
+ </span>
+ </div>
+</wicket:panel>
+</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/PathBreadcrumbsPanel.java b/src/com/gitblit/wicket/panels/PathBreadcrumbsPanel.java new file mode 100644 index 00000000..5ce356a2 --- /dev/null +++ b/src/com/gitblit/wicket/panels/PathBreadcrumbsPanel.java @@ -0,0 +1,79 @@ +package com.gitblit.wicket.panels;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.basic.Label;
+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 com.gitblit.wicket.LinkPanel;
+import com.gitblit.wicket.pages.TreePage;
+
+
+public class PathBreadcrumbsPanel extends Panel {
+
+ private static final long serialVersionUID = 1L;
+
+ private final String ROOT = "--ROOT--";
+
+ public PathBreadcrumbsPanel(String id, final String repositoryName, String pathName, final String commitId) {
+ super(id);
+ List<BreadCrumb> crumbs = new ArrayList<BreadCrumb>();
+ crumbs.add(new BreadCrumb("[" + repositoryName + "]", ROOT, false));
+
+ String[] paths = pathName.split("/");
+ StringBuilder sb = new StringBuilder();
+
+ for (int i = 0; i < paths.length; i++) {
+ String path = paths[i];
+ sb.append(path);
+ crumbs.add(new BreadCrumb(path, sb.toString(), (i == (paths.length - 1))));
+ sb.append("/");
+ }
+
+ ListDataProvider<BreadCrumb> crumbsDp = new ListDataProvider<BreadCrumb>(crumbs);
+ DataView<BreadCrumb> pathsView = new DataView<BreadCrumb>("path", crumbsDp) {
+ private static final long serialVersionUID = 1L;
+
+ public void populateItem(final Item<BreadCrumb> item) {
+ final BreadCrumb entry = item.getModelObject();
+ String path = entry.getPath();
+ String parameters = "p=" + repositoryName + ",h=" + commitId;
+ if (path != null) {
+ parameters += ",f=" + path;
+ }
+
+ item.add(new LinkPanel("pathLink", null, entry.name, TreePage.class, new PageParameters(parameters)));
+ item.add(new Label("pathSeparator", entry.isLeaf ? "":"/"));
+ }
+ };
+ add(pathsView);
+ }
+
+ private class BreadCrumb implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ final String name;
+ final String path;
+ final boolean isLeaf;
+
+ BreadCrumb(String name, String path, boolean isLeaf) {
+ this.name = name;
+ this.path = path;
+ this.isLeaf = isLeaf;
+ }
+
+ String getPath() {
+ if (path.equals(ROOT)) {
+ return null;
+ }
+ return path;
+ }
+ }
+}
\ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/PathLinksPanel.html b/src/com/gitblit/wicket/panels/PathLinksPanel.html new file mode 100644 index 00000000..08327b1b --- /dev/null +++ b/src/com/gitblit/wicket/panels/PathLinksPanel.html @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+<wicket:panel>
+ <div class="link">
+ <span wicket:id="diff"></span> | <span wicket:id="blob"></span> | <span wicket:id="history"></span>
+ </div>
+</wicket:panel>
+</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/PathLinksPanel.java b/src/com/gitblit/wicket/panels/PathLinksPanel.java new file mode 100644 index 00000000..fa8bdca6 --- /dev/null +++ b/src/com/gitblit/wicket/panels/PathLinksPanel.java @@ -0,0 +1,22 @@ +package com.gitblit.wicket.panels;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.panel.Panel;
+
+import com.gitblit.wicket.LinkPanel;
+import com.gitblit.wicket.models.PathModel;
+import com.gitblit.wicket.pages.BlobPage;
+
+
+public class PathLinksPanel extends Panel {
+
+ private static final long serialVersionUID = 1L;
+
+ public PathLinksPanel(String id, String repositoryName, PathModel path) {
+ super(id);
+ add(new Label("diff", "diff"));
+ add(new LinkPanel("blob", null, "blob", BlobPage.class, new PageParameters("p=" + repositoryName + ",h=" + path.commitId + ",f=" + path.path)));
+ add(new Label("history", "history"));
+ }
+}
\ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/RefsPanel.html b/src/com/gitblit/wicket/panels/RefsPanel.html new file mode 100644 index 00000000..e7be7c54 --- /dev/null +++ b/src/com/gitblit/wicket/panels/RefsPanel.html @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+<wicket:panel>
+ <span class="refs" wicket:id="ref">
+ <span wicket:id="refName">ref</span>
+ </span>
+</wicket:panel>
+</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/RefsPanel.java b/src/com/gitblit/wicket/panels/RefsPanel.java new file mode 100644 index 00000000..5dec57fe --- /dev/null +++ b/src/com/gitblit/wicket/panels/RefsPanel.java @@ -0,0 +1,66 @@ +package com.gitblit.wicket.panels;
+
+import java.util.ArrayList;
+import java.util.Collections;
+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.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.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+
+import com.gitblit.utils.JGitUtils;
+import com.gitblit.wicket.WicketUtils;
+
+
+public class RefsPanel extends Panel {
+
+ private static final long serialVersionUID = 1L;
+
+ public RefsPanel(String id, Repository r, RevCommit c) {
+ this(id, c, JGitUtils.getAllRefs(r));
+ }
+
+ public RefsPanel(String id, RevCommit c, Map<ObjectId, List<String>> refs) {
+ super(id);
+ List<String> refNames = refs.get(c.getId());
+ if (refNames == null) {
+ refNames = new ArrayList<String>();
+ }
+ Collections.sort(refNames);
+ ListDataProvider<String> refsDp = new ListDataProvider<String>(refNames);
+ DataView<String> refsView = new DataView<String>("ref", refsDp) {
+ private static final long serialVersionUID = 1L;
+ public void populateItem(final Item<String> item) {
+ String entry = item.getModelObject();
+ Component c = null;
+ if (entry.startsWith(Constants.R_HEADS)) {
+ // local head
+ c = new Label("refName", entry.substring(Constants.R_HEADS.length()));
+ WicketUtils.setCssClass(c, "head");
+ } else if (entry.startsWith(Constants.R_REMOTES)) {
+ // remote head
+ c = new Label("refName", entry.substring(Constants.R_REMOTES.length()));
+ WicketUtils.setCssClass(c, "ref");
+ } else if (entry.startsWith(Constants.R_TAGS)) {
+ // tag
+ c = new Label("refName", entry.substring(Constants.R_TAGS.length()));
+ WicketUtils.setCssClass(c, "tag");
+ } else {
+ // other
+ c = new Label("refName", entry);
+ }
+ WicketUtils.setHtmlTitle(c, entry);
+ item.add(c);
+ }
+ };
+ add(refsView);
+ }
+}
\ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/ShortLogLinksPanel.html b/src/com/gitblit/wicket/panels/ShortLogLinksPanel.html new file mode 100644 index 00000000..75d6b1ca --- /dev/null +++ b/src/com/gitblit/wicket/panels/ShortLogLinksPanel.html @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+<wicket:panel>
+ <div class="link">
+ <span wicket:id="commit"></span> | <span wicket:id="commitdiff"></span> | <span wicket:id="tree"></span>
+ </div>
+</wicket:panel>
+</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/ShortLogLinksPanel.java b/src/com/gitblit/wicket/panels/ShortLogLinksPanel.java new file mode 100644 index 00000000..58ec37ac --- /dev/null +++ b/src/com/gitblit/wicket/panels/ShortLogLinksPanel.java @@ -0,0 +1,23 @@ +package com.gitblit.wicket.panels;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.panel.Panel;
+
+import com.gitblit.wicket.LinkPanel;
+import com.gitblit.wicket.pages.CommitPage;
+import com.gitblit.wicket.pages.TreePage;
+
+
+public class ShortLogLinksPanel extends Panel {
+
+ private static final long serialVersionUID = 1L;
+
+ public ShortLogLinksPanel(String id, String repositoryName, String commitId) {
+ super(id);
+
+ add(new LinkPanel("commit", null, "commit", CommitPage.class, new PageParameters("p=" + repositoryName + ",h=" + commitId)));
+ add(new Label("commitdiff", "commitdiff"));
+ add(new LinkPanel("tree", null, "tree", TreePage.class, new PageParameters("p=" + repositoryName + ",h=" + commitId)));
+ }
+}
\ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/TagLinksPanel.html b/src/com/gitblit/wicket/panels/TagLinksPanel.html new file mode 100644 index 00000000..30934085 --- /dev/null +++ b/src/com/gitblit/wicket/panels/TagLinksPanel.html @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+<wicket:panel>
+ <div class="link">
+ <span wicket:id="commit"></span> | <span wicket:id="shortlog"></span> | <span wicket:id="log"></span>
+ </div>
+</wicket:panel>
+</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/TagLinksPanel.java b/src/com/gitblit/wicket/panels/TagLinksPanel.java new file mode 100644 index 00000000..73a9c3ae --- /dev/null +++ b/src/com/gitblit/wicket/panels/TagLinksPanel.java @@ -0,0 +1,23 @@ +package com.gitblit.wicket.panels;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.panel.Panel;
+
+import com.gitblit.wicket.LinkPanel;
+import com.gitblit.wicket.models.RefModel;
+import com.gitblit.wicket.pages.CommitPage;
+import com.gitblit.wicket.pages.LogPage;
+import com.gitblit.wicket.pages.ShortLogPage;
+
+
+public class TagLinksPanel extends Panel {
+
+ private static final long serialVersionUID = 1L;
+
+ public TagLinksPanel(String id, String repositoryName, RefModel tag) {
+ super(id);
+ add(new LinkPanel("commit", null, "commit", CommitPage.class, new PageParameters("p=" + repositoryName + ",h=" + tag.getCommitId().getName())));
+ add(new LinkPanel("shortlog", null, "shortlog", ShortLogPage.class, new PageParameters("p=" + repositoryName + ",h=" + tag.getName())));
+ add(new LinkPanel("log", null, "log", LogPage.class, new PageParameters("p=" + repositoryName + ",h=" + tag.getName())));
+ }
+}
\ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/TreeLinksPanel.html b/src/com/gitblit/wicket/panels/TreeLinksPanel.html new file mode 100644 index 00000000..d0c3b7f3 --- /dev/null +++ b/src/com/gitblit/wicket/panels/TreeLinksPanel.html @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+<wicket:panel>
+ <div class="link">
+ <span wicket:id="link"></span> | <span wicket:id="history"></span> | <span wicket:id="raw"></span>
+ </div>
+</wicket:panel>
+</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/TreeLinksPanel.java b/src/com/gitblit/wicket/panels/TreeLinksPanel.java new file mode 100644 index 00000000..21da66c9 --- /dev/null +++ b/src/com/gitblit/wicket/panels/TreeLinksPanel.java @@ -0,0 +1,29 @@ +package com.gitblit.wicket.panels;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.panel.Panel;
+
+import com.gitblit.wicket.LinkPanel;
+import com.gitblit.wicket.models.PathModel;
+import com.gitblit.wicket.pages.BlobPage;
+import com.gitblit.wicket.pages.TreePage;
+
+
+public class TreeLinksPanel extends Panel {
+
+ private static final long serialVersionUID = 1L;
+
+ public TreeLinksPanel(String id, String repositoryName, PathModel path) {
+ super(id);
+ if (path.isTree()) {
+ add(new LinkPanel("link", null, "tree", TreePage.class, new PageParameters("p=" + repositoryName + ",h=" + path.commitId + ",f=" + path.path)));
+ add(new Label("history", "history"));
+ add(new Label("raw", "").setVisible(false));
+ } else {
+ add(new LinkPanel("link", null, "blob", BlobPage.class, new PageParameters("p=" + repositoryName + ",h=" + path.commitId + ",f=" + path.path)));
+ add(new Label("history", "history"));
+ add(new Label("raw", "raw"));
+ }
+ }
+}
\ No newline at end of file |