Bow-commits
Threads by month
- ----- 2026 -----
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
May 2010
- 1 participants
- 41 discussions
r47 - in trunk: . src/main/java/org/chorem/bow src/main/webapp
by bbrossaud@users.chorem.org May 31, 2010
by bbrossaud@users.chorem.org May 31, 2010
May 31, 2010
Author: bbrossaud
Date: 2010-05-31 18:04:07 +0200 (Mon, 31 May 2010)
New Revision: 47
Url: http://chorem.org/repositories/revision/bow/47
Log:
fulltext research seems to work
Modified:
trunk/TODO.txt
trunk/src/main/java/org/chorem/bow/BookmarkActions.java
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
trunk/src/main/webapp/home.jsp
trunk/src/main/webapp/search.jsp
Modified: trunk/TODO.txt
===================================================================
--- trunk/TODO.txt 2010-05-31 13:58:55 UTC (rev 46)
+++ trunk/TODO.txt 2010-05-31 16:04:07 UTC (rev 47)
@@ -27,3 +27,5 @@
===> dans class user = String SearchEngine;
===> openSearch ==> proposer des url
+
+===> facetisations
Modified: trunk/src/main/java/org/chorem/bow/BookmarkActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-31 13:58:55 UTC (rev 46)
+++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-31 16:04:07 UTC (rev 47)
@@ -22,6 +22,7 @@
*/
public class BookmarkActions {
+ protected String fullTextLine = "";
protected List<Bookmark> bookmarks = new ArrayList<Bookmark>(); // bookmarks which contain the search tags
protected List<Bookmark> lastBookmarks = new ArrayList<Bookmark>();
protected Map<String, Integer> tagCloud = new HashMap<String, Integer>(); // associate a tag with its frequency
@@ -228,7 +229,29 @@
return "";
}
- public void createTagsCloud() {
+ public void fullText(String line) {
+ fullTextLine = line;
+ String[] fullText = line.split("\\s+");
+ List<Bookmark> save = new ArrayList<Bookmark>(bookmarks);
+ for (Bookmark bookmark : save) {
+ boolean delete = true;
+ Set<String> tags = bookmark.getTags();
+ String name = bookmark.getDescription();
+ for (String word : fullText) {
+ if (tags != null && tags.contains(word)) {
+ delete = false;
+ }
+ if (name.contains(word)) {
+ delete = false;
+ }
+ }
+ if (delete == true) {
+ bookmarks.remove(bookmark);
+ }
+ }
+ }
+
+ public void createTagCloud() {
tagCloud.clear();
deleteBookmarkBySearch();
createTagClougByBookmarks();
@@ -389,4 +412,8 @@
public int getTmax() {
return tmax;
}
+
+ public String getFullTextLine() {
+ return fullTextLine;
+ }
}
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-31 13:58:55 UTC (rev 46)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-31 16:04:07 UTC (rev 47)
@@ -207,6 +207,12 @@
log.debug("Going to actionOpenSearchResult");
}
this.actionOpenSearchResult(request, response, user, token);
+ } else if (action.equals("fullText") && user != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Going to actionFullText");
+ }
+ this.actionFullText(request, user);
+ request.getRequestDispatcher("search.jsp").forward(request, response);
} else {
if (user != null) {
request.getRequestDispatcher("error.jsp").forward(request, response);
@@ -361,8 +367,12 @@
}
}
String searchLine = request.getParameter("searchLine");
+ String fullText = request.getParameter("fullTextLine");
+ if (fullText == null) {
+ fullText = "";
+ }
if (searchLine != null) {
- response.sendRedirect("bow?action=search&searchLine=" + searchLine);
+ response.sendRedirect("bow?action=search&searchLine=" + searchLine + "&fullTextLine=" + fullText);
} else {
response.sendRedirect("bow?action=home");
}
@@ -379,8 +389,12 @@
}
}
String searchLine = request.getParameter("searchLine");
+ String fullText = request.getParameter("fullTextLine");
+ if (fullText == null) {
+ fullText = "";
+ }
if (searchLine != null) {
- response.sendRedirect("bow?action=search&searchLine=" + searchLine);
+ response.sendRedirect("bow?action=search&searchLine=" + searchLine + "&fullTextLine=" + fullText);
} else {
response.sendRedirect("bow?action=home");
}
@@ -401,8 +415,12 @@
}
}
String searchLine = request.getParameter("searchLine");
+ String fullText = request.getParameter("fullTextLine");
+ if (fullText == null) {
+ fullText = "";
+ }
if (searchLine != null) {
- response.sendRedirect("bow?action=search&searchLine=" + searchLine);
+ response.sendRedirect("bow?action=search&searchLine=" + searchLine + "&fullTextLine=" + fullText);
} else {
response.sendRedirect("bow?action=home");
}
@@ -436,7 +454,16 @@
tokenActions.setPermanentToken("");
}
}
- response.sendRedirect("bow?action=home");
+ String searchLine = request.getParameter("searchLine");
+ String fullText = request.getParameter("fullTextLine");
+ if (fullText == null) {
+ fullText = "";
+ }
+ if (searchLine != null) {
+ response.sendRedirect("bow?action=search&searchLine=" + searchLine + "&fullTextLine=" + fullText);
+ } else {
+ response.sendRedirect("bow?action=home");
+ }
}
/* @param request servlet request
@@ -533,17 +560,25 @@
}
protected BookmarkActions createBookmarkActions(HttpServletRequest request, List<Bookmark> bookList) {
- String words = request.getParameter("searchLine"); // retrieve informations taping in the search field
+ String fullText = request.getParameter("fullTextLine");
+ String searchLine = request.getParameter("searchLine"); // retrieve informations taping in the search field
BookmarkActions bookmarkActions = new BookmarkActions();
if (bookList != null) {
bookmarkActions.setBookmarks(bookList);
}
- bookmarkActions.addTags(words); // add the new tags
- String tag = request.getParameter("addTag");
- if (tag != null && !tag.isEmpty()) {
- bookmarkActions.addTag(tag);
+ if (fullText != null && !fullText.isEmpty()) {
+ log.debug("toto");
+ bookmarkActions.fullText(fullText);
+ bookmarkActions.createTagClougByBookmarks();
+ bookmarkActions.defineTValues();
+ } else {
+ bookmarkActions.addTags(searchLine); // add the new tags
+ String tag = request.getParameter("addTag");
+ if (tag != null && !tag.isEmpty()) {
+ bookmarkActions.addTag(tag);
+ }
+ bookmarkActions.createTagCloud(); // create the tags cloud with the new informations
}
- bookmarkActions.createTagsCloud(); // create the tags cloud with the new informations
return bookmarkActions;
}
@@ -702,7 +737,12 @@
}
}
}
- response.sendRedirect("bow?action=home");
+ String searchLine = request.getParameter("searchLine");
+ if (searchLine != null) {
+ response.sendRedirect("bow?action=search&searchLine=" + searchLine);
+ } else {
+ response.sendRedirect("bow?action=home");
+ }
}
protected void parseHtmlToBookmarks(NodeList list, User user, List<Bookmark> bookmarks, List<String> tagList)
@@ -782,4 +822,13 @@
response.sendRedirect("bow?action=home");
}
}
+
+ protected void actionFullText(HttpServletRequest request, User user) {
+ 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();
+ BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
+ log.debug(bookmarkActions.getBookmarks().size());
+ request.setAttribute("bookmarkActions", bookmarkActions);
+ }
}
Modified: trunk/src/main/webapp/home.jsp
===================================================================
--- trunk/src/main/webapp/home.jsp 2010-05-31 13:58:55 UTC (rev 46)
+++ trunk/src/main/webapp/home.jsp 2010-05-31 16:04:07 UTC (rev 47)
@@ -245,7 +245,14 @@
</div>
</div>
<div class="menu">
- <form method="post" action="bow?action=importBookmarks" enctype="multipart/form-data">
+ <form method="POST" action="bow?action=fullText" style="text-align: center;">
+ Full text research
+ <input style="float: left" type="text" name="fullTextLine" size="15" value="<%=bookmarkActions.getFullTextLine()%>"/>
+ <input style="float: left;" type="submit" value="Find" />
+ </form>
+ </div>
+ <div class="menu">
+ <form method="POST" action="bow?action=importBookmarks" enctype="multipart/form-data">
Import Bookmarks
<input type="file" name="upfile" />
<input type="submit" value="Import"/>
Modified: trunk/src/main/webapp/search.jsp
===================================================================
--- trunk/src/main/webapp/search.jsp 2010-05-31 13:58:55 UTC (rev 46)
+++ trunk/src/main/webapp/search.jsp 2010-05-31 16:04:07 UTC (rev 47)
@@ -17,6 +17,7 @@
String temporaryToken = tokenActions.getTemporaryToken();
String permanentToken = tokenActions.getPermanentToken();
String searchLine = bookmarkActions.getSearchLine();
+ String fullText = bookmarkActions.getFullTextLine();
String url = (String) request.getAttribute("bowUrl");
String version = (String) request.getAttribute("version");
%>
@@ -41,29 +42,29 @@
<th class="result remove">Remove</th>
<th class="result date">
Date
- <a style="text-decoration:none" href="bow?action=orderAsc&type=date&searchLine=<%=searchLine%>" >
+ <a style="text-decoration:none" href="bow?action=orderAsc&type=date&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>" >
<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&searchLine=<%=searchLine%>">
+ <a style="text-decoration:none" href="bow?action=orderDesc&type=date&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>">
<IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" />
</a>
</th>
<th class="result name">
Name
- <a style="text-decoration:none" href="bow?action=orderAsc&type=name&searchLine=<%=searchLine%>">
+ <a style="text-decoration:none" href="bow?action=orderAsc&type=name&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>">
<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&searchLine=<%=searchLine%>">
+ <a style="text-decoration:none" href="bow?action=orderDesc&type=name&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>">
<IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" />
</a>
</th>
<th class ="result tags">Tags</th>
<th class=" result click">
Click
- <a style="text-decoration:none" href="bow?action=orderAsc&type=click&searchLine=<%=searchLine%>">
+ <a style="text-decoration:none" href="bow?action=orderAsc&type=click&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>">
<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&searchLine=<%=searchLine%>">
+ <a style="text-decoration:none" href="bow?action=orderDesc&type=click&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>">
<IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" />
</a>
</th>
@@ -74,7 +75,7 @@
%>
<tr class="result">
<td class="result">
- <a style="border:none;" href="bow?action=removeBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>">
+ <a style="border: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>
</td>
@@ -89,11 +90,11 @@
%>
<td class="result">
<a title ="<%=alias%>" href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
- <form method="POST" action="bow?action=addAlias&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>" style="display: inline">
+ <form method="POST" action="bow?action=addAlias&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>" style="display: inline">
<input type="text" name="alias" size="10" value="<%=bookmark.getAlias()%>" />
<input style="display: inline;" type="submit" value="Add alias" />
</form>
- <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>">
+ <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>">
<input type="text" name="name" size="35" value="<%=bookmark.getDescription()%>" />
<input type="image" src="img/edit.png" title="Edit"/>
</form>
@@ -105,7 +106,7 @@
for (String tag : tagList) {
%>
<div style="display: inline">
- <a style="text-decoration:none" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&deleteTag=<%=tag%>&searchLine=<%=searchLine%>">
+ <a 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>
<%=tag%>
@@ -114,7 +115,7 @@
}
}
%>
- <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>">
+ <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>">
<input type="text" name="tags" size="35" value="<%=BookmarkActions.getBookmarkTagsString(bookmark)%>" />
<input type="image" src="img/edit.png" title="Edit"/>
</form>
@@ -142,10 +143,11 @@
<li><a href="bow?action=home">Home</a></li>
<li><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></li>
<li><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></li>
+ <li><a href="bow?action=generateToken&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>">Regenerate permanent token</a></li>
</ul>
</div>
<div class="menu">
- <form method="POST" action="bow?action=addUrl&searchLine=<%=searchLine%>">
+ <form method="POST" action="bow?action=addUrl&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>">
URL<br />
<input type="text" name="url" size="20" value="URL" /><br />
Name<br />
@@ -175,6 +177,22 @@
<input style="float: left" type="submit" value="Find" />
</form>
</div>
+ <div class="menu">
+ <form method="POST" action="bow?action=fullText" style="text-align: center;">
+ Full text research
+ <input style="float: left" type="text" name="fullTextLine" size="15" value="<%=bookmarkActions.getFullTextLine()%>" />
+ <input style="float: left;" type="submit" value="Find" />
+ </form>
+ </div>
+ <div class="menu">
+ <form method="post" action="bow?action=importBookmarks&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>" enctype="multipart/form-data">
+ Import Bookmarks
+ <input type="file" name="upfile" />
+ <input type="submit" value="Import"/>
+ </form>
+ <br />
+ <a href="bow?action=exportBookmarks&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>">Export bookmarks</a>
+ </div>
</div>
</div>
<div class="Index" id="footer">
1
0
Author: bbrossaud
Date: 2010-05-31 15:58:55 +0200 (Mon, 31 May 2010)
New Revision: 46
Url: http://chorem.org/repositories/revision/bow/46
Log:
remove bugs on opensearch
Modified:
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-31 13:54:19 UTC (rev 45)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-31 13:58:55 UTC (rev 46)
@@ -207,7 +207,6 @@
log.debug("Going to actionOpenSearchResult");
}
this.actionOpenSearchResult(request, response, user, token);
- request.getRequestDispatcher("openSearchResult.jsp").forward(request, response);
} else {
if (user != null) {
request.getRequestDispatcher("error.jsp").forward(request, response);
1
0
Author: bbrossaud
Date: 2010-05-31 15:54:19 +0200 (Mon, 31 May 2010)
New Revision: 45
Url: http://chorem.org/repositories/revision/bow/45
Log:
the opensearch now suggest the url if there are less than 5 bookmarks
Modified:
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
trunk/src/main/java/org/chorem/bow/OpenSearchActions.java
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-31 10:21:08 UTC (rev 44)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-31 13:54:19 UTC (rev 45)
@@ -12,7 +12,6 @@
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletException;
@@ -182,7 +181,6 @@
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");
@@ -228,13 +226,19 @@
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();
- BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
- request.setAttribute("bookmarkActions", bookmarkActions);
- request.setAttribute("token", token);
+ String searchLine = request.getParameter("searchLine");
+ if (searchLine != null && searchLine.matches("^http://[^ ]*") && !searchLine.contains(" ")) {
+ response.sendRedirect(searchLine);
+ } else {
+ 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();
+ BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
+ request.setAttribute("bookmarkActions", bookmarkActions);
+ request.setAttribute("token", token);
+ request.getRequestDispatcher("openSearchResult.jsp").forward(request, response);
+ }
}
protected void actionOpenSearchSuggestion(HttpServletRequest request, HttpServletResponse response, User user)
@@ -244,16 +248,23 @@
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);
String[] words = search.split("\\s+");
List<String> searchLine = new ArrayList<String>(Arrays.asList(words));
if (search.charAt(search.length() - 1) == ' ') {
searchLine.add("");
}
+ Criteria criteria = null;
+ if (searchLine.size() > 1) {
+ List<String> cpy = new ArrayList<String>(searchLine);
+ cpy.remove(cpy.size() - 1);
+ criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).
+ contains(Bookmark.FQ_FIELD_TAGS, cpy).criteria();
+ } else {
+ criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria();
+ }
+ List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
+ openSearchActions.setBookmarkList(bookList);
openSearchActions.findSuggestions(searchLine);
- log.debug("result={" + openSearchActions.getJsonResult() + "}");
request.setAttribute("openSearchAction", openSearchActions);
}
}
@@ -276,8 +287,8 @@
++click;
bookmark.setClick(click);
proxy.store(bookmark);
- String url = bookmark.getLink();
- response.sendRedirect(url);
+ String link = bookmark.getLink();
+ response.sendRedirect(link);
}
}
}
@@ -445,15 +456,15 @@
}
protected void addUrl(HttpServletRequest request, User user) {
- String url = request.getParameter("url"); // url of the website
+ String link = request.getParameter("url"); // url of the website
String name = request.getParameter("name");
Bookmark bookmark = null;
if (name != null) {
String tags = request.getParameter("tags"); // tags
- bookmark = BookmarkActions.createBookmark(url, name, tags, user, null);
+ bookmark = BookmarkActions.createBookmark(link, name, tags, user, null);
} else {
String nameAndTags = request.getParameter("nameAndTags");
- bookmark = BookmarkActions.createBookmark(url, nameAndTags, user);
+ bookmark = BookmarkActions.createBookmark(link, nameAndTags, user);
}
if (bookmark != null) {
WikittyProxy proxy = model.getProxy();
@@ -520,7 +531,6 @@
bookmarkActions.emptySearchline();
}
request.setAttribute("bookmarkActions", bookmarkActions);
-
}
protected BookmarkActions createBookmarkActions(HttpServletRequest request, List<Bookmark> bookList) {
Modified: trunk/src/main/java/org/chorem/bow/OpenSearchActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/OpenSearchActions.java 2010-05-31 10:21:08 UTC (rev 44)
+++ trunk/src/main/java/org/chorem/bow/OpenSearchActions.java 2010-05-31 13:54:19 UTC (rev 45)
@@ -26,28 +26,20 @@
public void findSuggestions(List<String> searchLine) {
int size = searchLine.size();
search = searchLine.toArray(new String[size]);
- if (!bookmarkList.isEmpty()) {
- int i;
- for (i = 0; i < (search.length - 1); ++i) {
- List<Bookmark> newList = new ArrayList<Bookmark>(bookmarkList);
- for (Bookmark bookmark : newList) {
- if (!bookmarkHasTag(bookmark, search[i])) {
- bookmarkList.remove(bookmark);
- }
- }
- }
- fieldSuggestionList(search[i], searchLine);
- }
+ fieldSuggestionList(search[size - 1], searchLine);
}
protected void fieldSuggestionList(String word, List<String> searchLine) {
if (bookmarkList != null) {
Map<String, Integer> map = new HashMap<String, Integer>();
- for (Bookmark bookmark : bookmarkList) {
+ List<Bookmark> save = new ArrayList<Bookmark>(bookmarkList);
+ for (Bookmark bookmark : save) {
Set<String> tagList = bookmark.getTags();
+ boolean contain = false;
if (tagList != null) {
for (String tag : tagList) {
if (tag.indexOf(word) == 0 && !searchLine.contains(tag)) {
+ contain = true;
if (map.containsKey(tag)) {
Integer count = map.get(tag);
++count;
@@ -58,6 +50,9 @@
}
}
}
+ if (contain == false) {
+ bookmarkList.remove(bookmark);
+ }
}
Set<String> keys = map.keySet();
for (String key : keys) {
@@ -114,6 +109,11 @@
str += ",";
}
}
+ if (bookmarkList.size() <= 5 && suggestions.size() > 0) {
+ for (Bookmark bookmark : bookmarkList) {
+ str += ",\"" + bookmark.getLink() + "\"";
+ }
+ }
str += "]";
return str;
}
1
0
May 31, 2010
Author: bbrossaud
Date: 2010-05-31 12:21:08 +0200 (Mon, 31 May 2010)
New Revision: 44
Url: http://chorem.org/repositories/revision/bow/44
Log:
addition tag works if bookmard doesn't have tag, importation adds the folder name as a tag to the bookmark tagList
Modified:
trunk/TODO.txt
trunk/src/main/java/org/chorem/bow/BookmarkActions.java
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
Modified: trunk/TODO.txt
===================================================================
--- trunk/TODO.txt 2010-05-28 15:09:08 UTC (rev 43)
+++ trunk/TODO.txt 2010-05-31 10:21:08 UTC (rev 44)
@@ -9,4 +9,21 @@
-> le && pour le nuage de tag (11 mai) OK
-> gestion des sessions (14 mai) OK
-> javascript ==> (11 mai) OK
--> Mise en forme (28 mai)
\ No newline at end of file
+-> Mise en forme (28 mai)
+
+
+===> corriger ajout de tag quand vide
+
+===> ajout des tags par repertoire
+
+===> seeks.fr + champs pour recherche
+
+===> champ recherche fulltext
+
+===> class bokkmarkFile = Id proprietaire, list<userID> writer, list<userId> reader;
+
+===> class bookmark = idBookmarkFile a la place de UserID;
+
+===> dans class user = String SearchEngine;
+
+===> openSearch ==> proposer des url
Modified: trunk/src/main/java/org/chorem/bow/BookmarkActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-28 15:09:08 UTC (rev 43)
+++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-31 10:21:08 UTC (rev 44)
@@ -30,6 +30,14 @@
protected int tmax = -1;
protected int tmin = -1;
+ public static Bookmark createBookmarkFromHtml(String html, String name, User user) {
+ String link = getUrlFromHtml(html);
+ String tags = getTagsFromHtml(html);
+ Date date = getDateFromHtml(html);
+ Bookmark bookmark = createBookmark(link, name, tags, user, date);
+ return bookmark;
+ }
+
public static Date getDateFromHtml(String html) {
Date date = null;
if (html != null) {
@@ -140,17 +148,37 @@
}
public static void addTagsToBookmark(String tags, Bookmark bookmark) {
- if (tags != null) {
+ if (tags != null && !tags.isEmpty()) {
tags = tags.trim();
String[] tagsTab = tags.split("\\s+"); // put the tags in an array
for (int i = 0; i < tagsTab.length; ++i) {
- if (!tagsTab[i].isEmpty()) {
- bookmark.addTags(tagsTab[i]); // Added tag for each rank (one tag by rank)
+ Set<String> tagList = bookmark.getTags();
+ if (tagList != null) {
+ if (!tagList.contains(tagsTab[i]) && !tagsTab[i].isEmpty()) {
+ bookmark.addTags(tagsTab[i]); // Added tag for each rank (one tag by rank)
+ }
+ } else {
+ bookmark.addTags(tagsTab[i]);
}
}
}
}
+ public static void addTagsToBookmark(List<String> tagList, Bookmark bookmark) {
+ if (tagList != null && !tagList.isEmpty()) {
+ for (String tag : tagList) {
+ Set<String> bookmarTags = bookmark.getTags();
+ if (bookmarTags != null) {
+ if (!bookmarTags.contains(tag) && !tag.isEmpty()) {
+ bookmark.addTags(tag); // Added tag for each rank (one tag by rank)
+ }
+ } else if (!tag.isEmpty()) {
+ bookmark.addTags(tag);
+ }
+ }
+ }
+ }
+
public static Bookmark createBookmark(String url, String name, String tags, User user, Date date) {
Bookmark bookmark = (Bookmark) new BookmarkImpl();
if (name != null) {
@@ -190,21 +218,6 @@
}
}
- public static void updateBookmarkTags(Bookmark bookmark, String tags) {
- if (tags != null && !tags.isEmpty()) {
- tags = tags.trim();
- String[] tagsTab = tags.split("\\s+"); // put the tags in an array
- for (int i = 0; i < tagsTab.length; ++i) {
- Set<String> tagList = bookmark.getTags();
- if (tagList != null) {
- if (!tagList.contains(tagsTab[i]) && !tagsTab[i].isEmpty()) {
- bookmark.addTags(tagsTab[i]); // Added tag for each rank (one tag by rank)
- }
- }
- }
- }
- }
-
public static String getBookmarkTagsString(Bookmark bookmark) {
if (bookmark != null) {
Set<String> tags = bookmark.getTags();
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-28 15:09:08 UTC (rev 43)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-31 10:21:08 UTC (rev 44)
@@ -221,7 +221,8 @@
request.getRequestDispatcher("login.jsp").forward(request, response);
}
} catch (Exception eee) {
- request.getRequestDispatcher("error.jsp").forward(request, response);
+ throw new ServletException("msg", eee);
+ // request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
@@ -345,7 +346,7 @@
Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId);
if (bookmark != null) {
BookmarkActions.updateBookmarkName(bookmark, name);
- BookmarkActions.updateBookmarkTags(bookmark, tags);
+ BookmarkActions.addTagsToBookmark(tags, bookmark);
proxy.store(bookmark);
}
}
@@ -687,7 +688,7 @@
Parser parser = new Parser(content);
NodeList list = parser.parse(null);
List<Bookmark> bookmarks = new ArrayList<Bookmark>();
- parseHtmlToBookmarks(list, user, bookmarks);
+ parseHtmlToBookmarks(list, user, bookmarks, new ArrayList<String>());
proxy.store(bookmarks);
}
}
@@ -695,28 +696,39 @@
response.sendRedirect("bow?action=home");
}
- protected void parseHtmlToBookmarks(NodeList list, User user, List<Bookmark> bookmarks)
+ protected void parseHtmlToBookmarks(NodeList list, User user, List<Bookmark> bookmarks, List<String> tagList)
throws ParserException {
if (list != null) {
+ boolean isFolder = false;
SimpleNodeIterator it = list.elements();
while (it.hasMoreNodes()) {
Node node = it.nextNode();
String plainText = node.toPlainTextString();
String text = node.getText();
- if (text != null && text.contains("A HREF")) {
- String url = BookmarkActions.getUrlFromHtml(text);
- String tags = BookmarkActions.getTagsFromHtml(text);
- Date date = BookmarkActions.getDateFromHtml(text);
- Bookmark bookmark = BookmarkActions.createBookmark(url, plainText, tags, user, date);
+ if (text != null && text.startsWith("H3")) {
+ log.debug(text);
+ if (plainText != null && !plainText.isEmpty()) {
+ tagList.add(plainText);
+ isFolder = true;
+ }
+ } else if (text != null && text.startsWith("A HREF")) {
+ Bookmark bookmark = BookmarkActions.createBookmarkFromHtml(text, plainText, user);
+ BookmarkActions.addTagsToBookmark(tagList, bookmark);
if (bookmark != null) {
bookmarks.add(bookmark);
}
}
NodeList children = node.getChildren();
if (children != null) {
- parseHtmlToBookmarks(children, user, bookmarks);
+ parseHtmlToBookmarks(children, user, bookmarks, tagList);
}
}
+ if (isFolder == true) {
+ int index = tagList.size() - 1;
+ if (index > -1) {
+ tagList.remove(index);
+ }
+ }
}
}
1
0
Author: bbrossaud
Date: 2010-05-28 17:09:08 +0200 (Fri, 28 May 2010)
New Revision: 43
Url: http://chorem.org/repositories/revision/bow/43
Log:
remove debug
Modified:
trunk/src/main/java/org/chorem/bow/AliasServlet.java
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
Modified: trunk/src/main/java/org/chorem/bow/AliasServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/AliasServlet.java 2010-05-28 15:01:26 UTC (rev 42)
+++ trunk/src/main/java/org/chorem/bow/AliasServlet.java 2010-05-28 15:09:08 UTC (rev 43)
@@ -4,14 +4,11 @@
*/
package org.chorem.bow;
-import com.sun.tools.javac.resources.version;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.ArgumentsParserException;
import org.nuiton.wikitty.Criteria;
@@ -24,9 +21,8 @@
*/
public class AliasServlet extends HttpServlet {
- private static final Log log = LogFactory.getLog(AliasServlet.class);
protected Model model = new Model();
- protected String bowUrl = "";
+ protected String bowUrl = "";
public AliasServlet() throws ArgumentsParserException {
ApplicationConfig config = new ApplicationConfig();
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-28 15:01:26 UTC (rev 42)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-28 15:09:08 UTC (rev 43)
@@ -646,7 +646,7 @@
return true;
}
- private void actionHome(HttpServletRequest request, User user) {
+ protected void actionHome(HttpServletRequest request, User user) {
WikittyProxy proxy = model.getProxy();
Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
addSortDescending(Bookmark.FQ_FIELD_CLICK);
@@ -666,7 +666,7 @@
request.setAttribute("bookmarkActions", bookmarkActions);
}
- private void actionImportBookmarks(HttpServletRequest request, HttpServletResponse response, User user)
+ protected void actionImportBookmarks(HttpServletRequest request, HttpServletResponse response, User user)
throws IOException, FileUploadException, ParserException {
// Check that we have a file upload request
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
@@ -695,7 +695,7 @@
response.sendRedirect("bow?action=home");
}
- private void parseHtmlToBookmarks(NodeList list, User user, List<Bookmark> bookmarks)
+ protected void parseHtmlToBookmarks(NodeList list, User user, List<Bookmark> bookmarks)
throws ParserException {
if (list != null) {
SimpleNodeIterator it = list.elements();
@@ -720,7 +720,7 @@
}
}
- private void actionExportBookmarks(HttpServletResponse response, User user)
+ protected void actionExportBookmarks(HttpServletResponse response, User user)
throws IOException {
WikittyProxy proxy = model.getProxy();
Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria();
@@ -736,7 +736,7 @@
op.close();
}
- private void actionAddAlias(HttpServletRequest request, HttpServletResponse response)
+ protected void actionAddAlias(HttpServletRequest request, HttpServletResponse response)
throws IOException {
String alias = request.getParameter("alias");
if (alias != null && !alias.isEmpty()) {
1
0
Author: bbrossaud
Date: 2010-05-28 17:01:26 +0200 (Fri, 28 May 2010)
New Revision: 42
Url: http://chorem.org/repositories/revision/bow/42
Log:
remove bugs in jsp
Modified:
trunk/src/main/webapp/home.jsp
trunk/src/main/webapp/search.jsp
Modified: trunk/src/main/webapp/home.jsp
===================================================================
--- trunk/src/main/webapp/home.jsp 2010-05-28 14:43:51 UTC (rev 41)
+++ trunk/src/main/webapp/home.jsp 2010-05-28 15:01:26 UTC (rev 42)
@@ -67,8 +67,14 @@
<td class="result">
<%=sdf.format(bookmark.getDate())%>
</td>
+ <%
+ String alias = bookmark.getAlias();
+ if (alias != null && !alias.isEmpty()) {
+ alias = url + "alias/" + alias;
+ }
+ %>
<td class="result" style="text-align: left">
- <a href="bow?action=addAlias&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
+ <a title ="<%=alias%>" href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
<form method="POST" action="bow?action=addAlias&bookmarkId=<%=bookmark.getWikittyId()%>" style="display: inline">
<input type="text" name="alias" size="10" value="<%=bookmark.getAlias()%>" />
<input style="display: inline;" type="submit" value="Add alias" />
@@ -80,9 +86,9 @@
</td>
<td class="result" style="text-align: left">
<%
- Set<String> tagList = bookmark.getTags();
- if (tagList != null && !tagList.isEmpty()) {
- for (String tag : tagList) {
+ Set<String> tagList = bookmark.getTags();
+ if (tagList != null && !tagList.isEmpty()) {
+ for (String tag : tagList) {
%>
<div style="display: inline">
<a style="text-decoration:none" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&deleteTag=<%=tag%>">
@@ -91,8 +97,8 @@
<%=tag%>
</div>
<%
+ }
}
- }
%>
<form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>">
<input type="text" name="tags" size="35" value="<%=BookmarkActions.getBookmarkTagsString(bookmark)%>" />
@@ -131,7 +137,7 @@
</th>
</tr>
<%
- for (Bookmark bookmark : lastBookmarks) {
+ for (Bookmark bookmark : lastBookmarks) {
%>
<tr class="result">
<td class="result">
@@ -142,8 +148,14 @@
<td class="result">
<%=sdf.format(bookmark.getDate())%>
</td>
+ <%
+ String alias = bookmark.getAlias();
+ if (alias != null && !alias.isEmpty()) {
+ alias = url + "alias/" + alias;
+ }
+ %>
<td class="result" style="text-align: left">
- <a href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
+ <a title ="<%=alias%>" href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
<form method="POST" action="bow?action=addAlias&bookmarkId=<%=bookmark.getWikittyId()%>" style="display: inline">
<input type="text" name="alias" size="10" value="<%=bookmark.getAlias()%>" />
<input style="display: inline;" type="submit" value="Add alias" />
@@ -155,9 +167,9 @@
</td>
<td class="result" style="text-align: left">
<%
- Set<String> tagList = bookmark.getTags();
- if (tagList != null && !tagList.isEmpty()) {
- for (String tag : tagList) {
+ Set<String> tagList = bookmark.getTags();
+ if (tagList != null && !tagList.isEmpty()) {
+ for (String tag : tagList) {
%>
<div style="display: inline">
<a style="text-decoration:none" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&deleteTag=<%=tag%>">
@@ -166,8 +178,8 @@
<%=tag%>
</div>
<%
+ }
}
- }
%>
<form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>">
<input type="text" name="tags" size="35" value="<%=BookmarkActions.getBookmarkTagsString(bookmark)%>" />
@@ -179,7 +191,7 @@
</td>
</tr>
<%
- }
+ }
%>
</table>
<%
Modified: trunk/src/main/webapp/search.jsp
===================================================================
--- trunk/src/main/webapp/search.jsp 2010-05-28 14:43:51 UTC (rev 41)
+++ trunk/src/main/webapp/search.jsp 2010-05-28 15:01:26 UTC (rev 42)
@@ -81,8 +81,14 @@
<td class="result">
<%=sdf.format(bookmark.getDate())%>
</td>
+ <%
+ String alias = bookmark.getAlias();
+ if (alias != null && !alias.isEmpty()) {
+ alias = url + "alias/" + alias;
+ }
+ %>
<td class="result">
- <a href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
+ <a title ="<%=alias%>" href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
<form method="POST" action="bow?action=addAlias&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>" style="display: inline">
<input type="text" name="alias" size="10" value="<%=bookmark.getAlias()%>" />
<input style="display: inline;" type="submit" value="Add alias" />
1
0
r41 - in trunk/src/main: java/org/chorem/bow resources webapp
by bbrossaud@users.chorem.org May 28, 2010
by bbrossaud@users.chorem.org May 28, 2010
May 28, 2010
Author: bbrossaud
Date: 2010-05-28 16:43:51 +0200 (Fri, 28 May 2010)
New Revision: 41
Url: http://chorem.org/repositories/revision/bow/41
Log:
add bow url in properties file
Added:
trunk/src/main/java/org/chorem/bow/AliasServlet.java
trunk/src/main/resources/bow.properties
Modified:
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
trunk/src/main/webapp/home.jsp
trunk/src/main/webapp/login.jsp
trunk/src/main/webapp/openSearchResult.jsp
trunk/src/main/webapp/register.jsp
trunk/src/main/webapp/search.jsp
Added: trunk/src/main/java/org/chorem/bow/AliasServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/AliasServlet.java (rev 0)
+++ trunk/src/main/java/org/chorem/bow/AliasServlet.java 2010-05-28 14:43:51 UTC (rev 41)
@@ -0,0 +1,74 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.chorem.bow;
+
+import com.sun.tools.javac.resources.version;
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.ApplicationConfig;
+import org.nuiton.util.ArgumentsParserException;
+import org.nuiton.wikitty.Criteria;
+import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.search.Search;
+
+/**
+ *
+ * @author bbrossaud
+ */
+public class AliasServlet extends HttpServlet {
+
+ private static final Log log = LogFactory.getLog(AliasServlet.class);
+ protected Model model = new Model();
+ protected String bowUrl = "";
+
+ public AliasServlet() throws ArgumentsParserException {
+ ApplicationConfig config = new ApplicationConfig();
+ config.setConfigFileName("bow.properties");
+ config.parse(new String[]{});
+ bowUrl = config.getOption("bow.url");
+ }
+
+ @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 {
+ try {
+ String url = request.getRequestURL().toString();
+ int index = url.indexOf("alias");
+ index += 5;
+ String alias = url.substring(index);
+ if (alias != null && !alias.isEmpty()) {
+ alias = alias.substring(1);
+ WikittyProxy proxy = model.getProxy();
+ Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_ALIAS, alias).criteria();
+ Bookmark bookmark = proxy.findByCriteria(Bookmark.class, criteria);
+ if (bookmark != null) {
+ String redirect = bookmark.getLink();
+ response.sendRedirect(redirect);
+ } else {
+ response.sendRedirect(bowUrl);
+ }
+ } else {
+ response.sendRedirect(bowUrl);
+ }
+ } catch (Exception eee) {
+ request.getRequestDispatcher("error.jsp").forward(request, response);
+ }
+ }
+}
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-28 14:12:51 UTC (rev 40)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-28 14:43:51 UTC (rev 41)
@@ -47,12 +47,20 @@
private static final Log log = LogFactory.getLog(ControllerServlet.class);
protected Model model = new Model();
protected String version = "";
+ protected String url = "";
- public ControllerServlet() throws ArgumentsParserException {
+ public ControllerServlet() throws ArgumentsParserException, Exception {
ApplicationConfig config = new ApplicationConfig();
config.setConfigFileName("bow.properties");
config.parse(new String[]{});
version = config.getOption("application.version");
+ url = config.getOption("bow.url");
+ if (url == null) {
+ throw new Exception("No bow.url=\"SERVER URL\" in bow.properties");
+ }
+ if (url.charAt(url.length() - 1) != '/') {
+ url += '/';
+ }
}
@Override
@@ -70,6 +78,7 @@
throws IOException, ServletException {
try {
request.setAttribute("version", version);
+ request.setAttribute("bowUrl", url);
HttpSession session = request.getSession(true);
User user = (User) session.getAttribute("user");
String token = request.getParameter("token"); // token or not
Added: trunk/src/main/resources/bow.properties
===================================================================
--- trunk/src/main/resources/bow.properties (rev 0)
+++ trunk/src/main/resources/bow.properties 2010-05-28 14:43:51 UTC (rev 41)
@@ -0,0 +1,2 @@
+application.version=${project.version}
+bow.url=http://localhost:8080/bow/
Modified: trunk/src/main/webapp/home.jsp
===================================================================
--- trunk/src/main/webapp/home.jsp 2010-05-28 14:12:51 UTC (rev 40)
+++ trunk/src/main/webapp/home.jsp 2010-05-28 14:43:51 UTC (rev 41)
@@ -16,9 +16,7 @@
if (tokenActions != null && bookmarkActions != null) {
String temporaryToken = tokenActions.getTemporaryToken();
String permanentToken = tokenActions.getPermanentToken();
- String url = request.getRequestURL().toString();
- int index = url.indexOf("home.jsp");
- url = url.substring(0, index);
+ String url = (String) request.getAttribute("bowUrl");
String version = (String) request.getAttribute("version");
%>
Modified: trunk/src/main/webapp/login.jsp
===================================================================
--- trunk/src/main/webapp/login.jsp 2010-05-28 14:12:51 UTC (rev 40)
+++ trunk/src/main/webapp/login.jsp 2010-05-28 14:43:51 UTC (rev 41)
@@ -1,7 +1,7 @@
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
String error = (String) request.getAttribute("msgError");
- String url = request.getRequestURL().toString();
+ String url = (String) request.getAttribute("bowUrl");
String version = (String) request.getAttribute("version");
%>
Modified: trunk/src/main/webapp/openSearchResult.jsp
===================================================================
--- trunk/src/main/webapp/openSearchResult.jsp 2010-05-28 14:12:51 UTC (rev 40)
+++ trunk/src/main/webapp/openSearchResult.jsp 2010-05-28 14:43:51 UTC (rev 41)
@@ -16,9 +16,7 @@
if (bookmarkActions != null) {
searchLine = bookmarkActions.getSearchLine();
}
- String url = request.getRequestURL().toString();
- int index = url.indexOf("openSearchResult.jsp");
- url = url.substring(0, index);
+ String url = (String) request.getAttribute("bowUrl");
%>
<html>
Modified: trunk/src/main/webapp/register.jsp
===================================================================
--- trunk/src/main/webapp/register.jsp 2010-05-28 14:12:51 UTC (rev 40)
+++ trunk/src/main/webapp/register.jsp 2010-05-28 14:43:51 UTC (rev 41)
@@ -1,9 +1,7 @@
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
String error = (String) request.getAttribute("msgError");
- String url = request.getRequestURL().toString();
- int index = url.indexOf("register.jsp");
- url = url.substring(0, index);
+ String url = (String) request.getAttribute("bowUrl");
String version = (String) request.getAttribute("version");
%>
<html>
Modified: trunk/src/main/webapp/search.jsp
===================================================================
--- trunk/src/main/webapp/search.jsp 2010-05-28 14:12:51 UTC (rev 40)
+++ trunk/src/main/webapp/search.jsp 2010-05-28 14:43:51 UTC (rev 41)
@@ -17,9 +17,7 @@
String temporaryToken = tokenActions.getTemporaryToken();
String permanentToken = tokenActions.getPermanentToken();
String searchLine = bookmarkActions.getSearchLine();
- String url = request.getRequestURL().toString();
- int index = url.indexOf("search.jsp");
- url = url.substring(0, index);
+ String url = (String) request.getAttribute("bowUrl");
String version = (String) request.getAttribute("version");
%>
1
0
May 28, 2010
Author: bbrossaud
Date: 2010-05-28 16:12:51 +0200 (Fri, 28 May 2010)
New Revision: 40
Url: http://chorem.org/repositories/revision/bow/40
Log:
addition link on home
Modified:
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
trunk/src/main/webapp/home.jsp
trunk/src/main/webapp/search.jsp
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-28 13:49:55 UTC (rev 39)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-28 14:12:51 UTC (rev 40)
@@ -48,7 +48,6 @@
protected Model model = new Model();
protected String version = "";
-
public ControllerServlet() throws ArgumentsParserException {
ApplicationConfig config = new ApplicationConfig();
config.setConfigFileName("bow.properties");
@@ -76,7 +75,6 @@
String token = request.getParameter("token"); // token or not
if (token != null && !token.isEmpty()) {
user = checkToken(token, session);
- log.debug(session.getAttribute("user"));
}
String action = request.getParameter("action");
if (action != null) {
@@ -204,14 +202,17 @@
this.actionOpenSearchResult(request, response, user, token);
request.getRequestDispatcher("openSearchResult.jsp").forward(request, response);
} else {
- request.getRequestDispatcher("error.jsp").forward(request, response);
+ if (user != null) {
+ request.getRequestDispatcher("error.jsp").forward(request, response);
+ } else {
+ request.getRequestDispatcher("login.jsp").forward(request, response);
+ }
}
} else {
request.getRequestDispatcher("login.jsp").forward(request, response);
}
} catch (Exception eee) {
- throw new ServletException("DO GET ERROR", eee);
-// request.getRequestDispatcher("error.jsp").forward(request, response);
+ request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
@@ -726,7 +727,7 @@
op.close();
}
- private void actionAddAlias(HttpServletRequest request, HttpServletResponse response)
+ private void actionAddAlias(HttpServletRequest request, HttpServletResponse response)
throws IOException {
String alias = request.getParameter("alias");
if (alias != null && !alias.isEmpty()) {
Modified: trunk/src/main/webapp/home.jsp
===================================================================
--- trunk/src/main/webapp/home.jsp 2010-05-28 13:49:55 UTC (rev 39)
+++ trunk/src/main/webapp/home.jsp 2010-05-28 14:12:51 UTC (rev 40)
@@ -28,7 +28,10 @@
<link rel="search" type="application/opensearchdescription+xml" title="bowPermanentSearchEngine" href="<%=url%>bow?action=permanentXml" />
<body>
<div id="table">
- <h1 class="result">Home</h1>
+ <h1 class="result">
+ <a style="float: left;font-size: 12px; margin-left: 10px;" href="<%=url%>bow?action=home">home</a>
+ Home
+ </h1>
<%
if (bookmarkActions != null) {
List<Bookmark> bookmarkList = bookmarkActions.getBookmarks();
Modified: trunk/src/main/webapp/search.jsp
===================================================================
--- trunk/src/main/webapp/search.jsp 2010-05-28 13:49:55 UTC (rev 39)
+++ trunk/src/main/webapp/search.jsp 2010-05-28 14:12:51 UTC (rev 40)
@@ -12,17 +12,15 @@
<%
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);
- String version = (String) request.getAttribute("version");
+ if (tokenActions != null && bookmarkActions != null) {
+ String temporaryToken = tokenActions.getTemporaryToken();
+ String permanentToken = tokenActions.getPermanentToken();
+ String searchLine = bookmarkActions.getSearchLine();
+ String url = request.getRequestURL().toString();
+ int index = url.indexOf("search.jsp");
+ url = url.substring(0, index);
+ String version = (String) request.getAttribute("version");
%>
<html>
@@ -31,11 +29,14 @@
<link rel="search" type="application/opensearchdescription+xml" title="bowPermanentSearchEngine" href="<%=url%>bow?action=permanentXml" />
<body>
<div id="table">
- <h1 class="result">My Bookmarks</h1>
+ <h1 class="result">
+ <a style="float: left;font-size: 12px; margin-left: 10px;" href="<%=url%>bow?action=home">home</a>
+ My Bookmarks
+ </h1>
<%
- if (bookmarkActions != null) {
- List<Bookmark> bookmarkList = bookmarkActions.getBookmarks();
- if (!bookmarkList.isEmpty()) {
+ if (bookmarkActions != null) {
+ List<Bookmark> bookmarkList = bookmarkActions.getBookmarks();
+ if (!bookmarkList.isEmpty()) {
%>
<table class="result">
<tr class="result">
@@ -70,8 +71,8 @@
</th>
</tr>
<%
- SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
- for (Bookmark bookmark : bookmarkList) {
+ SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
+ for (Bookmark bookmark : bookmarkList) {
%>
<tr class="result">
<td class="result">
@@ -84,7 +85,7 @@
</td>
<td class="result">
<a href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
- <form method="POST" action="bow?action=addAlias&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>" style="display: inline">
+ <form method="POST" action="bow?action=addAlias&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>" style="display: inline">
<input type="text" name="alias" size="10" value="<%=bookmark.getAlias()%>" />
<input style="display: inline;" type="submit" value="Add alias" />
</form>
@@ -95,9 +96,9 @@
</td>
<td class="result" style="text-align: left">
<%
- Set<String> tagList = bookmark.getTags();
- if (tagList != null && !tagList.isEmpty()) {
- for (String tag : tagList) {
+ Set<String> tagList = bookmark.getTags();
+ if (tagList != null && !tagList.isEmpty()) {
+ for (String tag : tagList) {
%>
<div style="display: inline">
<a style="text-decoration:none" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&deleteTag=<%=tag%>&searchLine=<%=searchLine%>">
@@ -106,8 +107,8 @@
<%=tag%>
</div>
<%
+ }
}
- }
%>
<form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>">
<input type="text" name="tags" size="35" value="<%=BookmarkActions.getBookmarkTagsString(bookmark)%>" />
@@ -119,15 +120,15 @@
</td>
</tr>
<%
- }
+ }
%>
</table>
<%
- } else {
+ } else {
%>
<h2 class="result">No Bookmarks</h2>
<% }
- }
+ }
%>
</div>
<div id="menu">
@@ -154,16 +155,16 @@
<div class="menu">
<div class="tagCloud">
<% if (bookmarkActions != null) {
- Map<String, Integer> tagsCloud = bookmarkActions.getTagsCloud();
- Set<String> tags = tagsCloud.keySet();
- for (String tag : tags) {
- int value = tagsCloud.get(tag);
- int font = bookmarkActions.getFont(value);
+ Map<String, Integer> tagsCloud = bookmarkActions.getTagsCloud();
+ Set<String> tags = tagsCloud.keySet();
+ for (String tag : tags) {
+ int value = tagsCloud.get(tag);
+ int font = bookmarkActions.getFont(value);
%>
<a href="bow?action=search&addTag=<%=tag%>&searchLine=<%=searchLine%>" title="<%=value%> results" class="tag" style="font-size: <%=font%>px;"><%=tag%></a>
<%
+ }
}
- }
%>
<form method="POST" action="bow?action=search" style="text-align: center;margin-left: 20px;">
<input style="float: left" type="text" name="searchLine" size="15" value="<%=searchLine%>" />
@@ -182,4 +183,5 @@
<a shape="rect" href="http://list.chorem.org/cgi-bin/mailman/listinfo/bow-users">Support utilisateur</a>
</div>
</body>
-</html>
\ No newline at end of file
+</html>
+<%}%>
\ No newline at end of file
1
0
Author: bbrossaud
Date: 2010-05-28 15:49:55 +0200 (Fri, 28 May 2010)
New Revision: 39
Url: http://chorem.org/repositories/revision/bow/39
Log:
remove bug on javascript
Modified:
trunk/src/main/webapp/home.jsp
Modified: trunk/src/main/webapp/home.jsp
===================================================================
--- trunk/src/main/webapp/home.jsp 2010-05-28 13:46:00 UTC (rev 38)
+++ trunk/src/main/webapp/home.jsp 2010-05-28 13:49:55 UTC (rev 39)
@@ -194,8 +194,8 @@
<div class="menu">
<ul id="meta">
<li><a href="bow?action=logout">Logout</a></li>
- <li><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);if%20(nameAndTags!=(document.title+'|')){var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);}void(0);">Temporary token</a></li>
- <li><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);if%20(nameAndTags!=(document.title+'|')){var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);}void(0);">Current permanent token</a></li>
+ <li><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+'|');if%20(nameAndTags!=(document.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></li>
+ <li><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+'|');if%20(nameAndTags!=(document.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></li>
<li><a href="bow?action=generateToken">Regenerate permanent token</a></li>
</ul>
</div>
1
0
May 28, 2010
Author: bbrossaud
Date: 2010-05-28 15:46:00 +0200 (Fri, 28 May 2010)
New Revision: 38
Url: http://chorem.org/repositories/revision/bow/38
Log:
remove bug on javascript
Modified:
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
trunk/src/main/webapp/home.jsp
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-28 12:47:46 UTC (rev 37)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-28 13:46:00 UTC (rev 38)
@@ -76,6 +76,7 @@
String token = request.getParameter("token"); // token or not
if (token != null && !token.isEmpty()) {
user = checkToken(token, session);
+ log.debug(session.getAttribute("user"));
}
String action = request.getParameter("action");
if (action != null) {
@@ -209,7 +210,8 @@
request.getRequestDispatcher("login.jsp").forward(request, response);
}
} catch (Exception eee) {
- request.getRequestDispatcher("error.jsp").forward(request, response);
+ throw new ServletException("DO GET ERROR", eee);
+// request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
Modified: trunk/src/main/webapp/home.jsp
===================================================================
--- trunk/src/main/webapp/home.jsp 2010-05-28 12:47:46 UTC (rev 37)
+++ trunk/src/main/webapp/home.jsp 2010-05-28 13:46:00 UTC (rev 38)
@@ -12,13 +12,14 @@
<%
TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions");
- String temporaryToken = tokenActions.getTemporaryToken();
- String permanentToken = tokenActions.getPermanentToken();
BookmarkActions bookmarkActions = (BookmarkActions) request.getAttribute("bookmarkActions");
- String url = request.getRequestURL().toString();
- int index = url.indexOf("home.jsp");
- url = url.substring(0, index);
- String version = (String) request.getAttribute("version");
+ if (tokenActions != null && bookmarkActions != null) {
+ String temporaryToken = tokenActions.getTemporaryToken();
+ String permanentToken = tokenActions.getPermanentToken();
+ String url = request.getRequestURL().toString();
+ int index = url.indexOf("home.jsp");
+ url = url.substring(0, index);
+ String version = (String) request.getAttribute("version");
%>
<html>
@@ -29,9 +30,9 @@
<div id="table">
<h1 class="result">Home</h1>
<%
- if (bookmarkActions != null) {
- List<Bookmark> bookmarkList = bookmarkActions.getBookmarks();
- if (!bookmarkList.isEmpty()) {
+ if (bookmarkActions != null) {
+ List<Bookmark> bookmarkList = bookmarkActions.getBookmarks();
+ if (!bookmarkList.isEmpty()) {
%>
<h2 class="result">The most used bookmarks</h2>
<table class="result">
@@ -53,8 +54,8 @@
</th>
</tr>
<%
- SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
- for (Bookmark bookmark : bookmarkList) {
+ SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
+ for (Bookmark bookmark : bookmarkList) {
%>
<tr class="result">
<td class="result">
@@ -102,12 +103,12 @@
</td>
</tr>
<%
- }
+ }
%>
</table>
<%
- List<Bookmark> lastBookmarks = bookmarkActions.getLastBookmarks();
- if (!lastBookmarks.isEmpty()) {
+ List<Bookmark> lastBookmarks = bookmarkActions.getLastBookmarks();
+ if (!lastBookmarks.isEmpty()) {
%>
<h2 class="result">The last addition bookmarks</h2>
<table class="result">
@@ -181,20 +182,20 @@
%>
</table>
<%
- }
- } else {
+ }
+ } else {
%>
<h2 class="result">No Bookmarks</h2>
<% }
- }
+ }
%>
</div>
<div id="menu">
<div class="menu">
<ul id="meta">
<li><a href="bow?action=logout">Logout</a></li>
- <li><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></li>
- <li><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></li>
+ <li><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);if%20(nameAndTags!=(document.title+'|')){var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);}void(0);">Temporary token</a></li>
+ <li><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);if%20(nameAndTags!=(document.title+'|')){var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);}void(0);">Current permanent token</a></li>
<li><a href="bow?action=generateToken">Regenerate permanent token</a></li>
</ul>
</div>
@@ -213,16 +214,16 @@
<div class="menu">
<div class="tagCloud">
<% if (bookmarkActions != null) {
- Map<String, Integer> tagsCloud = bookmarkActions.getTagsCloud();
- Set<String> tags = tagsCloud.keySet();
- for (String tag : tags) {
- int value = tagsCloud.get(tag);
- int font = bookmarkActions.getFont(value);
+ Map<String, Integer> tagsCloud = bookmarkActions.getTagsCloud();
+ Set<String> tags = tagsCloud.keySet();
+ for (String tag : tags) {
+ int value = tagsCloud.get(tag);
+ int font = bookmarkActions.getFont(value);
%>
<a href="bow?action=search&addTag=<%=tag%>" title="<%=value%> results" class="tag" style="font-size: <%=font%>px;"><%=tag%></a>
<%
+ }
}
- }
%>
<form method="POST" action="bow?action=search" style="text-align: center;margin-left: 20px;">
<input style="float: left" type="text" name="searchLine" size="15" />
@@ -250,4 +251,5 @@
<a shape="rect" href="http://list.chorem.org/cgi-bin/mailman/listinfo/bow-users">Support utilisateur</a>
</div>
</body>
-</html>
\ No newline at end of file
+</html>
+<%}%>
\ No newline at end of file
1
0
r37 - in trunk: . src/main/java/org/chorem/bow src/main/webapp src/main/webapp/WEB-INF src/main/xmi
by bbrossaud@users.chorem.org May 28, 2010
by bbrossaud@users.chorem.org May 28, 2010
May 28, 2010
Author: bbrossaud
Date: 2010-05-28 14:47:46 +0200 (Fri, 28 May 2010)
New Revision: 37
Url: http://chorem.org/repositories/revision/bow/37
Log:
addtion alias for url
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/java/org/chorem/bow/TokenActions.java
trunk/src/main/webapp/WEB-INF/web.xml
trunk/src/main/webapp/home.jsp
trunk/src/main/webapp/login.jsp
trunk/src/main/webapp/openSearchResult.jsp
trunk/src/main/webapp/register.jsp
trunk/src/main/webapp/search.jsp
trunk/src/main/xmi/bow.zargo
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-05-27 15:21:05 UTC (rev 36)
+++ trunk/pom.xml 2010-05-28 12:47:46 UTC (rev 37)
@@ -132,6 +132,16 @@
<build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+
<pluginManagement>
<plugins>
<plugin>
Modified: trunk/src/main/java/org/chorem/bow/BookmarkActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-27 15:21:05 UTC (rev 36)
+++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-28 12:47:46 UTC (rev 37)
@@ -4,7 +4,6 @@
*/
package org.chorem.bow;
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
@@ -58,9 +57,9 @@
export += bookmark.getLink() + "\" ";
Date date = bookmark.getDate();
if (date != null) {
- SimpleDateFormat sdf = new SimpleDateFormat("ss");
- String time = sdf.format(date);
- export += "ADD_DATE=\"" + time + "\" LAST_MODIFIED=\"" + time + "\"";
+ long milli = date.getTime();
+ String time = String.valueOf(milli / 1000);
+ export += "ADD_DATE=\"" + time + "\" LAST_MODIFIED=\"" + time + "\" ";
}
export += "LAST_CHARSET=\"UTF-8\" ";
Set<String> tags = bookmark.getTags();
@@ -126,13 +125,14 @@
bookmark.setClick(0);
bookmark.setEmail(user.getEmail()); // set the email (user name)
bookmark.setDate(new Date()); // set the date
+ bookmark.setAlias("");
return bookmark;
}
public static void addUrlToBookmark(String url, Bookmark bookmark) {
if (url != null && !url.isEmpty()) {
String link = url.trim();
- if (!link.contains("http://")) {
+ if (!link.contains("://")) {
link = "http://" + link;
}
bookmark.setLink(link);
@@ -179,6 +179,7 @@
date = new Date();
}
bookmark.setDate(date); // set the date
+ bookmark.setAlias("");
return bookmark;
}
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-27 15:21:05 UTC (rev 36)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-28 12:47:46 UTC (rev 37)
@@ -32,6 +32,8 @@
import org.htmlparser.util.NodeList;
import org.htmlparser.util.ParserException;
import org.htmlparser.util.SimpleNodeIterator;
+import org.nuiton.util.ApplicationConfig;
+import org.nuiton.util.ArgumentsParserException;
import org.nuiton.wikitty.Criteria;
import org.nuiton.wikitty.WikittyProxy;
import org.nuiton.wikitty.search.Search;
@@ -44,7 +46,16 @@
private static final Log log = LogFactory.getLog(ControllerServlet.class);
protected Model model = new Model();
+ protected String version = "";
+
+ public ControllerServlet() throws ArgumentsParserException {
+ ApplicationConfig config = new ApplicationConfig();
+ config.setConfigFileName("bow.properties");
+ config.parse(new String[]{});
+ version = config.getOption("application.version");
+ }
+
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
@@ -59,6 +70,7 @@
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
try {
+ request.setAttribute("version", version);
HttpSession session = request.getSession(true);
User user = (User) session.getAttribute("user");
String token = request.getParameter("token"); // token or not
@@ -84,7 +96,7 @@
this.actionLogin(request, response, session);
} else if (action.equals("logout")) {
if (log.isDebugEnabled()) {
- log.debug("Going to actionLogin");
+ log.debug("Going to actionLogout");
}
this.actionLogout(request, response, session);
} else if (action.equals("home") && user != null) {
@@ -124,6 +136,11 @@
log.debug("Going to actionDeleteTag");
}
this.actionDeleteTag(request, response, user);
+ } else if (action.equals("addAlias") && user != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Going to actionAddAlias");
+ }
+ this.actionAddAlias(request, response);
} else if (action.equals("removeBookmark") && user != null) {
if (log.isDebugEnabled()) {
log.debug("Going to actionRemoveBookmark");
@@ -186,20 +203,13 @@
this.actionOpenSearchResult(request, response, user, token);
request.getRequestDispatcher("openSearchResult.jsp").forward(request, response);
} else {
- if (log.isDebugEnabled()) {
- log.debug("Going to home");
- }
- request.getRequestDispatcher("login.jsp").forward(request, response);
+ request.getRequestDispatcher("error.jsp").forward(request, response);
}
} else {
- if (log.isDebugEnabled()) {
- log.debug("Going to home");
- }
request.getRequestDispatcher("login.jsp").forward(request, response);
}
} catch (Exception eee) {
- //request.getRequestDispatcher("error.jsp").forward(request, response);
- throw new ServletException("DO GET ERROR", eee);
+ request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
@@ -713,4 +723,30 @@
op.flush();
op.close();
}
+
+ private void actionAddAlias(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
+ String alias = request.getParameter("alias");
+ if (alias != null && !alias.isEmpty()) {
+ WikittyProxy proxy = model.getProxy();
+ Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_ALIAS, alias).criteria();
+ List<Bookmark> bookmarks = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
+ if (bookmarks == null || bookmarks.isEmpty()) {
+ String id = request.getParameter("bookmarkId");
+ if (id != null && !id.isEmpty()) {
+ Bookmark bookmark = proxy.restore(Bookmark.class, id);
+ if (bookmark != null) {
+ bookmark.setAlias(alias);
+ proxy.store(bookmark);
+ }
+ }
+ }
+ }
+ String searchLine = request.getParameter("searchLine");
+ if (searchLine != null) {
+ response.sendRedirect("bow?action=search&searchLine=" + searchLine);
+ } else {
+ response.sendRedirect("bow?action=home");
+ }
+ }
}
Modified: trunk/src/main/java/org/chorem/bow/Model.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/Model.java 2010-05-27 15:21:05 UTC (rev 36)
+++ trunk/src/main/java/org/chorem/bow/Model.java 2010-05-28 12:47:46 UTC (rev 37)
@@ -30,7 +30,7 @@
public void init() {
MultiStorageConfiguration config = new BasicConfiguration();
- this.configureJDBC(config);
+ Model.configureJDBC(config);
WikittyService jdbcStorage = new WikittyServiceMultiStorage(config);
proxy = new WikittyProxy();
Modified: trunk/src/main/java/org/chorem/bow/TokenActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/TokenActions.java 2010-05-27 15:21:05 UTC (rev 36)
+++ trunk/src/main/java/org/chorem/bow/TokenActions.java 2010-05-28 12:47:46 UTC (rev 37)
@@ -27,8 +27,8 @@
public String generateToken()
throws NoSuchAlgorithmException {
- Double rand = Math.random() * 1000000;
- int res = (int) Math.abs(rand); // generate a token between 0 and 1 000 000
+ Double rand = Math.random() * 100000000;
+ int res = (int) Math.abs(rand); // generate a token between 0 and 100 000 000
String tokenGenerated = String.valueOf(res);
tokenGenerated = StringUtil.encodeMD5(tokenGenerated); // encode the token in MD5
return tokenGenerated; // return the generate token
Modified: trunk/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/src/main/webapp/WEB-INF/web.xml 2010-05-27 15:21:05 UTC (rev 36)
+++ trunk/src/main/webapp/WEB-INF/web.xml 2010-05-28 12:47:46 UTC (rev 37)
@@ -8,11 +8,20 @@
<servlet-name>Controller</servlet-name>
</servlet>
- <welcome-file-list>
- <welcome-file>login.jsp</welcome-file>
- </welcome-file-list>
+ <servlet>
+ <servlet-class>org.chorem.bow.AliasServlet</servlet-class>
+ <servlet-name>Alias</servlet-name>
+ </servlet>
+ <welcome-file-list>
+ <welcome-file>bow</welcome-file>
+ </welcome-file-list>
+ <listener>
+ <listener-class>org.chorem.bow.ControllerServlet</listener-class>
+ </listener>
+
+
<!-- SERVLET MAPPING -->
<servlet-mapping>
@@ -20,4 +29,9 @@
<url-pattern>/bow</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Alias</servlet-name>
+ <url-pattern>/alias/*</url-pattern>
+ </servlet-mapping>
+
</web-app>
\ No newline at end of file
Modified: trunk/src/main/webapp/home.jsp
===================================================================
--- trunk/src/main/webapp/home.jsp 2010-05-27 15:21:05 UTC (rev 36)
+++ trunk/src/main/webapp/home.jsp 2010-05-28 12:47:46 UTC (rev 37)
@@ -15,13 +15,10 @@
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("home.jsp");
url = url.substring(0, index);
+ String version = (String) request.getAttribute("version");
%>
<html>
@@ -68,8 +65,12 @@
<td class="result">
<%=sdf.format(bookmark.getDate())%>
</td>
- <td class="result">
- <a href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
+ <td class="result" style="text-align: left">
+ <a href="bow?action=addAlias&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
+ <form method="POST" action="bow?action=addAlias&bookmarkId=<%=bookmark.getWikittyId()%>" style="display: inline">
+ <input type="text" name="alias" size="10" value="<%=bookmark.getAlias()%>" />
+ <input style="display: inline;" type="submit" value="Add alias" />
+ </form>
<form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>">
<input type="text" name="name" size="35" value="<%=bookmark.getDescription()%>" />
<input type="image" src="img/edit.png" title="Edit"/>
@@ -139,9 +140,13 @@
<td class="result">
<%=sdf.format(bookmark.getDate())%>
</td>
- <td class="result">
+ <td class="result" style="text-align: left">
<a href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
- <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>">
+ <form method="POST" action="bow?action=addAlias&bookmarkId=<%=bookmark.getWikittyId()%>" style="display: inline">
+ <input type="text" name="alias" size="10" value="<%=bookmark.getAlias()%>" />
+ <input style="display: inline;" type="submit" value="Add alias" />
+ </form>
+ <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>">
<input type="text" name="name" size="35" value="<%=bookmark.getDescription()%>" />
<input type="image" src="img/edit.png" title="Edit"/>
</form>
@@ -154,7 +159,7 @@
%>
<div style="display: inline">
<a 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" />
+ <IMG style="border:none;" SRC="img/delete.png" ALT="Delete tag" TITLE="Delete" />
</a>
<%=tag%>
</div>
@@ -164,7 +169,7 @@
%>
<form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>">
<input type="text" name="tags" size="35" value="<%=BookmarkActions.getBookmarkTagsString(bookmark)%>" />
- <input type="image" src="img/edit.png" title="Edit"/>
+ <input style="display: inline" type="image" src="img/edit.png" title="Edit"/>
</form>
</td>
<td class="result">
@@ -190,7 +195,7 @@
<li><a href="bow?action=logout">Logout</a></li>
<li><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></li>
<li><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></li>
- <li><a href="bow?action=generateToken&searchLine=<%=searchLine%>">Regenerate permanent token</a></li>
+ <li><a href="bow?action=generateToken">Regenerate permanent token</a></li>
</ul>
</div>
<div class="menu">
@@ -214,13 +219,13 @@
int value = tagsCloud.get(tag);
int font = bookmarkActions.getFont(value);
%>
- <a href="bow?action=search&addTag=<%=tag%>&searchLine=<%=searchLine%>" title="<%=value%> results" class="tag" style="font-size: <%=font%>px;"><%=tag%></a>
+ <a href="bow?action=search&addTag=<%=tag%>" title="<%=value%> results" class="tag" style="font-size: <%=font%>px;"><%=tag%></a>
<%
}
}
%>
<form method="POST" action="bow?action=search" style="text-align: center;margin-left: 20px;">
- <input style="float: left" type="text" name="searchLine" size="15" value="<%=searchLine%>" />
+ <input style="float: left" type="text" name="searchLine" size="15" />
<input style="float: left;" type="submit" value="Find" />
</form>
</div>
@@ -235,5 +240,14 @@
<a href="bow?action=exportBookmarks">Export bookmarks</a>
</div>
</div>
+ <div class="Index" id="footer">
+ <a shape="rect" href="<%=url%>">bow</a>
+ <a shape="rect" href="http://www.chorem.org/projects/list_files/bow"><%=version%></a> -
+ <a shape="rect" href="http://www.gnu.org/licenses/agpl.html">Licence AGPL</a> -
+ <span title="Copyright">©2010</span>
+ <a shape="rect" href="http://www.codelutin.com">Code Lutin</a> -
+ <a shape="rect" href="http://www.chorem.org/projects/bow/issues">Rapport de bug</a> -
+ <a shape="rect" href="http://list.chorem.org/cgi-bin/mailman/listinfo/bow-users">Support utilisateur</a>
+ </div>
</body>
</html>
\ No newline at end of file
Modified: trunk/src/main/webapp/login.jsp
===================================================================
--- trunk/src/main/webapp/login.jsp 2010-05-27 15:21:05 UTC (rev 36)
+++ trunk/src/main/webapp/login.jsp 2010-05-28 12:47:46 UTC (rev 37)
@@ -1,6 +1,8 @@
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
String error = (String) request.getAttribute("msgError");
+ String url = request.getRequestURL().toString();
+ String version = (String) request.getAttribute("version");
%>
<html>
@@ -19,5 +21,14 @@
<%if (error != null) {%>
<font color="red"><%=error%></font>
<%}%>
+ <div class="Index" id="footer">
+ <a shape="rect" href="<%=url%>">bow</a>
+ <a shape="rect" href="http://www.chorem.org/projects/list_files/bow"><%=version%></a> -
+ <a shape="rect" href="http://www.gnu.org/licenses/agpl.html">Licence AGPL</a> -
+ <span title="Copyright">©2010</span>
+ <a shape="rect" href="http://www.codelutin.com">Code Lutin</a> -
+ <a shape="rect" href="http://www.chorem.org/projects/bow/issues">Rapport de bug</a> -
+ <a shape="rect" href="http://list.chorem.org/cgi-bin/mailman/listinfo/bow-users">Support utilisateur</a>
+ </div>
</body>
</html>
\ No newline at end of file
Modified: trunk/src/main/webapp/openSearchResult.jsp
===================================================================
--- trunk/src/main/webapp/openSearchResult.jsp 2010-05-27 15:21:05 UTC (rev 36)
+++ trunk/src/main/webapp/openSearchResult.jsp 2010-05-28 12:47:46 UTC (rev 37)
@@ -74,9 +74,9 @@
</td>
<td class="result">
<%
- Set<String> tagList = bookmark.getTags();
- if (tagList != null && !tagList.isEmpty()) {
- for (String tag : tagList) {
+ Set<String> tagList = bookmark.getTags();
+ if (tagList != null && !tagList.isEmpty()) {
+ for (String tag : tagList) {
%>
<%=tag%>
<%
@@ -84,7 +84,7 @@
%>
</td>
<%
- }
+ }
%>
<td class="result">
<%=bookmark.getClick()%>
@@ -101,5 +101,14 @@
<% }
}
%>
+ <div class="Index" id="footer">
+ <a shape="rect" href="<%=url%>">bow</a>
+ <a shape="rect" href="http://www.chorem.org/projects/list_files/bow"></a> -
+ <a shape="rect" href="http://www.gnu.org/licenses/agpl.html">Licence AGPL</a> -
+ <span title="Copyright">©2009-2010</span>
+ <a shape="rect" href="http://www.codelutin.com">Code Lutin</a> -
+ <a shape="rect" href="http://www.chorem.org/projects/bow/issues">Rapport de bug</a> -
+ <a shape="rect" href="http://list.chorem.org/cgi-bin/mailman/listinfo/bow-users">Support utilisateur</a>
+ </div>
</body>
</html>
\ No newline at end of file
Modified: trunk/src/main/webapp/register.jsp
===================================================================
--- trunk/src/main/webapp/register.jsp 2010-05-27 15:21:05 UTC (rev 36)
+++ trunk/src/main/webapp/register.jsp 2010-05-28 12:47:46 UTC (rev 37)
@@ -1,5 +1,11 @@
<%@page contentType="text/html" pageEncoding="UTF-8"%>
-<%String error = (String) request.getAttribute("msgError");%>
+<%
+ String error = (String) request.getAttribute("msgError");
+ String url = request.getRequestURL().toString();
+ int index = url.indexOf("register.jsp");
+ url = url.substring(0, index);
+ String version = (String) request.getAttribute("version");
+%>
<html>
<link rel="stylesheet" type="text/css" href="./css/styles.css" />
<body>
@@ -12,11 +18,19 @@
<br />
<input type="submit" value="Register">
</form>
- <a href="bow?action=login">Return to the login page</a>
+ <a href="bow">Return to the login page</a>
<br />
<%if (error != null && error.isEmpty() == false) {%>
<font color="red"><%=error%></font>
<%}%>
-
+ <div class="Index" id="footer">
+ <a shape="rect" href="<%=url%>">bow</a>
+ <a shape="rect" href="http://www.chorem.org/projects/list_files/bow"><%=version%></a> -
+ <a shape="rect" href="http://www.gnu.org/licenses/agpl.html">Licence AGPL</a> -
+ <span title="Copyright">©2010</span>
+ <a shape="rect" href="http://www.codelutin.com">Code Lutin</a> -
+ <a shape="rect" href="http://www.chorem.org/projects/bow/issues">Rapport de bug</a> -
+ <a shape="rect" href="http://list.chorem.org/cgi-bin/mailman/listinfo/bow-users">Support utilisateur</a>
+ </div>
</body>
</html>
\ No newline at end of file
Modified: trunk/src/main/webapp/search.jsp
===================================================================
--- trunk/src/main/webapp/search.jsp 2010-05-27 15:21:05 UTC (rev 36)
+++ trunk/src/main/webapp/search.jsp 2010-05-28 12:47:46 UTC (rev 37)
@@ -22,6 +22,7 @@
String url = request.getRequestURL().toString();
int index = url.indexOf("search.jsp");
url = url.substring(0, index);
+ String version = (String) request.getAttribute("version");
%>
<html>
@@ -83,7 +84,11 @@
</td>
<td class="result">
<a href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
- <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>">
+ <form method="POST" action="bow?action=addAlias&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>" style="display: inline">
+ <input type="text" name="alias" size="10" value="<%=bookmark.getAlias()%>" />
+ <input style="display: inline;" type="submit" value="Add alias" />
+ </form>
+ <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>">
<input type="text" name="name" size="35" value="<%=bookmark.getDescription()%>" />
<input type="image" src="img/edit.png" title="Edit"/>
</form>
@@ -104,7 +109,7 @@
}
}
%>
- <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>">
+ <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>">
<input type="text" name="tags" size="35" value="<%=BookmarkActions.getBookmarkTagsString(bookmark)%>" />
<input type="image" src="img/edit.png" title="Edit"/>
</form>
@@ -167,5 +172,14 @@
</div>
</div>
</div>
+ <div class="Index" id="footer">
+ <a shape="rect" href="<%=url%>">bow</a>
+ <a shape="rect" href="http://www.chorem.org/projects/list_files/bow"><%=version%></a> -
+ <a shape="rect" href="http://www.gnu.org/licenses/agpl.html">Licence AGPL</a> -
+ <span title="Copyright">©2010</span>
+ <a shape="rect" href="http://www.codelutin.com">Code Lutin</a> -
+ <a shape="rect" href="http://www.chorem.org/projects/bow/issues">Rapport de bug</a> -
+ <a shape="rect" href="http://list.chorem.org/cgi-bin/mailman/listinfo/bow-users">Support utilisateur</a>
+ </div>
</body>
</html>
\ No newline at end of file
Modified: trunk/src/main/xmi/bow.zargo
===================================================================
(Binary files differ)
1
0
r36 - in trunk/src/main: java/org/chorem/bow webapp webapp/WEB-INF
by bbrossaud@users.chorem.org May 27, 2010
by bbrossaud@users.chorem.org May 27, 2010
May 27, 2010
Author: bbrossaud
Date: 2010-05-27 17:21:05 +0200 (Thu, 27 May 2010)
New Revision: 36
Url: http://chorem.org/repositories/revision/bow/36
Log:
removed bugs and changed the interface
Modified:
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/OpenSearchActions.java
trunk/src/main/webapp/WEB-INF/web.xml
trunk/src/main/webapp/home.jsp
trunk/src/main/webapp/login.jsp
trunk/src/main/webapp/register.jsp
trunk/src/main/webapp/search.jsp
Modified: trunk/src/main/java/org/chorem/bow/BookmarkActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-27 12:29:26 UTC (rev 35)
+++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-27 15:21:05 UTC (rev 36)
@@ -4,6 +4,7 @@
*/
package org.chorem.bow;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
@@ -30,6 +31,22 @@
protected int tmax = -1;
protected int tmin = -1;
+ public static Date getDateFromHtml(String html) {
+ Date date = null;
+ if (html != null) {
+ Pattern p = Pattern.compile("ADD_DATE=\"([^\"]*)\"");
+ Matcher m = p.matcher(html);
+ if (m.find()) {
+ String str = m.group(1);
+ if (str != null && !str.isEmpty()) {
+ long time = Long.valueOf(str) * 1000;
+ date = new Date(time);
+ }
+ }
+ }
+ return date;
+ }
+
public static String getExportHtmlBookmark(List<Bookmark> bookmarks) {
String export = "";
export = "<!DOCTYPE NETSCAPE-Bookmark-file-1>\n"
@@ -39,6 +56,12 @@
for (Bookmark bookmark : bookmarks) {
export += "<DT><A HREF=\"";
export += bookmark.getLink() + "\" ";
+ Date date = bookmark.getDate();
+ if (date != null) {
+ SimpleDateFormat sdf = new SimpleDateFormat("ss");
+ String time = sdf.format(date);
+ export += "ADD_DATE=\"" + time + "\" LAST_MODIFIED=\"" + time + "\"";
+ }
export += "LAST_CHARSET=\"UTF-8\" ";
Set<String> tags = bookmark.getTags();
if (tags != null && !tags.isEmpty()) {
@@ -128,7 +151,7 @@
}
}
- public static Bookmark createBookmark(String url, String name, String tags, User user) {
+ public static Bookmark createBookmark(String url, String name, String tags, User user, Date date) {
Bookmark bookmark = (Bookmark) new BookmarkImpl();
if (name != null) {
name = name.trim();
@@ -152,7 +175,10 @@
}
bookmark.setClick(0);
bookmark.setEmail(user.getEmail()); // set the email (user name)
- bookmark.setDate(new Date()); // set the date
+ if (date == null) {
+ date = new Date();
+ }
+ bookmark.setDate(date); // set the date
return bookmark;
}
@@ -208,6 +234,9 @@
bookmarks.remove(bookmark); // Delete bookmark which doesn't contain the tags from the search field
remove = true;
}
+ } else {
+ bookmarks.remove(bookmark); // Delete bookmark which doesn't contain the tags from the search field
+ remove = true;
}
}
}
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-27 12:29:26 UTC (rev 35)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-27 15:21:05 UTC (rev 36)
@@ -15,7 +15,6 @@
import java.util.Date;
import java.util.Iterator;
import java.util.List;
-import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
@@ -30,7 +29,6 @@
import org.apache.commons.logging.LogFactory;
import org.htmlparser.Node;
import org.htmlparser.Parser;
-import org.htmlparser.filters.TagNameFilter;
import org.htmlparser.util.NodeList;
import org.htmlparser.util.ParserException;
import org.htmlparser.util.SimpleNodeIterator;
@@ -46,7 +44,6 @@
private static final Log log = LogFactory.getLog(ControllerServlet.class);
protected Model model = new Model();
- protected String error = "";
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
@@ -110,7 +107,7 @@
if (log.isDebugEnabled()) {
log.debug("Going to actionExportBookmarks");
}
- this.actionExportBookmarks(request, response, user);
+ this.actionExportBookmarks(response, user);
} else if (action.equals("search") && user != null) {
if (log.isDebugEnabled()) {
log.debug("Going to actionSearch");
@@ -200,7 +197,6 @@
}
request.getRequestDispatcher("login.jsp").forward(request, response);
}
- request.setAttribute("errorMessage", error);
} catch (Exception eee) {
//request.getRequestDispatcher("error.jsp").forward(request, response);
throw new ServletException("DO GET ERROR", eee);
@@ -332,7 +328,11 @@
}
}
String searchLine = request.getParameter("searchLine");
- response.sendRedirect("bow?action=search&searchLine=" + searchLine);
+ if (searchLine != null) {
+ response.sendRedirect("bow?action=search&searchLine=" + searchLine);
+ } else {
+ response.sendRedirect("bow?action=home");
+ }
}
protected void actionRemoveBookmark(HttpServletRequest request, HttpServletResponse response, User user)
@@ -340,10 +340,17 @@
String bookmarkId = request.getParameter("bookmarkId");
if (bookmarkId != null && !bookmarkId.isEmpty()) {
WikittyProxy proxy = model.getProxy();
- proxy.delete(bookmarkId);
+ Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId);
+ if (bookmark != null) {
+ proxy.delete(bookmarkId);
+ }
}
String searchLine = request.getParameter("searchLine");
- response.sendRedirect("bow?action=search&searchLine=" + searchLine);
+ if (searchLine != null) {
+ response.sendRedirect("bow?action=search&searchLine=" + searchLine);
+ } else {
+ response.sendRedirect("bow?action=home");
+ }
}
protected void actionDeleteTag(HttpServletRequest request, HttpServletResponse response, User user)
@@ -361,7 +368,11 @@
}
}
String searchLine = request.getParameter("searchLine");
- response.sendRedirect("bow?action=search&searchLine=" + searchLine);
+ if (searchLine != null) {
+ response.sendRedirect("bow?action=search&searchLine=" + searchLine);
+ } else {
+ response.sendRedirect("bow?action=home");
+ }
}
@@ -416,7 +427,7 @@
Bookmark bookmark = null;
if (name != null) {
String tags = request.getParameter("tags"); // tags
- bookmark = BookmarkActions.createBookmark(url, name, tags, user);
+ bookmark = BookmarkActions.createBookmark(url, name, tags, user, null);
} else {
String nameAndTags = request.getParameter("nameAndTags");
bookmark = BookmarkActions.createBookmark(url, nameAndTags, user);
@@ -513,6 +524,8 @@
String email = request.getParameter("email");
String password = request.getParameter("password");
if (this.checkRegister(email, password)) { // check if all is well
+ String error = "Email and password must be correctly filled";
+ request.setAttribute("msgError", error);
request.getRequestDispatcher("register.jsp").forward(request, response);
} else {
WikittyProxy proxy = model.getProxy();
@@ -548,7 +561,8 @@
request.getRequestDispatcher("home.jsp").forward(request, response);
} else {
- error = "Unknow email or incorrect password";
+ String error = "Unknow email or incorrect password";
+ request.setAttribute("msgError", error);
request.getRequestDispatcher("login.jsp").forward(request, response);
}
}
@@ -607,7 +621,6 @@
}
}
}
- error = "Email and password must be correctly filled";
return true;
}
@@ -647,25 +660,23 @@
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();
if (!item.isFormField()) {
- String fieldName = item.getFieldName();
- log.debug("fieldname={" + fieldName + "}");
- String fileName = item.getName();
- log.debug("fileName={" + fileName + "}");
+ WikittyProxy proxy = model.getProxy();
String content = item.getString();
Parser parser = new Parser(content);
NodeList list = parser.parse(null);
- parseHtmlToBookmarks(list, user);
+ List<Bookmark> bookmarks = new ArrayList<Bookmark>();
+ parseHtmlToBookmarks(list, user, bookmarks);
+ proxy.store(bookmarks);
}
}
}
response.sendRedirect("bow?action=home");
}
- private void parseHtmlToBookmarks(NodeList list, User user)
+ private void parseHtmlToBookmarks(NodeList list, User user, List<Bookmark> bookmarks)
throws ParserException {
if (list != null) {
SimpleNodeIterator it = list.elements();
- WikittyProxy proxy = model.getProxy();
while (it.hasMoreNodes()) {
Node node = it.nextNode();
String plainText = node.toPlainTextString();
@@ -673,20 +684,21 @@
if (text != null && text.contains("A HREF")) {
String url = BookmarkActions.getUrlFromHtml(text);
String tags = BookmarkActions.getTagsFromHtml(text);
- Bookmark bookmark = BookmarkActions.createBookmark(url, plainText, tags, user);
+ Date date = BookmarkActions.getDateFromHtml(text);
+ Bookmark bookmark = BookmarkActions.createBookmark(url, plainText, tags, user, date);
if (bookmark != null) {
- proxy.store(bookmark);
+ bookmarks.add(bookmark);
}
}
NodeList children = node.getChildren();
if (children != null) {
- parseHtmlToBookmarks(children, user);
+ parseHtmlToBookmarks(children, user, bookmarks);
}
}
}
}
- private void actionExportBookmarks(HttpServletRequest request, HttpServletResponse response, User user)
+ private void actionExportBookmarks(HttpServletResponse response, User user)
throws IOException {
WikittyProxy proxy = model.getProxy();
Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria();
@@ -696,7 +708,6 @@
ServletOutputStream op = response.getOutputStream();
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=\"bookmarks.html\"");
- log.debug("export=["+export+"]");
response.setContentLength(buff.length);
op.write(buff, 0, buff.length);
op.flush();
Modified: trunk/src/main/java/org/chorem/bow/OpenSearchActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/OpenSearchActions.java 2010-05-27 12:29:26 UTC (rev 35)
+++ trunk/src/main/java/org/chorem/bow/OpenSearchActions.java 2010-05-27 15:21:05 UTC (rev 36)
@@ -45,14 +45,16 @@
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 && !searchLine.contains(tag)) {
- if (map.containsKey(tag)) {
- Integer count = map.get(tag);
- ++count;
- map.put(tag, count);
- } else {
- map.put(tag, 1);
+ if (tagList != null) {
+ for (String tag : tagList) {
+ if (tag.indexOf(word) == 0 && !searchLine.contains(tag)) {
+ if (map.containsKey(tag)) {
+ Integer count = map.get(tag);
+ ++count;
+ map.put(tag, count);
+ } else {
+ map.put(tag, 1);
+ }
}
}
}
@@ -71,8 +73,10 @@
protected boolean bookmarkHasTag(Bookmark bookmark, String tag) {
Set<String> tagList = bookmark.getTags();
- if (tagList.contains(tag)) {
- return true;
+ if (tagList != null) {
+ if (tagList.contains(tag)) {
+ return true;
+ }
}
return false;
}
Modified: trunk/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/src/main/webapp/WEB-INF/web.xml 2010-05-27 12:29:26 UTC (rev 35)
+++ trunk/src/main/webapp/WEB-INF/web.xml 2010-05-27 15:21:05 UTC (rev 36)
@@ -8,6 +8,11 @@
<servlet-name>Controller</servlet-name>
</servlet>
+ <welcome-file-list>
+ <welcome-file>login.jsp</welcome-file>
+ </welcome-file-list>
+
+
<!-- SERVLET MAPPING -->
<servlet-mapping>
Modified: trunk/src/main/webapp/home.jsp
===================================================================
--- trunk/src/main/webapp/home.jsp 2010-05-27 12:29:26 UTC (rev 35)
+++ trunk/src/main/webapp/home.jsp 2010-05-27 15:21:05 UTC (rev 36)
@@ -36,9 +36,12 @@
List<Bookmark> bookmarkList = bookmarkActions.getBookmarks();
if (!bookmarkList.isEmpty()) {
%>
- <h2 class="result">The most using bookmarks</h2>
+ <h2 class="result">The most used bookmarks</h2>
<table class="result">
<tr class="result">
+ <th class ="result remove">
+ remove
+ </th>
<th class="result date">
Date
</th>
@@ -58,10 +61,19 @@
%>
<tr class="result">
<td class="result">
+ <a style="border:none;" href="bow?action=removeBookmark&bookmarkId=<%=bookmark.getWikittyId()%>">
+ <IMG style="border:none;" SRC="img/remove.png" ALT="Remove bookmark" TITLE="Remove" />
+ </a>
+ </td>
+ <td class="result">
<%=sdf.format(bookmark.getDate())%>
</td>
<td class="result">
<a href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
+ <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>">
+ <input type="text" name="name" size="35" value="<%=bookmark.getDescription()%>" />
+ <input type="image" src="img/edit.png" title="Edit"/>
+ </form>
</td>
<td class="result" style="text-align: left">
<%
@@ -69,13 +81,20 @@
if (tagList != null && !tagList.isEmpty()) {
for (String tag : tagList) {
%>
- <div>
+ <div style="display: inline">
+ <a 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>
<%=tag%>
</div>
<%
}
}
%>
+ <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>">
+ <input type="text" name="tags" size="35" value="<%=BookmarkActions.getBookmarkTagsString(bookmark)%>" />
+ <input type="image" src="img/edit.png" title="Edit"/>
+ </form>
</td>
<td class="result">
<%=bookmark.getClick()%>
@@ -92,6 +111,9 @@
<h2 class="result">The last addition bookmarks</h2>
<table class="result">
<tr class="result">
+ <th class ="result remove">
+ remove
+ </th>
<th class="result date">
Date
</th>
@@ -110,10 +132,19 @@
%>
<tr class="result">
<td class="result">
+ <a style="border:none;" href="bow?action=removeBookmark&bookmarkId=<%=bookmark.getWikittyId()%>">
+ <IMG style="border:none;" SRC="img/remove.png" ALT="Remove bookmark" TITLE="Remove" />
+ </a>
+ </td>
+ <td class="result">
<%=sdf.format(bookmark.getDate())%>
</td>
<td class="result">
<a href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
+ <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>">
+ <input type="text" name="name" size="35" value="<%=bookmark.getDescription()%>" />
+ <input type="image" src="img/edit.png" title="Edit"/>
+ </form>
</td>
<td class="result" style="text-align: left">
<%
@@ -121,13 +152,20 @@
if (tagList != null && !tagList.isEmpty()) {
for (String tag : tagList) {
%>
- <div>
+ <div style="display: inline">
+ <a 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>
<%=tag%>
</div>
<%
}
}
%>
+ <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>">
+ <input type="text" name="tags" size="35" value="<%=BookmarkActions.getBookmarkTagsString(bookmark)%>" />
+ <input type="image" src="img/edit.png" title="Edit"/>
+ </form>
</td>
<td class="result">
<%=bookmark.getClick()%>
Modified: trunk/src/main/webapp/login.jsp
===================================================================
--- trunk/src/main/webapp/login.jsp 2010-05-27 12:29:26 UTC (rev 35)
+++ trunk/src/main/webapp/login.jsp 2010-05-27 15:21:05 UTC (rev 36)
@@ -1,6 +1,6 @@
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
- String error = (String) request.getAttribute("errorMessage");
+ String error = (String) request.getAttribute("msgError");
%>
<html>
@@ -8,13 +8,16 @@
<body>
<h1 class="login">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 />
+ email <input type="text" name="email" size="20">
+ <br />
+ password <input type=password name="password" size="20">
+ <br />
<input type="submit" value="login">
</form>
+ <a href="bow?action=registration">register</a>
+ <br />
<%if (error != null) {%>
<font color="red"><%=error%></font>
<%}%>
- <a href="bow?action=registration">register</a>
</body>
</html>
\ No newline at end of file
Modified: trunk/src/main/webapp/register.jsp
===================================================================
--- trunk/src/main/webapp/register.jsp 2010-05-27 12:29:26 UTC (rev 35)
+++ trunk/src/main/webapp/register.jsp 2010-05-27 15:21:05 UTC (rev 36)
@@ -1,18 +1,22 @@
<%@page contentType="text/html" pageEncoding="UTF-8"%>
-<%String error = (String) request.getAttribute("errorMessage");%>
+<%String error = (String) request.getAttribute("msgError");%>
<html>
<link rel="stylesheet" type="text/css" href="./css/styles.css" />
<body>
<h1 class="login">Register</h1>
<form method="POST" action="bow?action=register">
- email <input type="text" name="email" size="20"><br />
- password <input type=password name="password" size="20"><br />
+ email <input type="text" name="email" size="20">
+ <br />
+ password <input type=password name="password" size="20">
+ <br />
<input type="submit" value="Register">
</form>
- <%if (error != null && error.isEmpty() == false) {%>
- <br/><font color="red"><%=error%></font>
- <%}%>
<a href="bow?action=login">Return to the login page</a>
+ <br />
+ <%if (error != null && error.isEmpty() == false) {%>
+ <font color="red"><%=error%></font>
+ <%}%>
+
</body>
</html>
\ No newline at end of file
Modified: trunk/src/main/webapp/search.jsp
===================================================================
--- trunk/src/main/webapp/search.jsp 2010-05-27 12:29:26 UTC (rev 35)
+++ trunk/src/main/webapp/search.jsp 2010-05-27 15:21:05 UTC (rev 36)
@@ -58,7 +58,6 @@
</a>
</th>
<th class ="result tags">Tags</th>
- <th class="result edit">Edit</th>
<th class=" result click">
Click
<a style="text-decoration:none" href="bow?action=orderAsc&type=click&searchLine=<%=searchLine%>">
@@ -84,6 +83,10 @@
</td>
<td class="result">
<a href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
+ <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>">
+ <input type="text" name="name" size="35" value="<%=bookmark.getDescription()%>" />
+ <input type="image" src="img/edit.png" title="Edit"/>
+ </form>
</td>
<td class="result" style="text-align: left">
<%
@@ -91,7 +94,7 @@
if (tagList != null && !tagList.isEmpty()) {
for (String tag : tagList) {
%>
- <div>
+ <div style="display: inline">
<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>
@@ -101,10 +104,7 @@
}
}
%>
- </td>
- <td class="result">
- <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>">
- <input type="text" name="name" size="35" value="<%=bookmark.getDescription()%>" />
+ <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>">
<input type="text" name="tags" size="35" value="<%=BookmarkActions.getBookmarkTagsString(bookmark)%>" />
<input type="image" src="img/edit.png" title="Edit"/>
</form>
1
0
r35 - in trunk: . src/main/java/org/chorem/bow src/main/webapp
by bbrossaud@users.chorem.org May 27, 2010
by bbrossaud@users.chorem.org May 27, 2010
May 27, 2010
Author: bbrossaud
Date: 2010-05-27 14:29:26 +0200 (Thu, 27 May 2010)
New Revision: 35
Url: http://chorem.org/repositories/revision/bow/35
Log:
bookmarks importation and exportation works in html format
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/webapp/home.jsp
trunk/src/main/webapp/register.jsp
trunk/src/main/webapp/search.jsp
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-05-25 14:21:33 UTC (rev 34)
+++ trunk/pom.xml 2010-05-27 12:29:26 UTC (rev 35)
@@ -83,9 +83,20 @@
<version>1.2.2</version>
</dependency>
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ <version>1.2.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.htmlparser</groupId>
+ <artifactId>htmlparser</artifactId>
+ <version>1.6</version>
+ </dependency>
+
</dependencies>
-
<scm>
<connection>scm:svn:http://svn.chorem.org/svn/bow/trunk</connection>
<developerConnection>scm:svn:http://svn.chorem.org/svn/bow/trunk</developerConnection>
Modified: trunk/src/main/java/org/chorem/bow/BookmarkActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-25 14:21:33 UTC (rev 34)
+++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-27 12:29:26 UTC (rev 35)
@@ -12,6 +12,8 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.nuiton.util.StringUtil;
/**
@@ -23,15 +25,59 @@
protected List<Bookmark> bookmarks = new ArrayList<Bookmark>(); // bookmarks which contain the search tags
protected List<Bookmark> lastBookmarks = new ArrayList<Bookmark>();
protected Map<String, Integer> tagCloud = new HashMap<String, Integer>(); // associate a tag with its frequency
- // among all bookmarks
+ // among all bookmarks
protected List<String> tagsSearch = new ArrayList<String>(); // contains the tags taped in the search field
protected int tmax = -1;
protected int tmin = -1;
+ public static String getExportHtmlBookmark(List<Bookmark> bookmarks) {
+ String export = "";
+ export = "<!DOCTYPE NETSCAPE-Bookmark-file-1>\n"
+ + "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">\n"
+ + "<DL><p>\n";
+ if (bookmarks != null) {
+ for (Bookmark bookmark : bookmarks) {
+ export += "<DT><A HREF=\"";
+ export += bookmark.getLink() + "\" ";
+ export += "LAST_CHARSET=\"UTF-8\" ";
+ Set<String> tags = bookmark.getTags();
+ if (tags != null && !tags.isEmpty()) {
+ export += "SHORTCUTURL=\"" + getBookmarkTagsString(bookmark) + "\"";
+ }
+ export += ">" + bookmark.getDescription() + "</A>\n";
+ }
+ }
+ export += "</DL><p>";
+ return export;
+ }
+ public static String getUrlFromHtml(String html) {
+ String url = "";
+ if (html != null) {
+ Pattern p = Pattern.compile("A HREF=\"([^\"]*)\"");
+ Matcher m = p.matcher(html);
+ if (m.find()) {
+ url = m.group(1);
+ }
+ }
+ return url;
+ }
+
+ public static String getTagsFromHtml(String html) {
+ String tags = "";
+ if (html != null) {
+ Pattern p = Pattern.compile("SHORTCUTURL=\"([^\"]*)\"");
+ Matcher m = p.matcher(html);
+ if (m.find()) {
+ tags = m.group(1);
+ }
+ }
+ return tags;
+ }
+
/* @param url String which contains the bookmark url
* @param nameAndTags String which contains the name and the tags of the
- bookmark separated by '|' ==> name|tag1 tag2...
+ bookmark separated by '|' ==> name|tag1 tag2...
* @param user bookmark user
* @return null if all fields are not correctly filled
* @return Bookmark the website bookmark
@@ -44,23 +90,23 @@
if (nameIndex > 0) {
String name = nameAndTags.substring(0, nameIndex); // get the website name
if (!name.isEmpty()) {
- name = name.trim();
- bookmark.setDescription(name); // set the description (website name)
+ name = name.trim();
+ bookmark.setDescription(name); // set the description (website name)
}
}
-
String tags = nameAndTags;
if (nameIndex >= 0) {
tags = nameAndTags.substring(nameIndex + 1); // get tags, +1 because of '|'
}
- tags = tags.trim();
- String[] tagsTab = tags.split("\\s+"); // put the tags in an array
- for (int i = 0; i < tagsTab.length; ++i) {
- if (!tagsTab[i].isEmpty()) {
- bookmark.addTags(tagsTab[i]); // Added tag for each rank (one tag by rank)
- }
- }
+ addTagsToBookmark(tags, bookmark);
+ addUrlToBookmark(url, bookmark);
+ bookmark.setClick(0);
+ bookmark.setEmail(user.getEmail()); // set the email (user name)
+ bookmark.setDate(new Date()); // set the date
+ return bookmark;
+ }
+ public static void addUrlToBookmark(String url, Bookmark bookmark) {
if (url != null && !url.isEmpty()) {
String link = url.trim();
if (!link.contains("http://")) {
@@ -68,19 +114,26 @@
}
bookmark.setLink(link);
}
- bookmark.setClick(0);
- bookmark.setEmail(user.getEmail()); // set the email (user name)
- bookmark.setDate(new Date()); // set the date
- return bookmark;
}
+ public static void addTagsToBookmark(String tags, Bookmark bookmark) {
+ if (tags != null) {
+ tags = tags.trim();
+ String[] tagsTab = tags.split("\\s+"); // put the tags in an array
+ for (int i = 0; i < tagsTab.length; ++i) {
+ if (!tagsTab[i].isEmpty()) {
+ bookmark.addTags(tagsTab[i]); // Added tag for each rank (one tag by rank)
+ }
+ }
+ }
+ }
+
public static Bookmark createBookmark(String url, String name, String tags, User user) {
Bookmark bookmark = (Bookmark) new BookmarkImpl();
if (name != null) {
name = name.trim();
bookmark.setDescription(name);
- }
- else {
+ } else {
bookmark.setDescription("");
}
if (tags != null && !tags.isEmpty()) {
@@ -142,7 +195,7 @@
defineTValues();
}
- public void deleteBookmarkBySearch() {
+ public void deleteBookmarkBySearch() {
List<Bookmark> bookmarksList = new ArrayList<Bookmark>(bookmarks);
for (Bookmark bookmark : bookmarksList) {
Iterator it = tagsSearch.iterator();
@@ -197,7 +250,7 @@
while (it.hasNext()) {
value = (Integer) it.next();
if (tmax < value) { // search the most tag frequancy
- tmax = value;
+ tmax = value;
}
if (tmin == -1) {
tmin = value;
@@ -250,7 +303,7 @@
bookmarks = newList;
}
- public void setLastBookmarks(List<Bookmark> bookmarksList) {
+ public void setLastBookmarks(List<Bookmark> bookmarksList) {
List<Bookmark> newList = new ArrayList(bookmarksList);
lastBookmarks = newList;
}
@@ -264,8 +317,9 @@
if (tmax > tmin) {
font = (50 * (ti - tmin)) / (tmax - tmin); // get the font size for a tag frequency
}
- if (font < 10)
+ if (font < 10) {
font = 10;
+ }
return font;
}
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-25 14:21:33 UTC (rev 34)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-27 12:29:26 UTC (rev 35)
@@ -12,14 +12,28 @@
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Date;
+import java.util.Iterator;
import java.util.List;
+import javax.servlet.ServletContext;
import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileUploadException;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.htmlparser.Node;
+import org.htmlparser.Parser;
+import org.htmlparser.filters.TagNameFilter;
+import org.htmlparser.util.NodeList;
+import org.htmlparser.util.ParserException;
+import org.htmlparser.util.SimpleNodeIterator;
import org.nuiton.wikitty.Criteria;
import org.nuiton.wikitty.WikittyProxy;
import org.nuiton.wikitty.search.Search;
@@ -87,6 +101,16 @@
log.debug("Going to actionAddUrl");
}
this.actionAddUrl(request, response, user);
+ } else if (action.equals("importBookmarks") && user != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Going to actionImportBookmarks");
+ }
+ this.actionImportBookmarks(request, response, user);
+ } else if (action.equals("exportBookmarks") && user != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Going to actionExportBookmarks");
+ }
+ this.actionExportBookmarks(request, response, user);
} else if (action.equals("search") && user != null) {
if (log.isDebugEnabled()) {
log.debug("Going to actionSearch");
@@ -288,8 +312,8 @@
addSortDescending(Bookmark.FQ_FIELD_CLICK);
bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
}
- BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
- request.setAttribute("bookmarkActions", bookmarkActions);
+ BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
+ request.setAttribute("bookmarkActions", bookmarkActions);
}
}
@@ -606,4 +630,76 @@
}
request.setAttribute("bookmarkActions", bookmarkActions);
}
+
+ private void actionImportBookmarks(HttpServletRequest request, HttpServletResponse response, User user)
+ throws IOException, FileUploadException, ParserException {
+ // Check that we have a file upload request
+ boolean isMultipart = ServletFileUpload.isMultipartContent(request);
+ if (isMultipart == true) {
+ // Create a factory for disk-based file items
+ DiskFileItemFactory factory = new DiskFileItemFactory();
+ // Create a new file upload handler
+ ServletFileUpload upload = new ServletFileUpload(factory);
+ // Process the uploaded items
+ // Parse the request
+ List<FileItem> items = upload.parseRequest(request);
+ Iterator iter = items.iterator();
+ while (iter.hasNext()) {
+ FileItem item = (FileItem) iter.next();
+ if (!item.isFormField()) {
+ String fieldName = item.getFieldName();
+ log.debug("fieldname={" + fieldName + "}");
+ String fileName = item.getName();
+ log.debug("fileName={" + fileName + "}");
+ String content = item.getString();
+ Parser parser = new Parser(content);
+ NodeList list = parser.parse(null);
+ parseHtmlToBookmarks(list, user);
+ }
+ }
+ }
+ response.sendRedirect("bow?action=home");
+ }
+
+ private void parseHtmlToBookmarks(NodeList list, User user)
+ throws ParserException {
+ if (list != null) {
+ SimpleNodeIterator it = list.elements();
+ WikittyProxy proxy = model.getProxy();
+ while (it.hasMoreNodes()) {
+ Node node = it.nextNode();
+ String plainText = node.toPlainTextString();
+ String text = node.getText();
+ if (text != null && text.contains("A HREF")) {
+ String url = BookmarkActions.getUrlFromHtml(text);
+ String tags = BookmarkActions.getTagsFromHtml(text);
+ Bookmark bookmark = BookmarkActions.createBookmark(url, plainText, tags, user);
+ if (bookmark != null) {
+ proxy.store(bookmark);
+ }
+ }
+ NodeList children = node.getChildren();
+ if (children != null) {
+ parseHtmlToBookmarks(children, user);
+ }
+ }
+ }
+ }
+
+ private void actionExportBookmarks(HttpServletRequest request, HttpServletResponse response, User user)
+ throws IOException {
+ WikittyProxy proxy = model.getProxy();
+ Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria();
+ List<Bookmark> bookmarks = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
+ String export = BookmarkActions.getExportHtmlBookmark(bookmarks);
+ byte[] buff = export.getBytes();
+ ServletOutputStream op = response.getOutputStream();
+ response.setContentType("application/octet-stream");
+ response.setHeader("Content-Disposition", "attachment; filename=\"bookmarks.html\"");
+ log.debug("export=["+export+"]");
+ response.setContentLength(buff.length);
+ op.write(buff, 0, buff.length);
+ op.flush();
+ op.close();
+ }
}
Modified: trunk/src/main/webapp/home.jsp
===================================================================
--- trunk/src/main/webapp/home.jsp 2010-05-25 14:21:33 UTC (rev 34)
+++ trunk/src/main/webapp/home.jsp 2010-05-27 12:29:26 UTC (rev 35)
@@ -182,11 +182,20 @@
}
%>
<form method="POST" action="bow?action=search" style="text-align: center;margin-left: 20px;">
- <input style="float: left" type="text" name="searchLine" size="20" value="<%=searchLine%>" />
+ <input style="float: left" type="text" name="searchLine" size="15" value="<%=searchLine%>" />
<input style="float: left;" type="submit" value="Find" />
</form>
</div>
</div>
+ <div class="menu">
+ <form method="post" action="bow?action=importBookmarks" enctype="multipart/form-data">
+ Import Bookmarks
+ <input type="file" name="upfile" />
+ <input type="submit" value="Import"/>
+ </form>
+ <br />
+ <a href="bow?action=exportBookmarks">Export bookmarks</a>
+ </div>
</div>
</body>
</html>
\ No newline at end of file
Modified: trunk/src/main/webapp/register.jsp
===================================================================
--- trunk/src/main/webapp/register.jsp 2010-05-25 14:21:33 UTC (rev 34)
+++ trunk/src/main/webapp/register.jsp 2010-05-27 12:29:26 UTC (rev 35)
@@ -13,6 +13,6 @@
<%if (error != null && error.isEmpty() == false) {%>
<br/><font color="red"><%=error%></font>
<%}%>
- <a href="bow?action=home">Return to the login page</a>
+ <a href="bow?action=login">Return to the login page</a>
</body>
</html>
\ No newline at end of file
Modified: trunk/src/main/webapp/search.jsp
===================================================================
--- trunk/src/main/webapp/search.jsp 2010-05-25 14:21:33 UTC (rev 34)
+++ trunk/src/main/webapp/search.jsp 2010-05-27 12:29:26 UTC (rev 35)
@@ -161,7 +161,7 @@
}
%>
<form method="POST" action="bow?action=search" style="text-align: center;margin-left: 20px;">
- <input style="float: left" type="text" name="searchLine" size="20" value="<%=searchLine%>" />
+ <input style="float: left" type="text" name="searchLine" size="15" value="<%=searchLine%>" />
<input style="float: left" type="submit" value="Find" />
</form>
</div>
1
0
r34 - in trunk/src/main: java/org/chorem/bow webapp webapp/css
by bbrossaud@users.chorem.org May 25, 2010
by bbrossaud@users.chorem.org May 25, 2010
May 25, 2010
Author: bbrossaud
Date: 2010-05-25 16:21:33 +0200 (Tue, 25 May 2010)
New Revision: 34
Url: http://chorem.org/repositories/revision/bow/34
Log:
addition a tag area and a name area for the bookmark addition
Modified:
trunk/src/main/java/org/chorem/bow/BookmarkActions.java
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
trunk/src/main/webapp/css/styles.css
trunk/src/main/webapp/home.jsp
trunk/src/main/webapp/search.jsp
Modified: trunk/src/main/java/org/chorem/bow/BookmarkActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-25 13:16:43 UTC (rev 33)
+++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-25 14:21:33 UTC (rev 34)
@@ -55,11 +55,10 @@
}
tags = tags.trim();
String[] tagsTab = tags.split("\\s+"); // put the tags in an array
- if (tagsTab.length == 0) {
- return null;
- }
for (int i = 0; i < tagsTab.length; ++i) {
- bookmark.addTags(tagsTab[i]); // Added tag for each rank (one tag by rank)
+ if (!tagsTab[i].isEmpty()) {
+ bookmark.addTags(tagsTab[i]); // Added tag for each rank (one tag by rank)
+ }
}
if (url != null && !url.isEmpty()) {
@@ -75,25 +74,50 @@
return bookmark;
}
- 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
+ public static Bookmark createBookmark(String url, String name, String tags, User user) {
+ Bookmark bookmark = (Bookmark) new BookmarkImpl();
+ if (name != null) {
name = name.trim();
- bookmark.setDescription(name); // set the description (website name)
+ bookmark.setDescription(name);
}
+ else {
+ bookmark.setDescription("");
+ }
+ if (tags != null && !tags.isEmpty()) {
+ tags = tags.trim();
+ String[] tagsTab = tags.split("\\s+"); // put the tags in an array
+ for (int i = 0; i < tagsTab.length; ++i) {
+ if (!tagsTab[i].isEmpty()) {
+ bookmark.addTags(tagsTab[i]);
+ }
+ }
+ }
+ if (url != null) {
+ bookmark.setLink(url);
+ } else {
+ bookmark.setLink("");
+ }
+ bookmark.setClick(0);
+ bookmark.setEmail(user.getEmail()); // set the email (user name)
+ bookmark.setDate(new Date()); // set the date
+ return bookmark;
+ }
- String tags = nameAndTags;
- if (nameIndex >= 0) {
- tags = nameAndTags.substring(nameIndex + 1); // get tags, +1 because of '|'
+ public static void updateBookmarkName(Bookmark bookmark, String name) {
+ if (name != null) {
+ name = name.trim();
+ bookmark.setDescription(name);
}
- tags = tags.trim();
- String[] tagsTab = tags.split("\\s+"); // put the tags in an array
- if (tagsTab.length != 0) {
+ }
+
+ public static void updateBookmarkTags(Bookmark bookmark, String tags) {
+ if (tags != null && !tags.isEmpty()) {
+ tags = tags.trim();
+ String[] tagsTab = tags.split("\\s+"); // put the tags in an array
for (int i = 0; i < tagsTab.length; ++i) {
Set<String> tagList = bookmark.getTags();
if (tagList != null) {
- if (!tagList.contains(tagsTab[i])) {
+ if (!tagList.contains(tagsTab[i]) && !tagsTab[i].isEmpty()) {
bookmark.addTags(tagsTab[i]); // Added tag for each rank (one tag by rank)
}
}
@@ -101,6 +125,16 @@
}
}
+ public static String getBookmarkTagsString(Bookmark bookmark) {
+ if (bookmark != null) {
+ Set<String> tags = bookmark.getTags();
+ if (tags != null) {
+ return StringUtil.join(tags, " ", true);
+ }
+ }
+ return "";
+ }
+
public void createTagsCloud() {
tagCloud.clear();
deleteBookmarkBySearch();
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-25 13:16:43 UTC (rev 33)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-25 14:21:33 UTC (rev 34)
@@ -295,16 +295,16 @@
protected void actionEditBookmark(HttpServletRequest request, HttpServletResponse response, User user)
throws IOException, ServletException {
- String nameAndTags = request.getParameter("nameAndTags");
+ String tags = request.getParameter("tags");
+ String name = request.getParameter("name");
String bookmarkId = request.getParameter("bookmarkId");
- if (nameAndTags != null && bookmarkId != null) {
- if (!nameAndTags.isEmpty() && !bookmarkId.isEmpty()) {
- WikittyProxy proxy = model.getProxy();
- Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId);
- if (bookmark != null) {
- BookmarkActions.updateBookmark(bookmark, nameAndTags);
- proxy.store(bookmark);
- }
+ if (bookmarkId != null && !bookmarkId.isEmpty()) {
+ WikittyProxy proxy = model.getProxy();
+ Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId);
+ if (bookmark != null) {
+ BookmarkActions.updateBookmarkName(bookmark, name);
+ BookmarkActions.updateBookmarkTags(bookmark, tags);
+ proxy.store(bookmark);
}
}
String searchLine = request.getParameter("searchLine");
@@ -378,13 +378,25 @@
protected void actionAddUrl(HttpServletRequest request, HttpServletResponse response, User user)
throws IOException, ServletException {
addUrl(request, user);
- response.sendRedirect("bow?action=home");
+ String searchLine = request.getParameter("searchLine");
+ if (searchLine != null) {
+ response.sendRedirect("bow?action=search&searchLine=" + searchLine);
+ } else {
+ response.sendRedirect("bow?action=home");
+ }
}
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);
+ String name = request.getParameter("name");
+ Bookmark bookmark = null;
+ if (name != null) {
+ String tags = request.getParameter("tags"); // tags
+ bookmark = BookmarkActions.createBookmark(url, name, tags, user);
+ } else {
+ String nameAndTags = request.getParameter("nameAndTags");
+ bookmark = BookmarkActions.createBookmark(url, nameAndTags, user);
+ }
if (bookmark != null) {
WikittyProxy proxy = model.getProxy();
proxy.store(bookmark); // store the bookmark if all is Ok
Modified: trunk/src/main/webapp/css/styles.css
===================================================================
--- trunk/src/main/webapp/css/styles.css 2010-05-25 13:16:43 UTC (rev 33)
+++ trunk/src/main/webapp/css/styles.css 2010-05-25 14:21:33 UTC (rev 34)
@@ -1,7 +1,7 @@
table.result {
border:3px solid #6495ed;
border-collapse:collapse;
- width:750px;
+ width:900px;
margin:auto;
}
table.actions {
@@ -22,7 +22,7 @@
}
.edit {
- width:30%;
+ width:36%;
}
.name {
@@ -34,11 +34,11 @@
}
.date {
- width:12%;
+ width:13%;
}
.tags {
- width:19%;
+ width:12%;
}
td.result {
Modified: trunk/src/main/webapp/home.jsp
===================================================================
--- trunk/src/main/webapp/home.jsp 2010-05-25 13:16:43 UTC (rev 33)
+++ trunk/src/main/webapp/home.jsp 2010-05-25 14:21:33 UTC (rev 34)
@@ -159,8 +159,10 @@
<form method="POST" action="bow?action=addUrl">
URL<br />
<input type="text" name="url" size="20" value="URL" /><br />
- Name and Tags<br />
- <input type="text" name="nameAndTags" size="20" value="name|tag1 tag2..." /><br />
+ Name<br />
+ <input type="text" name="name" size="20" value="name" /><br />
+ Tags<br />
+ <input type="text" name="tags" size="20" value="tag1 tag2..." /><br />
<input type="submit" value="add" />
</form>
</div>
Modified: trunk/src/main/webapp/search.jsp
===================================================================
--- trunk/src/main/webapp/search.jsp 2010-05-25 13:16:43 UTC (rev 33)
+++ trunk/src/main/webapp/search.jsp 2010-05-25 14:21:33 UTC (rev 34)
@@ -104,7 +104,8 @@
</td>
<td class="result">
<form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>">
- <input type="text" name="nameAndTags" size="32" value="<%=bookmark.getDescription()%>|tag1 tag2 tag3" />
+ <input type="text" name="name" size="35" value="<%=bookmark.getDescription()%>" />
+ <input type="text" name="tags" size="35" value="<%=BookmarkActions.getBookmarkTagsString(bookmark)%>" />
<input type="image" src="img/edit.png" title="Edit"/>
</form>
</td>
@@ -134,11 +135,13 @@
</ul>
</div>
<div class="menu">
- <form method="POST" action="bow?action=addUrl">
+ <form method="POST" action="bow?action=addUrl&searchLine=<%=searchLine%>">
URL<br />
<input type="text" name="url" size="20" value="URL" /><br />
- Name and Tags<br />
- <input type="text" name="nameAndTags" size="20" value="name|tag1 tag2..." /><br />
+ Name<br />
+ <input type="text" name="name" size="20" value="name" /><br />
+ Tags<br />
+ <input type="text" name="tags" size="20" value="tag1 tag2..." /><br />
<input type="submit" value="add" />
</form>
</div>
@@ -159,7 +162,7 @@
%>
<form method="POST" action="bow?action=search" style="text-align: center;margin-left: 20px;">
<input style="float: left" type="text" name="searchLine" size="20" value="<%=searchLine%>" />
- <input style="float: left;" type="submit" value="Find" />
+ <input style="float: left" type="submit" value="Find" />
</form>
</div>
</div>
1
0
May 25, 2010
Author: bbrossaud
Date: 2010-05-25 15:16:43 +0200 (Tue, 25 May 2010)
New Revision: 33
Url: http://chorem.org/repositories/revision/bow/33
Log:
addition the last bookmarks and the most clickable bookmarks to the home page
Added:
trunk/src/main/webapp/login.jsp
Modified:
trunk/src/main/java/org/chorem/bow/BookmarkActions.java
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
trunk/src/main/webapp/home.jsp
trunk/src/main/webapp/search.jsp
Modified: trunk/src/main/java/org/chorem/bow/BookmarkActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-21 10:13:25 UTC (rev 32)
+++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-25 13:16:43 UTC (rev 33)
@@ -21,6 +21,7 @@
public class BookmarkActions {
protected List<Bookmark> bookmarks = new ArrayList<Bookmark>(); // bookmarks which contain the search tags
+ protected List<Bookmark> lastBookmarks = new ArrayList<Bookmark>();
protected Map<String, Integer> tagCloud = new HashMap<String, Integer>(); // associate a tag with its frequency
// among all bookmarks
protected List<String> tagsSearch = new ArrayList<String>(); // contains the tags taped in the search field
@@ -42,8 +43,10 @@
int nameIndex = nameAndTags.indexOf('|'); // get the index name of the website
if (nameIndex > 0) {
String name = nameAndTags.substring(0, nameIndex); // get the website name
+ if (!name.isEmpty()) {
name = name.trim();
bookmark.setDescription(name); // set the description (website name)
+ }
}
String tags = nameAndTags;
@@ -190,6 +193,16 @@
}
}
+ public void emptySearchline() {
+ List<Bookmark> bookmarkList = new ArrayList<Bookmark>(bookmarks);
+ for (Bookmark bookmark : bookmarkList) {
+ Set<String> tags = bookmark.getTags();
+ if (tags != null && !tags.isEmpty()) {
+ bookmarks.remove(bookmark);
+ }
+ }
+ }
+
public void reset() {
bookmarks.clear();
tagCloud.clear();
@@ -203,6 +216,11 @@
bookmarks = newList;
}
+ public void setLastBookmarks(List<Bookmark> bookmarksList) {
+ List<Bookmark> newList = new ArrayList(bookmarksList);
+ lastBookmarks = newList;
+ }
+
public String getSearchLine() {
return StringUtil.join(tagsSearch, " ", true); // return the search line created with the tags
}
@@ -229,6 +247,10 @@
return bookmarks;
}
+ public List<Bookmark> getLastBookmarks() {
+ return lastBookmarks;
+ }
+
public int getTmin() {
return tmin;
}
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-21 10:13:25 UTC (rev 32)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-25 13:16:43 UTC (rev 33)
@@ -76,6 +76,12 @@
log.debug("Going to actionLogin");
}
this.actionLogout(request, response, session);
+ } else if (action.equals("home") && user != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Going to actionHome.jsp");
+ }
+ this.actionHome(request, user);
+ request.getRequestDispatcher("home.jsp").forward(request, response);
} else if (action.equals("addUrl") && user != null) {
if (log.isDebugEnabled()) {
log.debug("Going to actionAddUrl");
@@ -85,7 +91,7 @@
if (log.isDebugEnabled()) {
log.debug("Going to actionSearch");
}
- this.actionSearch(request, response, user);
+ this.actionSearch(request, user);
request.getRequestDispatcher("search.jsp").forward(request, response);
} else if (action.equals("generateToken") && user != null) {
if (log.isDebugEnabled()) {
@@ -162,13 +168,13 @@
if (log.isDebugEnabled()) {
log.debug("Going to home");
}
- request.getRequestDispatcher("home.jsp").forward(request, response);
+ request.getRequestDispatcher("login.jsp").forward(request, response);
}
} else {
if (log.isDebugEnabled()) {
log.debug("Going to home");
}
- request.getRequestDispatcher("home.jsp").forward(request, response);
+ request.getRequestDispatcher("login.jsp").forward(request, response);
}
request.setAttribute("errorMessage", error);
} catch (Exception eee) {
@@ -183,7 +189,8 @@
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);
+ BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
+ request.setAttribute("bookmarkActions", bookmarkActions);
request.setAttribute("token", token);
}
@@ -212,7 +219,7 @@
protected void actionLogout(HttpServletRequest request, HttpServletResponse response, HttpSession session)
throws IOException, ServletException {
session.invalidate();
- request.getRequestDispatcher("home.jsp").forward(request, response);
+ request.getRequestDispatcher("login.jsp").forward(request, response);
}
protected void actionAddClick(HttpServletRequest request, HttpServletResponse response)
@@ -254,7 +261,8 @@
addSortAscending(Bookmark.FQ_FIELD_CLICK);
bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
}
- createBookmarkActions(request, bookList);
+ BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
+ request.setAttribute("bookmarkActions", bookmarkActions);
}
}
@@ -280,7 +288,8 @@
addSortDescending(Bookmark.FQ_FIELD_CLICK);
bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
}
- createBookmarkActions(request, bookList);
+ BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
+ request.setAttribute("bookmarkActions", bookmarkActions);
}
}
@@ -359,9 +368,7 @@
tokenActions.setPermanentToken("");
}
}
- session.setAttribute("tokenActions", tokenActions);
- String searchLine = request.getParameter("searchLine");
- response.sendRedirect("bow?action=search&searchLine=" + searchLine);
+ response.sendRedirect("bow?action=home");
}
/* @param request servlet request
@@ -371,8 +378,7 @@
protected void actionAddUrl(HttpServletRequest request, HttpServletResponse response, User user)
throws IOException, ServletException {
addUrl(request, user);
- String searchLine = request.getParameter("searchLine");
- response.sendRedirect("bow?action=search&searchLine=" + searchLine);
+ response.sendRedirect("bow?action=home");
}
protected void addUrl(HttpServletRequest request, User user) {
@@ -432,16 +438,22 @@
* @param response servlet response
* @throws ServletException if a servlet error occurs
*/
- protected void actionSearch(HttpServletRequest request, HttpServletResponse response, User user)
+ protected void actionSearch(HttpServletRequest request, User user)
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(); // select all bookmarks by user
- createBookmarkActions(request, bookList);
+ BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
+ String searchLine = bookmarkActions.getSearchLine();
+ if (searchLine.isEmpty()) {
+ bookmarkActions.emptySearchline();
+ }
+ request.setAttribute("bookmarkActions", bookmarkActions);
+
}
- protected void createBookmarkActions(HttpServletRequest request, List<Bookmark> bookList) {
+ protected BookmarkActions 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) {
@@ -453,7 +465,7 @@
bookmarkActions.addTag(tag);
}
bookmarkActions.createTagsCloud(); // create the tags cloud with the new informations
- request.setAttribute("bookmarkActions", bookmarkActions);
+ return bookmarkActions;
}
/* @param request servlet request
@@ -477,8 +489,8 @@
} else {
session.setAttribute("user", login);
initializeToken(session, login);
- actionSearch(request, response, login);
- request.getRequestDispatcher("search.jsp").forward(request, response);
+ actionHome(request, login);
+ request.getRequestDispatcher("home.jsp").forward(request, response);
}
}
}
@@ -496,12 +508,12 @@
if (login != null) {
session.setAttribute("user", login);
initializeToken(session, login);
- actionSearch(request, response, login);
- request.getRequestDispatcher("search.jsp").forward(request, response);
+ actionHome(request, login);
+ request.getRequestDispatcher("home.jsp").forward(request, response);
} else {
error = "Unknow email or incorrect password";
- request.getRequestDispatcher("home.jsp").forward(request, response);
+ request.getRequestDispatcher("login.jsp").forward(request, response);
}
}
@@ -531,7 +543,6 @@
* @return User the user exists
*/
protected User checkLogin(String email, String password) {
-
if (email != null && password != null) {
if (!email.isEmpty() && !password.isEmpty()) {
WikittyProxy proxy = model.getProxy();
@@ -563,4 +574,24 @@
error = "Email and password must be correctly filled";
return true;
}
+
+ private void actionHome(HttpServletRequest request, User user) {
+ 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(); // select all bookmarks by user
+ criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
+ addSortDescending(Bookmark.FQ_FIELD_DATE).setEndIndex(10);
+ List<Bookmark> lastBookmarks = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
+ BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
+ bookList = bookmarkActions.getBookmarks();
+ if (bookList.size() > 10) {
+ bookList = bookmarkActions.getBookmarks().subList(0, 10);
+ bookmarkActions.setBookmarks(bookList);
+ }
+ if (lastBookmarks != null) {
+ bookmarkActions.setLastBookmarks(lastBookmarks);
+ }
+ request.setAttribute("bookmarkActions", bookmarkActions);
+ }
}
Modified: trunk/src/main/webapp/home.jsp
===================================================================
--- trunk/src/main/webapp/home.jsp 2010-05-21 10:13:25 UTC (rev 32)
+++ trunk/src/main/webapp/home.jsp 2010-05-25 13:16:43 UTC (rev 33)
@@ -1,20 +1,190 @@
<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<%@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" %>
+
<%
- String error = (String) request.getAttribute("errorMessage");
+ 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("home.jsp");
+ url = url.substring(0, index);
%>
<html>
<link rel="stylesheet" type="text/css" href="./css/styles.css" />
+ <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>
- <h1 class="login">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>
- <%}%>
- <a href="bow?action=registration">register</a>
+ <div id="table">
+ <h1 class="result">Home</h1>
+ <%
+ if (bookmarkActions != null) {
+ List<Bookmark> bookmarkList = bookmarkActions.getBookmarks();
+ if (!bookmarkList.isEmpty()) {
+ %>
+ <h2 class="result">The most using bookmarks</h2>
+ <table class="result">
+ <tr class="result">
+ <th class="result date">
+ Date
+ </th>
+ <th class="result name">
+ Name
+ </th>
+ <th class ="result tags">
+ Tags
+ </th>
+ <th class=" result click">
+ Click
+ </th>
+ </tr>
+ <%
+ SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
+ for (Bookmark bookmark : bookmarkList) {
+ %>
+ <tr class="result">
+ <td class="result">
+ <%=sdf.format(bookmark.getDate())%>
+ </td>
+ <td class="result">
+ <a href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
+ </td>
+ <td class="result" style="text-align: left">
+ <%
+ Set<String> tagList = bookmark.getTags();
+ if (tagList != null && !tagList.isEmpty()) {
+ for (String tag : tagList) {
+ %>
+ <div>
+ <%=tag%>
+ </div>
+ <%
+ }
+ }
+ %>
+ </td>
+ <td class="result">
+ <%=bookmark.getClick()%>
+ </td>
+ </tr>
+ <%
+ }
+ %>
+ </table>
+ <%
+ List<Bookmark> lastBookmarks = bookmarkActions.getLastBookmarks();
+ if (!lastBookmarks.isEmpty()) {
+ %>
+ <h2 class="result">The last addition bookmarks</h2>
+ <table class="result">
+ <tr class="result">
+ <th class="result date">
+ Date
+ </th>
+ <th class="result name">
+ Name
+ </th>
+ <th class ="result tags">
+ Tags
+ </th>
+ <th class=" result click">
+ Click
+ </th>
+ </tr>
+ <%
+ for (Bookmark bookmark : lastBookmarks) {
+ %>
+ <tr class="result">
+ <td class="result">
+ <%=sdf.format(bookmark.getDate())%>
+ </td>
+ <td class="result">
+ <a href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
+ </td>
+ <td class="result" style="text-align: left">
+ <%
+ Set<String> tagList = bookmark.getTags();
+ if (tagList != null && !tagList.isEmpty()) {
+ for (String tag : tagList) {
+ %>
+ <div>
+ <%=tag%>
+ </div>
+ <%
+ }
+ }
+ %>
+ </td>
+ <td class="result">
+ <%=bookmark.getClick()%>
+ </td>
+ </tr>
+ <%
+ }
+ %>
+ </table>
+ <%
+ }
+ } else {
+ %>
+ <h2 class="result">No Bookmarks</h2>
+ <% }
+ }
+ %>
+ </div>
+ <div id="menu">
+ <div class="menu">
+ <ul id="meta">
+ <li><a href="bow?action=logout">Logout</a></li>
+ <li><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></li>
+ <li><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></li>
+ <li><a href="bow?action=generateToken&searchLine=<%=searchLine%>">Regenerate permanent token</a></li>
+ </ul>
+ </div>
+ <div class="menu">
+ <form method="POST" action="bow?action=addUrl">
+ URL<br />
+ <input type="text" name="url" size="20" value="URL" /><br />
+ Name and Tags<br />
+ <input type="text" name="nameAndTags" size="20" value="name|tag1 tag2..." /><br />
+ <input type="submit" value="add" />
+ </form>
+ </div>
+
+ <div class="menu">
+ <div class="tagCloud">
+ <% if (bookmarkActions != null) {
+ Map<String, Integer> tagsCloud = bookmarkActions.getTagsCloud();
+ Set<String> tags = tagsCloud.keySet();
+ for (String tag : tags) {
+ int value = tagsCloud.get(tag);
+ int font = bookmarkActions.getFont(value);
+ %>
+ <a href="bow?action=search&addTag=<%=tag%>&searchLine=<%=searchLine%>" title="<%=value%> results" class="tag" style="font-size: <%=font%>px;"><%=tag%></a>
+ <%
+ }
+ }
+ %>
+ <form method="POST" action="bow?action=search" style="text-align: center;margin-left: 20px;">
+ <input style="float: left" type="text" name="searchLine" size="20" value="<%=searchLine%>" />
+ <input style="float: left;" type="submit" value="Find" />
+ </form>
+ </div>
+ </div>
+ </div>
</body>
</html>
\ No newline at end of file
Copied: trunk/src/main/webapp/login.jsp (from rev 32, trunk/src/main/webapp/home.jsp)
===================================================================
--- trunk/src/main/webapp/login.jsp (rev 0)
+++ trunk/src/main/webapp/login.jsp 2010-05-25 13:16:43 UTC (rev 33)
@@ -0,0 +1,20 @@
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<%
+ String error = (String) request.getAttribute("errorMessage");
+%>
+
+<html>
+ <link rel="stylesheet" type="text/css" href="./css/styles.css" />
+ <body>
+ <h1 class="login">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>
+ <%}%>
+ <a href="bow?action=registration">register</a>
+ </body>
+</html>
\ No newline at end of file
Modified: trunk/src/main/webapp/search.jsp
===================================================================
--- trunk/src/main/webapp/search.jsp 2010-05-21 10:13:25 UTC (rev 32)
+++ trunk/src/main/webapp/search.jsp 2010-05-25 13:16:43 UTC (rev 33)
@@ -128,9 +128,9 @@
<div class="menu">
<ul id="meta">
<li><a href="bow?action=logout">Logout</a></li>
+ <li><a href="bow?action=home">Home</a></li>
<li><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></li>
<li><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></li>
- <li><a href="bow?action=generateToken&searchLine=<%=searchLine%>">Regenerate permanent token</a></li>
</ul>
</div>
<div class="menu">
1
0
r32 - in trunk/src/main: java/org/chorem/bow webapp webapp/css
by bbrossaud@users.chorem.org May 21, 2010
by bbrossaud@users.chorem.org May 21, 2010
May 21, 2010
Author: bbrossaud
Date: 2010-05-21 12:13:25 +0200 (Fri, 21 May 2010)
New Revision: 32
Url: http://chorem.org/repositories/revision/bow/32
Log:
addition 'http://' to the bookmark adress if it doesn't exist
Modified:
trunk/src/main/java/org/chorem/bow/BookmarkActions.java
trunk/src/main/webapp/css/styles.css
trunk/src/main/webapp/home.jsp
trunk/src/main/webapp/openSearchResult.jsp
trunk/src/main/webapp/register.jsp
trunk/src/main/webapp/search.jsp
Modified: trunk/src/main/java/org/chorem/bow/BookmarkActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-21 08:09:47 UTC (rev 31)
+++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-21 10:13:25 UTC (rev 32)
@@ -61,6 +61,9 @@
if (url != null && !url.isEmpty()) {
String link = url.trim();
+ if (!link.contains("http://")) {
+ link = "http://" + link;
+ }
bookmark.setLink(link);
}
bookmark.setClick(0);
Modified: trunk/src/main/webapp/css/styles.css
===================================================================
--- trunk/src/main/webapp/css/styles.css 2010-05-21 08:09:47 UTC (rev 31)
+++ trunk/src/main/webapp/css/styles.css 2010-05-21 10:13:25 UTC (rev 32)
@@ -89,6 +89,41 @@
width: 80%;
}
+h1.result {
+ font-family:monospace;
+ color:#FF3F42;
+ font-size:1.6em;
+ font-weight:normal;
+ line-height:20px;
+ margin-bottom:20px;
+ margin-left: 5px;
+ margin-right: 5px;
+ text-align: center;
+ background-color: #C5E3F7;
+ border-radius: 30px;
+ -webkit-border-radius: 30px;
+ -moz-border-radius: 30px;
+ -opera-border-radius:30px;
+
+}
+
+h1.login {
+ font-family:monospace;
+ color:#FF3F42;
+ border-bottom: 3px solid #C5E3F7;
+ margin-bottom: 10px;
+}
+
+h2.result {
+ font-family:monospace;
+ color:#FF3F42;
+ font-size:1em;
+ font-weight:normal;
+ line-height:20px;
+ margin-top:50px;
+ text-align: center;
+}
+
div.menu{
margin: 10px;
border-bottom: 1px solid #ccc;
@@ -105,22 +140,13 @@
a {
font-family:monospace;
- /*background-color:#EFF6FF;*/
color:#0078C8;
padding: 0;
margin: 0;
- /*text-decoration:none;*/
- /*border:2px solid;*/
- /*pour avoir un effet "outset" avec IE :*/
- /*border-color:#75CEFF #6495ed #6495ed #75CEFF;*/
-
}
a:hover {
color: #0095f8;
- /*background-color:#D3D3D3;*/
- /*border-color:#696969 #DCDCDC #DCDCDC #696969;*/
-
}
a.tag {
Modified: trunk/src/main/webapp/home.jsp
===================================================================
--- trunk/src/main/webapp/home.jsp 2010-05-21 08:09:47 UTC (rev 31)
+++ trunk/src/main/webapp/home.jsp 2010-05-21 10:13:25 UTC (rev 32)
@@ -4,8 +4,9 @@
%>
<html>
+ <link rel="stylesheet" type="text/css" href="./css/styles.css" />
<body>
- <h1>Login</h1>
+ <h1 class="login">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 />
@@ -14,6 +15,6 @@
<%if (error != null) {%>
<font color="red"><%=error%></font>
<%}%>
- <br/><a href="bow?action=registration">register</a>
+ <a href="bow?action=registration">register</a>
</body>
</html>
\ No newline at end of file
Modified: trunk/src/main/webapp/openSearchResult.jsp
===================================================================
--- trunk/src/main/webapp/openSearchResult.jsp 2010-05-21 08:09:47 UTC (rev 31)
+++ trunk/src/main/webapp/openSearchResult.jsp 2010-05-21 10:13:25 UTC (rev 32)
@@ -22,14 +22,14 @@
%>
<html>
+ <link rel="stylesheet" type="text/css" href="./css/styles.css" />
<body>
- <h1>Result</h1>
+ <h1 class="result">Results</h1>
<% if (bookmarkActions != null) {
List<Bookmark> bookmarkList = bookmarkActions.getBookmarks();
if (!bookmarkList.isEmpty()) {
%>
- <br/><br/>Results:<br/>
<table class="result">
<tr class="result">
<th class="result">
@@ -62,8 +62,8 @@
</th>
</tr>
<%
- SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
- for (Bookmark bookmark : bookmarkList) {
+ SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
+ for (Bookmark bookmark : bookmarkList) {
%>
<tr class="result">
<td class="result">
@@ -89,14 +89,15 @@
<td class="result">
<%=bookmark.getClick()%>
</td>
- <%
- }
- %>
+ </tr>
+ <%
+ }
+ %>
</table>
<%
- } else {
+ } else {
%>
- <br/><br/>No Bookmarks found<br/><br/>
+ <h2 class="result">No Bookmarks found</h2>
<% }
}
%>
Modified: trunk/src/main/webapp/register.jsp
===================================================================
--- trunk/src/main/webapp/register.jsp 2010-05-21 08:09:47 UTC (rev 31)
+++ trunk/src/main/webapp/register.jsp 2010-05-21 10:13:25 UTC (rev 32)
@@ -1,8 +1,9 @@
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%String error = (String) request.getAttribute("errorMessage");%>
<html>
+ <link rel="stylesheet" type="text/css" href="./css/styles.css" />
<body>
- <h1>Register</h1>
+ <h1 class="login">Register</h1>
<form method="POST" action="bow?action=register">
email <input type="text" name="email" size="20"><br />
@@ -12,6 +13,6 @@
<%if (error != null && error.isEmpty() == false) {%>
<br/><font color="red"><%=error%></font>
<%}%>
- <br/><a href="bow?action=home">Return to the login page</a>
+ <a href="bow?action=home">Return to the login page</a>
</body>
</html>
\ No newline at end of file
Modified: trunk/src/main/webapp/search.jsp
===================================================================
--- trunk/src/main/webapp/search.jsp 2010-05-21 08:09:47 UTC (rev 31)
+++ trunk/src/main/webapp/search.jsp 2010-05-21 10:13:25 UTC (rev 32)
@@ -30,12 +30,12 @@
<link rel="search" type="application/opensearchdescription+xml" title="bowPermanentSearchEngine" href="<%=url%>bow?action=permanentXml" />
<body>
<div id="table">
+ <h1 class="result">My Bookmarks</h1>
<%
if (bookmarkActions != null) {
List<Bookmark> bookmarkList = bookmarkActions.getBookmarks();
if (!bookmarkList.isEmpty()) {
%>
- Results:<br/>
<table class="result">
<tr class="result">
<th class="result remove">Remove</th>
@@ -70,8 +70,8 @@
</th>
</tr>
<%
- SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
- for (Bookmark bookmark : bookmarkList) {
+ SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
+ for (Bookmark bookmark : bookmarkList) {
%>
<tr class="result">
<td class="result">
@@ -111,16 +111,17 @@
<td class="result">
<%=bookmark.getClick()%>
</td>
- <%
+ </tr>
+ <%
}
- %>
+ %>
</table>
<%
- }
- } else {
+ } else {
%>
- <br/><br/>No Bookmarks<br/><br/>
+ <h2 class="result">No Bookmarks</h2>
<% }
+ }
%>
</div>
<div id="menu">
@@ -135,9 +136,9 @@
<div class="menu">
<form method="POST" action="bow?action=addUrl">
URL<br />
- <input onclick="this.value=''" type="text" name="url" size="20" value="URL" /><br />
+ <input type="text" name="url" size="20" value="URL" /><br />
Name and Tags<br />
- <input onclick="this.value='|'" type="text" name="nameAndTags" size="20" value="name|tag1 tag2..." /><br />
+ <input type="text" name="nameAndTags" size="20" value="name|tag1 tag2..." /><br />
<input type="submit" value="add" />
</form>
</div>
1
0
May 21, 2010
Author: bbrossaud
Date: 2010-05-21 10:09:47 +0200 (Fri, 21 May 2010)
New Revision: 31
Url: http://chorem.org/repositories/revision/bow/31
Log:
resolved problems with the cirtical actions in the search jsp page
Modified:
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
trunk/src/main/webapp/css/styles.css
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-20 15:11:58 UTC (rev 30)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-21 08:09:47 UTC (rev 31)
@@ -81,39 +81,32 @@
log.debug("Going to actionAddUrl");
}
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);
request.getRequestDispatcher("search.jsp").forward(request, response);
-
} else if (action.equals("generateToken") && user != null) {
if (log.isDebugEnabled()) {
log.debug("Going to actionGenerateToken");
}
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");
@@ -302,12 +295,11 @@
if (bookmark != null) {
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
- createBookmarkActions(request, bookList);
}
}
}
+ String searchLine = request.getParameter("searchLine");
+ response.sendRedirect("bow?action=search&searchLine=" + searchLine);
}
protected void actionRemoveBookmark(HttpServletRequest request, HttpServletResponse response, User user)
@@ -316,12 +308,9 @@
if (bookmarkId != null && !bookmarkId.isEmpty()) {
WikittyProxy proxy = model.getProxy();
proxy.delete(bookmarkId);
- 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) {
- createBookmarkActions(request, bookList);
- }
}
+ String searchLine = request.getParameter("searchLine");
+ response.sendRedirect("bow?action=search&searchLine=" + searchLine);
}
protected void actionDeleteTag(HttpServletRequest request, HttpServletResponse response, User user)
@@ -335,12 +324,11 @@
if (bookmark != null) {
bookmark.removeTags(tag);
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
- createBookmarkActions(request, bookList);
}
}
}
+ String searchLine = request.getParameter("searchLine");
+ response.sendRedirect("bow?action=search&searchLine=" + searchLine);
}
@@ -372,7 +360,8 @@
}
}
session.setAttribute("tokenActions", tokenActions);
- actionSearch(request, response, user);
+ String searchLine = request.getParameter("searchLine");
+ response.sendRedirect("bow?action=search&searchLine=" + searchLine);
}
/* @param request servlet request
@@ -382,7 +371,8 @@
protected void actionAddUrl(HttpServletRequest request, HttpServletResponse response, User user)
throws IOException, ServletException {
addUrl(request, user);
- actionSearch(request, response, user);
+ String searchLine = request.getParameter("searchLine");
+ response.sendRedirect("bow?action=search&searchLine=" + searchLine);
}
protected void addUrl(HttpServletRequest request, User user) {
Modified: trunk/src/main/webapp/css/styles.css
===================================================================
--- trunk/src/main/webapp/css/styles.css 2010-05-20 15:11:58 UTC (rev 30)
+++ trunk/src/main/webapp/css/styles.css 2010-05-21 08:09:47 UTC (rev 31)
@@ -84,8 +84,6 @@
#table {
margin: 0;
padding: 0;
- background-color:#eaf3f9;
- display: inline-block;
float: left;
position: relative;
width: 80%;
1
0
Author: bbrossaud
Date: 2010-05-20 17:11:58 +0200 (Thu, 20 May 2010)
New Revision: 30
Url: http://chorem.org/repositories/revision/bow/30
Log:
addition last search design
Modified:
trunk/src/main/webapp/css/styles.css
trunk/src/main/webapp/search.jsp
Modified: trunk/src/main/webapp/css/styles.css
===================================================================
--- trunk/src/main/webapp/css/styles.css 2010-05-20 09:38:01 UTC (rev 29)
+++ trunk/src/main/webapp/css/styles.css 2010-05-20 15:11:58 UTC (rev 30)
@@ -1,7 +1,7 @@
table.result {
border:3px solid #6495ed;
border-collapse:collapse;
- width:90%;
+ width:750px;
margin:auto;
}
table.actions {
@@ -15,11 +15,34 @@
border:1px dotted #6495ed;
padding:5px;
background-color:#EFF6FF;
- width:15%;
}
+
+.remove {
+ width:5%;
+}
+
+.edit {
+ width:30%;
+}
+
+.name {
+ width:20%;
+}
+
+.click {
+ width:14%;
+}
+
+.date {
+ width:12%;
+}
+
+.tags {
+ width:19%;
+}
+
td.result {
- font-family:sans-serif;
- font-size:80%;
+ font-family:monospace;
border:1px solid #6495ed;
padding:5px;
text-align:center;
@@ -33,7 +56,7 @@
}
div.tagCloud {
- background: #EEEEEE none repeat scroll 0 0;
+ background: #C5E3F7 none repeat scroll 0 0;
max-width: 300px;
min-width: 200px;
padding-bottom: 5px;
@@ -49,37 +72,62 @@
}
#menu {
- list-style-type: none;
margin: 0;
padding: 0;
- text-align: center;
+ float: left;
+ background-color:#eaf3f9;
+ display: inline-block;
+ position: relative;
+ width: 20%;
}
-#menu li {
- display: inline;
+#table {
+ margin: 0;
+ padding: 0;
+ background-color:#eaf3f9;
+ display: inline-block;
+ float: left;
+ position: relative;
+ width: 80%;
}
-#menu a {
+div.menu{
+ margin: 10px;
+ border-bottom: 1px solid #ccc;
+}
+
+#meta{
+ list-style-type: none;
+ padding-left: 0px;
+}
+
+#meta li {
+ margin-bottom: 5px;
+}
+
+a {
font-family:monospace;
- background-color:#EFF6FF;
- color:black;
- text-decoration:none;
- padding:2px;
- border:2px solid;
+ /*background-color:#EFF6FF;*/
+ color:#0078C8;
+ padding: 0;
+ margin: 0;
+ /*text-decoration:none;*/
+ /*border:2px solid;*/
/*pour avoir un effet "outset" avec IE :*/
- border-color:#75CEFF #6495ed #6495ed #75CEFF;
+ /*border-color:#75CEFF #6495ed #6495ed #75CEFF;*/
}
-a.menu:hover {
- background-color:#D3D3D3;
- border-color:#696969 #DCDCDC #DCDCDC #696969;
+a:hover {
+ color: #0095f8;
+ /*background-color:#D3D3D3;*/
+ /*border-color:#696969 #DCDCDC #DCDCDC #696969;*/
}
a.tag {
font-family:monospace;
- color: #EF5252;
+ color: #FF3F42;
margin-left: 2px;
margin-right: 2px;
border-radius: 30px;
Modified: trunk/src/main/webapp/search.jsp
===================================================================
--- trunk/src/main/webapp/search.jsp 2010-05-20 09:38:01 UTC (rev 29)
+++ trunk/src/main/webapp/search.jsp 2010-05-20 15:11:58 UTC (rev 30)
@@ -29,136 +29,139 @@
<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>
- <ul id="menu">
- <li><a href="bow?action=logout">Logout</a></li>
- <li><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></li>
- <li><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></li>
- <li><a href="bow?action=generateToken&searchLine=<%=searchLine%>">Regenerate permanent token</a></li>
- </ul>
- <br/><br/>
-
- <table class="actions">
- <tr>
- <td>
- <div class="tagCloud">
- <% if (bookmarkActions != null) {
- Map<String, Integer> tagsCloud = bookmarkActions.getTagsCloud();
- Set<String> tags = tagsCloud.keySet();
- for (String tag : tags) {
- int value = tagsCloud.get(tag);
- int font = bookmarkActions.getFont(value);
+ <div id="table">
+ <%
+ if (bookmarkActions != null) {
+ List<Bookmark> bookmarkList = bookmarkActions.getBookmarks();
+ if (!bookmarkList.isEmpty()) {
+ %>
+ Results:<br/>
+ <table class="result">
+ <tr class="result">
+ <th class="result remove">Remove</th>
+ <th class="result date">
+ 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&searchLine=<%=searchLine%>">
+ <IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" />
+ </a>
+ </th>
+ <th class="result name">
+ 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&searchLine=<%=searchLine%>">
+ <IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" />
+ </a>
+ </th>
+ <th class ="result tags">Tags</th>
+ <th class="result edit">Edit</th>
+ <th class=" result click">
+ 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&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 class="result">
+ <td class="result">
+ <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>
+ <td class="result">
+ <%=sdf.format(bookmark.getDate())%>
+ </td>
+ <td class="result">
+ <a href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
+ </td>
+ <td class="result" style="text-align: left">
+ <%
+ Set<String> tagList = bookmark.getTags();
+ if (tagList != null && !tagList.isEmpty()) {
+ for (String tag : tagList) {
%>
- <a href="bow?action=search&addTag=<%=tag%>&searchLine=<%=searchLine%>" title="<%=value%> results" class="tag" style="font-size: <%=font%>px;"><%=tag%></a>
+ <div>
+ <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>
+ <%=tag%>
+ </div>
<%
- }
+ }
+ }
%>
- </div>
- <form method="POST" action="bow?action=search" style="text-align: left;margin-left: 20px;">
- <input style="float: left" type="text" name="searchLine" size="20" value="<%=searchLine%>" />
- <input style="float: left;" type="submit" value="Find" />
- </form>
- </td>
- <td>
- <div style="float: right">
- <form method="POST" action="bow?action=addUrl">
- URL <input onclick="this.value=''" type="text" name="url" size="20" value="URL" /><br />
- Name and Tags <input onclick="this.value='|'" type="text" name="nameAndTags" size="20" value="name|tag1 tag2..." /><br />
- <input type="submit" value="add" />
+ </td>
+ <td class="result">
+ <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>">
+ <input type="text" name="nameAndTags" size="32" value="<%=bookmark.getDescription()%>|tag1 tag2 tag3" />
+ <input type="image" src="img/edit.png" title="Edit"/>
</form>
- </div>
- </td>
- </tr>
- </table>
- <%
- List<Bookmark> bookmarkList = bookmarkActions.getBookmarks();
- if (!bookmarkList.isEmpty()) {
- %>
- <br/><br/>Results:<br/>
- <table class="result">
- <tr class="result">
- <th class="result">Remove</th>
- <th class="result">
- 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&searchLine=<%=searchLine%>">
- <IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" />
- </a>
- </th>
- <th class="result">
- 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&searchLine=<%=searchLine%>">
- <IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" />
- </a>
- </th>
- <th class ="result">Tags</th>
- <th class="result">Edit</th>
- <th class="result">
- 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&searchLine=<%=searchLine%>">
- <IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" />
- </a>
- </th>
- </tr>
+ </td>
+ <td class="result">
+ <%=bookmark.getClick()%>
+ </td>
+ <%
+ }
+ %>
+ </table>
<%
- SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
- for (Bookmark bookmark : bookmarkList) {
+ }
+ } else {
%>
- <tr class="result">
- <td class="result">
- <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>
- <td class="result">
- <%=sdf.format(bookmark.getDate())%>
- </td>
- <td class="result">
- <a href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
- </td>
- <td class="result" style="text-align: left">
- <%
- Set<String> tagList = bookmark.getTags();
- if (tagList != null && !tagList.isEmpty()) {
- for (String tag : tagList) {
+ <br/><br/>No Bookmarks<br/><br/>
+ <% }
+ %>
+ </div>
+ <div id="menu">
+ <div class="menu">
+ <ul id="meta">
+ <li><a href="bow?action=logout">Logout</a></li>
+ <li><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></li>
+ <li><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></li>
+ <li><a href="bow?action=generateToken&searchLine=<%=searchLine%>">Regenerate permanent token</a></li>
+ </ul>
+ </div>
+ <div class="menu">
+ <form method="POST" action="bow?action=addUrl">
+ URL<br />
+ <input onclick="this.value=''" type="text" name="url" size="20" value="URL" /><br />
+ Name and Tags<br />
+ <input onclick="this.value='|'" type="text" name="nameAndTags" size="20" value="name|tag1 tag2..." /><br />
+ <input type="submit" value="add" />
+ </form>
+ </div>
+
+ <div class="menu">
+ <div class="tagCloud">
+ <% if (bookmarkActions != null) {
+ Map<String, Integer> tagsCloud = bookmarkActions.getTagsCloud();
+ Set<String> tags = tagsCloud.keySet();
+ for (String tag : tags) {
+ int value = tagsCloud.get(tag);
+ int font = bookmarkActions.getFont(value);
%>
- <div>
- <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>
- <%=tag%>
- </div>
+ <a href="bow?action=search&addTag=<%=tag%>&searchLine=<%=searchLine%>" title="<%=value%> results" class="tag" style="font-size: <%=font%>px;"><%=tag%></a>
<%
- }
- }
+ }
+ }
%>
- </td>
- <td class="result">
- <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 method="POST" action="bow?action=search" style="text-align: center;margin-left: 20px;">
+ <input style="float: left" type="text" name="searchLine" size="20" value="<%=searchLine%>" />
+ <input style="float: left;" type="submit" value="Find" />
</form>
- </td>
- <td class="result">
- <%=bookmark.getClick()%>
- </td>
- <%
- }
- %>
- </table>
- <%
- } else {
- %>
- <br/><br/>No Bookmarks<br/><br/>
- <% }
- }
- %>
+ </div>
+ </div>
+ </div>
</body>
</html>
\ No newline at end of file
1
0
r29 - in trunk: . src/main/webapp src/main/webapp/css src/main/webapp/img
by bbrossaud@users.chorem.org May 20, 2010
by bbrossaud@users.chorem.org May 20, 2010
May 20, 2010
Author: bbrossaud
Date: 2010-05-20 11:38:01 +0200 (Thu, 20 May 2010)
New Revision: 29
Url: http://chorem.org/repositories/revision/bow/29
Log:
addition bow image for opensearch
Added:
trunk/src/main/webapp/img/bow.gif
Modified:
trunk/TODO.txt
trunk/src/main/webapp/css/styles.css
trunk/src/main/webapp/openSearchResult.jsp
trunk/src/main/webapp/permanentXml.jsp
trunk/src/main/webapp/search.jsp
trunk/src/main/webapp/temporaryXml.jsp
Modified: trunk/TODO.txt
===================================================================
--- trunk/TODO.txt 2010-05-19 15:58:07 UTC (rev 28)
+++ trunk/TODO.txt 2010-05-20 09:38:01 UTC (rev 29)
@@ -3,10 +3,10 @@
-> edition, suppression bookmark + tag (14 mai) OK
-> triage multiple(nbre de clics, date d'ajout, Alpha) (14 mai) OK
--> token temporaire (14 mai)
--> completion ==> openSearch(xml)
- ==> meta(ex:<link rel="search" type="application/opensearchdescription+xml" href="/w/opensearch_desc.php" title="Wikip�dia (fr)" />)
+-> token temporaire (14 mai) OK
+-> completion ==> openSearch(xml) OK
+ ==> meta(ex:<link rel="search" type="application/opensearchdescription+xml" href="/w/opensearch_desc.php" title="Wikip�dia (fr)" />) OK
-> le && pour le nuage de tag (11 mai) OK
--> gestion des sessions (14 mai)
--> javascript ==> var script = document.createElement('script');script.src = url;script.type='text/javascript';document.body.appendChild(script); (11 mai) NOK
+-> gestion des sessions (14 mai) OK
+-> javascript ==> (11 mai) OK
-> Mise en forme (28 mai)
\ No newline at end of file
Modified: trunk/src/main/webapp/css/styles.css
===================================================================
--- trunk/src/main/webapp/css/styles.css 2010-05-19 15:58:07 UTC (rev 28)
+++ trunk/src/main/webapp/css/styles.css 2010-05-20 09:38:01 UTC (rev 29)
@@ -4,6 +4,12 @@
width:90%;
margin:auto;
}
+table.actions {
+ border-collapse:collapse;
+ width:90%;
+ margin:auto;
+}
+
th.result {
font-family:monospace;
border:1px dotted #6495ed;
@@ -36,31 +42,29 @@
padding-top: 5px;
margin-bottom: 5px;
text-align: center;
+ border-radius:40px;
-webkit-border-radius:40px;
+ -opera-border-radius:40px;
-moz-border-radius:40px;
- border-radius:40px;
}
-li.search {
- display: inline;
- margin-left: 5px;
- margin-right: 5px;
-}
-
-ul.search {
+#menu {
list-style-type: none;
margin: 0;
padding: 0;
text-align: center;
}
-a.menu {
+#menu li {
+ display: inline;
+}
+
+#menu a {
font-family:monospace;
background-color:#EFF6FF;
color:black;
text-decoration:none;
- text-align:center;
- padding:5px;
+ padding:2px;
border:2px solid;
/*pour avoir un effet "outset" avec IE :*/
border-color:#75CEFF #6495ed #6495ed #75CEFF;
@@ -78,9 +82,10 @@
color: #EF5252;
margin-left: 2px;
margin-right: 2px;
+ border-radius: 30px;
-webkit-border-radius: 30px;
-moz-border-radius: 30px;
- border-radius: 30px;
+ -opera-border-radius:30px;
text-decoration:none;
}
a.tag:hover {
Added: trunk/src/main/webapp/img/bow.gif
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/webapp/img/bow.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/src/main/webapp/openSearchResult.jsp
===================================================================
--- trunk/src/main/webapp/openSearchResult.jsp 2010-05-19 15:58:07 UTC (rev 28)
+++ trunk/src/main/webapp/openSearchResult.jsp 2010-05-20 09:38:01 UTC (rev 29)
@@ -30,9 +30,9 @@
if (!bookmarkList.isEmpty()) {
%>
<br/><br/>Results:<br/>
- <table border="1">
- <tr>
- <th>
+ <table class="result">
+ <tr class="result">
+ <th class="result">
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" />
@@ -41,7 +41,7 @@
<IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" />
</a>
</th>
- <th>
+ <th class="result">
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" />
@@ -50,8 +50,8 @@
<IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" />
</a>
</th>
- <th>Tags</th>
- <th>
+ <th class="result">Tags</th>
+ <th class="result">
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" />
@@ -65,14 +65,14 @@
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
for (Bookmark bookmark : bookmarkList) {
%>
- <tr>
- <td>
+ <tr class="result">
+ <td class="result">
<%=sdf.format(bookmark.getDate())%>
</td>
- <td>
+ <td class="result">
<a href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
</td>
- <td>
+ <td class="result">
<%
Set<String> tagList = bookmark.getTags();
if (tagList != null && !tagList.isEmpty()) {
@@ -86,7 +86,7 @@
<%
}
%>
- <td>
+ <td class="result">
<%=bookmark.getClick()%>
</td>
<%
Modified: trunk/src/main/webapp/permanentXml.jsp
===================================================================
--- trunk/src/main/webapp/permanentXml.jsp 2010-05-19 15:58:07 UTC (rev 28)
+++ trunk/src/main/webapp/permanentXml.jsp 2010-05-20 09:38:01 UTC (rev 29)
@@ -17,7 +17,7 @@
<ShortName>bowPermanentSearchEngine</ShortName>
<Description>bookmarkSearch</Description>
<InputEncoding>inputEncoding</InputEncoding>
- <Image width="16" height="16">data:image/x-icon;base64,imageData</Image>
+ <Image width="16" height="16" type="image/ico"><%=url%>img/bow.gif</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>
Modified: trunk/src/main/webapp/search.jsp
===================================================================
--- trunk/src/main/webapp/search.jsp 2010-05-19 15:58:07 UTC (rev 28)
+++ trunk/src/main/webapp/search.jsp 2010-05-20 09:38:01 UTC (rev 29)
@@ -29,42 +29,50 @@
<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>
- <ul class="search">
- <li style="display: inline;"><a class="menu" href="bow?action=logout">Logout</a></li>
- <li style="display: inline;"><a class="menu" 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></li>
- <li style="display: inline;"><a class="menu" 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></li>
- <li style="display: inline;"><a class="menu" href="bow?action=generateToken&searchLine=<%=searchLine%>">Regenerate permanent token</a></li>
+ <ul id="menu">
+ <li><a href="bow?action=logout">Logout</a></li>
+ <li><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></li>
+ <li><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></li>
+ <li><a href="bow?action=generateToken&searchLine=<%=searchLine%>">Regenerate permanent token</a></li>
</ul>
<br/><br/>
- <div id="searchbox" style="position: absolute; top: 100px; right: 20px;">
- <form method="POST" action="bow?action=addUrl">
- URL <input type="text" name="url" size="20" value="URL" /><br />
- Name and Tags <input type="text" name="nameAndTags" size="20" value="name|tag1 tag2..." /><br />
- <input type="submit" value="add" />
- </form>
- </div>
- <div class="tagCloud">
- <% if (bookmarkActions != null) {
- Map<String, Integer> tagsCloud = bookmarkActions.getTagsCloud();
- Set<String> tags = tagsCloud.keySet();
- for (String tag : tags) {
- int value = tagsCloud.get(tag);
- int font = bookmarkActions.getFont(value);
- %>
- <a href="bow?action=search&addTag=<%=tag%>&searchLine=<%=searchLine%>" class="tag" style="font-size: <%=font%>px;"><%=tag%></a>
- <%
- }
- %>
- </div>
+ <table class="actions">
+ <tr>
+ <td>
+ <div class="tagCloud">
+ <% if (bookmarkActions != null) {
+ Map<String, Integer> tagsCloud = bookmarkActions.getTagsCloud();
+ Set<String> tags = tagsCloud.keySet();
+ for (String tag : tags) {
+ int value = tagsCloud.get(tag);
+ int font = bookmarkActions.getFont(value);
+ %>
+ <a href="bow?action=search&addTag=<%=tag%>&searchLine=<%=searchLine%>" title="<%=value%> results" class="tag" style="font-size: <%=font%>px;"><%=tag%></a>
+ <%
+ }
+ %>
+ </div>
+ <form method="POST" action="bow?action=search" style="text-align: left;margin-left: 20px;">
+ <input style="float: left" type="text" name="searchLine" size="20" value="<%=searchLine%>" />
+ <input style="float: left;" type="submit" value="Find" />
+ </form>
+ </td>
+ <td>
+ <div style="float: right">
+ <form method="POST" action="bow?action=addUrl">
+ URL <input onclick="this.value=''" type="text" name="url" size="20" value="URL" /><br />
+ Name and Tags <input onclick="this.value='|'" type="text" name="nameAndTags" size="20" value="name|tag1 tag2..." /><br />
+ <input type="submit" value="add" />
+ </form>
+ </div>
+ </td>
+ </tr>
+ </table>
<%
List<Bookmark> bookmarkList = bookmarkActions.getBookmarks();
if (!bookmarkList.isEmpty()) {
%>
- <form method="POST" action="bow?action=search" style="text-align: left;margin-left: 20px">
- <input type="text" name="searchLine" size="20" value="<%=searchLine%>" /><br />
- <input type="submit" value="Find" />
- </form>
<br/><br/>Results:<br/>
<table class="result">
<tr class="result">
@@ -100,8 +108,8 @@
</th>
</tr>
<%
- SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
- for (Bookmark bookmark : bookmarkList) {
+ SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
+ for (Bookmark bookmark : bookmarkList) {
%>
<tr class="result">
<td class="result">
@@ -117,9 +125,9 @@
</td>
<td class="result" style="text-align: left">
<%
- Set<String> tagList = bookmark.getTags();
- if (tagList != null && !tagList.isEmpty()) {
- for (String tag : tagList) {
+ Set<String> tagList = bookmark.getTags();
+ if (tagList != null && !tagList.isEmpty()) {
+ for (String tag : tagList) {
%>
<div>
<a style="text-decoration:none" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&deleteTag=<%=tag%>&searchLine=<%=searchLine%>">
@@ -128,8 +136,8 @@
<%=tag%>
</div>
<%
- }
- }
+ }
+ }
%>
</td>
<td class="result">
@@ -142,11 +150,11 @@
<%=bookmark.getClick()%>
</td>
<%
- }
+ }
%>
</table>
<%
- } else {
+ } else {
%>
<br/><br/>No Bookmarks<br/><br/>
<% }
Modified: trunk/src/main/webapp/temporaryXml.jsp
===================================================================
--- trunk/src/main/webapp/temporaryXml.jsp 2010-05-19 15:58:07 UTC (rev 28)
+++ trunk/src/main/webapp/temporaryXml.jsp 2010-05-20 09:38:01 UTC (rev 29)
@@ -17,7 +17,7 @@
<ShortName>bowTemporarySearchEngine</ShortName>
<Description>bookmarkSearch</Description>
<InputEncoding>inputEncoding</InputEncoding>
- <Image width="16" height="16">data:image/x-icon;base64,imageData</Image>
+ <Image width="16" height="16" type="image/ico"><%=url%>img/bow.gif</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>
1
0
r28 - in trunk/src/main: java/org/chorem/bow webapp webapp/css webapp/img
by bbrossaud@users.chorem.org May 19, 2010
by bbrossaud@users.chorem.org May 19, 2010
May 19, 2010
Author: bbrossaud
Date: 2010-05-19 17:58:07 +0200 (Wed, 19 May 2010)
New Revision: 28
Url: http://chorem.org/repositories/revision/bow/28
Log:
better ergonomy for the search page and amelioration of the opensearch suggestion
Added:
trunk/src/main/webapp/img/asc.png
trunk/src/main/webapp/img/desc.png
Removed:
trunk/src/main/webapp/generateToken.jsp
trunk/src/main/webapp/img/asc.png
trunk/src/main/webapp/img/desc.png
Modified:
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/OpenSearchActions.java
trunk/src/main/webapp/css/styles.css
trunk/src/main/webapp/home.jsp
trunk/src/main/webapp/img/delete.png
trunk/src/main/webapp/openSearchResult.jsp
trunk/src/main/webapp/permanentXml.jsp
trunk/src/main/webapp/register.jsp
trunk/src/main/webapp/search.jsp
trunk/src/main/webapp/suggestions.jsp
trunk/src/main/webapp/temporaryXml.jsp
Modified: trunk/src/main/java/org/chorem/bow/BookmarkActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-18 15:26:01 UTC (rev 27)
+++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-19 15:58:07 UTC (rev 28)
@@ -99,6 +99,7 @@
tagCloud.clear();
deleteBookmarkBySearch();
createTagClougByBookmarks();
+ defineTValues();
}
public void deleteBookmarkBySearch() {
@@ -206,8 +207,10 @@
public int getFont(int ti) {
int font = 1;
if (tmax > tmin) {
- font = (15 * (ti - tmin)) / (tmax - tmin); // get the font size for a tag frequency
+ font = (50 * (ti - tmin)) / (tmax - tmin); // get the font size for a tag frequency
}
+ if (font < 10)
+ font = 10;
return font;
}
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-18 15:26:01 UTC (rev 27)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-19 15:58:07 UTC (rev 28)
@@ -10,6 +10,8 @@
*/
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@@ -53,7 +55,6 @@
user = checkToken(token, session);
}
String action = request.getParameter("action");
- response.setContentType("text/html");
if (action != null) {
if (action.equals("register")) {
if (log.isDebugEnabled()) {
@@ -197,16 +198,19 @@
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);
+ List<String> searchLine = new ArrayList<String>(Arrays.asList(words));
+ if (search.charAt(search.length() - 1) == ' ') {
+ searchLine.add("");
+ }
+ openSearchActions.findSuggestions(searchLine);
+ log.debug("result={" + openSearchActions.getJsonResult() + "}");
request.setAttribute("openSearchAction", openSearchActions);
}
}
@@ -441,7 +445,8 @@
protected void actionSearch(HttpServletRequest request, HttpServletResponse response, User user)
throws IOException, ServletException {
WikittyProxy proxy = model.getProxy();
- Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria();
+ 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(); // select all bookmarks by user
createBookmarkActions(request, bookList);
}
Modified: trunk/src/main/java/org/chorem/bow/OpenSearchActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/OpenSearchActions.java 2010-05-18 15:26:01 UTC (rev 27)
+++ trunk/src/main/java/org/chorem/bow/OpenSearchActions.java 2010-05-19 15:58:07 UTC (rev 28)
@@ -23,29 +23,30 @@
protected List<Suggestion> suggestions = new ArrayList<Suggestion>();
protected String[] search = null;
- public void findSuggestions(String[] words) {
- search = words;
+ public void findSuggestions(List<String> searchLine) {
+ int size = searchLine.size();
+ search = searchLine.toArray(new String[size]);
if (!bookmarkList.isEmpty()) {
int i;
- for (i = 0; i < (words.length - 1); ++i) {
+ for (i = 0; i < (search.length - 1); ++i) {
List<Bookmark> newList = new ArrayList<Bookmark>(bookmarkList);
for (Bookmark bookmark : newList) {
- if (!bookmarkHasTag(bookmark, words[i])) {
+ if (!bookmarkHasTag(bookmark, search[i])) {
bookmarkList.remove(bookmark);
}
}
}
- fieldSuggestionList(words[i]);
+ fieldSuggestionList(search[i], searchLine);
}
}
- protected void fieldSuggestionList(String word) {
+ protected void fieldSuggestionList(String word, List<String> searchLine) {
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 (tag.indexOf(word) == 0 && !searchLine.contains(tag)) {
if (map.containsKey(tag)) {
Integer count = map.get(tag);
++count;
Modified: trunk/src/main/webapp/css/styles.css
===================================================================
--- trunk/src/main/webapp/css/styles.css 2010-05-18 15:26:01 UTC (rev 27)
+++ trunk/src/main/webapp/css/styles.css 2010-05-19 15:58:07 UTC (rev 28)
@@ -1,3 +1,89 @@
-test {
+table.result {
+ border:3px solid #6495ed;
+ border-collapse:collapse;
+ width:90%;
+ margin:auto;
+}
+th.result {
+ font-family:monospace;
+ border:1px dotted #6495ed;
+ padding:5px;
+ background-color:#EFF6FF;
+ width:15%;
+}
+td.result {
+ font-family:sans-serif;
+ font-size:80%;
+ border:1px solid #6495ed;
+ padding:5px;
+ text-align:center;
+}
+caption {
+ font-family:sans-serif;
+}
-}
\ No newline at end of file
+a.logout {
+
+}
+
+div.tagCloud {
+ background: #EEEEEE none repeat scroll 0 0;
+ max-width: 300px;
+ min-width: 200px;
+ padding-bottom: 5px;
+ padding-left: 10px;
+ padding-right: 10px;
+ padding-top: 5px;
+ margin-bottom: 5px;
+ text-align: center;
+ -webkit-border-radius:40px;
+ -moz-border-radius:40px;
+ border-radius:40px;
+}
+
+li.search {
+ display: inline;
+ margin-left: 5px;
+ margin-right: 5px;
+}
+
+ul.search {
+ list-style-type: none;
+ margin: 0;
+ padding: 0;
+ text-align: center;
+}
+
+a.menu {
+ font-family:monospace;
+ background-color:#EFF6FF;
+ color:black;
+ text-decoration:none;
+ text-align:center;
+ padding:5px;
+ border:2px solid;
+ /*pour avoir un effet "outset" avec IE :*/
+ border-color:#75CEFF #6495ed #6495ed #75CEFF;
+
+}
+
+a.menu:hover {
+ background-color:#D3D3D3;
+ border-color:#696969 #DCDCDC #DCDCDC #696969;
+
+}
+
+a.tag {
+ font-family:monospace;
+ color: #EF5252;
+ margin-left: 2px;
+ margin-right: 2px;
+ -webkit-border-radius: 30px;
+ -moz-border-radius: 30px;
+ border-radius: 30px;
+ text-decoration:none;
+}
+a.tag:hover {
+ background:#A9BCE1 none repeat scroll 0 0;
+ color:#FFFFFF;
+}
Deleted: trunk/src/main/webapp/generateToken.jsp
===================================================================
--- trunk/src/main/webapp/generateToken.jsp 2010-05-18 15:26:01 UTC (rev 27)
+++ trunk/src/main/webapp/generateToken.jsp 2010-05-19 15:58:07 UTC (rev 28)
@@ -1,25 +0,0 @@
-
-<%@ page import="org.chorem.bow.TokenActions" %>
-
-<%TokenActions tokenActions = (TokenActions) request.getAttribute("tokenActions");
- String token = tokenActions.getToken();
- if (token != null && token.isEmpty() == false) {
-%>
-
-<html>
- <body>
- Use it to add new bookmarks without authentication : <br/><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=<%=token%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);">Session</a>
- <%
- } else {
- %>
- Token not available, try again later ...
- <%
- }
- %>
-
- <br/><br/><a href="bow?action=search">Return to the search page</a>
-
- </body>
-</html>
\ No newline at end of file
Modified: trunk/src/main/webapp/home.jsp
===================================================================
--- trunk/src/main/webapp/home.jsp 2010-05-18 15:26:01 UTC (rev 27)
+++ trunk/src/main/webapp/home.jsp 2010-05-19 15:58:07 UTC (rev 28)
@@ -1,9 +1,6 @@
-
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
String error = (String) request.getAttribute("errorMessage");
- String url = request.getRequestURL().toString();
- int index = url.indexOf("home.jsp");
- url = url.substring(0, index);
%>
<html>
Deleted: trunk/src/main/webapp/img/asc.png
===================================================================
(Binary files differ)
Copied: trunk/src/main/webapp/img/asc.png (from rev 23, trunk/src/main/webapp/img/desc.png)
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/webapp/img/asc.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Modified: trunk/src/main/webapp/img/delete.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/webapp/img/desc.png
===================================================================
(Binary files differ)
Copied: trunk/src/main/webapp/img/desc.png (from rev 23, trunk/src/main/webapp/img/asc.png)
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/webapp/img/desc.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Modified: trunk/src/main/webapp/openSearchResult.jsp
===================================================================
--- trunk/src/main/webapp/openSearchResult.jsp 2010-05-18 15:26:01 UTC (rev 27)
+++ trunk/src/main/webapp/openSearchResult.jsp 2010-05-19 15:58:07 UTC (rev 28)
@@ -1,15 +1,15 @@
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<%@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" %>
-<%@ 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 = "";
Modified: trunk/src/main/webapp/permanentXml.jsp
===================================================================
--- trunk/src/main/webapp/permanentXml.jsp 2010-05-18 15:26:01 UTC (rev 27)
+++ trunk/src/main/webapp/permanentXml.jsp 2010-05-19 15:58:07 UTC (rev 28)
@@ -1,4 +1,5 @@
-<%@ page import="org.chorem.bow.TokenActions" %>
+<%@page contentType="text/xml" pageEncoding="UTF-8"%>
+<%@page import="org.chorem.bow.TokenActions" %>
<%
TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions");
@@ -13,7 +14,7 @@
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
- <ShortName>bowTemporarySearchEngine</ShortName>
+ <ShortName>bowPermanentSearchEngine</ShortName>
<Description>bookmarkSearch</Description>
<InputEncoding>inputEncoding</InputEncoding>
<Image width="16" height="16">data:image/x-icon;base64,imageData</Image>
Modified: trunk/src/main/webapp/register.jsp
===================================================================
--- trunk/src/main/webapp/register.jsp 2010-05-18 15:26:01 UTC (rev 27)
+++ trunk/src/main/webapp/register.jsp 2010-05-19 15:58:07 UTC (rev 28)
@@ -1,4 +1,4 @@
-
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%String error = (String) request.getAttribute("errorMessage");%>
<html>
<body>
@@ -12,6 +12,6 @@
<%if (error != null && error.isEmpty() == false) {%>
<br/><font color="red"><%=error%></font>
<%}%>
- <br/><a href="bow?action=home">Return to the login page<a>
+ <br/><a href="bow?action=home">Return to the login page</a>
</body>
</html>
\ No newline at end of file
Modified: trunk/src/main/webapp/search.jsp
===================================================================
--- trunk/src/main/webapp/search.jsp 2010-05-18 15:26:01 UTC (rev 27)
+++ trunk/src/main/webapp/search.jsp 2010-05-19 15:58:07 UTC (rev 28)
@@ -1,15 +1,15 @@
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<%@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" %>
-<%@ 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" %>
-
<%
TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions");
String temporaryToken = tokenActions.getTemporaryToken();
@@ -25,51 +25,51 @@
%>
<html>
+ <link rel="stylesheet" type="text/css" href="./css/styles.css" />
<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='<%=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='<%=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&searchLine=<%=searchLine%>">Regenerate Permanent Token</a><br/><br/>
+ <ul class="search">
+ <li style="display: inline;"><a class="menu" href="bow?action=logout">Logout</a></li>
+ <li style="display: inline;"><a class="menu" 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></li>
+ <li style="display: inline;"><a class="menu" 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></li>
+ <li style="display: inline;"><a class="menu" href="bow?action=generateToken&searchLine=<%=searchLine%>">Regenerate permanent token</a></li>
+ </ul>
+ <br/><br/>
+ <div id="searchbox" style="position: absolute; top: 100px; right: 20px;">
+ <form method="POST" action="bow?action=addUrl">
+ URL <input type="text" name="url" size="20" value="URL" /><br />
+ Name and Tags <input type="text" name="nameAndTags" size="20" value="name|tag1 tag2..." /><br />
+ <input type="submit" value="add" />
+ </form>
+ </div>
- <h1>Search</h1>
-
- <form method="POST" action="bow?action=addUrl">
- URL <input type="text" name="url" size="20" value="URL" /><br />
- Name and Tags <input type="text" name="nameAndTags" size="20" value="name|tag1 tag2..." /><br />
- <input type="submit" value="add" />
- </form>
-
- <br/><br/><a href="bow?action=generateToken">Generate Token</a><br/><br/>
-
- <form method="POST" action="bow?action=search">
- <input type="text" name="searchLine" size="20" value="<%=searchLine%>" /><br />
- <input type="submit" value="Find" />
- </form>
-
- <% if (bookmarkActions != null) {
- Map<String, Integer> tagsCloud = bookmarkActions.getTagsCloud();
- Set<String> tags = tagsCloud.keySet();
- for (String tag : tags) {
- int value = tagsCloud.get(tag);
- int font = bookmarkActions.getFont(value);
- %>
-
- <FONT SIZE="<%=font%>" ><a href="bow?action=search&addTag=<%=tag%>&searchLine=<%=searchLine%>"><%=tag%></a></FONT>
-
+ <div class="tagCloud">
+ <% if (bookmarkActions != null) {
+ Map<String, Integer> tagsCloud = bookmarkActions.getTagsCloud();
+ Set<String> tags = tagsCloud.keySet();
+ for (String tag : tags) {
+ int value = tagsCloud.get(tag);
+ int font = bookmarkActions.getFont(value);
+ %>
+ <a href="bow?action=search&addTag=<%=tag%>&searchLine=<%=searchLine%>" class="tag" style="font-size: <%=font%>px;"><%=tag%></a>
+ <%
+ }
+ %>
+ </div>
<%
- }
List<Bookmark> bookmarkList = bookmarkActions.getBookmarks();
if (!bookmarkList.isEmpty()) {
%>
+ <form method="POST" action="bow?action=search" style="text-align: left;margin-left: 20px">
+ <input type="text" name="searchLine" size="20" value="<%=searchLine%>" /><br />
+ <input type="submit" value="Find" />
+ </form>
<br/><br/>Results:<br/>
- <table border="1">
- <tr>
- <th>Remove</th>
- <th>
+ <table class="result">
+ <tr class="result">
+ <th class="result">Remove</th>
+ <th class="result">
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" />
@@ -78,7 +78,7 @@
<IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" />
</a>
</th>
- <th>
+ <th class="result">
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" />
@@ -87,9 +87,9 @@
<IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" />
</a>
</th>
- <th>Tags</th>
- <th>Edit</th>
- <th>
+ <th class ="result">Tags</th>
+ <th class="result">Edit</th>
+ <th class="result">
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" />
@@ -103,40 +103,42 @@
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
for (Bookmark bookmark : bookmarkList) {
%>
- <tr>
- <td>
+ <tr class="result">
+ <td class="result">
<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>
- <td>
+ <td class="result">
<%=sdf.format(bookmark.getDate())%>
</td>
- <td>
+ <td class="result">
<a href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
</td>
- <td>
+ <td class="result" style="text-align: left">
<%
Set<String> tagList = bookmark.getTags();
if (tagList != null && !tagList.isEmpty()) {
for (String tag : tagList) {
%>
- <%=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>
+ <div>
+ <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>
+ <%=tag%>
+ </div>
<%
}
}
%>
</td>
- <td>
+ <td class="result">
<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>
+ <td class="result">
<%=bookmark.getClick()%>
</td>
<%
Modified: trunk/src/main/webapp/suggestions.jsp
===================================================================
--- trunk/src/main/webapp/suggestions.jsp 2010-05-18 15:26:01 UTC (rev 27)
+++ trunk/src/main/webapp/suggestions.jsp 2010-05-19 15:58:07 UTC (rev 28)
@@ -1,4 +1,4 @@
-
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="org.chorem.bow.OpenSearchActions" %>
<%@page import="org.chorem.bow.Suggestion" %>
<%@page import="java.util.List" %>
Modified: trunk/src/main/webapp/temporaryXml.jsp
===================================================================
--- trunk/src/main/webapp/temporaryXml.jsp 2010-05-18 15:26:01 UTC (rev 27)
+++ trunk/src/main/webapp/temporaryXml.jsp 2010-05-19 15:58:07 UTC (rev 28)
@@ -1,4 +1,5 @@
-<%@ page import="org.chorem.bow.TokenActions" %>
+<%@page contentType="text/xml" pageEncoding="UTF-8"%>
+<%@page import="org.chorem.bow.TokenActions" %>
<%
TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions");
1
0
r27 - in trunk/src/main: java/org/chorem/bow webapp/WEB-INF
by bbrossaud@users.chorem.org May 18, 2010
by bbrossaud@users.chorem.org May 18, 2010
May 18, 2010
Author: bbrossaud
Date: 2010-05-18 17:26:01 +0200 (Tue, 18 May 2010)
New Revision: 27
Url: http://chorem.org/repositories/revision/bow/27
Log:
deleted useless servlet
Removed:
trunk/src/main/java/org/chorem/bow/OpenSearchXmlServlet.java
Modified:
trunk/src/main/webapp/WEB-INF/web.xml
Deleted: trunk/src/main/java/org/chorem/bow/OpenSearchXmlServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/OpenSearchXmlServlet.java 2010-05-18 15:21:30 UTC (rev 26)
+++ trunk/src/main/java/org/chorem/bow/OpenSearchXmlServlet.java 2010-05-18 15:26:01 UTC (rev 27)
@@ -1,36 +0,0 @@
-/*
- * 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);
- }
-
-}
Modified: trunk/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/src/main/webapp/WEB-INF/web.xml 2010-05-18 15:21:30 UTC (rev 26)
+++ trunk/src/main/webapp/WEB-INF/web.xml 2010-05-18 15:26:01 UTC (rev 27)
@@ -8,11 +8,6 @@
<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>
@@ -20,9 +15,4 @@
<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
1
0
r26 - in trunk: . src/main/java/org/chorem/bow src/main/webapp src/main/webapp/WEB-INF
by bbrossaud@users.chorem.org May 18, 2010
by bbrossaud@users.chorem.org May 18, 2010
May 18, 2010
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
1
0
r25 - in trunk: . src/main/java/org/chorem/bow src/main/webapp
by bbrossaud@users.chorem.org May 14, 2010
by bbrossaud@users.chorem.org May 14, 2010
May 14, 2010
Author: bbrossaud
Date: 2010-05-14 17:09:05 +0200 (Fri, 14 May 2010)
New Revision: 25
Url: http://chorem.org/repositories/revision/bow/25
Log:
Session and temporary token works
Modified:
trunk/TODO.txt
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
trunk/src/main/java/org/chorem/bow/TokenActions.java
trunk/src/main/webapp/search.jsp
Modified: trunk/TODO.txt
===================================================================
--- trunk/TODO.txt 2010-05-14 09:52:06 UTC (rev 24)
+++ trunk/TODO.txt 2010-05-14 15:09:05 UTC (rev 25)
@@ -1,12 +1,12 @@
le 11 mai 2010
A faire pour le vendredi 28 mai:
--> edition, suppression bookmark + tag (14 mai)
--> triage multiple(nbre de clics, date d'ajout, Alpha) (14 mai)
+-> edition, suppression bookmark + tag (14 mai) OK
+-> triage multiple(nbre de clics, date d'ajout, Alpha) (14 mai) OK
-> token temporaire (14 mai)
-> completion ==> openSearch(xml)
==> meta(ex:<link rel="search" type="application/opensearchdescription+xml" href="/w/opensearch_desc.php" title="Wikip�dia (fr)" />)
-> le && pour le nuage de tag (11 mai) OK
--> gestion des sessions
+-> gestion des sessions (14 mai)
-> javascript ==> var script = document.createElement('script');script.src = url;script.type='text/javascript';document.body.appendChild(script); (11 mai) NOK
-> Mise en forme (28 mai)
\ No newline at end of file
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-14 09:52:06 UTC (rev 24)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-14 15:09:05 UTC (rev 25)
@@ -11,13 +11,11 @@
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.List;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.sharengo.wikitty.Criteria;
@@ -33,7 +31,6 @@
private static final Log log = LogFactory.getLog(ControllerServlet.class);
protected Model model = new Model();
protected BookmarkActions bookmarkActions = new BookmarkActions();
- protected User user = null;
protected TokenActions tokenActions = new TokenActions();
protected String error = "";
@@ -50,8 +47,9 @@
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
-// try {
- error = "";
+ try {
+ HttpSession session = request.getSession(true);
+ User user = (User) session.getAttribute("user");
String action = request.getParameter("action");
response.setContentType("text/html");
request.setAttribute("bookmarkActions", bookmarkActions);
@@ -61,7 +59,7 @@
if (log.isDebugEnabled()) {
log.debug("Going to actionRegister");
}
- this.actionRegister(request, response);
+ this.actionRegister(request, response, session);
} else if (action.equals("registration")) {
if (log.isDebugEnabled()) {
if (log.isDebugEnabled()) {
@@ -73,82 +71,90 @@
if (log.isDebugEnabled()) {
log.debug("Going to actionLogin");
}
- this.actionLogin(request, response);
+ this.actionLogin(request, response, session);
+ } else if (action.equals("logout")) {
+ if (log.isDebugEnabled()) {
+ log.debug("Going to actionLogin");
+ }
+ this.actionLogout(request, response, session);
} else if (action.equals("addUrl")) {
if (log.isDebugEnabled()) {
log.debug("Going to actionAddUrl");
}
- this.actionAddUrl(request, response);
+ this.actionAddUrl(request, response, session);
} else if (action.equals("search") && user != null) {
if (log.isDebugEnabled()) {
log.debug("Going to actionSearch");
}
- this.actionSearch(request, response);
+ this.actionSearch(request, response, user);
} else if (action.equals("clickOnTag") && user != null) {
if (log.isDebugEnabled()) {
log.debug("Going to actionClickOnTag");
}
- this.actionClickOnTag(request, response);
+ this.actionClickOnTag(request, response, user);
} else if (action.equals("generateToken") && user != null) {
if (log.isDebugEnabled()) {
log.debug("Going to actionGenerateToken");
}
try {
- this.actionGenerateToken(request, response);
+ this.actionGenerateToken(request, response, user);
} catch (NoSuchAlgorithmException ex) {
log.error("No Such Algorithm", ex);
request.getRequestDispatcher("error.jsp").forward(request, response);
}
- } else if (action.equals("deleteTag")) {
+ } else if (action.equals("deleteTag") && user != null) {
if (log.isDebugEnabled()) {
log.debug("Going to actionDeleteTag");
}
- this.actionDeleteTag(request, response);
- } else if (action.equals("removeBookmark")) {
+ this.actionDeleteTag(request, response, user);
+ } else if (action.equals("removeBookmark") && user != null) {
if (log.isDebugEnabled()) {
log.debug("Going to actionRemoveBookmark");
}
- this.actionRemoveBookmark(request, response);
- } else if (action.equals("editBookmark")) {
+ this.actionRemoveBookmark(request, response, user);
+ } else if (action.equals("editBookmark") && user != null) {
if (log.isDebugEnabled()) {
log.debug("Going to actionEditBookmark");
}
- this.actionEditBookmark(request, response);
- } else if (action.equals("orderAsc")) {
+ this.actionEditBookmark(request, response, user);
+ } else if (action.equals("orderAsc") && user != null) {
if (log.isDebugEnabled()) {
log.debug("Going to actionOrderAsc");
}
- this.actionOrderAsc(request, response);
- } else if (action.equals("orderDesc")) {
+ this.actionOrderAsc(request, response, user);
+ } else if (action.equals("orderDesc") && user != null) {
if (log.isDebugEnabled()) {
log.debug("Going to actionOrderDesc");
}
- this.actionOrderDesc(request, response);
- } else if (action.equals("addClick")) {
+ this.actionOrderDesc(request, response, user);
+ } else if (action.equals("addClick") && user != null) {
if (log.isDebugEnabled()) {
log.debug("Going to actionAddClic");
}
this.actionAddClick(request, response);
} else {
- user = null;
if (log.isDebugEnabled()) {
log.debug("Going to home");
}
request.getRequestDispatcher("home.jsp").forward(request, response);
}
} else {
- user = null;
if (log.isDebugEnabled()) {
log.debug("Going to home");
}
request.getRequestDispatcher("home.jsp").forward(request, response);
}
request.setAttribute("errorMessage", error);
-// } catch (Exception eee) {
-// request.getRequestDispatcher("error.jsp").forward(request, response);
-// }
+ } catch (Exception eee) {
+ request.getRequestDispatcher("error.jsp").forward(request, response);
+ }
}
+ protected void actionLogout(HttpServletRequest request, HttpServletResponse response, HttpSession session)
+ throws IOException, ServletException {
+ session.invalidate();
+ request.getRequestDispatcher("home.jsp").forward(request, response);
+ }
protected void actionAddClick(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
@@ -167,7 +173,7 @@
}
}
- protected void actionOrderAsc(HttpServletRequest request, HttpServletResponse response)
+ protected void actionOrderAsc(HttpServletRequest request, HttpServletResponse response, User user)
throws IOException, ServletException {
String type = request.getParameter("type");
if (type != null && !type.isEmpty()) {
@@ -197,7 +203,7 @@
request.getRequestDispatcher("search.jsp").forward(request, response);
}
- protected void actionOrderDesc(HttpServletRequest request, HttpServletResponse response)
+ protected void actionOrderDesc(HttpServletRequest request, HttpServletResponse response, User user)
throws IOException, ServletException {
String type = request.getParameter("type");
if (type != null && !type.isEmpty()) {
@@ -227,7 +233,7 @@
request.getRequestDispatcher("search.jsp").forward(request, response);
}
- protected void actionEditBookmark(HttpServletRequest request, HttpServletResponse response)
+ protected void actionEditBookmark(HttpServletRequest request, HttpServletResponse response, User user)
throws IOException, ServletException {
String nameAndTags = request.getParameter("nameAndTags");
String bookmarkId = request.getParameter("bookmarkId");
@@ -250,7 +256,7 @@
request.getRequestDispatcher("search.jsp").forward(request, response);
}
- protected void actionRemoveBookmark(HttpServletRequest request, HttpServletResponse response)
+ protected void actionRemoveBookmark(HttpServletRequest request, HttpServletResponse response, User user)
throws IOException, ServletException {
String bookmarkId = request.getParameter("bookmarkId");
if (bookmarkId != null && !bookmarkId.isEmpty()) {
@@ -266,7 +272,7 @@
request.getRequestDispatcher("search.jsp").forward(request, response);
}
- protected void actionDeleteTag(HttpServletRequest request, HttpServletResponse response)
+ protected void actionDeleteTag(HttpServletRequest request, HttpServletResponse response, User user)
throws IOException, ServletException {
String bookmarkId = request.getParameter("bookmarkId");
String tag = request.getParameter("tag");
@@ -294,65 +300,80 @@
* @param response servlet response
* @throws ServletException if a servlet error occurs
*/
- protected void actionGenerateToken(HttpServletRequest request, HttpServletResponse response)
+ protected void actionGenerateToken(HttpServletRequest request, HttpServletResponse response, User user)
throws IOException, ServletException, NoSuchAlgorithmException {
WikittyProxy proxy = model.getProxy();
+ Criteria criteria = Search.query().eq(User.FQ_FIELD_EMAIL, user.getEmail()).criteria();
+ Token currentToken = proxy.findByCriteria(Token.class, criteria);
+ if (currentToken != null) {
+ proxy.delete(currentToken.getWikittyId());
+ }
String token = tokenActions.generateToken(); // Generate an encoding MD5 token
- Criteria criteria = Search.query().eq(Token.FQ_FIELD_TOKEN, token).criteria();
+ 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.setToken(token);
+ tokenActions.setPermanentToken(token);
} else {
- tokenActions.setToken("");
+ tokenActions.setPermanentToken("");
}
- request.getRequestDispatcher("generateToken.jsp").forward(request, response);
+ request.getRequestDispatcher("search.jsp").forward(request, response);
}
/* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet error occurs
*/
- protected void actionAddUrl(HttpServletRequest request, HttpServletResponse response)
+ protected void actionAddUrl(HttpServletRequest request, HttpServletResponse response, HttpSession session)
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);
+ }
+ }
+ }
+
+ protected void addUrl(HttpServletRequest request, User user) {
String url = request.getParameter("url"); // url of the website
String nameAndTags = request.getParameter("nameAndTags"); // name and tags
- String token = request.getParameter("token"); // token or not
- if (url != null && nameAndTags != null) {
- if (user == null) { // If the user is null, it's maybe a bookmark addition by token
- user = checkToken(url, nameAndTags, token);
+ Bookmark bookmark = bookmarkActions.createBookmark(url, nameAndTags, user);
+ if (bookmark != null) {
+ WikittyProxy proxy = model.getProxy();
+ proxy.store(bookmark); // store the bookmark if all is Ok
+ if (log.isDebugEnabled()) {
+ log.debug("Adding URL");
}
- if (user != null) {
- if (!url.isEmpty() && !nameAndTags.isEmpty()) {
- Bookmark bookmark = bookmarkActions.createBookmark(url, nameAndTags, user);
- if (bookmark != null) {
- WikittyProxy proxy = model.getProxy();
- proxy.store(bookmark); // store the bookmark if all is Ok
- if (log.isDebugEnabled()) {
- log.debug("Adding URL");
- }
- if (token == null) {
- this.actionSearch(request, response);
- }
- }
- }
- }
}
}
- /* @param url String which contains the bookmark url
- * @param nameAndTags String which contains the name and the tags of the
- bookmark separated by '|' ==> name|tag1 tag2...
- * @param token String which contains the MD5 encoding token
+
+ protected User checkToken(String token, HttpSession session) {
+ if (checkTemporaryToken(token, session) == true) {
+ User user = (User) session.getAttribute("user");
+ return user;
+ }
+ User user = checkPermanentToken(token);
+ return user;
+ }
+
+
+ /* @param token String which contains the MD5 encoding token
* @return null the token doesn't exist
* @return User the token owner
*/
- protected User checkToken(String url, String nameAndTags, String token) {
- if (url != null && nameAndTags != null && token != null) {
+ protected User checkPermanentToken(String token) {
+ if (token != null) {
WikittyProxy proxy = model.getProxy();
Criteria criteria = Search.query().eq(Token.FQ_FIELD_TOKEN, token).criteria();
Token DbToken = proxy.findByCriteria(Token.class, criteria);
@@ -365,11 +386,22 @@
return null;
}
+ protected boolean checkTemporaryToken(String token, HttpSession session) {
+ String temporaryToken = (String) session.getAttribute("temporaryToken");
+ 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)
+ protected void actionClickOnTag(HttpServletRequest request, HttpServletResponse response, User user)
throws IOException, ServletException {
WikittyProxy proxy = model.getProxy();
String tag = request.getParameter("tag");
@@ -393,7 +425,7 @@
* @param response servlet response
* @throws ServletException if a servlet error occurs
*/
- protected void actionSearch(HttpServletRequest request, HttpServletResponse response)
+ 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
@@ -418,8 +450,8 @@
* @param response servlet response
* @throws ServletException if a servlet error occurs
*/
- protected void actionRegister(HttpServletRequest request, HttpServletResponse response)
- throws IOException, ServletException {
+ protected void actionRegister(HttpServletRequest request, HttpServletResponse response, HttpSession session)
+ throws IOException, ServletException, NoSuchAlgorithmException {
String email = request.getParameter("email");
String password = request.getParameter("password");
if (this.checkRegister(email, password)) { // check if all is well
@@ -429,12 +461,25 @@
UserImpl newUser = new UserImpl();
newUser.setPassword(request.getParameter("password"));
newUser.setEmail(request.getParameter("email"));
- this.user = proxy.store((User) newUser); // store the new user
- if (user == null) {
+ User login = proxy.store((User) newUser); // store the new user
+ if (login == null) {
request.getRequestDispatcher("error.jsp").forward(request, response);
} else {
- this.actionSearch(request, response);
- error="Email already exist";
+ 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);
}
}
}
@@ -443,15 +488,29 @@
* @param response servlet response
* @throws ServletException if a servlet error occurs
*/
- protected void actionLogin(HttpServletRequest request, HttpServletResponse response)
- throws IOException, ServletException {
+ protected void actionLogin(HttpServletRequest request, HttpServletResponse response, HttpSession session)
+ throws IOException, ServletException, NoSuchAlgorithmException {
String email = request.getParameter("email");
String password = request.getParameter("password");
User login = this.checkLogin(email, password); // check if the user exists
if (login != null) {
- this.user = login;
- this.actionSearch(request, response);
+ 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);
} else {
error = "Unknow email or incorrect password";
request.getRequestDispatcher("home.jsp").forward(request, response);
@@ -497,11 +556,4 @@
return true;
}
- public void setUser(User user) {
- this.user = user;
- }
-
- public User getUser() {
- return user;
- }
}
Modified: trunk/src/main/java/org/chorem/bow/TokenActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/TokenActions.java 2010-05-14 09:52:06 UTC (rev 24)
+++ trunk/src/main/java/org/chorem/bow/TokenActions.java 2010-05-14 15:09:05 UTC (rev 25)
@@ -14,12 +14,17 @@
public class TokenActions {
- String token = "";
+ String temporaryToken = "";
+ String permanentToken = "";
- public String getToken() {
- return token;
+ public String getPermanentToken() {
+ return permanentToken;
}
+ public String getTemporaryToken() {
+ return temporaryToken;
+ }
+
public String generateToken()
throws NoSuchAlgorithmException {
Double rand = Math.random() * 1000000;
@@ -29,7 +34,11 @@
return tokenGenerated; // return the generate token
}
- public void setToken(String token) {
- this.token = token;
+ public void setPermanentToken(String token) {
+ permanentToken = token;
}
+
+ public void setTemporaryToken(String token) {
+ temporaryToken = token;
+ }
}
Modified: trunk/src/main/webapp/search.jsp
===================================================================
--- trunk/src/main/webapp/search.jsp 2010-05-14 09:52:06 UTC (rev 24)
+++ trunk/src/main/webapp/search.jsp 2010-05-14 15:09:05 UTC (rev 25)
@@ -8,12 +8,25 @@
<%@ 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");%>
+<%
+ TokenActions tokenActions = (TokenActions) request.getAttribute("tokenActions");
+ String temporaryToken = tokenActions.getTemporaryToken();
+ String permanentToken = tokenActions.getPermanentToken();
+ BookmarkActions bookmarkActions = (BookmarkActions) request.getAttribute("bookmarkActions");
+%>
+
<html>
<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>
+ <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>
+ <br/>
+ <a href="bow?action=generateToken">Generate Permanent Token</a><br/><br/>
+
<h1>Search</h1>
<form method="POST" action="bow?action=addUrl">
@@ -106,7 +119,7 @@
<IMG style="border:none" SRC="img/delete.png" ALT="Delete tag" TITLE="Delete" />
</a>
<%
- }
+ }
%>
</td>
<td>
1
0
r24 - in trunk/src/main: java/org/chorem/bow resources webapp xmi
by bbrossaud@users.chorem.org May 14, 2010
by bbrossaud@users.chorem.org May 14, 2010
May 14, 2010
Author: bbrossaud
Date: 2010-05-14 11:52:06 +0200 (Fri, 14 May 2010)
New Revision: 24
Url: http://chorem.org/repositories/revision/bow/24
Log:
the count of the click works
Modified:
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/resources/wikitty-jdbc-config.properties
trunk/src/main/webapp/search.jsp
trunk/src/main/xmi/bow.zargo
Modified: trunk/src/main/java/org/chorem/bow/BookmarkActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-12 15:38:56 UTC (rev 23)
+++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-14 09:52:06 UTC (rev 24)
@@ -63,6 +63,7 @@
String link = url.trim();
bookmark.setLink(link);
}
+ bookmark.setClick(0);
bookmark.setEmail(user.getEmail()); // set the email (user name)
bookmark.setDate(new Date()); // set the date
return bookmark;
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-12 15:38:56 UTC (rev 23)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-14 09:52:06 UTC (rev 24)
@@ -124,6 +124,11 @@
log.debug("Going to actionOrderDesc");
}
this.actionOrderDesc(request, response);
+ } else if (action.equals("addClick")) {
+ if (log.isDebugEnabled()) {
+ log.debug("Going to actionAddClic");
+ }
+ this.actionAddClick(request, response);
} else {
user = null;
if (log.isDebugEnabled()) {
@@ -145,6 +150,23 @@
}
+ protected void actionAddClick(HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
+ String bookmarkId = request.getParameter("bookmarkId");
+ if (bookmarkId != null && !bookmarkId.isEmpty()) {
+ WikittyProxy proxy = model.getProxy();
+ Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId);
+ if (bookmark != null) {
+ int click = bookmark.getClick();
+ ++click;
+ bookmark.setClick(click);
+ proxy.store(bookmark);
+ String url = bookmark.getLink();
+ response.sendRedirect(url);
+ }
+ }
+ }
+
protected void actionOrderAsc(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String type = request.getParameter("type");
@@ -161,6 +183,11 @@
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().
+ 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);
@@ -186,6 +213,11 @@
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().
+ 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);
Modified: trunk/src/main/java/org/chorem/bow/Model.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/Model.java 2010-05-12 15:38:56 UTC (rev 23)
+++ trunk/src/main/java/org/chorem/bow/Model.java 2010-05-14 09:52:06 UTC (rev 24)
@@ -24,7 +24,7 @@
protected WikittyProxy proxy = null;
Model() {
- System.setProperty("solr.data.dir", System.getProperty("user.home") + "/databases/bow/solr");
+ System.setProperty("solr.data.dir", System.getProperty("user.home") + "/.bow/solr");
this.init();
}
Modified: trunk/src/main/resources/wikitty-jdbc-config.properties
===================================================================
--- trunk/src/main/resources/wikitty-jdbc-config.properties 2010-05-12 15:38:56 UTC (rev 23)
+++ trunk/src/main/resources/wikitty-jdbc-config.properties 2010-05-14 09:52:06 UTC (rev 24)
@@ -1,5 +1,5 @@
#Connection parameters
jdbc.con.driver=org.h2.Driver
-jdbc.con.host=jdbc:h2:file:/home/bbrossaud/projets/bow/solr
+jdbc.con.host=jdbc:h2:file:~/.bow/localdb/localdb
jdbc.con.userName=sa
jdbc.con.password=
Modified: trunk/src/main/webapp/search.jsp
===================================================================
--- trunk/src/main/webapp/search.jsp 2010-05-12 15:38:56 UTC (rev 23)
+++ trunk/src/main/webapp/search.jsp 2010-05-14 09:52:06 UTC (rev 24)
@@ -1,6 +1,8 @@
+
+<%@ page import="org.chorem.bow.Bookmark" %>
<%@ page import="org.chorem.bow.BookmarkActions" %>
-<%@ page import="org.chorem.bow.Bookmark" %>
<%@ 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" %>
@@ -49,7 +51,7 @@
<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" >
<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">
@@ -67,8 +69,18 @@
</th>
<th>Tags</th>
<th>Edit</th>
+ <th>
+ Click
+ <a style="text-decoration:none" href="bow?action=orderAsc&type=click">
+ <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">
+ <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>
@@ -78,10 +90,10 @@
</a>
</td>
<td>
- <%=bookmark.getDate()%>
+ <%=sdf.format(bookmark.getDate())%>
</td>
<td>
- <a href="<%=bookmark.getLink()%>"><%=bookmark.getDescription()%></a>
+ <a href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a>
</td>
<td>
<%
@@ -100,12 +112,15 @@
<td>
<form style="display: inline" method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>">
<input type="text" name="nameAndTags" size="50" value="<%=bookmark.getDescription()%>|tag1 tag2 tag3" />
- <input type="image" src="img/edit.png" value="edit" />
+ <input type="image" src="img/edit.png" title="Edit"/>
</form>
</td>
<%
}
%>
+ <td>
+ <%=bookmark.getClick()%>
+ </td>
<%
}
%>
Modified: trunk/src/main/xmi/bow.zargo
===================================================================
(Binary files differ)
1
0
r23 - in trunk/src/main: java/org/chorem/bow webapp webapp/img
by bbrossaud@users.chorem.org May 12, 2010
by bbrossaud@users.chorem.org May 12, 2010
May 12, 2010
Author: bbrossaud
Date: 2010-05-12 17:38:56 +0200 (Wed, 12 May 2010)
New Revision: 23
Url: http://chorem.org/repositories/revision/bow/23
Log:
order by name and date work
Added:
trunk/src/main/webapp/img/asc.png
trunk/src/main/webapp/img/desc.png
Modified:
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
trunk/src/main/webapp/search.jsp
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-12 13:41:08 UTC (rev 22)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-12 15:38:56 UTC (rev 23)
@@ -114,6 +114,16 @@
log.debug("Going to actionEditBookmark");
}
this.actionEditBookmark(request, response);
+ } else if (action.equals("orderAsc")) {
+ if (log.isDebugEnabled()) {
+ log.debug("Going to actionOrderAsc");
+ }
+ this.actionOrderAsc(request, response);
+ } else if (action.equals("orderDesc")) {
+ if (log.isDebugEnabled()) {
+ log.debug("Going to actionOrderDesc");
+ }
+ this.actionOrderDesc(request, response);
} else {
user = null;
if (log.isDebugEnabled()) {
@@ -134,6 +144,57 @@
// }
}
+
+ protected void actionOrderAsc(HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
+ String type = request.getParameter("type");
+ if (type != null && !type.isEmpty()) {
+ WikittyProxy proxy = model.getProxy();
+ List<Bookmark> bookList = null;
+ if (type.equals("name")) {
+ Criteria criteria = Search.query().
+ eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
+ addSortAscending(Bookmark.FQ_FIELD_DESCRIPTION);
+ bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
+ } else if (type.equals("date")) {
+ Criteria criteria = Search.query().
+ eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
+ addSortAscending(Bookmark.FQ_FIELD_DATE);
+ bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
+ }
+ if (bookList != null) {
+ bookmarkActions.setBookmarks(bookList);
+ bookmarkActions.createTagsCloud();
+ }
+ }
+ request.getRequestDispatcher("search.jsp").forward(request, response);
+ }
+
+ protected void actionOrderDesc(HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
+ String type = request.getParameter("type");
+ if (type != null && !type.isEmpty()) {
+ WikittyProxy proxy = model.getProxy();
+ List<Bookmark> bookList = null;
+ if (type.equals("name")) {
+ Criteria criteria = Search.query().
+ eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
+ addSortDescending(Bookmark.FQ_FIELD_DESCRIPTION);
+ bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
+ } else if (type.equals("date")) {
+ Criteria criteria = Search.query().
+ eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
+ addSortDescending(Bookmark.FQ_FIELD_DATE);
+ bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
+ }
+ if (bookList != null) {
+ bookmarkActions.setBookmarks(bookList);
+ bookmarkActions.createTagsCloud();
+ }
+ }
+ request.getRequestDispatcher("search.jsp").forward(request, response);
+ }
+
protected void actionEditBookmark(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String nameAndTags = request.getParameter("nameAndTags");
@@ -145,7 +206,6 @@
if (bookmark != null) {
bookmarkActions.updateBookmark(bookmark, nameAndTags);
proxy.store(bookmark);
- bookmarkActions.getBookmarks().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) {
@@ -164,7 +224,6 @@
if (bookmarkId != null && !bookmarkId.isEmpty()) {
WikittyProxy proxy = model.getProxy();
proxy.delete(bookmarkId);
- bookmarkActions.getBookmarks().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) {
@@ -186,7 +245,6 @@
if (bookmark != null) {
bookmark.removeTags(tag);
proxy.store(bookmark);
- bookmarkActions.getBookmarks().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) {
@@ -283,7 +341,6 @@
throws IOException, ServletException {
WikittyProxy proxy = model.getProxy();
String tag = request.getParameter("tag");
- bookmarkActions.getBookmarks().clear();
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
Added: trunk/src/main/webapp/img/asc.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/webapp/img/asc.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/main/webapp/img/desc.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/webapp/img/desc.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/src/main/webapp/search.jsp
===================================================================
--- trunk/src/main/webapp/search.jsp 2010-05-12 13:41:08 UTC (rev 22)
+++ trunk/src/main/webapp/search.jsp 2010-05-12 15:38:56 UTC (rev 23)
@@ -41,39 +41,79 @@
}
List<String> tagsSearch = bookmarkActions.getTagsSearch();
List<Bookmark> bookmarkList = bookmarkActions.getBookmarks();
- if (!bookmarkList.isEmpty() && !tagsSearch.isEmpty()) {
+ if (!bookmarkList.isEmpty()) {
%>
<br/><br/>Results:<br/>
+ <table border="1">
+ <tr>
+ <th>Remove</th>
+ <th>
+ Date
+ <a style="text-decoration:none" href="bow?action=orderAsc&type=date">
+ <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">
+ <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">
+ <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">
+ <IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" />
+ </a>
+ </th>
+ <th>Tags</th>
+ <th>Edit</th>
+ </tr>
+ <%
+ for (Bookmark bookmark : bookmarkList) {
+ %>
+ <tr>
+ <td>
+ <a style="border:none;" href="bow?action=removeBookmark&bookmarkId=<%=bookmark.getWikittyId()%>">
+ <IMG style="border:none;" SRC="img/remove.png" ALT="Remove bookmark" TITLE="Remove" />
+ </a>
+ </td>
+ <td>
+ <%=bookmark.getDate()%>
+ </td>
+ <td>
+ <a href="<%=bookmark.getLink()%>"><%=bookmark.getDescription()%></a>
+ </td>
+ <td>
+ <%
+ Set<String> tagList = bookmark.getTags();
+ if (tagList != null && !tagList.isEmpty()) {
+ for (String tag : tagList) {
+ %>
+ <%=tag%>
+ <a style="text-decoration:none" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&tag=<%=tag%>">
+ <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()%>">
+ <input type="text" name="nameAndTags" size="50" value="<%=bookmark.getDescription()%>|tag1 tag2 tag3" />
+ <input type="image" src="img/edit.png" value="edit" />
+ </form>
+ </td>
+ <%
+ }
+ %>
+ <%
+ }
+ %>
+ </table>
<%
- for (Bookmark bookmark : bookmarkList) {
+ } else {
%>
- <br/>
- <a style="border:none;" href="bow?action=removeBookmark&bookmarkId=<%=bookmark.getWikittyId()%>">
- <IMG style="border:none;" SRC="img/remove.png" ALT="Remove bookmark" TITLE="Remove" />
- </a>
- <a href="<%=bookmark.getLink()%>"><%=bookmark.getDescription()%></a>
- <%
- Set<String> tagList = bookmark.getTags();
- if (tagList != null && !tagList.isEmpty()) {
- for (String tag : tagList) {
- %>
- <%=tag%>
- <a style="text-decoration:none" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&tag=<%=tag%>">
- <IMG style="border:none" SRC="img/delete.png" ALT="Delete tag" TITLE="Delete" />
- </a>
- <%
- }
- %>
- <form style="display: inline" method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>">
- <input type="text" name="nameAndTags" size="50" value="<%=bookmark.getDescription()%>|tag1 tag2 tag3" />
- <input type="image" src="img/edit.png" value="edit" />
- </form>
- <%
- }
- }
- } else if (!tagsSearch.isEmpty() && bookmarkList.isEmpty()) {
- %>
- <br/><br/>No Result found<br/><br/>
+ <br/><br/>No Bookmarks<br/><br/>
<% }
}
%>
1
0