| | |
| | | */
|
| | | package com.gitblit.wicket.pages;
|
| | |
|
| | | import java.io.OutputStream;
|
| | | import java.util.List;
|
| | |
|
| | | import org.apache.wicket.PageParameters;
|
| | | import org.apache.wicket.markup.html.basic.Label;
|
| | | import org.apache.wicket.markup.html.link.BookmarkablePageLink;
|
| | | import org.apache.wicket.markup.html.link.ExternalLink;
|
| | | import org.apache.wicket.markup.html.link.Link;
|
| | | import org.apache.wicket.markup.html.panel.Fragment;
|
| | | import org.apache.wicket.markup.repeater.Item;
|
| | | import org.apache.wicket.markup.repeater.data.DataView;
|
| | | import org.apache.wicket.markup.repeater.data.ListDataProvider;
|
| | | import org.apache.wicket.request.target.resource.ResourceStreamRequestTarget;
|
| | | import org.apache.wicket.util.resource.AbstractResourceStreamWriter;
|
| | | import org.apache.wicket.util.resource.IResourceStream;
|
| | | import org.eclipse.jgit.lib.FileMode;
|
| | | import org.eclipse.jgit.lib.Repository;
|
| | | import org.eclipse.jgit.revwalk.RevCommit;
|
| | |
|
| | | import com.gitblit.models.PathModel;
|
| | | import com.gitblit.models.SubmoduleModel;
|
| | | import com.gitblit.models.UserModel;
|
| | | import com.gitblit.servlet.RawServlet;
|
| | | import com.gitblit.utils.ByteFormat;
|
| | | import com.gitblit.utils.JGitUtils;
|
| | | import com.gitblit.wicket.CacheControl;
|
| | | import com.gitblit.wicket.GitBlitWebSession;
|
| | | import com.gitblit.wicket.CacheControl.LastModified;
|
| | | import com.gitblit.wicket.WicketUtils;
|
| | | import com.gitblit.wicket.panels.CommitHeaderPanel;
|
| | |
| | |
|
| | | Repository r = getRepository();
|
| | | RevCommit commit = getCommit();
|
| | | List<PathModel> paths = JGitUtils.getFilesInPath(r, path, commit);
|
| | | List<PathModel> paths = JGitUtils.getFilesInPath2(r, path, commit);
|
| | |
|
| | | // tree page links
|
| | | add(new BookmarkablePageLink<Void>("historyLink", HistoryPage.class,
|
| | |
| | | if (path.lastIndexOf('/') > -1) {
|
| | | parentPath = path.substring(0, path.lastIndexOf('/'));
|
| | | }
|
| | | PathModel model = new PathModel("..", parentPath, 0, FileMode.TREE.getBits(), null, objectId);
|
| | | PathModel model = new PathModel("..", parentPath, null, 0, FileMode.TREE.getBits(), null, objectId);
|
| | | model.isParentPath = true;
|
| | | paths.add(0, model);
|
| | | }
|
| | |
|
| | | final String id = getBestCommitId(commit);
|
| | | |
| | | final ByteFormat byteFormat = new ByteFormat();
|
| | | final String baseUrl = WicketUtils.getGitblitURL(getRequest());
|
| | |
|
| | |
| | |
|
| | | @Override
|
| | | public void populateItem(final Item<PathModel> item) {
|
| | | PathModel entry = item.getModelObject();
|
| | | final PathModel entry = item.getModelObject();
|
| | | |
| | | item.add(new Label("pathPermissions", JGitUtils.getPermissionsFromMode(entry.mode)));
|
| | | |
| | | if (entry.isParentPath) {
|
| | | // parent .. path
|
| | | item.add(WicketUtils.newBlankImage("pathIcon"));
|
| | |
| | | item.add(new LinkPanel("pathName", null, entry.name, TreePage.class,
|
| | | WicketUtils
|
| | | .newPathParameter(repositoryName, id, entry.path)));
|
| | | item.add(new Label("filestore", getString("gb.filestore")).setVisible(false));
|
| | | item.add(new Label("pathLinks", ""));
|
| | | } else {
|
| | | if (entry.isTree()) {
|
| | |
| | | item.add(new LinkPanel("pathName", "list", entry.name, TreePage.class,
|
| | | WicketUtils.newPathParameter(repositoryName, id,
|
| | | entry.path)));
|
| | |
|
| | | item.add(new Label("filestore", getString("gb.filestore")).setVisible(false));
|
| | |
|
| | | // links
|
| | | Fragment links = new Fragment("pathLinks", "treeLinks", this);
|
| | |
| | | getShortObjectId(submoduleId), TreePage.class,
|
| | | WicketUtils.newPathParameter(submodulePath, submoduleId, "")).setEnabled(hasSubmodule));
|
| | |
|
| | | item.add(new Label("filestore", getString("gb.filestore")).setVisible(false));
|
| | | |
| | | Fragment links = new Fragment("pathLinks", "submoduleLinks", this);
|
| | | links.add(new BookmarkablePageLink<Void>("view", SummaryPage.class,
|
| | | WicketUtils.newRepositoryParameter(submodulePath)).setEnabled(hasSubmodule));
|
| | |
| | | }
|
| | | item.add(WicketUtils.getFileImage("pathIcon", entry.name));
|
| | | item.add(new Label("pathSize", byteFormat.format(entry.size)));
|
| | | item.add(new LinkPanel("pathName", "list", displayPath, BlobPage.class,
|
| | | WicketUtils.newPathParameter(repositoryName, id,
|
| | | path)));
|
| | |
|
| | | |
| | | // links
|
| | | Fragment links = new Fragment("pathLinks", "blobLinks", this);
|
| | | links.add(new BookmarkablePageLink<Void>("view", BlobPage.class,
|
| | | WicketUtils.newPathParameter(repositoryName, id,
|
| | | path)));
|
| | | links.add(new BookmarkablePageLink<Void>("raw", RawPage.class, WicketUtils
|
| | | .newPathParameter(repositoryName, id, path)));
|
| | | |
| | | if (entry.isFilestoreItem()) {
|
| | | item.add(new Label("filestore", getString("gb.filestore")).setVisible(true));
|
| | | |
| | | item.add(new LinkPanel("pathName", "list", displayPath, new Link<Object>("link", null) {
|
| | | |
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | @Override
|
| | | public void onClick() {
|
| | | |
| | | IResourceStream resourceStream = new AbstractResourceStreamWriter() {
|
| | | |
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | @Override |
| | | public void write(OutputStream output) {
|
| | | UserModel user = GitBlitWebSession.get().getUser();
|
| | | user = user == null ? UserModel.ANONYMOUS : user;
|
| | | |
| | | app().filestore().downloadBlob(entry.getFilestoreOid(), user, getRepositoryModel(), output);
|
| | | }
|
| | | };
|
| | | |
| | | |
| | | getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path));
|
| | | }}));
|
| | | |
| | | links.add(new Link<Object>("view", null) {
|
| | | |
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | @Override
|
| | | public void onClick() {
|
| | | |
| | | IResourceStream resourceStream = new AbstractResourceStreamWriter() {
|
| | | |
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | @Override |
| | | public void write(OutputStream output) {
|
| | | UserModel user = GitBlitWebSession.get().getUser();
|
| | | user = user == null ? UserModel.ANONYMOUS : user;
|
| | | |
| | | app().filestore().downloadBlob(entry.getFilestoreOid(), user, getRepositoryModel(), output);
|
| | | }
|
| | | };
|
| | | |
| | | |
| | | getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path));
|
| | | }});
|
| | | |
| | | links.add(new Link<Object>("raw", null) {
|
| | | |
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | @Override
|
| | | public void onClick() {
|
| | | |
| | | IResourceStream resourceStream = new AbstractResourceStreamWriter() {
|
| | | |
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | @Override |
| | | public void write(OutputStream output) {
|
| | | UserModel user = GitBlitWebSession.get().getUser();
|
| | | user = user == null ? UserModel.ANONYMOUS : user;
|
| | | |
| | | app().filestore().downloadBlob(entry.getFilestoreOid(), user, getRepositoryModel(), output);
|
| | | }
|
| | | };
|
| | | |
| | | |
| | | getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path));
|
| | | }});
|
| | | |
| | | } else {
|
| | | item.add(new Label("filestore", getString("gb.filestore")).setVisible(false));
|
| | | |
| | | item.add(new LinkPanel("pathName", "list", displayPath, BlobPage.class,
|
| | | WicketUtils.newPathParameter(repositoryName, id,
|
| | | path)));
|
| | | |
| | | links.add(new BookmarkablePageLink<Void>("view", BlobPage.class,
|
| | | WicketUtils.newPathParameter(repositoryName, id,
|
| | | path)));
|
| | | String rawUrl = RawServlet.asLink(getContextUrl(), repositoryName, id, path);
|
| | | links.add(new ExternalLink("raw", rawUrl));
|
| | | }
|
| | | |
| | | links.add(new BookmarkablePageLink<Void>("blame", BlamePage.class,
|
| | | WicketUtils.newPathParameter(repositoryName, id,
|
| | | path)));
|
| | |
| | | protected String getPageName() {
|
| | | return getString("gb.tree");
|
| | | }
|
| | |
|
| | | @Override
|
| | | protected boolean isCommitPage() {
|
| | | return true;
|
| | | }
|
| | |
|
| | | }
|