James Moger
2014-07-03 a40cbcfc4fab2ca16304c7393a68fe95a9322edc
src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.java
@@ -36,7 +36,6 @@
import com.gitblit.Constants.AccessPermission;
import com.gitblit.Constants.AccessRestrictionType;
import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.GitClientApplication;
import com.gitblit.models.RepositoryModel;
@@ -81,7 +80,7 @@
      HttpServletRequest req = ((WebRequest) getRequest()).getHttpServletRequest();
      List<RepositoryUrl> repositoryUrls = GitBlit.self().getRepositoryUrls(req, user, repository);
      List<RepositoryUrl> repositoryUrls = app().services().getRepositoryUrls(req, user, repository);
      // grab primary url from the top of the list
      primaryUrl = repositoryUrls.size() == 0 ? null : repositoryUrls.get(0);
@@ -104,7 +103,7 @@
         add(createRepositoryIndicators(repository));
      }
      boolean allowAppLinks = GitBlit.getBoolean(Keys.web.allowAppCloneLinks, true);
      boolean allowAppLinks = app().settings().getBoolean(Keys.web.allowAppCloneLinks, true);
      if (onlyUrls || !canClone || !allowAppLinks) {
         // only display the url(s)
         add(new Label("applicationMenusPanel").setVisible(false));
@@ -163,7 +162,10 @@
      }
      // access restriction icon and tooltip
      if (GitBlit.isServingRepositories()) {
      if (repository.isMirror) {
         urlPanel.add(WicketUtils.newImage("accessRestrictionIcon", "mirror_16x16.png",
               getString("gb.isMirror")));
      } else if (app().services().isServingRepositories()) {
         switch (repository.accessRestriction) {
         case NONE:
            urlPanel.add(WicketUtils.newClearPixel("accessRestrictionIcon").setVisible(false));
@@ -208,12 +210,12 @@
      return urlPanel;
   }
   protected Fragment createApplicationMenus(String wicketId, UserModel user, final RepositoryModel repository, final List<RepositoryUrl> repositoryUrls) {
   protected Fragment createApplicationMenus(String wicketId, final UserModel user, final RepositoryModel repository, final List<RepositoryUrl> repositoryUrls) {
      final List<GitClientApplication> displayedApps = new ArrayList<GitClientApplication>();
      final String userAgent = ((WebClientInfo) GitBlitWebSession.get().getClientInfo()).getUserAgent();
      if (user.canClone(repository)) {
         for (GitClientApplication app : GitBlit.self().getClientApplications()) {
         for (GitClientApplication app : app().gitblit().getClientApplications()) {
            if (app.isActive && app.allowsPlatform(userAgent)) {
               displayedApps.add(app);
            }
@@ -307,13 +309,13 @@
                  if (!StringUtils.isEmpty(clientApp.cloneUrl)) {
                     // custom registered url
                     String url = substitute(clientApp.cloneUrl, repoUrl.url, baseURL);
                     String url = substitute(clientApp.cloneUrl, repoUrl.url, baseURL, user.username, repository.name);
                     fragment.add(new LinkPanel("content", "applicationMenuItem", getString("gb.clone") + " " + repoUrl.url, url));
                     repoLinkItem.add(fragment);
                     fragment.add(new Label("copyFunction").setVisible(false));
                  } else if (!StringUtils.isEmpty(clientApp.command)) {
                     // command-line
                     String command = substitute(clientApp.command, repoUrl.url, baseURL);
                     String command = substitute(clientApp.command, repoUrl.url, baseURL, user.username, repository.name);
                     Label content = new Label("content", command);
                     WicketUtils.setCssClass(content, "commandMenuItem");
                     fragment.add(content);
@@ -332,8 +334,8 @@
      return applicationMenus;
   }
   protected String substitute(String pattern, String repoUrl, String baseUrl) {
      return pattern.replace("${repoUrl}", repoUrl).replace("${baseUrl}", baseUrl);
   protected String substitute(String pattern, String repoUrl, String baseUrl, String username, String repository) {
      return pattern.replace("${repoUrl}", repoUrl).replace("${baseUrl}", baseUrl).replace("${username}", username).replace("${repository}", repository);
   }
   protected Label createPermissionBadge(String wicketId, RepositoryUrl repoUrl) {
@@ -345,7 +347,7 @@
   }
   protected Fragment createCopyFragment(String text) {
      if (GitBlit.getBoolean(Keys.web.allowFlashCopyToClipboard, true)) {
      if (app().settings().getBoolean(Keys.web.allowFlashCopyToClipboard, true)) {
         // clippy: flash-based copy & paste
         Fragment copyFragment = new Fragment("copyFunction", "clippyPanel", this);
         String baseUrl = WicketUtils.getGitblitURL(getRequest());
@@ -450,12 +452,12 @@
         fragment.add(wc);
      }
      boolean allowForking = GitBlit.getBoolean(Keys.web.allowForking, true);
      boolean allowForking = app().settings().getBoolean(Keys.web.allowForking, true);
      if (!allowForking || user == null || !user.isAuthenticated) {
         // must be logged-in to fork, hide all fork controls
         fragment.add(new Label("forksProhibitedIndicator").setVisible(false));
      } else {
         String fork = GitBlit.self().getFork(user.username, repository.name);
         String fork = app().repositories().getFork(user.username, repository.name);
         boolean hasFork = fork != null;
         boolean canFork = user.canFork(repository);