From ea936aa63d7a756ca7d0284f76b830656d1e8918 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Tue, 27 Sep 2011 09:49:57 -0400
Subject: [PATCH] Documentation.

---
 src/com/gitblit/wicket/pages/BasePage.java |   63 +++++++++++++++++++++++++++----
 1 files changed, 55 insertions(+), 8 deletions(-)

diff --git a/src/com/gitblit/wicket/pages/BasePage.java b/src/com/gitblit/wicket/pages/BasePage.java
index 06d5483..0169c8e 100644
--- a/src/com/gitblit/wicket/pages/BasePage.java
+++ b/src/com/gitblit/wicket/pages/BasePage.java
@@ -22,12 +22,15 @@
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.wicket.MarkupContainer;
 import org.apache.wicket.PageParameters;
 import org.apache.wicket.RestartResponseAtInterceptPageException;
 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.link.BookmarkablePageLink;
 import org.apache.wicket.markup.html.panel.FeedbackPanel;
+import org.apache.wicket.markup.html.panel.Fragment;
 import org.apache.wicket.protocol.http.WebRequest;
 import org.apache.wicket.protocol.http.WebResponse;
 import org.apache.wicket.protocol.http.servlet.ServletWebRequest;
@@ -36,6 +39,7 @@
 
 import com.gitblit.Constants;
 import com.gitblit.Constants.AccessRestrictionType;
+import com.gitblit.Constants.FederationStrategy;
 import com.gitblit.GitBlit;
 import com.gitblit.Keys;
 import com.gitblit.models.UserModel;
@@ -105,17 +109,12 @@
 		// footer
 		if (GitBlit.getBoolean(Keys.web.authenticateViewPages, true)
 				|| GitBlit.getBoolean(Keys.web.authenticateAdminPages, true)) {
-			if (GitBlitWebSession.get().isLoggedIn()) {
-				// logout
-				add(new LinkPanel("userPanel", null, getString("gb.logout") + " "
-						+ GitBlitWebSession.get().getUser().toString(), LogoutPage.class));
-			} else {
-				// login
-				add(new LinkPanel("userPanel", null, getString("gb.login"), LoginPage.class));
-			}
+			UserFragment userFragment = new UserFragment("userPanel", "userFragment", BasePage.this);
+			add(userFragment);
 		} else {
 			add(new Label("userPanel", ""));
 		}
+
 		add(new Label("gbVersion", "v" + Constants.VERSION));
 		if (GitBlit.getBoolean(Keys.web.aggressiveHeapManagement, false)) {
 			System.gc();
@@ -137,6 +136,24 @@
 				break;
 			case VIEW:
 				map.put(type, getString("gb.viewRestricted"));
+				break;
+			}
+		}
+		return map;
+	}
+	
+	protected Map<FederationStrategy, String> getFederationTypes() {
+		Map<FederationStrategy, String> map = new LinkedHashMap<FederationStrategy, String>();
+		for (FederationStrategy type : FederationStrategy.values()) {
+			switch (type) {
+			case EXCLUDE:
+				map.put(type, getString("gb.excludeFromFederation"));
+				break;
+			case FEDERATE_THIS:
+				map.put(type, getString("gb.federateThis"));
+				break;
+			case FEDERATE_ORIGIN:
+				map.put(type, getString("gb.federateOrigin"));
 				break;
 			}
 		}
@@ -186,4 +203,34 @@
 			throw new RestartResponseAtInterceptPageException(LoginPage.class);
 		}
 	}
+
+	/**
+	 * Panel fragment for displaying login or logout/change_password links.
+	 * 
+	 */
+	static class UserFragment extends Fragment {
+
+		private static final long serialVersionUID = 1L;
+
+		public UserFragment(String id, String markupId, MarkupContainer markupProvider) {
+			super(id, markupId, markupProvider);
+
+			if (GitBlitWebSession.get().isLoggedIn()) {
+				// username, logout, and change password
+				add(new Label("username", GitBlitWebSession.get().getUser().toString() + ":"));
+				add(new LinkPanel("loginLink", null, markupProvider.getString("gb.logout"),
+						LogoutPage.class));
+				// quick and dirty hack for showing a separator
+				add(new Label("separator", "|"));
+				add(new BookmarkablePageLink<Void>("changePasswordLink", ChangePasswordPage.class));
+			} else {
+				// login
+				add(new Label("username").setVisible(false));
+				add(new LinkPanel("loginLink", null, markupProvider.getString("gb.login"),
+						LoginPage.class));
+				add(new Label("separator").setVisible(false));
+				add(new Label("changePasswordLink").setVisible(false));
+			}
+		}
+	}
 }

--
Gitblit v1.9.1