Author: kcardineaud Date: 2011-07-28 14:38:56 +0200 (Thu, 28 Jul 2011) New Revision: 190 Url: http://nuiton.org/repositories/revision/scmwebeditor/190 Log: Add a verification for rst on commit Modified: trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java trunk/src/main/resources/struts.xml trunk/src/main/webapp/WEB-INF/content/modificationViewer.jsp trunk/src/main/webapp/WEB-INF/content/save.jsp trunk/src/main/webapp/css/main.css Modified: trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java =================================================================== --- trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java 2011-07-27 12:55:22 UTC (rev 189) +++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java 2011-07-28 12:38:56 UTC (rev 190) @@ -12,6 +12,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts2.interceptor.ServletRequestAware; +import org.nuiton.jrst.JRST; import org.nuiton.scmwebeditor.ScmWebEditorBaseAction; import org.nuiton.scmwebeditor.SvnSession; import org.tmatesoft.svn.core.SVNAuthenticationException; @@ -39,6 +40,7 @@ protected String pw; protected String address; protected String lastText; + protected String fileType; protected HttpServletRequest request; @@ -55,6 +57,14 @@ return newText; } + public String getFileType() { + return fileType; + } + + public void setFileType(String fileType) { + this.fileType = fileType; + } + public void setNewText(String newText) { this.newText = newText; } @@ -99,9 +109,34 @@ this.lastText = lastText; } + protected boolean testRstParsing(String newText) { + try { + if(log.isDebugEnabled()) { + log.debug("RST generate success"); + } + return true; + } catch (Exception e) { + if(log.isErrorEnabled()) { + log.error("RST generate fail",e); + } + return false; + } + + + } + + public String execute() { + if(fileType.equals("rst")) { + if(!testRstParsing(newText)) { + return "errorRst"; + } + } + + + HttpSession httpSession = request.getSession(true); SvnSession svnSess = getSvnSession(httpSession); Modified: trunk/src/main/resources/struts.xml =================================================================== --- trunk/src/main/resources/struts.xml 2011-07-27 12:55:22 UTC (rev 189) +++ trunk/src/main/resources/struts.xml 2011-07-28 12:38:56 UTC (rev 190) @@ -21,6 +21,7 @@ <result name="login" >/WEB-INF/content/modificationViewer.jsp</result> <result name="error">/WEB-INF/content/badFileRedirect.jsp</result> <result name="errorPath">/WEB-INF/content/badFileRedirect.jsp</result> + <result name="errorRst">/WEB-INF/content/badFileRedirect.jsp</result> </action> <action name="save" class="org.nuiton.scmwebeditor.actions.SaveAction" method="save"> Modified: trunk/src/main/webapp/WEB-INF/content/modificationViewer.jsp =================================================================== --- trunk/src/main/webapp/WEB-INF/content/modificationViewer.jsp 2011-07-27 12:55:22 UTC (rev 189) +++ trunk/src/main/webapp/WEB-INF/content/modificationViewer.jsp 2011-07-28 12:38:56 UTC (rev 190) @@ -55,14 +55,21 @@ <h2><s:text name="scm.welcome"/></h2> <% String typeEditor="null"; - if (request.getAttribute("format")!=null && request.getAttribute("format").equals("rst")){ + if (request.getAttribute("format")!=null && request.getAttribute("format").equals("rst")) { %> - <h4><s:text name="scm.info.ProblemWithRst"/> <a href="http://docutils.sourceforge.net/rst.html"><s:text name="scm.info.rstWebsite"/></a>.</h4> - <% } %> + <h4><s:text name="scm.info.ProblemWithRst"/> <a href="http://docutils.sourceforge.net/rst.html"><s:text name="scm.info.rstWebsite"/></a>.</h4> + <% } %> </center> <form method="post" action=commit.action id="editForm"> + <% + if (request.getAttribute("format")!=null && request.getAttribute("format").equals("rst")){ + %> + <input type="hidden" name="fileType" value="rst" /> + <% } else { %> + <input type="hidden" name="fileType" value="other" /> + <% } %> Modified: trunk/src/main/webapp/WEB-INF/content/save.jsp =================================================================== --- trunk/src/main/webapp/WEB-INF/content/save.jsp 2011-07-27 12:55:22 UTC (rev 189) +++ trunk/src/main/webapp/WEB-INF/content/save.jsp 2011-07-28 12:38:56 UTC (rev 190) @@ -9,6 +9,9 @@ <s:elseif test="result=='error'" > <h4> Can't save modification </h4> </s:elseif> + <s:elseif test="result=='errorPath'" > + <h4> Can't save modification, RST is not valid</h4> + </s:elseif> <s:elseif test="result=='uselessSave'" > <h4> It's useless to save the file, file is not modify</h4> </s:elseif> Modified: trunk/src/main/webapp/css/main.css =================================================================== --- trunk/src/main/webapp/css/main.css 2011-07-27 12:55:22 UTC (rev 189) +++ trunk/src/main/webapp/css/main.css 2011-07-28 12:38:56 UTC (rev 190) @@ -6,6 +6,11 @@ margin:auto; } + +img { + border:none; + } + .wwlbl , .wwctrl { display:inline; }