r26 - in trunk: . src/main/java/org/chorem/bow src/main/webapp src/main/webapp/WEB-INF
Author: bbrossaud Date: 2010-05-18 17:21:30 +0200 (Tue, 18 May 2010) New Revision: 26 Url: http://chorem.org/repositories/revision/bow/26 Log: permanent and temporary opensearch functionalities addition Added: trunk/src/main/java/org/chorem/bow/OpenSearchActions.java trunk/src/main/java/org/chorem/bow/OpenSearchXmlServlet.java trunk/src/main/java/org/chorem/bow/Suggestion.java trunk/src/main/java/org/chorem/bow/SuggestionsComparator.java trunk/src/main/webapp/openSearchResult.jsp trunk/src/main/webapp/permanentXml.jsp trunk/src/main/webapp/suggestions.jsp trunk/src/main/webapp/temporaryXml.jsp Modified: trunk/pom.xml trunk/src/main/java/org/chorem/bow/BookmarkActions.java trunk/src/main/java/org/chorem/bow/ControllerServlet.java trunk/src/main/java/org/chorem/bow/Model.java trunk/src/main/webapp/WEB-INF/web.xml trunk/src/main/webapp/generateToken.jsp trunk/src/main/webapp/home.jsp trunk/src/main/webapp/search.jsp Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-05-14 15:09:05 UTC (rev 25) +++ trunk/pom.xml 2010-05-18 15:21:30 UTC (rev 26) @@ -48,27 +48,20 @@ </dependency> <dependency> - <groupId>org.sharengo.wikengo</groupId> - <artifactId>core-wikitty-api</artifactId> + <groupId>org.nuiton.wikitty</groupId> + <artifactId>wikitty-api</artifactId> <version>${wikitty.version}</version> </dependency> <dependency> - <groupId>org.sharengo.wikengo</groupId> - <artifactId>core-wikitty-jdbc-impl</artifactId> + <groupId>org.nuiton.wikitty</groupId> + <artifactId>wikitty-jdbc-impl</artifactId> <version>${wikitty.version}</version> - - <exclusions> - <exclusion> - <groupId>org.mortbay.jetty</groupId> - <artifactId>jetty</artifactId> - </exclusion> - </exclusions> </dependency> <dependency> - <groupId>org.sharengo.wikengo</groupId> - <artifactId>core-wikitty-multistorage-impl</artifactId> + <groupId>org.nuiton.wikitty</groupId> + <artifactId>wikitty-multistorage-impl</artifactId> <version>${wikitty.version}</version> </dependency> @@ -119,7 +112,7 @@ <!--projectId>core-wikitty</projectId--> <!--platform>nuiton.org</platform--> <projectId>bow</projectId> - <wikitty.version>1.5-cl-SNAPSHOT</wikitty.version> + <wikitty.version>2.0-SNAPSHOT</wikitty.version> <!-- common versions used in sub-poms --> <junit.version>4.7</junit.version> <siteLocales>en</siteLocales> @@ -170,7 +163,7 @@ </xmiResources> <includes>**/*.objectmodel</includes> <resolver>org.nuiton.util.FasterCachedResourceResolver</resolver> - <templates>org.sharengo.wikitty.generator.WikittyMetaGenerator</templates> + <templates>org.nuiton.wikitty.generator.WikittyMetaGenerator</templates> <defaultPackage>com.jurismarches.vradi</defaultPackage> <extractedPackages>org.chorem.bow</extractedPackages> <generatedPackages>org.chorem.bow</generatedPackages> @@ -185,8 +178,8 @@ <dependencies> <dependency> - <groupId>org.sharengo.wikengo</groupId> - <artifactId>core-wikitty-generators</artifactId> + <groupId>org.nuiton.wikitty</groupId> + <artifactId>wikitty-generators</artifactId> <version>${wikitty.version}</version> </dependency> <!-- Meta model uml d'eclipse --> Modified: trunk/src/main/java/org/chorem/bow/BookmarkActions.java =================================================================== --- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-14 15:09:05 UTC (rev 25) +++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-18 15:21:30 UTC (rev 26) @@ -35,7 +35,7 @@ * @return null if all fields are not correctly filled * @return Bookmark the website bookmark */ - public Bookmark createBookmark(String url, String nameAndTags, User user) { + public static Bookmark createBookmark(String url, String nameAndTags, User user) { Bookmark bookmark = (Bookmark) new BookmarkImpl(); @@ -69,7 +69,7 @@ return bookmark; } - public void updateBookmark(Bookmark bookmark, String nameAndTags) { + public static void updateBookmark(Bookmark bookmark, String nameAndTags) { int nameIndex = nameAndTags.indexOf('|'); // get the index name of the website if (nameIndex > 0) { String name = nameAndTags.substring(0, nameIndex); // get the website name @@ -172,11 +172,16 @@ } } - public void addTags(String[] tags) { - for (int i = 0; i - < tags.length; i++) { - if (!tagsSearch.contains(tags[i])) { - tagsSearch.add(tags[i]); + public void addTags(String str) { + if (str != null) { + if (!str.isEmpty()) { + str = str.trim(); + String[] tags = str.split("\\s+"); + for (int i = 0; i < tags.length; i++) { + if (!tagsSearch.contains(tags[i])) { + tagsSearch.add(tags[i]); + } + } } } } Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java =================================================================== --- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-14 15:09:05 UTC (rev 25) +++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-18 15:21:30 UTC (rev 26) @@ -18,9 +18,9 @@ import javax.servlet.http.HttpSession; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.sharengo.wikitty.Criteria; -import org.sharengo.wikitty.WikittyProxy; -import org.sharengo.wikitty.search.Search; +import org.nuiton.wikitty.Criteria; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.search.Search; /** * @@ -30,8 +30,6 @@ private static final Log log = LogFactory.getLog(ControllerServlet.class); protected Model model = new Model(); - protected BookmarkActions bookmarkActions = new BookmarkActions(); - protected TokenActions tokenActions = new TokenActions(); protected String error = ""; @Override @@ -47,13 +45,15 @@ @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - try { + try { HttpSession session = request.getSession(true); User user = (User) session.getAttribute("user"); + String token = request.getParameter("token"); // token or not + if (token != null && !token.isEmpty()) { + user = checkToken(token, session); + } String action = request.getParameter("action"); response.setContentType("text/html"); - request.setAttribute("bookmarkActions", bookmarkActions); - request.setAttribute("tokenActions", tokenActions); if (action != null) { if (action.equals("register")) { if (log.isDebugEnabled()) { @@ -62,9 +62,7 @@ this.actionRegister(request, response, session); } else if (action.equals("registration")) { if (log.isDebugEnabled()) { - if (log.isDebugEnabled()) { - log.debug("Going to Register"); - } + log.debug("Going to Register"); } request.getRequestDispatcher("register.jsp").forward(request, response); } else if (action.equals("login")) { @@ -77,61 +75,95 @@ log.debug("Going to actionLogin"); } this.actionLogout(request, response, session); - } else if (action.equals("addUrl")) { + } else if (action.equals("addUrl") && user != null) { if (log.isDebugEnabled()) { log.debug("Going to actionAddUrl"); } - this.actionAddUrl(request, response, session); + this.actionAddUrl(request, response, user); + request.getRequestDispatcher("search.jsp").forward(request, response); + } else if (action.equals("search") && user != null) { if (log.isDebugEnabled()) { log.debug("Going to actionSearch"); } this.actionSearch(request, response, user); - } else if (action.equals("clickOnTag") && user != null) { - if (log.isDebugEnabled()) { - log.debug("Going to actionClickOnTag"); - } - this.actionClickOnTag(request, response, user); + request.getRequestDispatcher("search.jsp").forward(request, response); + } else if (action.equals("generateToken") && user != null) { if (log.isDebugEnabled()) { log.debug("Going to actionGenerateToken"); } - try { - this.actionGenerateToken(request, response, user); - } catch (NoSuchAlgorithmException ex) { - log.error("No Such Algorithm", ex); - request.getRequestDispatcher("error.jsp").forward(request, response); - } + this.actionGenerateToken(request, response, user, session); + request.getRequestDispatcher("search.jsp").forward(request, response); } else if (action.equals("deleteTag") && user != null) { if (log.isDebugEnabled()) { log.debug("Going to actionDeleteTag"); } this.actionDeleteTag(request, response, user); + request.getRequestDispatcher("search.jsp").forward(request, response); } else if (action.equals("removeBookmark") && user != null) { if (log.isDebugEnabled()) { log.debug("Going to actionRemoveBookmark"); } this.actionRemoveBookmark(request, response, user); + request.getRequestDispatcher("search.jsp").forward(request, response); } else if (action.equals("editBookmark") && user != null) { if (log.isDebugEnabled()) { log.debug("Going to actionEditBookmark"); } this.actionEditBookmark(request, response, user); + request.getRequestDispatcher("search.jsp").forward(request, response); } else if (action.equals("orderAsc") && user != null) { if (log.isDebugEnabled()) { log.debug("Going to actionOrderAsc"); } this.actionOrderAsc(request, response, user); + request.getRequestDispatcher("search.jsp").forward(request, response); + } else if (action.equals("orderAscOS") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionOrderAsc"); + } + this.actionOrderAsc(request, response, user); + request.getRequestDispatcher("openSearchResult.jsp").forward(request, response); } else if (action.equals("orderDesc") && user != null) { if (log.isDebugEnabled()) { log.debug("Going to actionOrderDesc"); } this.actionOrderDesc(request, response, user); + request.getRequestDispatcher("search.jsp").forward(request, response); + } else if (action.equals("orderDescOS") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionOrderDesc"); + } + this.actionOrderDesc(request, response, user); + request.getRequestDispatcher("openSearchResult.jsp").forward(request, response); } else if (action.equals("addClick") && user != null) { if (log.isDebugEnabled()) { log.debug("Going to actionAddClic"); } this.actionAddClick(request, response); + } else if (action.equals("temporaryXml")) { + if (log.isDebugEnabled()) { + log.debug("Going to temporaryXml.jsp"); + } + request.getRequestDispatcher("temporaryXml.jsp").forward(request, response); + } else if (action.equals("permanentXml")) { + if (log.isDebugEnabled()) { + log.debug("Going to permanentXml.jsp"); + } + request.getRequestDispatcher("permanentXml.jsp").forward(request, response); + } else if (action.equals("openSearchSuggestion") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionOpenSearchSuggestion"); + } + this.actionOpenSearchSuggestion(request, response, user); + request.getRequestDispatcher("suggestions.jsp").forward(request, response); + } else if (action.equals("openSearchResult") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionOpenSearchResult"); + } + this.actionOpenSearchResult(request, response, user, token); + request.getRequestDispatcher("openSearchResult.jsp").forward(request, response); } else { if (log.isDebugEnabled()) { log.debug("Going to home"); @@ -146,10 +178,40 @@ } request.setAttribute("errorMessage", error); } catch (Exception eee) { - request.getRequestDispatcher("error.jsp").forward(request, response); + //request.getRequestDispatcher("error.jsp").forward(request, response); + throw new ServletException("DO GET ERROR", eee); } } + protected void actionOpenSearchResult(HttpServletRequest request, HttpServletResponse response, User user, String token) + throws IOException, ServletException { + WikittyProxy proxy = model.getProxy(); + Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(). + addSortDescending(Bookmark.FQ_FIELD_CLICK); + List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); + createBookmarkActions(request, bookList); + request.setAttribute("token", token); + } + + protected void actionOpenSearchSuggestion(HttpServletRequest request, HttpServletResponse response, User user) + throws IOException, ServletException { + if (user != null) { + String search = request.getParameter("search"); + log.debug("search={" + search + "}"); + if (search != null) { + OpenSearchActions openSearchActions = new OpenSearchActions(); + WikittyProxy proxy = model.getProxy(); + Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(); + List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); + openSearchActions.setBookmarkList(bookList); + search = search.trim(); + String[] words = search.split("\\s+"); + openSearchActions.findSuggestions(words); + request.setAttribute("openSearchAction", openSearchActions); + } + } + } + protected void actionLogout(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws IOException, ServletException { session.invalidate(); @@ -189,18 +251,14 @@ eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(). addSortAscending(Bookmark.FQ_FIELD_DATE); bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); - } else if(type.equals("click")) { - Criteria criteria = Search.query(). + } else if (type.equals("click")) { + Criteria criteria = Search.query(). eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(). addSortAscending(Bookmark.FQ_FIELD_CLICK); bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); } - if (bookList != null) { - bookmarkActions.setBookmarks(bookList); - bookmarkActions.createTagsCloud(); - } + createBookmarkActions(request, bookList); } - request.getRequestDispatcher("search.jsp").forward(request, response); } protected void actionOrderDesc(HttpServletRequest request, HttpServletResponse response, User user) @@ -219,18 +277,14 @@ eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(). addSortDescending(Bookmark.FQ_FIELD_DATE); bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); - } else if(type.equals("click")) { - Criteria criteria = Search.query(). + } else if (type.equals("click")) { + Criteria criteria = Search.query(). eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(). addSortDescending(Bookmark.FQ_FIELD_CLICK); bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); } - if (bookList != null) { - bookmarkActions.setBookmarks(bookList); - bookmarkActions.createTagsCloud(); - } + createBookmarkActions(request, bookList); } - request.getRequestDispatcher("search.jsp").forward(request, response); } protected void actionEditBookmark(HttpServletRequest request, HttpServletResponse response, User user) @@ -242,18 +296,14 @@ WikittyProxy proxy = model.getProxy(); Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId); if (bookmark != null) { - bookmarkActions.updateBookmark(bookmark, nameAndTags); + BookmarkActions.updateBookmark(bookmark, nameAndTags); proxy.store(bookmark); Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(); List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); // select all bookmarks by user - if (bookList != null) { - bookmarkActions.setBookmarks(bookList); - bookmarkActions.createTagsCloud(); - } + createBookmarkActions(request, bookList); } } } - request.getRequestDispatcher("search.jsp").forward(request, response); } protected void actionRemoveBookmark(HttpServletRequest request, HttpServletResponse response, User user) @@ -265,19 +315,17 @@ Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(); List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); // select all bookmarks by user if (bookList != null) { - bookmarkActions.setBookmarks(bookList); - bookmarkActions.createTagsCloud(); + createBookmarkActions(request, bookList); } } - request.getRequestDispatcher("search.jsp").forward(request, response); } protected void actionDeleteTag(HttpServletRequest request, HttpServletResponse response, User user) throws IOException, ServletException { String bookmarkId = request.getParameter("bookmarkId"); - String tag = request.getParameter("tag"); + String tag = request.getParameter("deleteTag"); if (tag != null && bookmarkId != null) { - if (!tag.isEmpty() && !bookmarkId.isEmpty()) { + if (!bookmarkId.isEmpty()) { WikittyProxy proxy = model.getProxy(); Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId); if (bookmark != null) { @@ -285,14 +333,10 @@ proxy.store(bookmark); Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(); List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); // select all bookmarks by user - if (bookList != null) { - bookmarkActions.setBookmarks(bookList); - bookmarkActions.createTagsCloud(); - } + createBookmarkActions(request, bookList); } } } - request.getRequestDispatcher("search.jsp").forward(request, response); } @@ -300,7 +344,7 @@ * @param response servlet response * @throws ServletException if a servlet error occurs */ - protected void actionGenerateToken(HttpServletRequest request, HttpServletResponse response, User user) + protected void actionGenerateToken(HttpServletRequest request, HttpServletResponse response, User user, HttpSession session) throws IOException, ServletException, NoSuchAlgorithmException { WikittyProxy proxy = model.getProxy(); @@ -309,45 +353,38 @@ if (currentToken != null) { proxy.delete(currentToken.getWikittyId()); } - String token = tokenActions.generateToken(); // Generate an encoding MD5 token - criteria = Search.query().eq(Token.FQ_FIELD_TOKEN, token).criteria(); - if (proxy.findByCriteria(Token.class, criteria) == null) { // Check if the token already exists - TokenImpl newToken = new TokenImpl(); - newToken.setToken(token); - newToken.setEmail(user.getEmail()); - proxy.store((Token) newToken); // If the token doesn't exist, it is stored - tokenActions.setPermanentToken(token); - } else { - tokenActions.setPermanentToken(""); + TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions"); + if (tokenActions != null) { + String token = tokenActions.generateToken(); // Generate an encoding MD5 token + criteria = Search.query().eq(Token.FQ_FIELD_TOKEN, token).criteria(); + if (proxy.findByCriteria(Token.class, criteria) == null) { // Check if the token already exists + TokenImpl newToken = new TokenImpl(); + newToken.setToken(token); + newToken.setEmail(user.getEmail()); + proxy.store((Token) newToken); // If the token doesn't exist, it is stored + tokenActions.setPermanentToken(token); + } else { + tokenActions.setPermanentToken(""); + } } - request.getRequestDispatcher("search.jsp").forward(request, response); + session.setAttribute("tokenActions", tokenActions); + actionSearch(request, response, user); } /* @param request servlet request * @param response servlet response * @throws ServletException if a servlet error occurs */ - protected void actionAddUrl(HttpServletRequest request, HttpServletResponse response, HttpSession session) + protected void actionAddUrl(HttpServletRequest request, HttpServletResponse response, User user) throws IOException, ServletException { - String token = request.getParameter("token"); // token or not - if (token != null && !token.isEmpty()) { - User user = checkToken(token, session); - addUrl(request, user); - } - else { - User user = (User) session.getAttribute("user"); - if (user != null) { - addUrl(request, user); - actionSearch(request, response, user); - } - } - + addUrl(request, user); + actionSearch(request, response, user); } protected void addUrl(HttpServletRequest request, User user) { String url = request.getParameter("url"); // url of the website String nameAndTags = request.getParameter("nameAndTags"); // name and tags - Bookmark bookmark = bookmarkActions.createBookmark(url, nameAndTags, user); + Bookmark bookmark = BookmarkActions.createBookmark(url, nameAndTags, user); if (bookmark != null) { WikittyProxy proxy = model.getProxy(); proxy.store(bookmark); // store the bookmark if all is Ok @@ -357,7 +394,6 @@ } } - protected User checkToken(String token, HttpSession session) { if (checkTemporaryToken(token, session) == true) { User user = (User) session.getAttribute("user"); @@ -367,7 +403,6 @@ return user; } - /* @param token String which contains the MD5 encoding token * @return null the token doesn't exist * @return User the token owner @@ -387,63 +422,43 @@ } protected boolean checkTemporaryToken(String token, HttpSession session) { - String temporaryToken = (String) session.getAttribute("temporaryToken"); - if (temporaryToken != null) { - if (temporaryToken.equals(token)) { - return true; + TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions"); + if (tokenActions != null) { + String temporaryToken = tokenActions.getTemporaryToken(); + if (temporaryToken != null) { + if (temporaryToken.equals(token)) { + return true; + } } } return false; - } /* @param request servlet request * @param response servlet response * @throws ServletException if a servlet error occurs */ - protected void actionClickOnTag(HttpServletRequest request, HttpServletResponse response, User user) + protected void actionSearch(HttpServletRequest request, HttpServletResponse response, User user) throws IOException, ServletException { WikittyProxy proxy = model.getProxy(); - String tag = request.getParameter("tag"); - bookmarkActions.getTagsCloud().clear(); Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(); List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); // select all bookmarks by user - if (bookList != null) { - bookmarkActions.setBookmarks(bookList); - } - if (tag != null) { - if (!tag.isEmpty()) { - tag = tag.trim(); - bookmarkActions.addTag(tag); // if a new tag is selected, adding in tag list - } - } - bookmarkActions.createTagsCloud(); // create the tags cloud with the new informations - request.getRequestDispatcher("search.jsp").forward(request, response); + createBookmarkActions(request, bookList); } - /* @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet error occurs - */ - protected void actionSearch(HttpServletRequest request, HttpServletResponse response, User user) - throws IOException, ServletException { - WikittyProxy proxy = model.getProxy(); - String words = request.getParameter("words"); // retrieve informations taping in the search field - bookmarkActions.reset(); - Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(); - List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); // select all bookmarks by user + protected void createBookmarkActions(HttpServletRequest request, List<Bookmark> bookList) { + String words = request.getParameter("searchLine"); // retrieve informations taping in the search field + BookmarkActions bookmarkActions = new BookmarkActions(); if (bookList != null) { bookmarkActions.setBookmarks(bookList); } - if (words != null) { - if (!words.isEmpty()) { - words = words.trim(); - String[] tags = words.split("\\s+"); - bookmarkActions.addTags(tags); // add the new tags - } + bookmarkActions.addTags(words); // add the new tags + String tag = request.getParameter("addTag"); + if (tag != null && !tag.isEmpty()) { + bookmarkActions.addTag(tag); } bookmarkActions.createTagsCloud(); // create the tags cloud with the new informations - request.getRequestDispatcher("search.jsp").forward(request, response); + request.setAttribute("bookmarkActions", bookmarkActions); } /* @param request servlet request @@ -466,20 +481,9 @@ request.getRequestDispatcher("error.jsp").forward(request, response); } else { session.setAttribute("user", login); - Criteria criteria = Search.query().eq(User.FQ_FIELD_EMAIL, login.getEmail()).criteria(); - Token token = proxy.findByCriteria(Token.class, criteria); - if (token == null) { - token = new TokenImpl(); - String newToken = tokenActions.generateToken(); - token.setToken(newToken); - token.setEmail(login.getEmail()); - proxy.store(token); - } - tokenActions.setPermanentToken(token.getToken()); - String temporaryToken = tokenActions.generateToken(); - tokenActions.setTemporaryToken(temporaryToken); - session.setAttribute("temporaryToken", temporaryToken); - this.actionSearch(request, response, login); + initializeToken(session, login); + actionSearch(request, response, login); + request.getRequestDispatcher("search.jsp").forward(request, response); } } } @@ -495,28 +499,37 @@ User login = this.checkLogin(email, password); // check if the user exists if (login != null) { - WikittyProxy proxy = model.getProxy(); session.setAttribute("user", login); - Criteria criteria = Search.query().eq(User.FQ_FIELD_EMAIL, login.getEmail()).criteria(); - Token token = proxy.findByCriteria(Token.class, criteria); - if (token == null) { - token = new TokenImpl(); - String newToken = tokenActions.generateToken(); - token.setToken(newToken); - token.setEmail(login.getEmail()); - proxy.store(token); - } - tokenActions.setPermanentToken(token.getToken()); - String temporaryToken = tokenActions.generateToken(); - tokenActions.setTemporaryToken(temporaryToken); - session.setAttribute("temporaryToken", temporaryToken); - this.actionSearch(request, response, login); + initializeToken(session, login); + actionSearch(request, response, login); + request.getRequestDispatcher("search.jsp").forward(request, response); + } else { error = "Unknow email or incorrect password"; request.getRequestDispatcher("home.jsp").forward(request, response); } } + protected void initializeToken(HttpSession session, User login) + throws NoSuchAlgorithmException { + WikittyProxy proxy = model.getProxy(); + Criteria criteria = Search.query().eq(User.FQ_FIELD_EMAIL, login.getEmail()).criteria(); + Token token = proxy.findByCriteria(Token.class, criteria); + TokenActions tokenActions = new TokenActions(); + if (token == null) { + token = new TokenImpl(); + String newToken = tokenActions.generateToken(); + token.setToken(newToken); + token.setEmail(login.getEmail()); + proxy.store(token); + } + tokenActions.setPermanentToken(token.getToken()); + String temporaryToken = tokenActions.generateToken(); + tokenActions.setTemporaryToken(temporaryToken); + session.setAttribute("tokenActions", tokenActions); + } + + /* @param email String which contains the user name (email) * @param password String which contains the user password * @return null the user doesn't exist @@ -555,5 +568,4 @@ error = "Email and password must be correctly filled"; return true; } - } Modified: trunk/src/main/java/org/chorem/bow/Model.java =================================================================== --- trunk/src/main/java/org/chorem/bow/Model.java 2010-05-14 15:09:05 UTC (rev 25) +++ trunk/src/main/java/org/chorem/bow/Model.java 2010-05-18 15:21:30 UTC (rev 26) @@ -5,15 +5,15 @@ package org.chorem.bow; import java.util.Properties; -import org.sharengo.wikitty.WikittyExtensionStorage; -import org.sharengo.wikitty.WikittyProxy; -import org.sharengo.wikitty.WikittyService; -import org.sharengo.wikitty.WikittyStorage; -import org.sharengo.wikitty.jdbc.WikittyExtensionStorageJDBC; -import org.sharengo.wikitty.jdbc.WikittyStorageJDBC; -import org.sharengo.wikitty.multistorage.MultiStorageConfiguration; -import org.sharengo.wikitty.multistorage.MultiStorageConfiguration.BasicConfiguration; -import org.sharengo.wikitty.multistorage.WikittyServiceMultiStorage; +import org.nuiton.wikitty.WikittyExtensionStorage; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.WikittyService; +import org.nuiton.wikitty.WikittyStorage; +import org.nuiton.wikitty.jdbc.WikittyExtensionStorageJDBC; +import org.nuiton.wikitty.jdbc.WikittyStorageJDBC; +import org.nuiton.wikitty.multistorage.MultiStorageConfiguration; +import org.nuiton.wikitty.multistorage.MultiStorageConfiguration.BasicConfiguration; +import org.nuiton.wikitty.multistorage.WikittyServiceMultiStorage; /** * Added: trunk/src/main/java/org/chorem/bow/OpenSearchActions.java =================================================================== --- trunk/src/main/java/org/chorem/bow/OpenSearchActions.java (rev 0) +++ trunk/src/main/java/org/chorem/bow/OpenSearchActions.java 2010-05-18 15:21:30 UTC (rev 26) @@ -0,0 +1,149 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.chorem.bow; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.apache.commons.lang.StringUtils; + +/** + * + * @author bbrossaud + */ +public class OpenSearchActions { + + protected List<Bookmark> bookmarkList = new ArrayList<Bookmark>(); + protected List<Suggestion> suggestions = new ArrayList<Suggestion>(); + protected String[] search = null; + + public void findSuggestions(String[] words) { + search = words; + if (!bookmarkList.isEmpty()) { + int i; + for (i = 0; i < (words.length - 1); ++i) { + List<Bookmark> newList = new ArrayList<Bookmark>(bookmarkList); + for (Bookmark bookmark : newList) { + if (!bookmarkHasTag(bookmark, words[i])) { + bookmarkList.remove(bookmark); + } + } + } + fieldSuggestionList(words[i]); + } + } + + protected void fieldSuggestionList(String word) { + if (bookmarkList != null) { + Map<String, Integer> map = new HashMap<String, Integer>(); + for (Bookmark bookmark : bookmarkList) { + Set<String> tagList = bookmark.getTags(); + for (String tag : tagList) { + if (tag.indexOf(word) == 0) { + if (map.containsKey(tag)) { + Integer count = map.get(tag); + ++count; + map.put(tag, count); + } else { + map.put(tag, 1); + } + } + } + } + Set<String> keys = map.keySet(); + for (String key : keys) { + Suggestion newSuggestion = new Suggestion(); + newSuggestion.setName(key); + newSuggestion.setNb(map.get(key)); + suggestions.add(newSuggestion); + } + + Collections.sort(suggestions, new SuggestionsComparator()); + } + } + + protected boolean bookmarkHasTag(Bookmark bookmark, String tag) { + Set<String> tagList = bookmark.getTags(); + if (tagList.contains(tag)) { + return true; + } + return false; + } + + public void setBookmarkList(List<Bookmark> bookmarks) { + if (bookmarks != null) { + List<Bookmark> newList = new ArrayList(bookmarks); + bookmarkList = newList; + } + } + + public String getJsonResult() { + String str = "["; + + str += "\"" + StringUtils.join(search, ' ') + "\","; + str += getJsonSuggestions(); + str += ","; + str += getJsonDescription(); + str += "]"; + return str; + } + + public String getJsonSuggestions() { + String str = "["; + String srch = ""; + Iterator<Suggestion> it = suggestions.iterator(); + if (search.length > 1) { + srch = StringUtils.join(search, ' ', 0, (search.length - 1)); + srch += " "; + } + while (it.hasNext()) { + Suggestion su = it.next(); + str += "\"" + srch + su.getName() + "\""; + if (it.hasNext()) { + str += ","; + } + } + str += "]"; + return str; + } + + public String getJsonDescription() { + String str = "["; + Iterator<Suggestion> it = suggestions.iterator(); + while (it.hasNext()) { + Suggestion su = it.next(); + str += "\"" + su.getNb() + " results\""; + if (it.hasNext()) { + str += ","; + } + } + str += "]"; + return str; + } + + public void setSearch(String[] tab) { + search = tab; + } + + public void setSuggestionList(List<Suggestion> list) { + suggestions = list; + } + + public List<Bookmark> getBookmarkList() { + return bookmarkList; + } + + public String[] getSearch() { + return search; + } + + public List<Suggestion> getSuggestionList() { + return suggestions; + } +} Added: trunk/src/main/java/org/chorem/bow/OpenSearchXmlServlet.java =================================================================== --- trunk/src/main/java/org/chorem/bow/OpenSearchXmlServlet.java (rev 0) +++ trunk/src/main/java/org/chorem/bow/OpenSearchXmlServlet.java 2010-05-18 15:21:30 UTC (rev 26) @@ -0,0 +1,36 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package org.chorem.bow; + +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * + * @author bbrossaud + */ +public class OpenSearchXmlServlet extends HttpServlet { + + @Override + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + this.doPost(request, response); + } + + /* @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet error occurs + */ + @Override + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + request.getRequestDispatcher("xml.jsp").forward(request, response); + } + +} Added: trunk/src/main/java/org/chorem/bow/Suggestion.java =================================================================== --- trunk/src/main/java/org/chorem/bow/Suggestion.java (rev 0) +++ trunk/src/main/java/org/chorem/bow/Suggestion.java 2010-05-18 15:21:30 UTC (rev 26) @@ -0,0 +1,31 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package org.chorem.bow; + +/** + * + * @author bbrossaud + */ +public class Suggestion { + int nb = 0; + String name = ""; + + public void setNb(int value) { + nb = value; + } + + public void setName(String str) { + name = str; + } + + public int getNb() { + return nb; + } + + public String getName() { + return name; + } +} Added: trunk/src/main/java/org/chorem/bow/SuggestionsComparator.java =================================================================== --- trunk/src/main/java/org/chorem/bow/SuggestionsComparator.java (rev 0) +++ trunk/src/main/java/org/chorem/bow/SuggestionsComparator.java 2010-05-18 15:21:30 UTC (rev 26) @@ -0,0 +1,24 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package org.chorem.bow; + +import java.util.Comparator; + +/** + * + * @author bbrossaud + */ +public class SuggestionsComparator implements Comparator<Suggestion> { + + @Override + public int compare(Suggestion o1, Suggestion o2) { + if (o1.getNb() < o2.getNb()) + return 1; + if (o1.getNb() > o2.getNb()) + return -1; + return 0; + } +} Modified: trunk/src/main/webapp/WEB-INF/web.xml =================================================================== --- trunk/src/main/webapp/WEB-INF/web.xml 2010-05-14 15:09:05 UTC (rev 25) +++ trunk/src/main/webapp/WEB-INF/web.xml 2010-05-18 15:21:30 UTC (rev 26) @@ -1,19 +1,28 @@ <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:/java.sun.com/dtd/web-app_2_3.dtd"> -<!-- SERVLET --> + <!-- SERVLET --> <servlet> <servlet-class>org.chorem.bow.ControllerServlet</servlet-class> <servlet-name>Controller</servlet-name> </servlet> + <servlet> + <servlet-class>org.chorem.bow.OpenSearchXmlServlet</servlet-class> + <servlet-name>XML</servlet-name> + </servlet> -<!-- SERVLET MAPPING --> + <!-- SERVLET MAPPING --> <servlet-mapping> <servlet-name>Controller</servlet-name> <url-pattern>/bow</url-pattern> </servlet-mapping> + <servlet-mapping> + <servlet-name>XML</servlet-name> + <url-pattern>/xml</url-pattern> + </servlet-mapping> + </web-app> \ No newline at end of file Modified: trunk/src/main/webapp/generateToken.jsp =================================================================== --- trunk/src/main/webapp/generateToken.jsp 2010-05-14 15:09:05 UTC (rev 25) +++ trunk/src/main/webapp/generateToken.jsp 2010-05-18 15:21:30 UTC (rev 26) @@ -1,3 +1,4 @@ + <%@ page import="org.chorem.bow.TokenActions" %> <%TokenActions tokenActions = (TokenActions) request.getAttribute("tokenActions"); Modified: trunk/src/main/webapp/home.jsp =================================================================== --- trunk/src/main/webapp/home.jsp 2010-05-14 15:09:05 UTC (rev 25) +++ trunk/src/main/webapp/home.jsp 2010-05-18 15:21:30 UTC (rev 26) @@ -1,16 +1,22 @@ -<%String error = (String) request.getAttribute("errorMessage");%> +<% + String error = (String) request.getAttribute("errorMessage"); + String url = request.getRequestURL().toString(); + int index = url.indexOf("home.jsp"); + url = url.substring(0, index); +%> + <html> - <body> - <h1>Login</h1> - <form method="POST" action="bow?action=login"> - email <input type="text" name="email" size="20"><br /> - password <input type=password name="password" size="20"><br /> - <input type="submit" value="login"> - </form> - <%if (error != null) {%> - <font color="red"><%=error%></font> - <%}%> - <br/><a href="bow?action=registration">register</a> - </body> + <body> + <h1>Login</h1> + <form method="POST" action="bow?action=login"> + email <input type="text" name="email" size="20"><br /> + password <input type=password name="password" size="20"><br /> + <input type="submit" value="login"> + </form> + <%if (error != null) {%> + <font color="red"><%=error%></font> + <%}%> + <br/><a href="bow?action=registration">register</a> + </body> </html> \ No newline at end of file Added: trunk/src/main/webapp/openSearchResult.jsp =================================================================== --- trunk/src/main/webapp/openSearchResult.jsp (rev 0) +++ trunk/src/main/webapp/openSearchResult.jsp 2010-05-18 15:21:30 UTC (rev 26) @@ -0,0 +1,104 @@ + +<%@ page import="org.chorem.bow.Bookmark" %> +<%@ page import="org.chorem.bow.BookmarkActions" %> +<%@ page import="java.util.HashMap" %> +<%@ page import="java.text.SimpleDateFormat" %> +<%@ page import="java.util.Iterator" %> +<%@ page import="java.util.Map" %> +<%@ page import="java.util.Set" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="java.util.List" %> +<%@ page import="org.chorem.bow.TokenActions" %> + +<% + BookmarkActions bookmarkActions = (BookmarkActions) request.getAttribute("bookmarkActions"); + String searchLine = ""; + if (bookmarkActions != null) { + searchLine = bookmarkActions.getSearchLine(); + } + String url = request.getRequestURL().toString(); + int index = url.indexOf("openSearchResult.jsp"); + url = url.substring(0, index); +%> + +<html> + <body> + <h1>Result</h1> + + <% if (bookmarkActions != null) { + List<Bookmark> bookmarkList = bookmarkActions.getBookmarks(); + if (!bookmarkList.isEmpty()) { + %> + <br/><br/>Results:<br/> + <table border="1"> + <tr> + <th> + Date + <a style="text-decoration:none" href="bow?action=orderAscOS&type=date&searchLine=<%=searchLine%>" > + <IMG style="border:none" SRC="img/asc.png" ALT="order ASC" TITLE="Asc" /> + </a> + <a style="text-decoration:none" href="bow?action=orderDescOS&type=date&searchLine=<%=searchLine%>"> + <IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" /> + </a> + </th> + <th> + Name + <a style="text-decoration:none" href="bow?action=orderAscOS&type=name&searchLine=<%=searchLine%>"> + <IMG style="border:none" SRC="img/asc.png" ALT="order ASC" TITLE="Asc" /> + </a> + <a style="text-decoration:none" href="bow?action=orderDescOS&type=name&searchLine=<%=searchLine%>"> + <IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" /> + </a> + </th> + <th>Tags</th> + <th> + Click + <a style="text-decoration:none" href="bow?action=orderAscOS&type=click&searchLine=<%=searchLine%>"> + <IMG style="border:none" SRC="img/asc.png" ALT="order ASC" TITLE="Asc" /> + </a> + <a style="text-decoration:none" href="bow?action=orderDescOS&type=click&searchLine=<%=searchLine%>"> + <IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" /> + </a> + </th> + </tr> + <% + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); + for (Bookmark bookmark : bookmarkList) { + %> + <tr> + <td> + <%=sdf.format(bookmark.getDate())%> + </td> + <td> + <a href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a> + </td> + <td> + <% + Set<String> tagList = bookmark.getTags(); + if (tagList != null && !tagList.isEmpty()) { + for (String tag : tagList) { + %> + <%=tag%> + <% + } + %> + </td> + <% + } + %> + <td> + <%=bookmark.getClick()%> + </td> + <% + } + %> + </table> + <% + } else { + %> + <br/><br/>No Bookmarks found<br/><br/> + <% } + } + %> + </body> +</html> \ No newline at end of file Added: trunk/src/main/webapp/permanentXml.jsp =================================================================== --- trunk/src/main/webapp/permanentXml.jsp (rev 0) +++ trunk/src/main/webapp/permanentXml.jsp 2010-05-18 15:21:30 UTC (rev 26) @@ -0,0 +1,23 @@ +<%@ page import="org.chorem.bow.TokenActions" %> + +<% + TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions"); + String token = ""; + if (tokenActions != null) { + token = tokenActions.getPermanentToken(); + } + String url = request.getRequestURL().toString(); + int index = url.indexOf("permanentXml.jsp"); + url = url.substring(0, index); +%> + +<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" + xmlns:moz="http://www.mozilla.org/2006/browser/search/"> + <ShortName>bowTemporarySearchEngine</ShortName> + <Description>bookmarkSearch</Description> + <InputEncoding>inputEncoding</InputEncoding> + <Image width="16" height="16">data:image/x-icon;base64,imageData</Image> + <Url type="text/html" method="GET" template="<%=url%>bow?action=openSearchResult&token=<%=token%>&searchLine={searchTerms}" /> + <Url type="application/x-suggestions+json" method="GET" template="<%=url%>bow?action=openSearchSuggestion&token=<%=token%>&search={searchTerms}" /> + <moz:SearchForm><%=url%>bow</moz:SearchForm> +</OpenSearchDescription> \ No newline at end of file Modified: trunk/src/main/webapp/search.jsp =================================================================== --- trunk/src/main/webapp/search.jsp 2010-05-14 15:09:05 UTC (rev 25) +++ trunk/src/main/webapp/search.jsp 2010-05-18 15:21:30 UTC (rev 26) @@ -10,22 +10,30 @@ <%@ page import="java.util.List" %> <%@ page import="org.chorem.bow.TokenActions" %> - <% - TokenActions tokenActions = (TokenActions) request.getAttribute("tokenActions"); + TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions"); String temporaryToken = tokenActions.getTemporaryToken(); String permanentToken = tokenActions.getPermanentToken(); BookmarkActions bookmarkActions = (BookmarkActions) request.getAttribute("bookmarkActions"); + String searchLine = ""; + if (bookmarkActions != null) { + searchLine = bookmarkActions.getSearchLine(); + } + String url = request.getRequestURL().toString(); + int index = url.indexOf("search.jsp"); + url = url.substring(0, index); %> <html> + <link rel="search" type="application/opensearchdescription+xml" title="bowTemporarySearchEngine" href="<%=url%>bow?action=temporaryXml" /> + <link rel="search" type="application/opensearchdescription+xml" title="bowPermanentSearchEngine" href="<%=url%>bow?action=permanentXml" /> <body> <a href="bow?action=logout">Logout</a><br/> - <a href="javascript:var%20url=location.href;var%20nameAndTags=prompt('Entrez%20le%20nom%20du%20lien%20et%20la%20liste%20des%20tags%20sous%20la%20forme:%20name|tag1%20tag2%20tag3',%20document.title+'|');var%20link='http://localhost:8080/bow/bow?action=addUrl&token=<%=temporaryToken%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);">Temporary token</a> + <a href="javascript:var%20url=location.href;var%20nameAndTags=prompt('Entrez%20le%20nom%20du%20lien%20et%20la%20liste%20des%20tags%20sous%20la%20forme:%20name|tag1%20tag2%20tag3',%20document.title+'|');var%20link='<%=url%>bow?action=addUrl&token=<%=temporaryToken%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);void(0);">Temporary token</a> <br/> - <a href="javascript:var%20url=location.href;var%20nameAndTags=prompt('Entrez%20le%20nom%20du%20lien%20et%20la%20liste%20des%20tags%20sous%20la%20forme:%20name|tag1%20tag2%20tag3',%20document.title+'|');var%20link='http://localhost:8080/bow/bow?action=addUrl&token=<%=permanentToken%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);">Permanent token</a> + <a href="javascript:var%20url=location.href;var%20nameAndTags=prompt('Entrez%20le%20nom%20du%20lien%20et%20la%20liste%20des%20tags%20sous%20la%20forme:%20name|tag1%20tag2%20tag3',%20document.title+'|');var%20link='<%=url%>bow?action=addUrl&token=<%=permanentToken%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);void(0);">Current permanent token</a> <br/> - <a href="bow?action=generateToken">Generate Permanent Token</a><br/><br/> + <a href="bow?action=generateToken&searchLine=<%=searchLine%>">Regenerate Permanent Token</a><br/><br/> <h1>Search</h1> @@ -38,7 +46,7 @@ <br/><br/><a href="bow?action=generateToken">Generate Token</a><br/><br/> <form method="POST" action="bow?action=search"> - <input type="text" name="words" size="20" value="<%=bookmarkActions.getSearchLine()%>" /><br /> + <input type="text" name="searchLine" size="20" value="<%=searchLine%>" /><br /> <input type="submit" value="Find" /> </form> @@ -50,11 +58,10 @@ int font = bookmarkActions.getFont(value); %> - <FONT SIZE="<%=font%>" ><a href="bow?action=clickOnTag&tag=<%=tag%>"><%=tag%></a></FONT> + <FONT SIZE="<%=font%>" ><a href="bow?action=search&addTag=<%=tag%>&searchLine=<%=searchLine%>"><%=tag%></a></FONT> <% } - List<String> tagsSearch = bookmarkActions.getTagsSearch(); List<Bookmark> bookmarkList = bookmarkActions.getBookmarks(); if (!bookmarkList.isEmpty()) { %> @@ -64,19 +71,19 @@ <th>Remove</th> <th> Date - <a style="text-decoration:none" href="bow?action=orderAsc&type=date" > + <a style="text-decoration:none" href="bow?action=orderAsc&type=date&searchLine=<%=searchLine%>" > <IMG style="border:none" SRC="img/asc.png" ALT="order ASC" TITLE="Asc" /> </a> - <a style="text-decoration:none" href="bow?action=orderDesc&type=date"> + <a style="text-decoration:none" href="bow?action=orderDesc&type=date&searchLine=<%=searchLine%>"> <IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" /> </a> </th> <th> Name - <a style="text-decoration:none" href="bow?action=orderAsc&type=name"> + <a style="text-decoration:none" href="bow?action=orderAsc&type=name&searchLine=<%=searchLine%>"> <IMG style="border:none" SRC="img/asc.png" ALT="order ASC" TITLE="Asc" /> </a> - <a style="text-decoration:none" href="bow?action=orderDesc&type=name"> + <a style="text-decoration:none" href="bow?action=orderDesc&type=name&searchLine=<%=searchLine%>"> <IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" /> </a> </th> @@ -84,10 +91,10 @@ <th>Edit</th> <th> Click - <a style="text-decoration:none" href="bow?action=orderAsc&type=click"> + <a style="text-decoration:none" href="bow?action=orderAsc&type=click&searchLine=<%=searchLine%>"> <IMG style="border:none" SRC="img/asc.png" ALT="order ASC" TITLE="Asc" /> </a> - <a style="text-decoration:none" href="bow?action=orderDesc&type=click"> + <a style="text-decoration:none" href="bow?action=orderDesc&type=click&searchLine=<%=searchLine%>"> <IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" /> </a> </th> @@ -98,7 +105,7 @@ %> <tr> <td> - <a style="border:none;" href="bow?action=removeBookmark&bookmarkId=<%=bookmark.getWikittyId()%>"> + <a style="border:none;" href="bow?action=removeBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>"> <IMG style="border:none;" SRC="img/remove.png" ALT="Remove bookmark" TITLE="Remove" /> </a> </td> @@ -115,22 +122,20 @@ for (String tag : tagList) { %> <%=tag%> - <a style="text-decoration:none" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&tag=<%=tag%>"> + <a style="text-decoration:none" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&deleteTag=<%=tag%>&searchLine=<%=searchLine%>"> <IMG style="border:none" SRC="img/delete.png" ALT="Delete tag" TITLE="Delete" /> </a> <% - } + } + } %> </td> <td> - <form style="display: inline" method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>"> + <form style="display: inline" method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>"> <input type="text" name="nameAndTags" size="50" value="<%=bookmark.getDescription()%>|tag1 tag2 tag3" /> <input type="image" src="img/edit.png" title="Edit"/> </form> </td> - <% - } - %> <td> <%=bookmark.getClick()%> </td> Added: trunk/src/main/webapp/suggestions.jsp =================================================================== --- trunk/src/main/webapp/suggestions.jsp (rev 0) +++ trunk/src/main/webapp/suggestions.jsp 2010-05-18 15:21:30 UTC (rev 26) @@ -0,0 +1,21 @@ + +<%@page import="org.chorem.bow.OpenSearchActions" %> +<%@page import="org.chorem.bow.Suggestion" %> +<%@page import="java.util.List" %> +<%@page import="java.util.Iterator" %> + + +<% + OpenSearchActions osa = (OpenSearchActions) request.getAttribute("openSearchAction"); + if (osa != null) { + String[] word = osa.getSearch(); + if (word != null) { + List<Suggestion> suggestions = osa.getSuggestionList(); + if (suggestions != null) { +%> +<%=osa.getJsonResult()%> +<% + } + } + } +%> \ No newline at end of file Added: trunk/src/main/webapp/temporaryXml.jsp =================================================================== --- trunk/src/main/webapp/temporaryXml.jsp (rev 0) +++ trunk/src/main/webapp/temporaryXml.jsp 2010-05-18 15:21:30 UTC (rev 26) @@ -0,0 +1,23 @@ +<%@ page import="org.chorem.bow.TokenActions" %> + +<% + TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions"); + String token = ""; + if (tokenActions != null) { + token = tokenActions.getTemporaryToken(); + } + String url = request.getRequestURL().toString(); + int index = url.indexOf("temporaryXml.jsp"); + url = url.substring(0, index); +%> + +<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" + xmlns:moz="http://www.mozilla.org/2006/browser/search/"> + <ShortName>bowTemporarySearchEngine</ShortName> + <Description>bookmarkSearch</Description> + <InputEncoding>inputEncoding</InputEncoding> + <Image width="16" height="16">data:image/x-icon;base64,imageData</Image> + <Url type="text/html" method="GET" template="<%=url%>bow?action=openSearchResult&token=<%=token%>&searchLine={searchTerms}" /> + <Url type="application/x-suggestions+json" method="GET" template="<%=url%>bow?action=openSearchSuggestion&token=<%=token%>&search={searchTerms}" /> + <moz:SearchForm><%=url%>bow</moz:SearchForm> +</OpenSearchDescription> \ No newline at end of file
participants (1)
-
bbrossaudï¼ users.chorem.org