From c50b28fd613bbf73672c2b5e7eacf8eac585424d Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 28 Aug 2012 18:26:05 +0200 Subject: [PATCH] Feature #1431: Move sunstone login to erb template and reuse common html head (cherry picked from commit 3547a59b5a7d750faab1e6c53ebd6a704ae2d5a5) --- install.sh | 10 ++-- src/sunstone/sunstone-server.rb | 8 +-- src/sunstone/templates/login.html | 52 ------------------- src/sunstone/views/_login_standard.erb | 24 +++++++++ .../login_x509.html => views/_login_x509.erb} | 25 --------- src/sunstone/views/login.erb | 31 +++++++++++ 6 files changed, 60 insertions(+), 90 deletions(-) delete mode 100644 src/sunstone/templates/login.html create mode 100644 src/sunstone/views/_login_standard.erb rename src/sunstone/{templates/login_x509.html => views/_login_x509.erb} (54%) create mode 100644 src/sunstone/views/login.erb diff --git a/install.sh b/install.sh index 433b59eca0..6fa3478b92 100755 --- a/install.sh +++ b/install.sh @@ -280,7 +280,6 @@ SUNSTONE_DIRS="$SUNSTONE_LOCATION/routes \ $SUNSTONE_LOCATION/public/vendor/FontAwesome/css \ $SUNSTONE_LOCATION/public/vendor/FontAwesome/font \ $SUNSTONE_LOCATION/public/images \ - $SUNSTONE_LOCATION/templates \ $SUNSTONE_LOCATION/views" OZONES_DIRS="$OZONES_LOCATION/lib \ @@ -485,7 +484,6 @@ INSTALL_SUNSTONE_FILES=( SUNSTONE_BIN_FILES:$BIN_LOCATION SUNSTONE_MODELS_FILES:$SUNSTONE_LOCATION/models SUNSTONE_MODELS_JSON_FILES:$SUNSTONE_LOCATION/models/OpenNebulaJSON - SUNSTONE_TEMPLATE_FILES:$SUNSTONE_LOCATION/templates SUNSTONE_VIEWS_FILES:$SUNSTONE_LOCATION/views SUNSTONE_PUBLIC_JS_FILES:$SUNSTONE_LOCATION/public/js SUNSTONE_PUBLIC_JS_PLUGINS_FILES:$SUNSTONE_LOCATION/public/js/plugins @@ -1253,10 +1251,10 @@ SUNSTONE_MODELS_JSON_FILES="src/sunstone/models/OpenNebulaJSON/HostJSON.rb \ src/sunstone/models/OpenNebulaJSON/DatastoreJSON.rb \ src/sunstone/models/OpenNebulaJSON/VirtualNetworkJSON.rb" -SUNSTONE_TEMPLATE_FILES="src/sunstone/templates/login.html \ - src/sunstone/templates/login_x509.html" - -SUNSTONE_VIEWS_FILES="src/sunstone/views/index.erb" +SUNSTONE_VIEWS_FILES="src/sunstone/views/index.erb \ + src/sunstone/views/login.erb \ + src/sunstone/views/_login_standard.erb \ + src/sunstone/views/_login_x509.erb" SUNSTONE_PUBLIC_JS_FILES="src/sunstone/public/js/layout.js \ src/sunstone/public/js/login.js \ diff --git a/src/sunstone/sunstone-server.rb b/src/sunstone/sunstone-server.rb index 5bab9f0f55..0870aa9cd8 100755 --- a/src/sunstone/sunstone-server.rb +++ b/src/sunstone/sunstone-server.rb @@ -246,13 +246,7 @@ end get '/login' do if !authorized? - if settings.config[:auth] == "x509" - templ = "login_x509.html" - else - templ = "login.html" - end - - return File.read(File.dirname(__FILE__)+'/templates/'+templ) + erb :login end end diff --git a/src/sunstone/templates/login.html b/src/sunstone/templates/login.html deleted file mode 100644 index 690afc7c93..0000000000 --- a/src/sunstone/templates/login.html +++ /dev/null @@ -1,52 +0,0 @@ - - - - OpenNebula Sunstone Login - - - - - - - - - - - - - - - -
-
-
- -
-
- -
-
-
- Username - - Password - -
- - - - retrieving - -
-
-
-
- - diff --git a/src/sunstone/views/_login_standard.erb b/src/sunstone/views/_login_standard.erb new file mode 100644 index 0000000000..4b41a5b543 --- /dev/null +++ b/src/sunstone/views/_login_standard.erb @@ -0,0 +1,24 @@ +
+
+
+ +
+
+ +
+
+
+ Username + + Password + +
+ + + + retrieving + +
+
+
+
diff --git a/src/sunstone/templates/login_x509.html b/src/sunstone/views/_login_x509.erb similarity index 54% rename from src/sunstone/templates/login_x509.html rename to src/sunstone/views/_login_x509.erb index 0cb1292ba7..52d3da5775 100644 --- a/src/sunstone/templates/login_x509.html +++ b/src/sunstone/views/_login_x509.erb @@ -1,26 +1,3 @@ - - - - OpenNebula Sunstone Login - - - - - - - - - - - - - - -
@@ -43,5 +20,3 @@
- - diff --git a/src/sunstone/views/login.erb b/src/sunstone/views/login.erb new file mode 100644 index 0000000000..97098495ec --- /dev/null +++ b/src/sunstone/views/login.erb @@ -0,0 +1,31 @@ + + + + OpenNebula Sunstone Login + + + + + + + + + + + + + + + +<% if settings.config[:auth] == "x509" %> + <%= erb :_login_x509 %> +<% else %> + <%= erb :_login_standard %> +<% end %> + + +