r61 - in trunk/src/main: java/org/nuiton/scmwebeditor webapp
Author: glorieux Date: 2009-12-18 11:32:59 +0100 (Fri, 18 Dec 2009) New Revision: 61 Added: trunk/src/main/webapp/pictureUpload.js Modified: trunk/src/main/java/org/nuiton/scmwebeditor/ScmWebEditorMainServlet.java trunk/src/main/java/org/nuiton/scmwebeditor/SearchServlet.java trunk/src/main/webapp/GereSession.js trunk/src/main/webapp/ModificationViewer.jsp trunk/src/main/webapp/Saver.js trunk/src/main/webapp/cancelRedirectDelete.js trunk/src/main/webapp/fileSearch.js Log: Add menu(xml) editon support from maven site. Change ScmWebEditor look. Modified: trunk/src/main/java/org/nuiton/scmwebeditor/ScmWebEditorMainServlet.java =================================================================== --- trunk/src/main/java/org/nuiton/scmwebeditor/ScmWebEditorMainServlet.java 2009-12-18 10:25:03 UTC (rev 60) +++ trunk/src/main/java/org/nuiton/scmwebeditor/ScmWebEditorMainServlet.java 2009-12-18 10:32:59 UTC (rev 61) @@ -37,6 +37,8 @@ import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; +import org.apache.commons.lang.StringEscapeUtils; +import org.jdom.output.EscapeStrategy; /** * @author geoffroy lorieux @@ -110,12 +112,12 @@ String paramLang = request.getParameter(PARAMETER_LANG); String paramDefaultLang = request.getParameter(PARAMETER_DEFAULT_LANG); - String paramFormat = request.getParameter(PARAMETER_FORMAT); + String paramFormat = request.getParameter(PARAMETER_FORMAT) != null ? request.getParameter(PARAMETER_FORMAT) : ""; - String relativePath = "/src/site/" + paramLang + "/" + paramFormat + "/"; + String relativePath = "/src/site/" + paramLang + "/" +( paramFormat.equals("") ? "" : paramFormat+"/"); if (paramLang.equals(paramDefaultLang)) { // on a maven site, default locale is on root - relativePath = "/src/site/" + paramFormat + "/"; + relativePath = "/src/site/" +( paramFormat.equals("") ? "" : paramFormat+"/"); paramProjectUrl = paramProjectUrl.replace("/"+paramDefaultLang+"/", "/"); } @@ -172,7 +174,8 @@ File file_in_dir = new File(svnSess.getCheckoutdir(), svnSess.getFileName()); try { String original_text = FileUtils.readFileToString(file_in_dir); - request.setAttribute(ATTRIBUTE_ORIG_TEXT, original_text); + request.setAttribute(PARAMETER_FORMAT, svnSess.getFormat()); + request.setAttribute(ATTRIBUTE_ORIG_TEXT, StringEscapeUtils.escapeHtml(original_text)); request.setAttribute(ATTRIBUTE_INVALIDATE_MAX_TIME, (httpSession.getMaxInactiveInterval() / 60)); request.setAttribute(ATTRIBUTE_LOGIN, (svnSess.getLogin() != null && !svnSess.getLogin().equalsIgnoreCase("") ? svnSess.getLogin() : null)); request.setAttribute(ATTRIBUTE_IS_LOGIN, (svnSess.getLogin() != null && svnSess.getPassword() != null && !svnSess.getLogin().equalsIgnoreCase("") && !svnSess.getPassword().equalsIgnoreCase(""))); @@ -231,6 +234,9 @@ svnSess.getLogin() != null && !svnSess.getLogin().equalsIgnoreCase("") ? svnSess.getLogin() : request.getParameter(PARAMETER_USERNAME), svnSess.getPassword() != null && !svnSess.getPassword().equalsIgnoreCase("") ? svnSess.getPassword() : request.getParameter(PARAMETER_PW)); + String originalText = StringEscapeUtils.unescapeHtml(request.getParameter(PARAMETER_ORIG_TEXT)); + String myText = StringEscapeUtils.unescapeHtml(request.getParameter(PARAMETER_MYTEXT)); + File pathToFile = new File(svnSess.getCheckoutdir(), svnSess.getFileName()); SVNCommitClient commitClient = new SVNCommitClient(svnSess.getManager(), svnSess.getSvnOption()); @@ -241,8 +247,8 @@ File[] tabFile = new File[1]; tabFile[0] = pathToFile; // Sending Data to SVN - - if (!request.getParameter(PARAMETER_MYTEXT).equals(request.getParameter(PARAMETER_ORIG_TEXT))) { + + if (!myText.equals(originalText)) { try { log.debug("Je commit"); //TODO-TC20091124 Should add a prefix to the commit file ? something like from scmwebeditor -- Modified: trunk/src/main/java/org/nuiton/scmwebeditor/SearchServlet.java =================================================================== --- trunk/src/main/java/org/nuiton/scmwebeditor/SearchServlet.java 2009-12-18 10:25:03 UTC (rev 60) +++ trunk/src/main/java/org/nuiton/scmwebeditor/SearchServlet.java 2009-12-18 10:32:59 UTC (rev 61) @@ -17,6 +17,9 @@ package org.nuiton.scmwebeditor; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.ServletException; @@ -24,15 +27,24 @@ import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.tmatesoft.svn.core.ISVNCanceller; import org.tmatesoft.svn.core.ISVNDirEntryHandler; import org.tmatesoft.svn.core.SVNDirEntry; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; +import org.tmatesoft.svn.core.internal.io.svn.ISVNConnector; +import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryImpl; import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions; +import org.tmatesoft.svn.core.io.ISVNTunnelProvider; +import org.tmatesoft.svn.core.io.SVNRepository; +import org.tmatesoft.svn.core.wc.DefaultSVNRepositoryPool; +import org.tmatesoft.svn.core.wc.ISVNRepositoryPool; +import org.tmatesoft.svn.core.wc.SVNClientManager; import org.tmatesoft.svn.core.wc.SVNLogClient; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc.SVNWCUtil; +import org.tmatesoft.svn.util.ISVNDebugLog; public class SearchServlet extends AbstractScmWebEditorServlet { @@ -47,7 +59,7 @@ * @throws ServletException if a servlet-specific error occurs */ @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException{ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException { try { String adresse = request.getParameter(PARAMETER_ADRESSE); if (log.isDebugEnabled()) { @@ -56,21 +68,28 @@ //Create default access DefaultSVNOptions svnOption = SVNWCUtil.createDefaultOptions(false); ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(); + log.debug("Authentication manager and svnOption created"); //Convert url to SVNUrl - SVNURL svnUrl; - svnUrl = SVNURL.parseURIEncoded(adresse); + SVNURL svnUrl = SVNURL.parseURIEncoded(adresse); + log.debug("Svn url created"); + // create a SVNRepositoryPool + SVNClientManager plop = SVNClientManager.newInstance(svnOption, authManager); + ISVNRepositoryPool pool = plop.getRepositoryPool(); //get a SVNLogClient - SVNLogClient logClient = new SVNLogClient(authManager, svnOption); + SVNLogClient logClient = new SVNLogClient(pool, svnOption); + log.debug("LogClient Created"); //recup info about svn repository ISVNDirEntryHandler dirEntryHandler = new ISVNDirEntryHandler() { - @Override - public void handleDirEntry(SVNDirEntry arg0) throws SVNException { - log.debug("le fichier est: " + arg0.getName()); + public void handleDirEntry(SVNDirEntry dirEntry) throws SVNException { + log.debug("Handle dirEntries"); + log.debug("le fichier est: " + dirEntry.getName()); throw new UnsupportedOperationException("Not supported yet."); } }; + log.debug("Begin handle listEntries"); logClient.doList(svnUrl, SVNRevision.WORKING, SVNRevision.HEAD, true, true, dirEntryHandler); + log.debug("List handle"); } catch (SVNException ex) { response.setStatus(401); Logger.getLogger(SearchServlet.class.getName()).log(Level.SEVERE, null, ex); Modified: trunk/src/main/webapp/GereSession.js =================================================================== --- trunk/src/main/webapp/GereSession.js 2009-12-18 10:25:03 UTC (rev 60) +++ trunk/src/main/webapp/GereSession.js 2009-12-18 10:32:59 UTC (rev 61) @@ -9,7 +9,7 @@ { msg+='s'; } - msg+='.\nDo you want to reload this page ?'; + msg+='.\nDo you want to reload this page ?(You will not lose your data)'; if(confirm(msg)) { Modified: trunk/src/main/webapp/ModificationViewer.jsp =================================================================== --- trunk/src/main/webapp/ModificationViewer.jsp 2009-12-18 10:25:03 UTC (rev 60) +++ trunk/src/main/webapp/ModificationViewer.jsp 2009-12-18 10:32:59 UTC (rev 61) @@ -14,8 +14,8 @@ <body onload="cleanForm();geresession(<%=request.getAttribute("InvalidateMaxTime")%>, 5);"> <img src="img/ScmWebEditor_main.png" alt="$alt" /> <center><h2><p>Welcome on SCMWebEditor</p></h2> - <h4><p>For any Problem with RestruturedText visit <a href="http://docutils.sourceforge.net/rst.html">RST documentation website</a>.</p></h4></center> - + <%if (request.getAttribute("format").equals("rst") == true){ + %><h4><p>For any Problem with RestruturedText visit <a href="http://docutils.sourceforge.net/rst.html">RST documentation website</a>.</p></h4></center><%}%> <center><form method="post" action=<%=request.getAttribute("scmEditorUri")%>> <script src="GereFormSize.js"></script> <textarea name="Mytext" id="Mytext" rows="20" cols="150"><%=request.getAttribute("OrigText")%></textarea> @@ -29,30 +29,24 @@ <p>Commit Message: <input type="text" name="Commit_message"/></p> <%if (request.getAttribute("IsLogin").equals(false) == true){ - %><p><label ACCESSKEY=U>User name: <input TYPE=text NAME=username SIZE=12></label> - <label ACCESSKEY=P>Password: <input TYPE=password NAME=pw SIZE=12></label> </p><% + %><p><label ACCESSKEY=U>User name: <input TYPE=text NAME=username SIZE=12 /></label> + <label ACCESSKEY=P>Password: <input TYPE=password NAME=pw SIZE=12 /></label> </p><% } else { %><p>You are log as: <%=request.getAttribute("Login")%></p> - <input type="hidden" NAME=username> - <input type="hidden" NAME=pw><% + <input type="hidden" NAME=username /> + <input type="hidden" NAME=pw /><% }%> - <input type="hidden" name="Orig_text" value="<%=request.getAttribute("OrigText")%>"/> - <input type="hidden" name="scmEditorUrl" value="<%=request.getAttribute("scmEditorUrl")%>"> - <input type="hidden" name="previewServletUrl" value="<%=request.getAttribute("previewServletUrl")%>"> + <input type="hidden" name="Orig_text" value=<%=request.getAttribute("OrigText")%>/> + <input type="hidden" name="scmEditorUrl" value="<%=request.getAttribute("scmEditorUrl")%>"/> + <input type="hidden" name="previewServletUrl" value="<%=request.getAttribute("previewServletUrl")%>"/> <input type="button" value="Save and Continue Editing" name="SaveandC" onclick="javascript:saver(this.form.Mytext, this.form.username, this.form.pw, this.form.Commit_message, this.form.Orig_text, this.form.scmEditorUrl);"/> <input type="submit" value="Save and Quit" name="Save"/> - <input type="button" value="Preview" name="Preview" onclick="javascript:preview(this.form.Mytext, this.form.previewServletUrl);"/> + <%if (request.getAttribute("format").equals("rst") == true){ + %><input type="button" value="Preview" name="Preview" onclick="javascript:preview(this.form.Mytext, this.form.previewServletUrl);"/><%}%> <input type="reset" value="Reset" name="Reset" /> <input type="hidden" value="<%=request.getAttribute("Project_url")%>" name="Project_url"> <input type="button" value="Exit" name="Cancel" onclick="javascript:cancelRedirectDelete(this.form.Orig_text, this.form.username, this.form.pw, this.form.Commit_message, this.form.Project_url, this.form.scmEditorUrl);"/> - </form></center> - <center><form action="/nuiton-rstedit/pictureUpload" enctype="multipart/form-data" method="post" id="form1" onsubmit="this.target = 'UploadTarget1'"> - - <iframe id="UploadTarget1" name="UploadTarget1" src="" style="width:0px;height:0px;border:0"></iframe> - - <p>Upload a picture: <input id="newPic" type="file" name="newPic" size="30"> - <input type="submit" value="Upload" name="upPic"/></p> - </form></center> + </form></center> <p align="right">©2004-2009 CodeLutin</p> </body> </html> Modified: trunk/src/main/webapp/Saver.js =================================================================== --- trunk/src/main/webapp/Saver.js 2009-12-18 10:25:03 UTC (rev 60) +++ trunk/src/main/webapp/Saver.js 2009-12-18 10:32:59 UTC (rev 61) @@ -48,7 +48,12 @@ { if (my_text.value != orig_text.value){ if (confirm("Do you really want to save?")){ - sendReq("POST", scmEditorUrl, my_text, login, pass, message, orig_text); + if (message.value == ""){ + alert("You must enter a Commit message!!!", ""); + } + else { + sendReq("POST", scmEditorUrl, my_text, login, pass, message, orig_text); + } } } else{ alert("File don't need to be save."); Modified: trunk/src/main/webapp/cancelRedirectDelete.js =================================================================== --- trunk/src/main/webapp/cancelRedirectDelete.js 2009-12-18 10:25:03 UTC (rev 60) +++ trunk/src/main/webapp/cancelRedirectDelete.js 2009-12-18 10:32:59 UTC (rev 61) @@ -1,9 +1,9 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. +/** + * @author geoffroy lorieux */ + function createRequestObjec() { var req; Modified: trunk/src/main/webapp/fileSearch.js =================================================================== --- trunk/src/main/webapp/fileSearch.js 2009-12-18 10:25:03 UTC (rev 60) +++ trunk/src/main/webapp/fileSearch.js 2009-12-18 10:32:59 UTC (rev 61) @@ -44,4 +44,4 @@ alert(scmPath.value); alert(scmEditorUrl.value); sendRequestToFileSearchServlet(scmPath, scmEditorUrl); -} \ No newline at end of file +}
participants (1)
-
glorieux@users.nuiton.org