← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12560: Login page locale. Using localstorage instead of cookies. Properly json encoding translation stri...

 

------------------------------------------------------------
revno: 12560
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-10-10 17:49:20 +0200
message:
  Login page locale. Using localstorage instead of cookies. Properly json encoding translation strings.
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/account.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/recovery.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/restore.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/loginStrings.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/settings/systemAppearanceSettingsString.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/account.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/accountStrings.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/recovery.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/recoveryStrings.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/restore.vm
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/encoding/velocity/EncoderVelocityContext.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/account.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/account.js	2013-10-07 09:33:02 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/account.js	2013-10-10 15:49:20 +0000
@@ -41,11 +41,11 @@
 
 
 var login = {};
-login.localeCookie = "dhis2.locale";
+login.localeKey = "dhis2.locale.ui";
 
 $( document ).ready( function() {
 
-    var locale = $.cookie( login.localeCookie );
+    var locale = localStorage[login.localeKey];
     
     if ( undefined !== locale && locale )
     {

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/recovery.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/recovery.js	2013-10-07 09:33:02 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/recovery.js	2013-10-10 15:49:20 +0000
@@ -1,10 +1,10 @@
 
 var login = {};
-login.localeCookie = "dhis2.locale";
+login.localeKey = "dhis2.locale.ui";
 
 $( document ).ready( function() {
 
-    var locale = $.cookie( login.localeCookie );
+	var locale = localStorage[login.localeKey];
     
     if ( undefined !== locale && locale )
     {
@@ -43,8 +43,8 @@
 login.changeLocale = function( locale )
 {		
 	$.get( 'recoveryStrings.action?loc=' + locale, function( json ) {				
-		$('#account_recovery').html( json.account_recovery );
-		$('#label_username').html( json.user_name );
+		$('#accountRecovery').html( json.account_recovery );
+		$('#labelUsername').html( json.user_name );
 		$('#recoveryButton').val( json.recover );
 		$('#recoverySuccessMessage').html( json.recover_success_message );
 		$('#recoveryErrorMessage').html( json.recover_error_message );

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/restore.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/restore.js	2013-10-06 11:32:14 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/restore.js	2013-10-10 15:49:20 +0000
@@ -1,7 +1,4 @@
 
-var login = {};
-login.localeCookie = "dhis2.locale";
-
 var validationRules = {
 	rules: {
 		code: {

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.js	2013-10-10 12:00:38 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.js	2013-10-10 15:49:20 +0000
@@ -1,6 +1,6 @@
 
 var login = {};
-login.localeCookie = "dhis2.locale";
+login.localeKey = "dhis2.locale.ui";
 
 $( document ).ready( function() 
 {
@@ -13,7 +13,7 @@
         sessionStorage.removeItem( 'orgUnitSelected' );
     } );
     
-    var locale = $.cookie( login.localeCookie );
+    var locale = localStorage[login.localeKey];
     
     if ( undefined !== locale && locale )
     {
@@ -28,8 +28,8 @@
 	
 	if ( locale )
 	{
-		login.changeLocale( locale );	
-		$.cookie( login.localeCookie, locale, { expires : 356*10 } );
+		login.changeLocale( locale );
+		localStorage[login.localeKey] = locale;
 	}
 }
 

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.vm	2013-10-10 12:00:38 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.vm	2013-10-10 15:49:20 +0000
@@ -6,7 +6,6 @@
         <meta name="keywords" content="DHIS 2">
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
         <script type="text/javascript" src="../javascripts/jQuery/jquery.min.js"></script>
-        <script type="text/javascript" src="../javascripts/jQuery/jquery.cookie.js"></script>
         <script type="text/javascript" src="login.js"></script>
         <link type="text/css" rel="stylesheet" href="../css/widgets.css">
         <link type="text/css" rel="stylesheet" href="../css/login.css">

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/loginStrings.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/loginStrings.vm	2013-10-10 12:00:38 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/loginStrings.vm	2013-10-10 15:49:20 +0000
@@ -1,24 +1,14 @@
 {
-"create_an_account": "$!i18nObject.getString( "create_an_account" )",
-"login_username": "$!i18nObject.getString( "login_username" )",
-"login_password": "$!i18nObject.getString( "login_password" )",
-"forgot_password": "$!i18nObject.getString( "forgot_password" )",
-"create_an_account": "$!i18nObject.getString( "create_an_account" )",
-"wrong_username_or_password": "$!i18nObject.getString( "wrong_username_or_password" )",
-"powered_by": "$!i18nObject.getString( "powered_by" )",
-"login": "$!i18nObject.getString( "login" )",
-
-"applicationTitle": "$!encoder.htmlEncode( $!translations.get( "applicationTitle" ) )",
-
-#set($strKeyApplicationIntro =  $!translations.get( "keyApplicationIntro" ) )
-#set($strKeyApplicationIntro = $strKeyApplicationIntro.replaceAll( "'", '&#39;' ) )
-"keyApplicationIntro": "$!encoder.jsEncode( $strKeyApplicationIntro )",
-
-#set($strKeyApplicationNotification =  $!translations.get( "keyApplicationNotification" ) )
-#set($strKeyApplicationNotification = $strKeyApplicationNotification.replaceAll( "'", '&#39;' ) )
-"keyApplicationNotification": "$!encoder.jsEncode( $strKeyApplicationNotification )",
-
-#set($strKeyApplicationFooter =  $!translations.get( "keyApplicationFooter" ) )
-#set($strKeyApplicationFooter = $strKeyApplicationFooter.replaceAll("'", '&#39;') )
-"keyApplicationFooter": "$!encoder.jsEncode( $strKeyApplicationFooter )"
+"create_an_account": "$!encoder.jsonEncode( $i18nObject.getString( "create_an_account" ) )",
+"login_username": "$!encoder.jsonEncode( $i18nObject.getString( "login_username" ) )",
+"login_password": "$!encoder.jsonEncode( $i18nObject.getString( "login_password" ) )",
+"forgot_password": "$!encoder.jsonEncode( $i18nObject.getString( "forgot_password" ) )",
+"create_an_account": "$!encoder.jsonEncode( $i18nObject.getString( "create_an_account" ) )",
+"wrong_username_or_password": "$!encoder.jsonEncode( $i18nObject.getString( "wrong_username_or_password" ) )",
+"powered_by": "$!encoder.jsonEncode( $i18nObject.getString( "powered_by" ) )",
+"login": "$!encoder.jsonEncode( $i18nObject.getString( "login" ) )",
+"applicationTitle": "$!encoder.jsonEncode( $!translations.get( "applicationTitle" ) )",
+"keyApplicationIntro": "$!encoder.jsonEncode( $translations.get( "keyApplicationIntro" ) )",
+"keyApplicationNotification": "$!encoder.jsonEncode( $translations.get( "keyApplicationNotification" ) )",
+"keyApplicationFooter": "$!encoder.jsonEncode( $translations.get( "keyApplicationFooter" ) )"
 }

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/settings/systemAppearanceSettingsString.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/settings/systemAppearanceSettingsString.vm	2013-10-10 12:00:38 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/settings/systemAppearanceSettingsString.vm	2013-10-10 15:49:20 +0000
@@ -1,15 +1,6 @@
 {
-"applicationTitle": "$!encoder.htmlEncode( $!translations.get( "applicationTitle" ) )",
-
-#set($strKeyApplicationIntro =  $!translations.get( "keyApplicationIntro" ) )
-#set($strKeyApplicationIntro = $strKeyApplicationIntro.replaceAll( "'", '&#39;' ) )
-"keyApplicationIntro": "$!encoder.jsEncode( $strKeyApplicationIntro )",
-
-#set($strKeyApplicationNotification =  $!translations.get( "keyApplicationNotification" ) )
-#set($strKeyApplicationNotification = $strKeyApplicationNotification.replaceAll( "'", '&#39;' ) )
-"keyApplicationNotification": "$!encoder.jsEncode( $strKeyApplicationNotification )",
-
-#set($strKeyApplicationFooter =  $!translations.get( "keyApplicationFooter" ) )
-#set($strKeyApplicationFooter = $strKeyApplicationFooter.replaceAll("'", '&#39;') )
-"keyApplicationFooter": "$!encoder.jsEncode( $strKeyApplicationFooter )"
+"applicationTitle": "$!encoder.jsonEncode( $!translations.get( "applicationTitle" ) )",
+"keyApplicationIntro": "$!encoder.jsonEncode( $translations.get( "keyApplicationIntro" ) )",
+"keyApplicationNotification": "$!encoder.jsonEncode( $translations.get( "keyApplicationNotification" ) )",
+"keyApplicationFooter": "$!encoder.jsonEncode( $translations.get( "keyApplicationFooter" ) )"
 }

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/account.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/account.vm	2013-10-07 09:33:02 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/account.vm	2013-10-10 15:49:20 +0000
@@ -3,7 +3,6 @@
 <head>
     <title>$encoder.htmlEncode( $applicationTitle )</title>
     <script type="text/javascript" src="../javascripts/jQuery/jquery.min.js"></script>
-    <script type="text/javascript" src="../javascripts/jQuery/jquery.cookie.js"></script>
     <script type="text/javascript" src="../javascripts/jQuery/jquery.validate.js"></script>
     <script type="text/javascript" src="../javascripts/jQuery/jquery.validate.ext.js"></script>
     <script type="text/javascript" src="../javascripts/useraccount/account.js"></script>

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/accountStrings.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/accountStrings.vm	2013-10-07 09:33:02 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/accountStrings.vm	2013-10-10 15:49:20 +0000
@@ -1,15 +1,15 @@
 {
-"create_new_account": "$!i18nObject.getString( "create_new_account" )",
-"name": "$!i18nObject.getString( "new_user_account_name" )",
-"first_name": "$!i18nObject.getString( "new_user_account_first_name" )",
-"last_name": "$!i18nObject.getString( "new_user_account_last_name" )",
-"user_name": "$!i18nObject.getString( "user_name" )",
-"password": "$!i18nObject.getString( "password" )",
-"confirm_password": "$!i18nObject.getString( "confirm_password" )",
-"email": "$!i18nObject.getString( "email" )",
-"mobile_phone": "$!i18nObject.getString( "mobile_phone" )",
-"employer": "$!i18nObject.getString( "employer" )",
-"prove_not_robot": "$!i18nObject.getString( "prove_you_are_not_a_robot" )",
-"cant_read_words": "$!i18nObject.getString( "cant_read_the_words_try_another_one" )",
-"create": "$!i18nObject.getString( "create" )"
+"create_new_account": "$!encoder.jsonEncode( $i18nObject.getString( "create_new_account" ) )",
+"name": "$!encoder.jsonEncode( $i18nObject.getString( "new_user_account_name" ) )",
+"first_name": "$!encoder.jsonEncode( $i18nObject.getString( "new_user_account_first_name" ) )",
+"last_name": "$!encoder.jsonEncode( $i18nObject.getString( "new_user_account_last_name" ) )",
+"user_name": "$!encoder.jsonEncode( $i18nObject.getString( "user_name" ) )",
+"password": "$!encoder.jsonEncode( $i18nObject.getString( "password" ) )",
+"confirm_password": "$!encoder.jsonEncode( $i18nObject.getString( "confirm_password" ) )",
+"email": "$!encoder.jsonEncode( $i18nObject.getString( "email" ) )",
+"mobile_phone": "$!encoder.jsonEncode( $i18nObject.getString( "mobile_phone" ) )",
+"employer": "$!encoder.jsonEncode( $i18nObject.getString( "employer" ) )",
+"prove_not_robot": "$!encoder.jsonEncode( $i18nObject.getString( "prove_you_are_not_a_robot" ) )",
+"cant_read_words": "$!encoder.jsonEncode( $i18nObject.getString( "cant_read_the_words_try_another_one" ) )",
+"create": "$!encoder.jsonEncode( $i18nObject.getString( "create" ) )"
 }

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/recovery.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/recovery.vm	2013-10-07 09:33:02 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/recovery.vm	2013-10-10 15:49:20 +0000
@@ -3,7 +3,6 @@
 <head>
     <title>$encoder.htmlEncode( $applicationTitle )</title>
     <script type="text/javascript" src="../javascripts/jQuery/jquery.min.js"></script>
-    <script type="text/javascript" src="../javascripts/jQuery/jquery.cookie.js"></script>
     <script type="text/javascript" src="../javascripts/useraccount/recovery.js"></script>
     <link type="text/css" rel="stylesheet" href="../css/account.css">
 </head>
@@ -17,13 +16,13 @@
 
 <div id="accountInput">
 
-<h3><span id="account_recovery">$i18n.getString( "account_recovery" )</span></h3>
+<h3><span id="accountRecovery">$i18n.getString( "account_recovery" )</span></h3>
 
 <form id="recoveryForm">
 
 <table>
     <tr>
-        <td style="width:100px"><label id="label_username" for="username">$i18n.getString( "user_name" )</label></td>
+        <td style="width:100px"><label id="labelUsername" for="username">$i18n.getString( "user_name" )</label></td>
         <td><input type="text" id="username" name="username" autocomplete="off"></td>
     </tr>
     <tr>

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/recoveryStrings.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/recoveryStrings.vm	2013-10-07 09:33:02 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/recoveryStrings.vm	2013-10-10 15:49:20 +0000
@@ -1,7 +1,7 @@
 {
-"account_recovery": "$!i18nObject.getString( "account_recovery" )",
-"user_name": "$!i18nObject.getString( "user_name" )",
-"recover": "$!i18nObject.getString( "recover" )",
-"recover_success_message": "$!i18nObject.getString( "recover_success_message" )",
-"recover_error_message": "$!i18nObject.getString( "recover_error_message" )"
+"account_recovery": "$!encoder.jsonEncode( $i18nObject.getString( "account_recovery" ) )",
+"user_name": "$!encoder.jsonEncode( $i18nObject.getString( "user_name" ) )",
+"recover": "$!encoder.jsonEncode( $i18nObject.getString( "recover" ) )",
+"recover_success_message": "$encoder.jsonEncode( $!i18nObject.getString( "recover_success_message" ) )",
+"recover_error_message": "$encoder.jsonEncode( $!i18nObject.getString( "recover_error_message" ) )"
 }

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/restore.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/restore.vm	2013-10-06 11:32:14 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/restore.vm	2013-10-10 15:49:20 +0000
@@ -3,7 +3,6 @@
 <head>
     <title>$encoder.htmlEncode( $applicationTitle )</title>
     <script type="text/javascript" src="../javascripts/jQuery/jquery.min.js"></script>
-    <script type="text/javascript" src="../javascripts/jQuery/jquery.cookie.js"></script>
     <script type="text/javascript" src="../javascripts/jQuery/jquery.validate.js"></script>
     <script type="text/javascript" src="../javascripts/jQuery/jquery.validate.ext.js"></script>
     <script type="text/javascript" src="../javascripts/useraccount/restore.js"></script>

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/encoding/velocity/EncoderVelocityContext.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/encoding/velocity/EncoderVelocityContext.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/encoding/velocity/EncoderVelocityContext.java	2013-10-10 15:49:20 +0000
@@ -33,8 +33,6 @@
 
 /**
  * @author Torgeir Lorange Ostby
- * @version $Id: EncoderVelocityContext.java 5824 2008-10-07 18:00:24Z larshelg
- *          $
  */
 public class EncoderVelocityContext
     extends VelocityContext