| | |
| | |
|
| | | HttpServletRequest req = ((WebRequest) getRequest()).getHttpServletRequest();
|
| | |
|
| | | List<RepositoryUrl> repositoryUrls = app().gitblit().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);
|
| | |
|
| | | boolean canClone = primaryUrl != null && ((primaryUrl.permission == null) || primaryUrl.permission.atLeast(AccessPermission.CLONE));
|
| | | boolean canClone = primaryUrl != null && (!primaryUrl.hasPermission() || primaryUrl.permission.atLeast(AccessPermission.CLONE));
|
| | |
|
| | | if (repositoryUrls.size() == 0 || !canClone) {
|
| | | // no urls, nothing to show.
|
| | |
| | | fragment.add(content);
|
| | | item.add(fragment);
|
| | |
|
| | | Label permissionLabel = new Label("permission", repoUrl.isExternal() ? externalPermission : repoUrl.permission.toString());
|
| | | Label permissionLabel = new Label("permission", repoUrl.hasPermission() ? repoUrl.permission.toString() : externalPermission);
|
| | | WicketUtils.setPermissionClass(permissionLabel, repoUrl.permission);
|
| | | String tooltip = getProtocolPermissionDescription(repository, repoUrl);
|
| | | WicketUtils.setHtmlTooltip(permissionLabel, tooltip);
|
| | |
| | | if (repository.isMirror) {
|
| | | urlPanel.add(WicketUtils.newImage("accessRestrictionIcon", "mirror_16x16.png",
|
| | | getString("gb.isMirror")));
|
| | | } else if (app().runtime().isServingRepositories()) {
|
| | | } else if (app().services().isServingRepositories()) {
|
| | | switch (repository.accessRestriction) {
|
| | | case NONE:
|
| | | urlPanel.add(WicketUtils.newClearPixel("accessRestrictionIcon").setVisible(false));
|
| | |
| | |
|
| | | urlPanel.add(new Label("primaryUrl", primaryUrl.url).setRenderBodyOnly(true));
|
| | |
|
| | | Label permissionLabel = new Label("primaryUrlPermission", primaryUrl.isExternal() ? externalPermission : primaryUrl.permission.toString());
|
| | | Label permissionLabel = new Label("primaryUrlPermission", primaryUrl.hasPermission() ? primaryUrl.permission.toString() : externalPermission);
|
| | | String tooltip = getProtocolPermissionDescription(repository, primaryUrl);
|
| | | WicketUtils.setHtmlTooltip(permissionLabel, tooltip);
|
| | | urlPanel.add(permissionLabel);
|
| | |
| | | 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();
|
| | |
|
| | |
| | | // filter the urls for the client app
|
| | | List<RepositoryUrl> urls = new ArrayList<RepositoryUrl>();
|
| | | for (RepositoryUrl repoUrl : repositoryUrls) {
|
| | | if (clientApp.minimumPermission == null || repoUrl.permission == null) {
|
| | | // no minimum permission or external permissions, assume it is satisfactory
|
| | | if (clientApp.minimumPermission == null || !repoUrl.hasPermission()) {
|
| | | // no minimum permission or untracked permissions, assume it is satisfactory
|
| | | if (clientApp.supportsTransport(repoUrl.url)) {
|
| | | urls.add(repoUrl);
|
| | | }
|
| | |
| | |
|
| | | 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);
|
| | |
| | | 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) {
|
| | | Label permissionLabel = new Label(wicketId, repoUrl.isExternal() ? externalPermission : repoUrl.permission.toString());
|
| | | Label permissionLabel = new Label(wicketId, repoUrl.hasPermission() ? repoUrl.permission.toString() : externalPermission);
|
| | | WicketUtils.setPermissionClass(permissionLabel, repoUrl.permission);
|
| | | String tooltip = getProtocolPermissionDescription(repository, repoUrl);
|
| | | WicketUtils.setHtmlTooltip(permissionLabel, tooltip);
|
| | |
| | | RepositoryUrl repoUrl) {
|
| | | if (!urlPermissionsMap.containsKey(repoUrl.url)) {
|
| | | String note;
|
| | | if (repoUrl.isExternal()) {
|
| | | String protocol;
|
| | | int protocolIndex = repoUrl.url.indexOf("://");
|
| | | if (protocolIndex > -1) {
|
| | | // explicit protocol specified
|
| | | protocol = repoUrl.url.substring(0, protocolIndex);
|
| | | } else {
|
| | | // implicit SSH url
|
| | | protocol = "ssh";
|
| | | }
|
| | | note = MessageFormat.format(getString("gb.externalPermissions"), protocol);
|
| | | } else {
|
| | | if (repoUrl.hasPermission()) {
|
| | | note = null;
|
| | | String key;
|
| | | switch (repoUrl.permission) {
|
| | |
| | | String description = MessageFormat.format(pattern, repoUrl.permission.toString());
|
| | | note = description;
|
| | | }
|
| | | } else {
|
| | | String protocol;
|
| | | int protocolIndex = repoUrl.url.indexOf("://");
|
| | | if (protocolIndex > -1) {
|
| | | // explicit protocol specified
|
| | | protocol = repoUrl.url.substring(0, protocolIndex);
|
| | | } else {
|
| | | // implicit SSH url
|
| | | protocol = "ssh";
|
| | | }
|
| | | note = MessageFormat.format(getString("gb.externalPermissions"), protocol);
|
| | | }
|
| | | urlPermissionsMap.put(repoUrl.url, note);
|
| | | }
|