use of com.gitblit.wicket.GitblitRedirectException in project gitblit by gitblit.
the class UserPage method setup.
private void setup(PageParameters params) {
setupPage("", "");
// check to see if we should display a login message
boolean authenticateView = app().settings().getBoolean(Keys.web.authenticateViewPages, true);
if (authenticateView && !GitBlitWebSession.get().isLoggedIn()) {
authenticationError("Please login");
return;
}
String userName = WicketUtils.getUsername(params);
if (StringUtils.isEmpty(userName)) {
throw new GitblitRedirectException(GitBlitWebApp.get().getHomePage());
}
UserModel user = app().users().getUserModel(userName);
if (user == null) {
// construct a temporary user model
user = new UserModel(userName);
}
add(new UserTitlePanel("userTitlePanel", user, user.username));
UserModel sessionUser = GitBlitWebSession.get().getUser();
boolean isMyProfile = sessionUser != null && sessionUser.equals(user);
if (isMyProfile) {
addPreferences(user);
if (app().services().isServingSSH()) {
// show the SSH key management tab
addSshKeys(user);
} else {
// SSH daemon is disabled, hide keys tab
add(new Label("sshKeysLink").setVisible(false));
add(new Label("sshKeysTab").setVisible(false));
}
} else {
// visiting user
add(new Label("preferencesLink").setVisible(false));
add(new Label("preferencesTab").setVisible(false));
add(new Label("sshKeysLink").setVisible(false));
add(new Label("sshKeysTab").setVisible(false));
}
List<RepositoryModel> repositories = getRepositories(params);
Collections.sort(repositories, new Comparator<RepositoryModel>() {
@Override
public int compare(RepositoryModel o1, RepositoryModel o2) {
// reverse-chronological sort
return o2.lastChange.compareTo(o1.lastChange);
}
});
final ListDataProvider<RepositoryModel> dp = new ListDataProvider<RepositoryModel>(repositories);
DataView<RepositoryModel> dataView = new DataView<RepositoryModel>("repositoryList", dp) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(final Item<RepositoryModel> item) {
final RepositoryModel entry = item.getModelObject();
ProjectRepositoryPanel row = new ProjectRepositoryPanel("repository", getLocalizer(), this, showAdmin, entry, getAccessRestrictions());
item.add(row);
}
};
add(dataView);
}
use of com.gitblit.wicket.GitblitRedirectException in project gitblit by gitblit.
the class ProjectPage method setup.
private void setup(PageParameters params) {
setupPage("", "");
// check to see if we should display a login message
boolean authenticateView = app().settings().getBoolean(Keys.web.authenticateViewPages, true);
if (authenticateView && !GitBlitWebSession.get().isLoggedIn()) {
authenticationError("Please login");
return;
}
String projectName = params == null ? null : WicketUtils.getProjectName(params);
if (StringUtils.isEmpty(projectName)) {
throw new GitblitRedirectException(GitBlitWebApp.get().getHomePage());
}
ProjectModel project = getProjectModel(projectName);
if (project == null) {
throw new GitblitRedirectException(GitBlitWebApp.get().getHomePage());
}
add(new Label("projectTitle", project.getDisplayName()));
add(new Label("projectDescription", project.description));
String feedLink = SyndicationServlet.asLink(getRequest().getRelativePathPrefixToContextRoot(), projectName, null, 0);
add(new ExternalLink("syndication", feedLink));
add(WicketUtils.syndicationDiscoveryLink(SyndicationServlet.getTitle(project.getDisplayName(), null), feedLink));
// project markdown message
String pmessage = transformMarkdown(project.projectMarkdown);
Component projectMessage = new Label("projectMessage", pmessage).setEscapeModelStrings(false).setVisible(pmessage.length() > 0);
add(projectMessage);
// markdown message above repositories list
String rmessage = transformMarkdown(project.repositoriesMarkdown);
Component repositoriesMessage = new Label("repositoriesMessage", rmessage).setEscapeModelStrings(false).setVisible(rmessage.length() > 0);
add(repositoriesMessage);
UserModel user = GitBlitWebSession.get().getUser();
if (user == null) {
user = UserModel.ANONYMOUS;
}
int daysBack = params == null ? 0 : WicketUtils.getDaysBack(params);
if (daysBack < 1) {
daysBack = app().settings().getInteger(Keys.web.activityDuration, 7);
}
// reflog utils.
if (params != null) {
params.remove("db");
}
List<RepositoryModel> repositories = getRepositories(params);
Collections.sort(repositories, new Comparator<RepositoryModel>() {
@Override
public int compare(RepositoryModel o1, RepositoryModel o2) {
// reverse-chronological sort
return o2.lastChange.compareTo(o1.lastChange);
}
});
addActivity(user, repositories, getString("gb.recentActivity"), daysBack);
if (repositories.isEmpty()) {
add(new Label("repositoryList").setVisible(false));
} else {
FilterableRepositoryList repoList = new FilterableRepositoryList("repositoryList", repositories);
repoList.setAllowCreate(user.canCreate(project.name + "/"));
add(repoList);
}
}
Aggregations