takalat commented on a change in pull request #44:
URL: https://github.com/apache/jspwiki/pull/44#discussion_r585901733



##########
File path: jspwiki-war/src/main/webapp/templates/default/commonheader.jsp
##########
@@ -156,4 +177,76 @@ String.I18N.PREFIX = "javascript.";
          src="<wiki:Link format='url' templatefile='skins/' /><c:out 
value='${prefs.SkinName}/skin.js' />" ></script>
 </c:if>
 
+
+
+<%-- Support for cookie acceptance --%>
+ <c:if test='${!(prefs.cookies)}'>
+<script type="text/javascript">
+document.addEventListener("DOMContentLoaded", readyForCookieTest);
+var appBaseName = 
document.querySelector('meta[name="wikiApplicationName"]').content;
+
+function sendAjaxCookieConfirmation(dialogElem){
+               var request = new XMLHttpRequest();
+               var appBaseUrl = "/"+appBaseName+"/";
+               var cookieAcceptParam = "?cookies=true";
+               request.open('GET', appBaseUrl+cookieAcceptParam, true);
+
+               request.onload = function() {
+                 if (this.status >= 200 && this.status < 400) {
+                       // Success!
+                       var resp = this.response;
+                       console.log("Cookies accepted!");
+                       dialogElem.toggle();
+                       dialogElem.hide();
+                       dialogElem.destroy();
+                 } else {
+                       // We reached our target server, but it returned an 
error
+                 }
+       };
+
+       request.onerror = function() {
+         // There was a connection error of some sort
+       };      
+               request.send();
+       }
+var cookiesAllow = ${prefs.cookies};
+
+function setCookie(cname, cvalue, exdays) {
+         var d = new Date();
+         // Cookie setting lasts for 1 day before deleted from browser.
+         // TODO: Setup in server preference for client's preferred cookie 
lifetime.
+         d.setTime(d.getTime() + (exdays*24*60*60*1000));
+         var expires = "expires="+ d.toUTCString();
+               document.cookie ="CookiePrefs={"+ cname + ":'" + cvalue + "'}";
+       }
+
+function readyForCookieTest(){
+if(!cookiesAllow){     
+               var cookieDialogHtml = "<div class='dialog-message'>This 
application uses cookies to work properly. By using the application you 
understand and accept the use of necessary cookies. Click OK to proceed.</div>";

Review comment:
       Hi @juanpablo-santos 
   English and Finnish i18ns for cookie html dialog are done in the latest 
commit.
   
   I'm happy to help!

##########
File path: 
jspwiki-main/src/main/java/org/apache/wiki/preferences/Preferences.java
##########
@@ -125,19 +133,21 @@ public static void reloadPreferences( final PageContext 
pageContext ) {
      * @param request
      * @param prefs The default hashmap of preferences
      */
-       private static void parseJSONPreferences( final HttpServletRequest 
request, final Preferences prefs ) {
-        final String prefVal = TextUtil.urlDecodeUTF8( 
HttpUtil.retrieveCookieValue( request, "JSPWikiUserPrefs" ) );
-        if( prefVal != null ) {
+       private static void parseJSONPreferences( final Preferences prefs, 
final String prefVal ) {       

Review comment:
       I assume this meant only changing signature to package scope. Changed 
method modifier to <none> in the latest commit.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to