| | |
| | | import org.apache.wicket.protocol.http.WebResponse;
|
| | |
|
| | | import com.gitblit.Constants;
|
| | | import com.gitblit.GitBlit;
|
| | | import com.gitblit.Keys;
|
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.models.TeamModel;
|
| | |
| | | StringBuilder buffer = new StringBuilder();
|
| | | buffer.append("<style type=\"text/css\">\n");
|
| | | buffer.append(".navbar-inner {\n");
|
| | | final String headerBackground = GitBlit.getString(Keys.web.headerBackgroundColor, null);
|
| | | final String headerBackground = app().settings().getString(Keys.web.headerBackgroundColor, null);
|
| | | if (!StringUtils.isEmpty(headerBackground)) {
|
| | | buffer.append(MessageFormat.format("background-color: {0};\n", headerBackground));
|
| | | }
|
| | | final String headerBorder = GitBlit.getString(Keys.web.headerBorderColor, null);
|
| | | final String headerBorder = app().settings().getString(Keys.web.headerBorderColor, null);
|
| | | if (!StringUtils.isEmpty(headerBorder)) {
|
| | | buffer.append(MessageFormat.format("border-bottom: 1px solid {0} !important;\n", headerBorder));
|
| | | }
|
| | | buffer.append("}\n");
|
| | | final String headerBorderFocus = GitBlit.getString(Keys.web.headerBorderFocusColor, null);
|
| | | final String headerBorderFocus = app().settings().getString(Keys.web.headerBorderFocusColor, null);
|
| | | if (!StringUtils.isEmpty(headerBorderFocus)) {
|
| | | buffer.append(".navbar ul li:focus, .navbar .active {\n");
|
| | | buffer.append(MessageFormat.format("border-bottom: 4px solid {0};\n", headerBorderFocus));
|
| | | buffer.append("}\n");
|
| | | }
|
| | | final String headerForeground = GitBlit.getString(Keys.web.headerForegroundColor, null);
|
| | | final String headerForeground = app().settings().getString(Keys.web.headerForegroundColor, null);
|
| | | if (!StringUtils.isEmpty(headerForeground)) {
|
| | | buffer.append(".navbar ul.nav li a {\n");
|
| | | buffer.append(MessageFormat.format("color: {0};\n", headerForeground));
|
| | |
| | | buffer.append(MessageFormat.format("color: {0};\n", headerForeground));
|
| | | buffer.append("}\n");
|
| | | }
|
| | | final String headerHover = GitBlit.getString(Keys.web.headerHoverColor, null);
|
| | | final String headerHover = app().settings().getString(Keys.web.headerHoverColor, null);
|
| | | if (!StringUtils.isEmpty(headerHover)) {
|
| | | buffer.append(".navbar ul.nav li a:hover {\n");
|
| | | buffer.append(MessageFormat.format("color: {0} !important;\n", headerHover));
|
| | |
| | | }
|
| | | }));
|
| | |
|
| | | boolean authenticateView = GitBlit.getBoolean(Keys.web.authenticateViewPages, false);
|
| | | boolean authenticateAdmin = GitBlit.getBoolean(Keys.web.authenticateAdminPages, true);
|
| | | boolean allowAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, true);
|
| | | boolean authenticateView = app().settings().getBoolean(Keys.web.authenticateViewPages, false);
|
| | | boolean authenticateAdmin = app().settings().getBoolean(Keys.web.authenticateAdminPages, true);
|
| | | boolean allowAdmin = app().settings().getBoolean(Keys.web.allowAdministration, true);
|
| | |
|
| | | if (authenticateAdmin) {
|
| | | showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin();
|
| | |
| | | add(new Label("userPanel").setVisible(false));
|
| | | }
|
| | |
|
| | | boolean showRegistrations = GitBlit.canFederate()
|
| | | && GitBlit.getBoolean(Keys.web.showFederationRegistrations, false);
|
| | | boolean showRegistrations = app().federation().canFederate()
|
| | | && app().settings().getBoolean(Keys.web.showFederationRegistrations, false);
|
| | |
|
| | | // navigation links
|
| | | List<PageRegistration> pages = new ArrayList<PageRegistration>();
|
| | |
| | | pages.add(new PageRegistration("gb.repositories", RepositoriesPage.class,
|
| | | getRootPageParameters()));
|
| | | pages.add(new PageRegistration("gb.activity", ActivityPage.class, getRootPageParameters()));
|
| | | if (GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true)) {
|
| | | if (app().settings().getBoolean(Keys.web.allowLuceneIndexing, true)) {
|
| | | pages.add(new PageRegistration("gb.search", LuceneSearchPage.class));
|
| | | }
|
| | | if (showAdmin) {
|
| | |
| | | if (!StringUtils.isEmpty(cachedMessage)) {
|
| | | error(cachedMessage);
|
| | | } else if (showAdmin) {
|
| | | int pendingProposals = GitBlit.self().getPendingFederationProposals().size();
|
| | | int pendingProposals = app().federation().getPendingFederationProposals().size();
|
| | | if (pendingProposals == 1) {
|
| | | info(getString("gb.OneProposalToReview"));
|
| | | } else if (pendingProposals > 1) {
|
| | |
| | |
|
| | | // remove days back parameter if it is the default value
|
| | | if (params.containsKey("db")
|
| | | && params.getInt("db") == GitBlit.getInteger(Keys.web.activityDuration, 7)) {
|
| | | && params.getInt("db") == app().settings().getInteger(Keys.web.activityDuration, 7)) {
|
| | | params.remove("db");
|
| | | }
|
| | | return params;
|
| | |
| | | session.setUser(user);
|
| | |
|
| | | // Set Cookie
|
| | | if (GitBlit.getBoolean(Keys.web.allowCookieAuthentication, false)) {
|
| | | if (app().settings().getBoolean(Keys.web.allowCookieAuthentication, false)) {
|
| | | WebResponse response = (WebResponse) getRequestCycle().getResponse();
|
| | | GitBlit.self().setCookie(response, user);
|
| | | app().session().setCookie(response, user);
|
| | | }
|
| | |
|
| | | if (!session.continueRequest()) {
|
| | |
| | | protected List<RepositoryModel> getRepositoryModels() {
|
| | | if (repositoryModels.isEmpty()) {
|
| | | final UserModel user = GitBlitWebSession.get().getUser();
|
| | | List<RepositoryModel> repositories = GitBlit.self().getRepositoryModels(user);
|
| | | List<RepositoryModel> repositories = app().repositories().getRepositoryModels(user);
|
| | | repositoryModels.addAll(repositories);
|
| | | Collections.sort(repositoryModels);
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | // custom filters
|
| | | String customFilters = GitBlit.getString(Keys.web.customFilters, null);
|
| | | String customFilters = app().settings().getString(Keys.web.customFilters, null);
|
| | | if (!StringUtils.isEmpty(customFilters)) {
|
| | | boolean addedExpression = false;
|
| | | List<String> expressions = StringUtils.getStringsFromValue(customFilters, "!!!");
|
| | |
| | |
|
| | | protected List<DropDownMenuItem> getTimeFilterItems(PageParameters params) {
|
| | | // days back choices - additive parameters
|
| | | int daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);
|
| | | int maxDaysBack = GitBlit.getInteger(Keys.web.activityDurationMaximum, 30);
|
| | | int daysBack = app().settings().getInteger(Keys.web.activityDuration, 7);
|
| | | int maxDaysBack = app().settings().getInteger(Keys.web.activityDurationMaximum, 30);
|
| | | if (daysBack < 1) {
|
| | | daysBack = 7;
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | List<DropDownMenuItem> items = new ArrayList<DropDownMenuItem>();
|
| | | Set<Integer> choicesSet = new TreeSet<Integer>(GitBlit.getIntegers(Keys.web.activityDurationChoices));
|
| | | Set<Integer> choicesSet = new TreeSet<Integer>(app().settings().getIntegers(Keys.web.activityDurationChoices));
|
| | | if (choicesSet.isEmpty()) {
|
| | | choicesSet.addAll(Arrays.asList(1, 3, 7, 14, 21, 28));
|
| | | }
|
| | |
| | | String regex = WicketUtils.getRegEx(params);
|
| | | String team = WicketUtils.getTeam(params);
|
| | | int daysBack = params.getInt("db", 0);
|
| | | int maxDaysBack = GitBlit.getInteger(Keys.web.activityDurationMaximum, 30);
|
| | | int maxDaysBack = app().settings().getInteger(Keys.web.activityDurationMaximum, 30);
|
| | |
|
| | | List<RepositoryModel> availableModels = getRepositoryModels();
|
| | | Set<RepositoryModel> models = new HashSet<RepositoryModel>();
|
| | |
| | | if (!StringUtils.isEmpty(projectName)) {
|
| | | // try named project
|
| | | hasParameter = true;
|
| | | if (projectName.equalsIgnoreCase(GitBlit.getString(Keys.web.repositoryRootGroupName, "main"))) {
|
| | | if (projectName.equalsIgnoreCase(app().settings().getString(Keys.web.repositoryRootGroupName, "main"))) {
|
| | | // root project/group
|
| | | for (RepositoryModel model : availableModels) {
|
| | | if (model.name.indexOf('/') == -1) {
|
| | |
| | | // need TeamModels first
|
| | | List<TeamModel> teamModels = new ArrayList<TeamModel>();
|
| | | for (String name : teams) {
|
| | | TeamModel teamModel = GitBlit.self().getTeamModel(name);
|
| | | TeamModel teamModel = app().users().getTeamModel(name);
|
| | | if (teamModel != null) {
|
| | | teamModels.add(teamModel);
|
| | | }
|
| | |
| | | String username = RootPage.this.username.getObject();
|
| | | char[] password = RootPage.this.password.getObject().toCharArray();
|
| | |
|
| | | UserModel user = GitBlit.self().authenticate(username, password);
|
| | | UserModel user = app().session().authenticate(username, password);
|
| | | if (user == null) {
|
| | | error(getString("gb.invalidUsernameOrPassword"));
|
| | | } else if (user.username.equals(Constants.FEDERATION_USER)) {
|
| | |
| | | /**
|
| | | * Menu for the authenticated user.
|
| | | */
|
| | | static class UserMenu extends Fragment {
|
| | | class UserMenu extends Fragment {
|
| | |
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | |
| | |
|
| | | GitBlitWebSession session = GitBlitWebSession.get();
|
| | | UserModel user = session.getUser();
|
| | | boolean editCredentials = GitBlit.self().supportsCredentialChanges(user);
|
| | | boolean editCredentials = app().users().supportsCredentialChanges(user);
|
| | | boolean standardLogin = session.authenticationType.isStandard();
|
| | |
|
| | | if (GitBlit.getBoolean(Keys.web.allowGravatar, true)) {
|
| | | if (app().settings().getBoolean(Keys.web.allowGravatar, true)) {
|
| | | add(new GravatarImage("username", user.getDisplayName(),
|
| | | user.emailAddress, "navbarGravatar", 20, false, false));
|
| | | } else {
|