aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject [1/7] Installing JQuery and bootstrap from bower
Date Fri, 27 Dec 2013 18:40:43 GMT
Updated Branches:
  refs/heads/master 446c2446b -> 1bc872a73


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/1bc872a7/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 79faeed..7e33ed8 100644
--- a/build.gradle
+++ b/build.gradle
@@ -84,6 +84,9 @@ sourceSets {
   }
   main {
     compileClasspath += sourceSets.generated.output
+    resources {
+      srcDir '3rdparty/javascript'
+    }
   }
   test {
     compileClasspath += sourceSets.generated.output
@@ -99,6 +102,10 @@ sourceSets {
 jar {
   dependsOn 'about'
   from sourceSets.generated.output
+  manifest {
+    attributes('Created-By': 'Gradle')
+    attributes('Main-Class': 'com.twitter.aurora.scheduler.app.SchedulerMain')
+  }
 }
 
 dependencies {

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/1bc872a7/docs/developing-aurora-scheduler.md
----------------------------------------------------------------------
diff --git a/docs/developing-aurora-scheduler.md b/docs/developing-aurora-scheduler.md
index 1beafdc..95bf472 100644
--- a/docs/developing-aurora-scheduler.md
+++ b/docs/developing-aurora-scheduler.md
@@ -55,6 +55,33 @@ NOTE: Anyone thinking about adding a new dependency should first familiarize
the
 Apache Foundation's third-party licensing
 [policy](http://www.apache.org/legal/resolved.html#category-x).
 
+Developing Aurora UI
+======================
+
+Installing bower (optional)
+----------------------------
+Third party JS libraries used in Aurora (located at 3rdparty/javascript/bower_components)
are
+managed by bower, a JS dependency manager. Bower is only required if you plan to add, remove
or
+update JS libraries. Bower can be installed using the following command:
+
+    npm install -g bower
+
+Bower depends on node.js and npm. The easiest way to install node on a mac is via brew:
+
+    brew install node
+
+For more node.js installation options refer to https://github.com/joyent/node/wiki/Installation.
+
+More info on installing and using bower can be found at: http://bower.io/. Once installed,
you can
+use the following commands to view and modify the bower repo at
+3rdparty/javascript/bower_components
+
+    bower list
+    bower install <library name>
+    bower remove <library name>
+    bower update <library name>
+    bower help
+
 Developing the Aurora Build System
 ==================================
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/1bc872a7/src/main/java/com/twitter/aurora/scheduler/http/ServletModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/twitter/aurora/scheduler/http/ServletModule.java b/src/main/java/com/twitter/aurora/scheduler/http/ServletModule.java
index 2922f35..825e2e1 100644
--- a/src/main/java/com/twitter/aurora/scheduler/http/ServletModule.java
+++ b/src/main/java/com/twitter/aurora/scheduler/http/ServletModule.java
@@ -22,6 +22,7 @@ import javax.inject.Singleton;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
+import com.google.common.io.Resources;
 import com.google.common.net.MediaType;
 import com.google.inject.AbstractModule;
 import com.google.inject.Key;
@@ -40,9 +41,6 @@ import com.twitter.common.application.modules.LocalServiceRegistry;
 import com.twitter.common.base.ExceptionalCommand;
 import com.twitter.common.net.pool.DynamicHostSet;
 import com.twitter.common.net.pool.DynamicHostSet.MonitorException;
-import com.twitter.common.webassets.bootstrap.BootstrapModule;
-import com.twitter.common.webassets.bootstrap.BootstrapModule.BootstrapVersion;
-import com.twitter.common.webassets.jquery.JQueryModule;
 import com.twitter.thrift.ServiceInstance;
 
 import static com.sun.jersey.api.core.ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS;
@@ -66,9 +64,6 @@ public class ServletModule extends AbstractModule {
     requireBinding(Key.get(String.class, ClusterName.class));
     requireBinding(QuotaManager.class);
 
-    install(new JQueryModule());
-    install(new BootstrapModule(BootstrapVersion.VERSION_2_3_2));
-
     // Bindings required for the leader redirector.
     requireBinding(LocalServiceRegistry.class);
     requireBinding(Key.get(new TypeLiteral<DynamicHostSet<ServiceInstance>>()
{ }));
@@ -105,10 +100,15 @@ public class ServletModule extends AbstractModule {
     });
 
     // Static assets.
+    registerJQueryAssets();
+    registerBootstrapAssets();
+
     registerAsset("assets/util.js", "/js/util.js");
     registerAsset("assets/dictionary.js", "/js/dictionary.js");
     registerAsset("assets/images/viz.png", "/images/viz.png");
     registerAsset("assets/images/aurora.png", "/images/aurora.png");
+
+    // Register datatables
     registerAsset("assets/datatables/css/jquery.dataTables.css", "/css/jquery.dataTables.css");
     registerAsset("assets/datatables/images/back_disabled.png", "/images/back_disabled.png");
     registerAsset(
@@ -150,29 +150,63 @@ public class ServletModule extends AbstractModule {
     LifecycleModule.bindStartupAction(binder(), RedirectMonitor.class);
   }
 
+  private void registerJQueryAssets() {
+    registerAsset("bower_components/jquery/jquery.js", "/js/jquery.min.js", false);
+  }
+
+  private void registerBootstrapAssets() {
+    final String BOOTSTRAP_PATH = "bower_components/bootstrap.css/";
+
+    registerAsset(BOOTSTRAP_PATH + "js/bootstrap.min.js", "/js/bootstrap.min.js", false);
+    registerAsset(BOOTSTRAP_PATH + "css/bootstrap.min.css", "/css/bootstrap.min.css", false);
+    registerAsset(BOOTSTRAP_PATH + "css/bootstrap-responsive.min.css",
+        "/css/bootstrap-responsive.min.css",
+        false);
+    registerAsset(BOOTSTRAP_PATH + "img/glyphicons-halflings-white.png",
+        "/img/glyphicons-halflings-white.png",
+        false);
+    registerAsset(BOOTSTRAP_PATH + "img/glyphicons-halflings.png",
+        "/img/glyphicons-halflings.png",
+        false);
+  }
+
   private void registerAsset(String resourceLocation, String registerLocation) {
-    MediaType mediaType;
-
-    if (registerLocation.endsWith(".png")) {
-      mediaType = MediaType.PNG;
-    } else if (registerLocation.endsWith(".js")) {
-      mediaType = MediaType.JAVASCRIPT_UTF_8;
-    } else if (registerLocation.endsWith(".html")) {
-      mediaType = MediaType.HTML_UTF_8;
-    } else if (registerLocation.endsWith(".css")) {
-      mediaType = MediaType.CSS_UTF_8;
+    registerAsset(resourceLocation, registerLocation, true);
+  }
+
+  private void registerAsset(String resourceLocation, String registerLocation, boolean isRelative)
{
+    String mediaType = getMediaType(registerLocation).toString();
+
+    if (isRelative) {
+      Registration.registerHttpAsset(
+          binder(),
+          registerLocation,
+          ServletModule.class,
+          resourceLocation,
+          mediaType,
+          true);
     } else {
-      throw new IllegalArgumentException("Could not determine media type for "
-          + registerLocation);
+      Registration.registerHttpAsset(
+          binder(),
+          registerLocation,
+          Resources.getResource(resourceLocation),
+          mediaType,
+          true);
     }
+  }
 
-    Registration.registerHttpAsset(
-      binder(),
-      registerLocation,
-      ServletModule.class,
-      resourceLocation,
-      mediaType.toString(),
-      true);
+  private MediaType getMediaType(String filePath) {
+    if (filePath.endsWith(".png")) {
+      return MediaType.PNG;
+    } else if (filePath.endsWith(".js")) {
+      return MediaType.JAVASCRIPT_UTF_8;
+    } else if (filePath.endsWith(".html")) {
+      return MediaType.HTML_UTF_8;
+    } else if (filePath.endsWith(".css")) {
+      return MediaType.CSS_UTF_8;
+    } else {
+      throw new IllegalArgumentException("Could not determine media type for " + filePath);
+    }
   }
 
   static class RedirectMonitor implements ExceptionalCommand<MonitorException> {


Mime
View raw message