Author: bbrossaud Date: 2010-06-04 15:37:29 +0200 (Fri, 04 Jun 2010) New Revision: 67 Url: http://chorem.org/repositories/revision/bow/67 Log: addition edition in javascript or not Modified: trunk/src/main/java/org/chorem/bow/BowProxy.java trunk/src/main/java/org/chorem/bow/ControllerServlet.java trunk/src/main/webapp/header.jsp trunk/src/main/webapp/home.jsp trunk/src/main/webapp/main.jsp trunk/src/main/webapp/search2.jsp Modified: trunk/src/main/java/org/chorem/bow/BowProxy.java =================================================================== --- trunk/src/main/java/org/chorem/bow/BowProxy.java 2010-06-03 16:03:39 UTC (rev 66) +++ trunk/src/main/java/org/chorem/bow/BowProxy.java 2010-06-04 13:37:29 UTC (rev 67) @@ -23,6 +23,7 @@ import org.nuiton.wikitty.WikittyProxy; import org.nuiton.wikitty.WikittyService; import org.nuiton.wikitty.WikittyServiceCached; +import org.nuiton.wikitty.WikittyServiceNotifier; import org.nuiton.wikitty.jdbc.WikittyServiceJDBC; /** @@ -51,6 +52,8 @@ protected BowProxy(BowConfig config) { WikittyService ws = new WikittyServiceJDBC(config.getFlatOptions()); + // fix me 04/06/2009 + ws = new WikittyServiceNotifier(ws); ws = new WikittyServiceCached(ws); setWikittyService(ws); } Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java =================================================================== --- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-06-03 16:03:39 UTC (rev 66) +++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-06-04 13:37:29 UTC (rev 67) @@ -400,19 +400,27 @@ */ protected void actionEditBookmark(HttpServletRequest request, HttpServletResponse response, User user) throws IOException, ServletException { - String tags = request.getParameter("tags"); - String name = request.getParameter("name"); String bookmarkId = request.getParameter("bookmarkId"); if (bookmarkId != null && !bookmarkId.isEmpty()) { WikittyProxy proxy = BowProxy.getInstance(); Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId); if (bookmark != null) { - BookmarkActions.updateBookmarkName(bookmark, name); - BookmarkActions.addTagsToBookmark(tags, bookmark); - proxy.store(bookmark); + request.setAttribute("link", bookmark.getLink()); + request.setAttribute("name", bookmark.getDescription()); + request.setAttribute("alias", bookmark.getAlias()); + request.setAttribute("tags", BookmarkActions.getBookmarkTagsString(bookmark)); + request.setAttribute("button", "Modify"); + request.setAttribute("action", "bow?action=modifyBookmark"); + request.setAttribute("bookmarkId", bookmarkId); } } - redirectToTheGoodPage(request, response); + String searchLine = request.getParameter("searchLine"); + if (searchLine == null) { + actionHome(request, user); + } else { + actionSearch(request, user); + } + request.getRequestDispatcher("main.jsp").forward(request, response); } /* @param request servlet request @@ -493,7 +501,7 @@ redirectToTheGoodPage(request, response); } - protected void actionModifyBookmark(HttpServletRequest request, HttpServletResponse response, User user) + protected void actionModifyBookmark(HttpServletRequest request, HttpServletResponse response, User user) throws IOException { String link = request.getParameter("url"); // url of the website String name = request.getParameter("name"); // website name Modified: trunk/src/main/webapp/header.jsp =================================================================== --- trunk/src/main/webapp/header.jsp 2010-06-03 16:03:39 UTC (rev 66) +++ trunk/src/main/webapp/header.jsp 2010-06-04 13:37:29 UTC (rev 67) @@ -11,15 +11,39 @@ <link rel="search" type="application/opensearchdescription+xml" title="bowPermanentSearchEngine" href="<%=url%>bow?action=permanentXml" /> <script type="text/javascript"> <!-- - function modify(name, alias, tags, url, action) { + function modify(name, alias, tags, link, action, id) { var form = document.getElementById("bookmarkForm"); - form.elements["url"].value = url; + form.elements["url"].value = link; form.elements["name"].value = name; form.elements["tags"].value = tags; form.elements["alias"].value = alias; form.elements["submit"].value = 'Modif'; form.action = action; + var del = null; + var count = 0; + for ((del = document.getElementById(id + count)); del != null; del = document.getElementById(id + count)) { + del.style.display = 'inline'; + ++count; + } + return false; } + + function modifyLast(name, alias, tags, link, action, id) { + var form = document.getElementById("bookmarkForm"); + form.elements["url"].value = link; + form.elements["name"].value = name; + form.elements["tags"].value = tags; + form.elements["alias"].value = alias; + form.elements["submit"].value = 'Modif'; + form.action = action; + var del = null; + var count = 0; + for ((del = document.getElementById(count + id)); del != null; del = document.getElementById(count + id)) { + del.style.display = 'inline'; + ++count; + } + return false; + } //--> </script> </head> \ No newline at end of file Modified: trunk/src/main/webapp/home.jsp =================================================================== --- trunk/src/main/webapp/home.jsp 2010-06-03 16:03:39 UTC (rev 66) +++ trunk/src/main/webapp/home.jsp 2010-06-04 13:37:29 UTC (rev 67) @@ -16,6 +16,33 @@ String temporaryToken = tokenActions.getTemporaryToken(); String permanentToken = tokenActions.getPermanentToken(); String url = (String) request.getAttribute("bowUrl"); + + String formLink = (String) request.getAttribute("link"); + String formName = (String) request.getAttribute("name"); + String formBookmarkId = (String) request.getAttribute("bookmarkId"); + String formTags = (String) request.getAttribute("tags"); + String formAlias = (String) request.getAttribute("alias"); + String formButton = (String) request.getAttribute("button"); + String formAction = (String) request.getAttribute("action"); + + if (formLink == null) { + formLink = "URL"; + } + if (formName == null) { + formName = "name"; + } + if (formTags == null) { + formTags = "tag1 tag2..."; + } + if (formAlias == null) { + formAlias = "alias"; + } + if (formButton == null) { + formButton = "Add"; + } + if (formAction == null) { + formAction = "bow?action=addUrl"; + } %> <body> <div id="table"> @@ -32,6 +59,8 @@ <% for (Bookmark bookmark : bookmarkList) { + String link = bookmark.getLink(); + link = link.replace("'", "\\'"); %> <table class="result"> <tr class="result"> @@ -44,7 +73,9 @@ </div> <div style="float: right"> - <input type="image" src="img/edit.png" title="Edit" onclick="modify('<%=bookmark.getDescription()%>', '<%=bookmark.getAlias()%>', '<%=BookmarkActions.getBookmarkTagsString(bookmark)%>', '<%=bookmark.getLink()%>', 'bow?action=modifyBookmark&bookmarkId=<%=bookmark.getWikittyId()%>')"/> + <a style="border:none;text-decoration: none" href="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>" onclick="return modify('<%=bookmark.getDescription()%>', '<%=bookmark.getAlias()%>', '<%=BookmarkActions.getBookmarkTagsString(bookmark)%>', '<%=link%>', 'bow?action=modifyBookmark&bookmarkId=<%=bookmark.getWikittyId()%>', '<%=bookmark.getWikittyId()%>');"> + <IMG style="border:none;" src="img/edit.png" title="Edit" ALT="Edit Bookmark" /> + </a> <a style="border:none;text-decoration: none" href="bow?action=removeBookmark&bookmarkId=<%=bookmark.getWikittyId()%>"> <IMG style="border:none;" SRC="img/remove.png" ALT="Remove bookmark" TITLE="Remove" /> </a> @@ -69,21 +100,29 @@ <br /> tags : <% - Set<String> tagList = bookmark.getTags(); - if (tagList != null && !tagList.isEmpty()) { - for (String tag : tagList) { + Set<String> tagList = bookmark.getTags(); + if (tagList != null && !tagList.isEmpty()) { + int count = 0; + for (String tag : tagList) { + if (formBookmarkId != null && formBookmarkId.equals(bookmark.getWikittyId())) { %> - <a id="delete" style="display:none;" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&deleteTag=<%=tag%>" > + <a id="<%=bookmark.getWikittyId() + count%>" style="text-decoration: none;" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&deleteTag=<%=tag%>" > <IMG style="border:none;" SRC="img/delete.png" ALT="Delete tag" TITLE="Delete" /> </a> + <%} else {%> + <a id="<%=bookmark.getWikittyId() + count%>" style="display:none; text-decoration: none;" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&deleteTag=<%=tag%>" > + <IMG style="border:none;" SRC="img/delete.png" ALT="Delete tag" TITLE="Delete" /> + </a> + <%}%> <a href="bow?action=search&searchLine=<%=tag%>" style="text-decoration: none"><%=tag%></a> <% - } + ++count; + } %> </div> </td> <% - } + } %> </tr> <br /> @@ -103,6 +142,8 @@ <h2 class="result">The last addition bookmarks</h2> <% for (Bookmark bookmark : lastBookmarks) { + String link = bookmark.getLink(); + link = link.replace("'", "\\'"); %> <table class="result"> <tr class="result"> @@ -115,7 +156,9 @@ </div> <div style="float: right"> - <input type="image" src="img/edit.png" title="Edit" onclick="modify('<%=bookmark.getDescription()%>', '<%=bookmark.getAlias()%>', '<%=BookmarkActions.getBookmarkTagsString(bookmark)%>', '<%=bookmark.getLink()%>', 'bow?action=modifyBookmark&bookmarkId=<%=bookmark.getWikittyId()%>')"/> + <a style="border:none;text-decoration: none" href="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>" onclick="return modifyLast('<%=bookmark.getDescription()%>', '<%=bookmark.getAlias()%>', '<%=BookmarkActions.getBookmarkTagsString(bookmark)%>', '<%=link%>', 'bow?action=modifyBookmark&bookmarkId=<%=bookmark.getWikittyId()%>', '<%=bookmark.getWikittyId()%>');"> + <IMG style="border:none;" src="img/edit.png" title="Edit" ALT="Edit Bookmark" /> + </a> <a style="border:none;text-decoration: none" href="bow?action=removeBookmark&bookmarkId=<%=bookmark.getWikittyId()%>"> <IMG style="border:none;" SRC="img/remove.png" ALT="Remove bookmark" TITLE="Remove" /> </a> @@ -142,14 +185,22 @@ <% Set<String> tagList = bookmark.getTags(); if (tagList != null && !tagList.isEmpty()) { + int count = 0; for (String tag : tagList) { + if (formBookmarkId != null && formBookmarkId.equals(bookmark.getWikittyId())) { %> - <a id="delete" style="display:none;" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&deleteTag=<%=tag%>" > + <a id="<%=count + bookmark.getWikittyId()%>" style="text-decoration: none;" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&deleteTag=<%=tag%>" > <IMG style="border:none;" SRC="img/delete.png" ALT="Delete tag" TITLE="Delete" /> </a> + <%} else {%> + <a id="<%=count + bookmark.getWikittyId()%>" style="display:none; text-decoration: none;" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&deleteTag=<%=tag%>" > + <IMG style="border:none;" SRC="img/delete.png" ALT="Delete tag" TITLE="Delete" /> + </a> + <%}%> <a href="bow?action=search&searchLine=<%=tag%>" style="text-decoration: none"><%=tag%></a> <% - } + ++count; + } %> </div> </td> @@ -179,15 +230,15 @@ </ul> </div> <div class="menu"> - <form id="bookmarkForm" method="POST" action="bow?action=addUrl"> + <form id="bookmarkForm" method="POST" action="<%=formAction%>"> URL<br /> - <input type="text" name="url" size="20" value="URL" /><br /> + <input type="text" name="url" size="20" value="<%=formLink%>" /><br /> Name<br /> - <input type="text" name="name" size="20" value="name" /><br /> + <input type="text" name="name" size="20" value="<%=formName%>" /><br /> Tags<br /> - <input type="text" name="tags" size="20" value="tag1 tag2..." /><br /> - Alias<br /><input type="text" name="alias" size="20" value="alias" /><br /> - <input type="submit" name="submit" value="add" /> + <input type="text" name="tags" size="20" value="<%=formTags%>" /><br /> + Alias<br /><input type="text" name="alias" size="20" value="<%=formAlias%>" /><br /> + <input type="submit" name="submit" value="<%=formButton%>" /> </form> </div> Modified: trunk/src/main/webapp/main.jsp =================================================================== --- trunk/src/main/webapp/main.jsp 2010-06-03 16:03:39 UTC (rev 66) +++ trunk/src/main/webapp/main.jsp 2010-06-04 13:37:29 UTC (rev 67) @@ -9,6 +9,14 @@ String searchLine = bookmarkActions.getSearchLine(); String url = (String) request.getAttribute("bowUrl"); String version = (String) request.getAttribute("version"); + + String formLink = (String) request.getAttribute("link"); + String formName = (String) request.getAttribute("name"); + String formBookmarkId = (String) request.getAttribute("bookmarkId"); + String formTags = (String) request.getAttribute("tags"); + String formAlias = (String) request.getAttribute("alias"); + String formButton = (String) request.getAttribute("button"); + String formAction = (String) request.getAttribute("action"); %> <html> @@ -22,6 +30,13 @@ <jsp:param name="bookmarkActions" value="<%=tokenActions%>" /> <jsp:param name="bookmarkActions" value="<%=bookmarkActions%>" /> <jsp:param name="bowUrl" value="<%=url%>"/> + <jsp:param name="link" value="<%=formLink%>"/> + <jsp:param name="name" value="<%=formName%>"/> + <jsp:param name="bookmarkId" value="<%=formBookmarkId%>"/> + <jsp:param name="tags" value="<%=formTags%>"/> + <jsp:param name="alias" value="<%=formAlias%>"/> + <jsp:param name="button" value="<%=formButton%>"/> + <jsp:param name="action" value="<%=formAction%>"/> </jsp:include> <% } else { %> @@ -29,6 +44,13 @@ <jsp:param name="bookmarkActions" value="<%=tokenActions%>" /> <jsp:param name="bookmarkActions" value="<%=bookmarkActions%>" /> <jsp:param name="bowUrl" value="<%=url%>"/> + <jsp:param name="link" value="<%=formLink%>"/> + <jsp:param name="name" value="<%=formName%>"/> + <jsp:param name="bookmarkId" value="<%=formBookmarkId%>"/> + <jsp:param name="tags" value="<%=formTags%>"/> + <jsp:param name="alias" value="<%=formAlias%>"/> + <jsp:param name="button" value="<%=formButton%>"/> + <jsp:param name="action" value="<%=formAction%>"/> </jsp:include> <% } %> Modified: trunk/src/main/webapp/search2.jsp =================================================================== --- trunk/src/main/webapp/search2.jsp 2010-06-03 16:03:39 UTC (rev 66) +++ trunk/src/main/webapp/search2.jsp 2010-06-04 13:37:29 UTC (rev 67) @@ -18,6 +18,33 @@ String searchLine = bookmarkActions.getSearchLine(); String fullText = bookmarkActions.getFullTextLine(); String url = (String) request.getAttribute("bowUrl"); + + String formLink = (String) request.getAttribute("link"); + String formName = (String) request.getAttribute("name"); + String formBookmarkId = (String) request.getAttribute("bookmarkId"); + String formTags = (String) request.getAttribute("tags"); + String formAlias = (String) request.getAttribute("alias"); + String formButton = (String) request.getAttribute("button"); + String formAction = (String) request.getAttribute("action"); + + if (formLink == null) { + formLink = "URL"; + } + if (formName == null) { + formName = "name"; + } + if (formTags == null) { + formTags = "tag1 tag2..."; + } + if (formAlias == null) { + formAlias = "alias"; + } + if (formButton == null) { + formButton = "Add"; + } + if (formAction == null) { + formAction = "bow?action=addUrl"; + } %> <body> @@ -55,6 +82,8 @@ if (!bookmarkList.isEmpty()) { SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); for (Bookmark bookmark : bookmarkList) { + String link = bookmark.getLink(); + link = link.replace("'", "\\'"); %> <table class="result"> <tr class="result"> @@ -67,7 +96,9 @@ </div> <div style="float: right"> - <input type="image" src="img/edit.png" title="Edit" onclick="modify('<%=bookmark.getDescription()%>', '<%=bookmark.getAlias()%>', '<%=BookmarkActions.getBookmarkTagsString(bookmark)%>', '<%=bookmark.getLink()%>', 'bow?action=modifyBookmark&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>&bookmarkId=<%=bookmark.getWikittyId()%>')"/> + <a style="border:none;text-decoration: none" href="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>" onclick="return modify('<%=bookmark.getDescription()%>', '<%=bookmark.getAlias()%>', '<%=BookmarkActions.getBookmarkTagsString(bookmark)%>', '<%=link%>', 'bow?action=modifyBookmark&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>&bookmarkId=<%=bookmark.getWikittyId()%>', '<%=bookmark.getWikittyId()%>');"> + <IMG style="border:none;" src="img/edit.png" title="Edit" ALT="Edit Bookmark" /> + </a> <a style="border:none;text-decoration: none" href="bow?action=removeBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>"> <IMG style="border:none;" SRC="img/remove.png" ALT="Remove bookmark" TITLE="Remove" /> </a> @@ -94,13 +125,23 @@ <% Set<String> tagList = bookmark.getTags(); if (tagList != null && !tagList.isEmpty()) { + int count = 0; for (String tag : tagList) { + if (formBookmarkId != null && formBookmarkId.equals(bookmark.getWikittyId())) { %> - <a id="delete" style="display:none;" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&deleteTag=<%=tag%>" > + <a id="<%=bookmark.getWikittyId() + count%>" style="text-decoration: none;" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&deleteTag=<%=tag%>&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>" > <IMG style="border:none;" SRC="img/delete.png" ALT="Delete tag" TITLE="Delete" /> </a> - <a href="bow?action=search&searchLine=<%=tag%>" style="text-decoration: none"><%=tag%></a> + <%} else {%> + <a id="<%=bookmark.getWikittyId() + count%>" style="display:none; text-decoration: none;" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&deleteTag=<%=tag%>&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>" > + <IMG style="border:none;" SRC="img/delete.png" ALT="Delete tag" TITLE="Delete" /> + </a> <%}%> + <a href="bow?action=search&searchLine=<%=tag%>" style="text-decoration: none;"><%=tag%></a> + <% + ++count; + } + %> </div> </td> <% @@ -129,16 +170,16 @@ </ul> </div> <div class="menu"> - <form id="bookmarkForm" method="POST" action="bow?action=addUrl&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>"> + <form id="bookmarkForm" method="POST" action="<%=formAction%>&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>"> URL<br /> - <input type="text" name="url" size="20" value="URL" /><br /> + <input type="text" name="url" size="20" value="<%=formLink%>" /><br /> Name<br /> - <input type="text" name="name" size="20" value="name" /><br /> + <input type="text" name="name" size="20" value="<%=formName%>" /><br /> Tags<br /> - <input type="text" name="tags" size="20" value="tag1 tag2..." /><br /> + <input type="text" name="tags" size="20" value="<%=formTags%>" /><br /> Alias<br /> - <input type="text" name="alias" size="20" value="alias" /><br /> - <input type="submit" name="submit" value="add" /> + <input type="text" name="alias" size="20" value="<%=formAlias%>" /><br /> + <input type="submit" name="submit" value="<%=formButton%>" /> </form> </div>