From a7571bc1d831a83643d4fc5257a510a1bb53316b Mon Sep 17 00:00:00 2001 From: James Moger Date: Thu, 29 Sep 2011 23:34:04 -0400 Subject: [PATCH] Split RepositoriesPage into 3 pages. Inline page header authentication. --- resources/bootstrap.gb.css | 38 +++++---- resources/markdown.css | 2 - .../gitblit/wicket/AuthorizationStrategy.java | 8 +- src/com/gitblit/wicket/GitBlitWebApp.java | 10 +-- .../gitblit/wicket/GitBlitWebApp.properties | 4 +- src/com/gitblit/wicket/pages/BasePage.java | 6 +- .../wicket/pages/EditRepositoryPage.html | 18 ++--- .../wicket/pages/EditRepositoryPage.java | 9 ++- .../gitblit/wicket/pages/EditUserPage.html | 9 +-- .../gitblit/wicket/pages/EditUserPage.java | 7 +- .../gitblit/wicket/pages/FederationPage.html | 17 ++++ .../gitblit/wicket/pages/FederationPage.java | 51 ++++++++++++ .../pages/FederationRegistrationPage.html | 5 -- .../pages/FederationRegistrationPage.java | 6 +- src/com/gitblit/wicket/pages/LoginPage.html | 36 --------- .../wicket/pages/RepositoriesPage.html | 25 ------ .../wicket/pages/RepositoriesPage.java | 66 +--------------- .../wicket/pages/ReviewProposalPage.html | 5 -- .../wicket/pages/ReviewProposalPage.java | 11 ++- src/com/gitblit/wicket/pages/RootPage.html | 36 +++++++++ .../pages/{LoginPage.java => RootPage.java} | 77 ++++++++++++++----- .../wicket/pages/SendProposalPage.html | 14 +--- .../wicket/pages/SendProposalPage.java | 4 +- .../gitblit/wicket/pages/StandardPage.html | 32 ++++++++ .../gitblit/wicket/pages/StandardPage.java | 40 ++++++++++ src/com/gitblit/wicket/pages/UsersPage.html | 11 +++ src/com/gitblit/wicket/pages/UsersPage.java | 29 +++++++ 27 files changed, 340 insertions(+), 236 deletions(-) create mode 100644 src/com/gitblit/wicket/pages/FederationPage.html create mode 100644 src/com/gitblit/wicket/pages/FederationPage.java delete mode 100644 src/com/gitblit/wicket/pages/LoginPage.html create mode 100644 src/com/gitblit/wicket/pages/RootPage.html rename src/com/gitblit/wicket/pages/{LoginPage.java => RootPage.java} (52%) create mode 100644 src/com/gitblit/wicket/pages/StandardPage.html create mode 100644 src/com/gitblit/wicket/pages/StandardPage.java create mode 100644 src/com/gitblit/wicket/pages/UsersPage.html create mode 100644 src/com/gitblit/wicket/pages/UsersPage.java diff --git a/resources/bootstrap.gb.css b/resources/bootstrap.gb.css index 747f812b..db91249b 100644 --- a/resources/bootstrap.gb.css +++ b/resources/bootstrap.gb.css @@ -26,11 +26,11 @@ } .page-header { - margin-bottom: 5px; + margin-bottom: 5px; } .page-header h2 small { - font-size: 90%; + font-size: 80%; font-weight: bold; } @@ -492,6 +492,20 @@ table.repositories tr.group td { border-bottom: 1px solid #ccc; } +table.palette { border:0; width: 0 !important; } +table.palette td.header { + font-weight: bold; + background-color: #ffffff !important; + padding-top: 0px !important; + margin-bottom: 0 !imporant; + border: 0 !important; + border-radius: 0 !important; + line-height: 1em; +} +table.palette td.pane { + padding: 0px; +} + table.gitnotes { border: 0; } @@ -644,19 +658,17 @@ span .localBranch { border-color: #00cc33; } -.feedbackPanelERROR { - color: red; - list-style-image: url(bullet_error.png); - font-weight: bold; - vertical-align: top; - padding:0; - margin:0; +.feedbackPanelERROR, .feedbackPanelINFO { + list-style: none; } -.feedbackPanelINFO { -/* position:relative;padding:7px 15px;margin-bottom:18px;color:#404040;background-color:#eedc94;background-repeat:repeat-x;background-image:-khtml-gradient(linear, left top, left bottom, from(#fceec1), to(#eedc94));background-image:-moz-linear-gradient(top, #fceec1, #eedc94);background-image:-ms-linear-gradient(top, #fceec1, #eedc94);background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #fceec1), color-stop(100%, #eedc94));background-image:-webkit-linear-gradient(top, #fceec1, #eedc94);background-image:-o-linear-gradient(top, #fceec1, #eedc94);background-image:linear-gradient(top, #fceec1, #eedc94);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fceec1', endColorstr='#eedc94', GradientType=0);text-shadow:0 -1px 0 rgba(0, 0, 0, 0.25);border-color:#eedc94 #eedc94 #e4c652;border-color:rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);text-shadow:0 1px 0 rgba(255, 255, 255, 0.5);border-width:1px;border-style:solid;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 0 rgba(255, 255, 255, 0.25);-moz-box-shadow:inset 0 1px 0 rgba(255, 255, 255, 0.25);box-shadow:inset 0 1px 0 rgba(255, 255, 255, 0.25);} */ - list-style: none; - background-color:#ddf4fb;border-color:#c6edf9; +.feedbackPanelINFO span, .feedbackPanelERROR span { + position:relative;padding:7px 15px;margin-top:5px;margin-bottom:5px;color:#404040;background-color:#eedc94;background-repeat:repeat-x;background-image:-khtml-gradient(linear, left top, left bottom, from(#fceec1), to(#eedc94));background-image:-moz-linear-gradient(top, #fceec1, #eedc94);background-image:-ms-linear-gradient(top, #fceec1, #eedc94);background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #fceec1), color-stop(100%, #eedc94));background-image:-webkit-linear-gradient(top, #fceec1, #eedc94);background-image:-o-linear-gradient(top, #fceec1, #eedc94);background-image:linear-gradient(top, #fceec1, #eedc94);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fceec1', endColorstr='#eedc94', GradientType=0);text-shadow:0 -1px 0 rgba(0, 0, 0, 0.25);border-color:#eedc94 #eedc94 #e4c652;border-color:rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);text-shadow:0 1px 0 rgba(255, 255, 255, 0.5);border-width:1px;border-style:solid;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 0 rgba(255, 255, 255, 0.25);-moz-box-shadow:inset 0 1px 0 rgba(255, 255, 255, 0.25);box-shadow:inset 0 1px 0 rgba(255, 255, 255, 0.25); +} + +.feedbackPanelERROR span { + color: #ffffff; + background-color:#c43c35;background-repeat:repeat-x;background-image:-khtml-gradient(linear, left top, left bottom, from(#ee5f5b), to(#c43c35));background-image:-moz-linear-gradient(top, #ee5f5b, #c43c35);background-image:-ms-linear-gradient(top, #ee5f5b, #c43c35);background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #ee5f5b), color-stop(100%, #c43c35));background-image:-webkit-linear-gradient(top, #ee5f5b, #c43c35);background-image:-o-linear-gradient(top, #ee5f5b, #c43c35);background-image:linear-gradient(top, #ee5f5b, #c43c35);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ee5f5b', endColorstr='#c43c35', GradientType=0);text-shadow:0 -1px 0 rgba(0, 0, 0, 0.25);border-color:#c43c35 #c43c35 #882a25;border-color:rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); } /* google-code-prettify line numbers */ diff --git a/resources/markdown.css b/resources/markdown.css index 1623078e..e0bfe386 100644 --- a/resources/markdown.css +++ b/resources/markdown.css @@ -23,14 +23,12 @@ div.markdown h6 { div.markdown h1 { margin-top: 0.5em; margin-bottom: 0.5em; - padding-bottom: 0.5em; border-bottom: 2px solid #000080 !important; } div.markdown h2 { margin-top: 1em; margin-bottom: 0.5em; - padding-bottom: 0.5em; border-bottom: 2px solid #000080 !important; } diff --git a/src/com/gitblit/wicket/AuthorizationStrategy.java b/src/com/gitblit/wicket/AuthorizationStrategy.java index b6b745bd..19bee6d8 100644 --- a/src/com/gitblit/wicket/AuthorizationStrategy.java +++ b/src/com/gitblit/wicket/AuthorizationStrategy.java @@ -24,7 +24,6 @@ import com.gitblit.GitBlit; import com.gitblit.Keys; import com.gitblit.models.UserModel; import com.gitblit.wicket.pages.BasePage; -import com.gitblit.wicket.pages.LoginPage; import com.gitblit.wicket.pages.RepositoriesPage; public class AuthorizationStrategy extends AbstractPageAuthorizationStrategy implements @@ -73,12 +72,7 @@ public class AuthorizationStrategy extends AbstractPageAuthorizationStrategy imp @Override public void onUnauthorizedInstantiation(Component component) { if (component instanceof BasePage) { - GitBlitWebSession session = GitBlitWebSession.get(); - if (!session.isLoggedIn()) { - throw new RestartResponseAtInterceptPageException(LoginPage.class); - } else { - throw new RestartResponseAtInterceptPageException(RepositoriesPage.class); - } + throw new RestartResponseAtInterceptPageException(RepositoriesPage.class); } } } diff --git a/src/com/gitblit/wicket/GitBlitWebApp.java b/src/com/gitblit/wicket/GitBlitWebApp.java index 8c41df07..3edcf6a7 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.java +++ b/src/com/gitblit/wicket/GitBlitWebApp.java @@ -32,17 +32,15 @@ import com.gitblit.wicket.pages.BranchesPage; import com.gitblit.wicket.pages.CommitDiffPage; import com.gitblit.wicket.pages.CommitPage; import com.gitblit.wicket.pages.DocsPage; -import com.gitblit.wicket.pages.ReviewProposalPage; import com.gitblit.wicket.pages.FederationRegistrationPage; import com.gitblit.wicket.pages.HistoryPage; import com.gitblit.wicket.pages.LogPage; -import com.gitblit.wicket.pages.LoginPage; -import com.gitblit.wicket.pages.LogoutPage; import com.gitblit.wicket.pages.MarkdownPage; import com.gitblit.wicket.pages.MetricsPage; import com.gitblit.wicket.pages.PatchPage; import com.gitblit.wicket.pages.RawPage; import com.gitblit.wicket.pages.RepositoriesPage; +import com.gitblit.wicket.pages.ReviewProposalPage; import com.gitblit.wicket.pages.SearchPage; import com.gitblit.wicket.pages.SummaryPage; import com.gitblit.wicket.pages.TagPage; @@ -100,12 +98,6 @@ public class GitBlitWebApp extends WebApplication { // federation urls mount("/proposal", ReviewProposalPage.class, "t"); mount("/registration", FederationRegistrationPage.class, "u", "n"); - - // setup login/logout urls, if we are using authentication - if (useAuthentication) { - mount("/login", LoginPage.class); - mount("/logout", LogoutPage.class); - } } private void mount(String location, Class clazz, String... parameters) { diff --git a/src/com/gitblit/wicket/GitBlitWebApp.properties b/src/com/gitblit/wicket/GitBlitWebApp.properties index f279612d..9e76a034 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/com/gitblit/wicket/GitBlitWebApp.properties @@ -138,4 +138,6 @@ gb.federationSets = federation sets gb.message = message gb.myUrlDescription = the publicly accessible url for your Gitblit instance gb.destinationUrl = send to -gb.destinationUrlDescription = the url of the Gitblit instance to send your proposal \ No newline at end of file +gb.destinationUrlDescription = the url of the Gitblit instance to send your proposal +gb.users = users +gb.federation = federation \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/BasePage.java b/src/com/gitblit/wicket/pages/BasePage.java index ebb4e897..0cb91d57 100644 --- a/src/com/gitblit/wicket/pages/BasePage.java +++ b/src/com/gitblit/wicket/pages/BasePage.java @@ -44,7 +44,6 @@ import com.gitblit.GitBlit; import com.gitblit.Keys; import com.gitblit.models.UserModel; import com.gitblit.wicket.GitBlitWebSession; -import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.LinkPanel; public abstract class BasePage extends WebPage { @@ -190,7 +189,7 @@ public abstract class BasePage extends WebPage { if (GitBlitWebSession.get().isLoggedIn()) { error(message, true); } else { - throw new RestartResponseAtInterceptPageException(LoginPage.class); + throw new RestartResponseAtInterceptPageException(RepositoriesPage.class); } } @@ -216,8 +215,7 @@ public abstract class BasePage extends WebPage { } else { // login add(new Label("username").setVisible(false)); - add(new LinkPanel("loginLink", null, markupProvider.getString("gb.login"), - LoginPage.class)); + add(new Label("loginLink").setVisible(false)); add(new Label("separator").setVisible(false)); add(new Label("changePasswordLink").setVisible(false)); } diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.html b/src/com/gitblit/wicket/pages/EditRepositoryPage.html index 4a9690b1..f9a0f793 100644 --- a/src/com/gitblit/wicket/pages/EditRepositoryPage.html +++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.html @@ -6,18 +6,13 @@ - -
- -
[Feedback Panel]
-
- - - + + + @@ -25,16 +20,15 @@ - + - + - +
 
 
 
 
 
 


 
-
\ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/com/gitblit/wicket/pages/EditRepositoryPage.java index 7349ca5f..ae7966d0 100644 --- a/src/com/gitblit/wicket/pages/EditRepositoryPage.java +++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.java @@ -47,7 +47,7 @@ import com.gitblit.utils.StringUtils; import com.gitblit.wicket.GitBlitWebSession; import com.gitblit.wicket.WicketUtils; -public class EditRepositoryPage extends BasePage { +public class EditRepositoryPage extends StandardPage { private final boolean isCreate; @@ -76,15 +76,16 @@ public class EditRepositoryPage extends BasePage { List federationSets = new ArrayList(); List repositoryUsers = new ArrayList(); if (isCreate) { - super.setupPage("", getString("gb.newRepository")); + super.setupPage(getString("gb.newRepository"), ""); } else { - super.setupPage("", getString("gb.edit")); + super.setupPage(getString("gb.edit"), repositoryModel.name); if (repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE)) { repositoryUsers.addAll(GitBlit.self().getRepositoryUsers(repositoryModel)); Collections.sort(repositoryUsers); } federationSets.addAll(repositoryModel.federationSets); - } + } + final String oldName = repositoryModel.name; // users palette diff --git a/src/com/gitblit/wicket/pages/EditUserPage.html b/src/com/gitblit/wicket/pages/EditUserPage.html index 2f90bbfa..ceda3cbf 100644 --- a/src/com/gitblit/wicket/pages/EditUserPage.html +++ b/src/com/gitblit/wicket/pages/EditUserPage.html @@ -6,12 +6,7 @@ - -
- -
[Feedback Panel]
- - +
@@ -21,7 +16,7 @@ - +
 
 
 
diff --git a/src/com/gitblit/wicket/pages/EditUserPage.java b/src/com/gitblit/wicket/pages/EditUserPage.java index a3589117..8dbb0d90 100644 --- a/src/com/gitblit/wicket/pages/EditUserPage.java +++ b/src/com/gitblit/wicket/pages/EditUserPage.java @@ -44,7 +44,7 @@ import com.gitblit.wicket.RequiresAdminRole; import com.gitblit.wicket.WicketUtils; @RequiresAdminRole -public class EditUserPage extends BasePage { +public class EditUserPage extends StandardPage { private final boolean isCreate; @@ -66,10 +66,11 @@ public class EditUserPage extends BasePage { protected void setupPage(final UserModel userModel) { if (isCreate) { - super.setupPage("", getString("gb.newUser")); + super.setupPage(getString("gb.newUser"), ""); } else { - super.setupPage("", getString("gb.edit")); + super.setupPage(getString("gb.edit"), userModel.username); } + final Model confirmPassword = new Model( StringUtils.isEmpty(userModel.password) ? "" : userModel.password); CompoundPropertyModel model = new CompoundPropertyModel(userModel); diff --git a/src/com/gitblit/wicket/pages/FederationPage.html b/src/com/gitblit/wicket/pages/FederationPage.html new file mode 100644 index 00000000..ab8a9417 --- /dev/null +++ b/src/com/gitblit/wicket/pages/FederationPage.html @@ -0,0 +1,17 @@ + + + + + +
[federation proposals panel]
+ +
[federation registrations panel]
+ +
[federation tokens panel]
+ +
+ + \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/FederationPage.java b/src/com/gitblit/wicket/pages/FederationPage.java new file mode 100644 index 00000000..b993f718 --- /dev/null +++ b/src/com/gitblit/wicket/pages/FederationPage.java @@ -0,0 +1,51 @@ +/* + * Copyright 2011 gitblit.com. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gitblit.wicket.pages; + +import com.gitblit.GitBlit; +import com.gitblit.Keys; +import com.gitblit.wicket.panels.FederationProposalsPanel; +import com.gitblit.wicket.panels.FederationRegistrationsPanel; +import com.gitblit.wicket.panels.FederationTokensPanel; + +public class FederationPage extends RootPage { + + public FederationPage() { + super(); + + boolean showFederation = showAdmin && GitBlit.canFederate(); + add(new FederationTokensPanel("federationTokensPanel", showFederation) + .setVisible(showFederation)); + FederationProposalsPanel proposalsPanel = new FederationProposalsPanel( + "federationProposalsPanel"); + if (showFederation) { + proposalsPanel.hideIfEmpty(); + } else { + proposalsPanel.setVisible(false); + } + + boolean showRegistrations = GitBlit.getBoolean(Keys.web.showFederationRegistrations, false); + FederationRegistrationsPanel registrationsPanel = new FederationRegistrationsPanel( + "federationRegistrationsPanel"); + if (showAdmin || showRegistrations) { + registrationsPanel.hideIfEmpty(); + } else { + registrationsPanel.setVisible(false); + } + add(proposalsPanel); + add(registrationsPanel); + } +} diff --git a/src/com/gitblit/wicket/pages/FederationRegistrationPage.html b/src/com/gitblit/wicket/pages/FederationRegistrationPage.html index c7c5bdef..de30cf34 100644 --- a/src/com/gitblit/wicket/pages/FederationRegistrationPage.html +++ b/src/com/gitblit/wicket/pages/FederationRegistrationPage.html @@ -6,11 +6,6 @@ - -
- -
[Feedback Panel]
- diff --git a/src/com/gitblit/wicket/pages/FederationRegistrationPage.java b/src/com/gitblit/wicket/pages/FederationRegistrationPage.java index 00cc2ebb..aed94a41 100644 --- a/src/com/gitblit/wicket/pages/FederationRegistrationPage.java +++ b/src/com/gitblit/wicket/pages/FederationRegistrationPage.java @@ -31,7 +31,7 @@ import com.gitblit.models.FederationModel.RepositoryStatus; import com.gitblit.wicket.GitBlitWebSession; import com.gitblit.wicket.WicketUtils; -public class FederationRegistrationPage extends BasePage { +public class FederationRegistrationPage extends StandardPage { public FederationRegistrationPage(PageParameters params) { super(params); @@ -53,8 +53,8 @@ public class FederationRegistrationPage extends BasePage { error("Could not find federation registration!", true); } - setupPage("", registration.isResultData() ? getString("gb.federationResults") - : getString("gb.federationRegistration")); + setupPage(registration.isResultData() ? getString("gb.federationResults") + : getString("gb.federationRegistration"), registration.url); add(new Label("url", registration.url)); add(WicketUtils.getRegistrationImage("typeIcon", registration, this)); diff --git a/src/com/gitblit/wicket/pages/LoginPage.html b/src/com/gitblit/wicket/pages/LoginPage.html deleted file mode 100644 index 5f9b779f..00000000 --- a/src/com/gitblit/wicket/pages/LoginPage.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - [page title] - - - - - -
-
- Gitblit
-
[name]
-
- -
-
-

-   - -

-   - -

- -

-
- -
- - \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/RepositoriesPage.html b/src/com/gitblit/wicket/pages/RepositoriesPage.html index 6aa55de9..c883099c 100644 --- a/src/com/gitblit/wicket/pages/RepositoriesPage.html +++ b/src/com/gitblit/wicket/pages/RepositoriesPage.html @@ -9,34 +9,9 @@ -
-
-
- - - -
- - - - -
-
-
-
[Feedback Panel]
-
[repositories message]
[repositories panel]
- -
[users panel]
- -
[federation tokens panel]
- -
[federation proposals panel]
- -
[federation registrations panel]
-
\ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/RepositoriesPage.java b/src/com/gitblit/wicket/pages/RepositoriesPage.java index 619d42ed..ce532a76 100644 --- a/src/com/gitblit/wicket/pages/RepositoriesPage.java +++ b/src/com/gitblit/wicket/pages/RepositoriesPage.java @@ -19,7 +19,6 @@ import java.io.File; import java.io.FileReader; import java.io.InputStream; import java.io.InputStreamReader; -import java.text.MessageFormat; import org.apache.wicket.Component; import org.apache.wicket.markup.html.basic.Label; @@ -29,50 +28,13 @@ import com.gitblit.GitBlit; import com.gitblit.Keys; import com.gitblit.utils.MarkdownUtils; import com.gitblit.utils.StringUtils; -import com.gitblit.wicket.GitBlitWebSession; import com.gitblit.wicket.WicketUtils; -import com.gitblit.wicket.panels.FederationProposalsPanel; -import com.gitblit.wicket.panels.FederationRegistrationsPanel; -import com.gitblit.wicket.panels.FederationTokensPanel; import com.gitblit.wicket.panels.RepositoriesPanel; -import com.gitblit.wicket.panels.UsersPanel; -public class RepositoriesPage extends BasePage { +public class RepositoriesPage extends RootPage { public RepositoriesPage() { - super(); - setupPage("", ""); - - final boolean showAdmin; - if (GitBlit.getBoolean(Keys.web.authenticateAdminPages, true)) { - boolean allowAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, false); - showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin(); - // authentication requires state and session - setStatelessHint(false); - } else { - showAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, false); - if (GitBlit.getBoolean(Keys.web.authenticateViewPages, false)) { - // authentication requires state and session - setStatelessHint(false); - } else { - // no authentication required, no state and no session required - setStatelessHint(true); - } - } - - // display an error message cached from a redirect - String cachedMessage = GitBlitWebSession.get().clearErrorMessage(); - if (!StringUtils.isEmpty(cachedMessage)) { - error(cachedMessage); - } else if (showAdmin) { - int pendingProposals = GitBlit.self().getPendingFederationProposals().size(); - if (pendingProposals == 1) { - info("There is 1 federation proposal awaiting review."); - } else if (pendingProposals > 1) { - info(MessageFormat.format("There are {0} federation proposals awaiting review.", - pendingProposals)); - } - } + super(); // Load the markdown welcome message String messageSource = GitBlit.getString(Keys.web.repositoriesMessage, "gitblit"); @@ -109,28 +71,6 @@ public class RepositoriesPage extends BasePage { Component repositoriesMessage = new Label("repositoriesMessage", message) .setEscapeModelStrings(false); add(repositoriesMessage); - add(new RepositoriesPanel("repositoriesPanel", showAdmin, null, getAccessRestrictions())); - add(new UsersPanel("usersPanel", showAdmin).setVisible(showAdmin)); - boolean showFederation = showAdmin && GitBlit.canFederate(); - add(new FederationTokensPanel("federationTokensPanel", showFederation) - .setVisible(showFederation)); - FederationProposalsPanel proposalsPanel = new FederationProposalsPanel( - "federationProposalsPanel"); - if (showFederation) { - proposalsPanel.hideIfEmpty(); - } else { - proposalsPanel.setVisible(false); - } - - boolean showRegistrations = GitBlit.getBoolean(Keys.web.showFederationRegistrations, false); - FederationRegistrationsPanel registrationsPanel = new FederationRegistrationsPanel( - "federationRegistrationsPanel"); - if (showAdmin || showRegistrations) { - registrationsPanel.hideIfEmpty(); - } else { - registrationsPanel.setVisible(false); - } - add(proposalsPanel); - add(registrationsPanel); + add(new RepositoriesPanel("repositoriesPanel", showAdmin, null, getAccessRestrictions())); } } diff --git a/src/com/gitblit/wicket/pages/ReviewProposalPage.html b/src/com/gitblit/wicket/pages/ReviewProposalPage.html index d4244ea0..7f26f281 100644 --- a/src/com/gitblit/wicket/pages/ReviewProposalPage.html +++ b/src/com/gitblit/wicket/pages/ReviewProposalPage.html @@ -6,11 +6,6 @@ - -
- -
[Feedback Panel]
-
url [url]
diff --git a/src/com/gitblit/wicket/pages/ReviewProposalPage.java b/src/com/gitblit/wicket/pages/ReviewProposalPage.java index b006d80f..2f2d6f39 100644 --- a/src/com/gitblit/wicket/pages/ReviewProposalPage.java +++ b/src/com/gitblit/wicket/pages/ReviewProposalPage.java @@ -33,7 +33,7 @@ import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.RepositoriesPanel; @RequiresAdminRole -public class ReviewProposalPage extends BasePage { +public class ReviewProposalPage extends StandardPage { private final String PROPS_PATTERN = "{0} = {1}\n"; @@ -42,9 +42,6 @@ public class ReviewProposalPage extends BasePage { public ReviewProposalPage(PageParameters params) { super(params); - setupPage("", getString("gb.proposals")); - setStatelessHint(true); - final String token = WicketUtils.getToken(params); FederationProposal proposal = GitBlit.self().getPendingFederationProposal(token); @@ -52,13 +49,15 @@ public class ReviewProposalPage extends BasePage { error("Could not find federation proposal!", true); } + setupPage(getString("gb.proposals"), proposal.url); + + add(new Label("url", proposal.url)); add(new Label("message", proposal.message)); add(WicketUtils.createTimestampLabel("received", proposal.received, getTimeZone())); add(new Label("token", proposal.token)); add(new Label("tokenType", proposal.tokenType.name())); - - boolean go = true; + String p; if (GitBlit.isGO()) { // gitblit.properties definition diff --git a/src/com/gitblit/wicket/pages/RootPage.html b/src/com/gitblit/wicket/pages/RootPage.html new file mode 100644 index 00000000..59a0fe14 --- /dev/null +++ b/src/com/gitblit/wicket/pages/RootPage.html @@ -0,0 +1,36 @@ + + + + +
+
+
+ + + + + + +
+ + + + +
+
+
+ +
[Feedback Panel]
+ + + +
+ + \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/LoginPage.java b/src/com/gitblit/wicket/pages/RootPage.java similarity index 52% rename from src/com/gitblit/wicket/pages/LoginPage.java rename to src/com/gitblit/wicket/pages/RootPage.java index 45e1e2dc..dd64de66 100644 --- a/src/com/gitblit/wicket/pages/LoginPage.java +++ b/src/com/gitblit/wicket/pages/RootPage.java @@ -15,16 +15,14 @@ */ package com.gitblit.wicket.pages; +import java.text.MessageFormat; + import javax.servlet.http.Cookie; -import org.apache.wicket.PageParameters; -import org.apache.wicket.RestartResponseException; -import org.apache.wicket.markup.html.WebPage; -import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.PasswordTextField; import org.apache.wicket.markup.html.form.StatelessForm; import org.apache.wicket.markup.html.form.TextField; -import org.apache.wicket.markup.html.panel.FeedbackPanel; +import org.apache.wicket.markup.html.link.BookmarkablePageLink; import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; import org.apache.wicket.protocol.http.WebRequest; @@ -34,37 +32,59 @@ import com.gitblit.Constants; import com.gitblit.GitBlit; import com.gitblit.Keys; import com.gitblit.models.UserModel; +import com.gitblit.utils.StringUtils; import com.gitblit.wicket.GitBlitWebSession; -public class LoginPage extends WebPage { +public abstract class RootPage extends BasePage { + + final boolean showAdmin; IModel username = new Model(""); IModel password = new Model(""); - public LoginPage(PageParameters params) { - super(params); + public RootPage() { + super(); + setupPage("", ""); - // If we are already logged in because user directly accessed - // the login url, redirect to the home page - if (GitBlitWebSession.get().isLoggedIn()) { - throw new RestartResponseException(getApplication().getHomePage()); + // try to automatically login from cookie + if (!GitBlitWebSession.get().isLoggedIn() + && GitBlit.getBoolean(Keys.web.allowCookieAuthentication, false)) { + loginByCookie(); } - if (GitBlit.getBoolean(Keys.web.allowCookieAuthentication, false)) { - loginByCookie(); + if (GitBlit.getBoolean(Keys.web.authenticateAdminPages, true)) { + boolean allowAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, false); + showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin(); + // authentication requires state and session + setStatelessHint(false); + } else { + showAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, false); + if (GitBlit.getBoolean(Keys.web.authenticateViewPages, false)) { + // authentication requires state and session + setStatelessHint(false); + } else { + // no authentication required, no state and no session required + setStatelessHint(true); + } } + boolean showRegistrations = GitBlit.canFederate() + && GitBlit.getBoolean(Keys.web.showFederationRegistrations, false); - add(new Label("title", GitBlit.getString(Keys.web.siteName, Constants.NAME))); - add(new Label("name", GitBlit.getString(Keys.web.siteName, Constants.NAME))); + // navigation links + add(new BookmarkablePageLink("repositories", RepositoriesPage.class)); + add(new BookmarkablePageLink("users", UsersPage.class).setVisible(showAdmin)); + add(new BookmarkablePageLink("federation", FederationPage.class).setVisible(showAdmin + || showRegistrations)); + // login form StatelessForm loginForm = new StatelessForm("loginForm") { private static final long serialVersionUID = 1L; @Override public void onSubmit() { - String username = LoginPage.this.username.getObject(); - char[] password = LoginPage.this.password.getObject().toCharArray(); + String username = RootPage.this.username.getObject(); + char[] password = RootPage.this.password.getObject().toCharArray(); UserModel user = GitBlit.self().authenticate(username, password); if (user == null) { @@ -81,8 +101,27 @@ public class LoginPage extends WebPage { }; loginForm.add(new TextField("username", username)); loginForm.add(new PasswordTextField("password", password)); - loginForm.add(new FeedbackPanel("feedback")); add(loginForm); + if (GitBlit.getBoolean(Keys.web.authenticateViewPages, true) + || GitBlit.getBoolean(Keys.web.authenticateAdminPages, true)) { + loginForm.setVisible(!GitBlitWebSession.get().isLoggedIn()); + } else { + loginForm.setVisible(false); + } + + // display an error message cached from a redirect + String cachedMessage = GitBlitWebSession.get().clearErrorMessage(); + if (!StringUtils.isEmpty(cachedMessage)) { + error(cachedMessage); + } else if (showAdmin) { + int pendingProposals = GitBlit.self().getPendingFederationProposals().size(); + if (pendingProposals == 1) { + info("There is 1 federation proposal awaiting review."); + } else if (pendingProposals > 1) { + info(MessageFormat.format("There are {0} federation proposals awaiting review.", + pendingProposals)); + } + } } private void loginByCookie() { diff --git a/src/com/gitblit/wicket/pages/SendProposalPage.html b/src/com/gitblit/wicket/pages/SendProposalPage.html index 90fe0a27..794cb702 100644 --- a/src/com/gitblit/wicket/pages/SendProposalPage.html +++ b/src/com/gitblit/wicket/pages/SendProposalPage.html @@ -6,21 +6,15 @@ - - -
- -
[Feedback Panel]
-
received[received]
- - - + + + - +
url  
destination url  
message
url  
destination url  
message
type[token type]
token[token]
diff --git a/src/com/gitblit/wicket/pages/SendProposalPage.java b/src/com/gitblit/wicket/pages/SendProposalPage.java index 635b4321..11f97a08 100644 --- a/src/com/gitblit/wicket/pages/SendProposalPage.java +++ b/src/com/gitblit/wicket/pages/SendProposalPage.java @@ -37,7 +37,7 @@ import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.RepositoriesPanel; @RequiresAdminRole -public class SendProposalPage extends BasePage { +public class SendProposalPage extends StandardPage { public String myUrl; @@ -48,7 +48,7 @@ public class SendProposalPage extends BasePage { public SendProposalPage(PageParameters params) { super(params); - setupPage("", getString("gb.sendProposal")); + setupPage(getString("gb.sendProposal"), ""); setStatelessHint(true); final String token = WicketUtils.getToken(params); diff --git a/src/com/gitblit/wicket/pages/StandardPage.html b/src/com/gitblit/wicket/pages/StandardPage.html new file mode 100644 index 00000000..cb6dcd5c --- /dev/null +++ b/src/com/gitblit/wicket/pages/StandardPage.html @@ -0,0 +1,32 @@ + + + + + + +
+
+
+ + + +
+
+
+ + +
[Feedback Panel]
+ + + + + + +
+ + \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/StandardPage.java b/src/com/gitblit/wicket/pages/StandardPage.java new file mode 100644 index 00000000..ff16b631 --- /dev/null +++ b/src/com/gitblit/wicket/pages/StandardPage.java @@ -0,0 +1,40 @@ +/* + * Copyright 2011 gitblit.com. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gitblit.wicket.pages; + +import org.apache.wicket.PageParameters; +import org.apache.wicket.markup.html.basic.Label; + +public abstract class StandardPage extends BasePage { + + public StandardPage() { + // create constructor + super(); + setStatelessHint(true); + } + + public StandardPage(PageParameters params) { + // edit constructor + super(params); + setStatelessHint(true); + } + + protected void setupPage(String pageName, String subName) { + add(new Label("pageName", pageName)); + add(new Label("pageSubName", "/ " + subName)); + super.setupPage("", pageName); + } +} diff --git a/src/com/gitblit/wicket/pages/UsersPage.html b/src/com/gitblit/wicket/pages/UsersPage.html new file mode 100644 index 00000000..4d14496d --- /dev/null +++ b/src/com/gitblit/wicket/pages/UsersPage.html @@ -0,0 +1,11 @@ + + + + +
[users panel]
+
+ + \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/UsersPage.java b/src/com/gitblit/wicket/pages/UsersPage.java new file mode 100644 index 00000000..9a7f8a58 --- /dev/null +++ b/src/com/gitblit/wicket/pages/UsersPage.java @@ -0,0 +1,29 @@ +/* + * Copyright 2011 gitblit.com. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gitblit.wicket.pages; + +import com.gitblit.wicket.RequiresAdminRole; +import com.gitblit.wicket.panels.UsersPanel; + +@RequiresAdminRole +public class UsersPage extends RootPage { + + public UsersPage() { + super(); + + add(new UsersPanel("usersPanel", showAdmin).setVisible(showAdmin)); + } +} -- 2.39.5