Get favicon url from injected properties
[pithos-web-client] / src / gr / grnet / pithos / web / client / Pithos.java
index a304a9b..197931b 100644 (file)
@@ -40,6 +40,8 @@ import com.google.gwt.core.client.JsArrayString;
 import com.google.gwt.core.client.Scheduler;
 import com.google.gwt.core.client.Scheduler.RepeatingCommand;
 import com.google.gwt.core.client.Scheduler.ScheduledCommand;
+import com.google.gwt.dom.client.*;
+import com.google.gwt.dom.client.Element;
 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;
 import com.google.gwt.event.logical.shared.ResizeEvent;
@@ -114,6 +116,13 @@ public class Pithos implements EntryPoint, ResizeHandler {
         return getFromOtherPropertiesOrDefault(key, null);
     }
 
+    private static final boolean SHOW_COPYRIGHT;
+    static {
+        final String valueStr = getFromOtherPropertiesOrDefault("SHOW_COPYRIGHT", "true").trim().toLowerCase();
+        SHOW_COPYRIGHT = "true".equals(valueStr);
+        LOG("SHOW_COPYRIGHT = '", valueStr, "' ==> ", SHOW_COPYRIGHT);
+    }
+
     public static final String OTHERPROPS_STORAGE_API_URL = getFromOtherPropertiesOrNull("STORAGE_API_URL");
     public static final String OTHERPROPS_USER_CATALOGS_API_URL = getFromOtherPropertiesOrNull("USER_CATALOGS_API_URL");
     static {
@@ -173,6 +182,8 @@ public class Pithos implements EntryPoint, ResizeHandler {
         }
     }
 
+    public static String FAVICON_URL = getFromOtherPropertiesOrNull("FAVICON_URL");
+
     public interface Style extends CssResource {
         String commandAnchor();
 
@@ -486,6 +497,16 @@ public class Pithos implements EntryPoint, ResizeHandler {
     }
 
     private void initialize() {
+        // Inject the dynamically provided favicon
+        if(FAVICON_URL != null) {
+            final Document document = Document.get();
+            final Element head = document.getElementsByTagName("head").getItem(0);
+            final LinkElement link = document.createLinkElement();
+            link.setRel("icon");
+            link.setHref(FAVICON_URL);
+            head.appendChild(link);
+        }
+
         userCatalogs.updateWithIDAndName("*", "All Pithos users");
 
         lastModified = new Date(); //Initialize if-modified-since value with now.
@@ -835,11 +856,6 @@ public class Pithos implements EntryPoint, ResizeHandler {
         this.userID = authSplit[0];
         this.userToken = authSplit[1];
 
-        String gotoUrl = Window.Location.getParameter("goto");
-        if(gotoUrl != null && gotoUrl.length() > 0) {
-            Window.Location.assign(gotoUrl);
-            return false;
-        }
         return true;
     }
 
@@ -1110,6 +1126,10 @@ public class Pithos implements EntryPoint, ResizeHandler {
         return STORAGE_VIEW_URL;
     }
 
+    public static boolean isShowCopyrightMessage() {
+        return SHOW_COPYRIGHT;
+    }
+
     public static String getUserCatalogsURL() {
         return USER_CATALOGS_API_URL;
     }
@@ -1118,6 +1138,10 @@ public class Pithos implements EntryPoint, ResizeHandler {
         return Pithos.getStorageViewURL() + file.getOwnerID() + file.getUri();
     }
 
+    public static String getVersionedFileViewURL(File file, int version) {
+        return getFileViewURL(file) + "?version=" + version;
+    }
+
     /**
      * History support for folder navigation
      * adds a new browser history entry