| | |
| | |
|
| | | import org.apache.wicket.Component;
|
| | | import org.apache.wicket.PageParameters;
|
| | | import org.apache.wicket.RestartResponseException;
|
| | | import org.apache.wicket.behavior.SimpleAttributeModifier;
|
| | | import org.apache.wicket.markup.html.basic.Label;
|
| | | import org.apache.wicket.markup.html.form.DropDownChoice;
|
| | |
| | | import com.gitblit.Constants;
|
| | | import com.gitblit.GitBlitException;
|
| | | import com.gitblit.Keys;
|
| | | import com.gitblit.PagesServlet;
|
| | | import com.gitblit.SyndicationServlet;
|
| | | import com.gitblit.models.ProjectModel;
|
| | | import com.gitblit.models.RefModel;
|
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.models.SubmoduleModel;
|
| | | import com.gitblit.models.UserModel;
|
| | | import com.gitblit.models.UserRepositoryPreferences;
|
| | | import com.gitblit.servlet.PagesServlet;
|
| | | import com.gitblit.servlet.SyndicationServlet;
|
| | | import com.gitblit.tickets.TicketIndexer.Lucene;
|
| | | import com.gitblit.utils.ArrayUtils;
|
| | | import com.gitblit.utils.BugtraqProcessor;
|
| | | import com.gitblit.utils.DeepCopier;
|
| | | import com.gitblit.utils.JGitUtils;
|
| | | import com.gitblit.utils.MessageProcessor;
|
| | | import com.gitblit.utils.RefLogUtils;
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.gitblit.wicket.CacheControl;
|
| | |
| | | public RepositoryPage(PageParameters params) {
|
| | | super(params);
|
| | | repositoryName = WicketUtils.getRepositoryName(params);
|
| | | String root =StringUtils.getFirstPathElement(repositoryName);
|
| | | String root = StringUtils.getFirstPathElement(repositoryName);
|
| | | if (StringUtils.isEmpty(root)) {
|
| | | projectName = app().settings().getString(Keys.web.repositoryRootGroupName, "main");
|
| | | } else {
|
| | |
| | | }
|
| | |
|
| | | if (!getRepositoryModel().hasCommits) {
|
| | | setResponsePage(EmptyRepositoryPage.class, params);
|
| | | throw new RestartResponseException(EmptyRepositoryPage.class, params);
|
| | | }
|
| | |
|
| | | if (getRepositoryModel().isCollectingGarbage) {
|
| | |
| | | UserRepositoryPreferences prefs = user.getPreferences().getRepositoryPreferences(getRepositoryModel().name);
|
| | | prefs.starred = star;
|
| | | try {
|
| | | app().users().updateUserModel(user.username, user, false);
|
| | | app().gitblit().reviseUser(user.username, user);
|
| | | } catch (GitBlitException e) {
|
| | | logger.error("Failed to update user " + user.username, e);
|
| | | error(getString("gb.failedToUpdateUser"), false);
|
| | |
| | | return getClass();
|
| | | }
|
| | |
|
| | | protected MessageProcessor messageProcessor() {
|
| | | return new MessageProcessor(app().settings());
|
| | | protected BugtraqProcessor bugtraqProcessor() {
|
| | | return new BugtraqProcessor(app().settings());
|
| | | }
|
| | |
|
| | | private Map<String, PageRegistration> registerPages() {
|
| | |
| | | }
|
| | | pages.put("commits", new PageRegistration("gb.commits", LogPage.class, params));
|
| | | pages.put("tree", new PageRegistration("gb.tree", TreePage.class, params));
|
| | | if (app().tickets().isReady() && (app().tickets().isAcceptingNewTickets(getRepositoryModel()) || app().tickets().hasTickets(getRepositoryModel()))) {
|
| | | PageParameters tParams = new PageParameters(params);
|
| | | for (String state : TicketsPage.openStatii) {
|
| | | tParams.add(Lucene.status.name(), state);
|
| | | }
|
| | | pages.put("tickets", new PageRegistration("gb.tickets", TicketsPage.class, tParams)); |
| | | } |
| | | pages.put("docs", new PageRegistration("gb.docs", DocsPage.class, params, true));
|
| | | pages.put("compare", new PageRegistration("gb.compare", ComparePage.class, params, true));
|
| | | if (app().settings().getBoolean(Keys.web.allowForking, true)) {
|
| | | pages.put("forks", new PageRegistration("gb.forks", ForksPage.class, params, true));
|
| | | }
|
| | | pages.put("compare", new PageRegistration("gb.compare", ComparePage.class, params, true)); |
| | |
|
| | | // conditional links
|
| | | // per-repository extra page links
|
| | |
| | | }
|
| | | add(new LinkPanel("repositoryName", null, name, SummaryPage.class,
|
| | | WicketUtils.newRepositoryParameter(repositoryName)));
|
| | | add(new Label("pageName", pageName).setRenderBodyOnly(true));
|
| | |
|
| | | UserModel user = GitBlitWebSession.get().getUser();
|
| | | if (user == null) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | // new ticket button
|
| | | if (user.isAuthenticated && app().tickets().isAcceptingNewTickets(getRepositoryModel())) {
|
| | | String newTicketUrl = getRequestCycle().urlFor(NewTicketPage.class, WicketUtils.newRepositoryParameter(repositoryName)).toString();
|
| | | addToolbarButton("newTicketLink", "fa fa-ticket", getString("gb.new"), newTicketUrl);
|
| | | } else {
|
| | | add(new Label("newTicketLink").setVisible(false));
|
| | | }
|
| | |
|
| | | // (un)star link allows a user to star a repository
|
| | | if (user.isAuthenticated) {
|
| | | PageParameters starParams = DeepCopier.copy(getPageParameters());
|
| | |
| | | }
|
| | |
|
| | | // fork controls
|
| | | if (!allowForkControls() || user == null || !user.isAuthenticated) {
|
| | | if (!allowForkControls() || !user.isAuthenticated) {
|
| | | // must be logged-in to fork, hide all fork controls
|
| | | add(new ExternalLink("forkLink", "").setVisible(false));
|
| | | add(new ExternalLink("myForkLink", "").setVisible(false));
|
| | |
| | |
|
| | | protected void addFullText(String wicketId, String text) {
|
| | | RepositoryModel model = getRepositoryModel();
|
| | | String content = messageProcessor().processCommitMessage(model, text);
|
| | | String content = bugtraqProcessor().processCommitMessage(r, model, text);
|
| | | String html;
|
| | | switch (model.commitMessageRenderer) {
|
| | | case MARKDOWN:
|