Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
Use the same top nav bar on index.html and search results.
lucciomand0bed78d0285
diff --git a/htroot/index.html b/htroot/index.htmlindex 7ee2dbcfc..5af481042 100644--- a/htroot/index.html+++ b/htroot/index.html@@ -41,7 +41,7 @@#(topmenu)##%env/templates/embeddedheader.template%#::- #%env/templates/simpleheader.template%#+ #%env/templates/simpleSearchHeader.template%#<script type="text/javascript">document.getElementById("header_websearch").className += " active";</script>diff --git a/htroot/index.java b/htroot/index.javaindex 3a03e8a52..725929037 100644--- a/htroot/index.java+++ b/htroot/index.java@@ -52,9 +52,15 @@ public class index {}// access control- final boolean authorizedAccess = sb.verifyAuthentication(header);- if ((post != null) && (post.containsKey("publicPage"))) {- if (!authorizedAccess) {+ String authenticatedUserName = null;+ final boolean adminAuthenticated = sb.verifyAuthentication(header);++ if(adminAuthenticated) {+ authenticatedUserName = sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin");+ }++ if ((post != null) && (post.containsKey("auth") || post.containsKey("publicPage"))) {+ if (!adminAuthenticated) {prop.authenticationRequired();return prop;}@@ -136,9 +142,47 @@ public class index {prop.put("searchdomswitches_searchapp_check", (contentdom == ContentDomain.APP) ? "1" : "0");prop.put("search.navigation", sb.getConfig("search.navigation", "all") );prop.put("search.verify", sb.getConfig("search.verify", "iffresh") );++ handleTopNavBarLoginSection(header, sb, prop, authenticatedUserName);+// online caution timingsb.localSearchLastAccess = System.currentTimeMillis();return prop;}++ /**+ * Add any eventually relevant information to generate the proper login link or status in the top navigation bar+ * @param header the current request headers+ * @param sb the server environment+ * @param prop the servlet answer object+ * @param authenticatedUserName the name of the currently authenticated user or null+ */+ private static void handleTopNavBarLoginSection(final RequestHeader header, final Switchboard sb,+ final serverObjects prop, String authenticatedUserName) {+ final boolean showLogin = sb.getConfigBool(SwitchboardConstants.SEARCH_PUBLIC_TOP_NAV_BAR_LOGIN,+ SwitchboardConstants.SEARCH_PUBLIC_TOP_NAV_BAR_LOGIN_DEFAULT);+ if(showLogin) {+ if(authenticatedUserName != null) {+ /* Show the name of the authenticated user */+ prop.put("showLogin", 1);+ prop.put("showLogin_userName", authenticatedUserName);+ } else {+ /* Show a login link */+ prop.put("showLogin", 2);++ /* The login link targets the same URL as the current location, just adding the 'auth' parameter to indicates that access to extended search features is desired */+ StringBuilder loginURL = new StringBuilder("index.html?auth");+ final String query = header.getQueryString();+ if(query != null) {+ loginURL.append("&").append(query);+ }+++ prop.put("showLogin_loginURL", loginURL.toString());+ }+ } else {+ prop.put("showLogin", 0);+ }+ }}diff --git a/htroot/yacysearch.java b/htroot/yacysearch.javaindex 17626528f..8f07e8244 100644--- a/htroot/yacysearch.java+++ b/htroot/yacysearch.java@@ -109,8 +109,7 @@ public class yacysearch {if(adminAuthenticated) {authenticatedUserName = sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin");- }- if (!extendedSearchRights) {+ } else {final UserDB.Entry user = sb.userDB != null ? sb.userDB.getUser(header) : null;if(user != null) {extendedSearchRights = user.hasRight(UserDB.AccessRight.EXTENDED_SEARCH_RIGHT);