Bow-commits
Threads by month
- ----- 2026 -----
- 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
- 617 discussions
r23 - in trunk/src/main: java/org/chorem/bow webapp webapp/img
by bbrossaud@users.chorem.org 12 May '10
by bbrossaud@users.chorem.org 12 May '10
12 May '10
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
r22 - in trunk: . src/main/java/org/chorem/bow src/main/webapp src/main/webapp/img
by bbrossaud@users.chorem.org 12 May '10
by bbrossaud@users.chorem.org 12 May '10
12 May '10
Author: bbrossaud
Date: 2010-05-12 15:41:08 +0200 (Wed, 12 May 2010)
New Revision: 22
Url: http://chorem.org/repositories/revision/bow/22
Log:
the bookmark edition is done
Added:
trunk/src/main/webapp/img/delete.png
trunk/src/main/webapp/img/edit.png
trunk/src/main/webapp/img/remove.png
Removed:
trunk/src/main/webapp/img/delete.gif
trunk/src/main/webapp/img/remove.gif
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/search.jsp
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-05-12 10:09:44 UTC (rev 21)
+++ trunk/pom.xml 2010-05-12 13:41:08 UTC (rev 22)
@@ -89,6 +89,7 @@
<artifactId>nuiton-utils</artifactId>
<version>1.2.2</version>
</dependency>
+
</dependencies>
Modified: trunk/src/main/java/org/chorem/bow/BookmarkActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-12 10:09:44 UTC (rev 21)
+++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-12 13:41:08 UTC (rev 22)
@@ -37,33 +37,63 @@
*/
public Bookmark createBookmark(String url, String nameAndTags, User user) {
+ Bookmark bookmark = (Bookmark) new BookmarkImpl();
+
int nameIndex = nameAndTags.indexOf('|'); // get the index name of the website
- if (nameIndex < 0) { // nameAndTags ==> name|tag1 tag2 tag3...
- return null;
+ if (nameIndex > 0) {
+ String name = nameAndTags.substring(0, nameIndex); // get the website name
+ name = name.trim();
+ bookmark.setDescription(name); // set the description (website name)
}
- Bookmark bookmark = (Bookmark) new BookmarkImpl();
- String link = url.trim();
- bookmark.setLink(link);
-
- String name = nameAndTags.substring(0, nameIndex); // get the website name
- name = name.trim();
- bookmark.setDescription(name); // set the description (website name)
-
- String tags = nameAndTags.substring(nameIndex + 1); // get tags, +1 because of '|'
+ 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
- if (tagsTab.length == 0)
+ 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 (url != null && !url.isEmpty()) {
+ String link = url.trim();
+ bookmark.setLink(link);
+ }
bookmark.setEmail(user.getEmail()); // set the email (user name)
bookmark.setDate(new Date()); // set the date
return bookmark;
}
+ public 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
+ 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
+ if (tagsTab.length != 0) {
+ for (int i = 0; i < tagsTab.length; ++i) {
+ Set<String> tagList = bookmark.getTags();
+ if (tagList != null) {
+ if (!tagList.contains(tagsTab[i])) {
+ bookmark.addTags(tagsTab[i]); // Added tag for each rank (one tag by rank)
+ }
+ }
+ }
+ }
+ }
+
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-12 10:09:44 UTC (rev 21)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-12 13:41:08 UTC (rev 22)
@@ -109,6 +109,11 @@
log.debug("Going to actionRemoveBookmark");
}
this.actionRemoveBookmark(request, response);
+ } else if (action.equals("editBookmark")) {
+ if (log.isDebugEnabled()) {
+ log.debug("Going to actionEditBookmark");
+ }
+ this.actionEditBookmark(request, response);
} else {
user = null;
if (log.isDebugEnabled()) {
@@ -129,6 +134,30 @@
// }
}
+ protected void actionEditBookmark(HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
+ String nameAndTags = request.getParameter("nameAndTags");
+ 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);
+ 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) {
+ bookmarkActions.setBookmarks(bookList);
+ bookmarkActions.createTagsCloud();
+ }
+ }
+ }
+ }
+ request.getRequestDispatcher("search.jsp").forward(request, response);
+ }
+
protected void actionRemoveBookmark(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String bookmarkId = request.getParameter("bookmarkId");
@@ -146,7 +175,6 @@
request.getRequestDispatcher("search.jsp").forward(request, response);
}
-
protected void actionDeleteTag(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String bookmarkId = request.getParameter("bookmarkId");
Deleted: trunk/src/main/webapp/img/delete.gif
===================================================================
(Binary files differ)
Added: trunk/src/main/webapp/img/delete.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/webapp/img/delete.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/main/webapp/img/edit.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/webapp/img/edit.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Deleted: trunk/src/main/webapp/img/remove.gif
===================================================================
(Binary files differ)
Added: trunk/src/main/webapp/img/remove.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/webapp/img/remove.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/src/main/webapp/search.jsp
===================================================================
--- trunk/src/main/webapp/search.jsp 2010-05-12 10:09:44 UTC (rev 21)
+++ trunk/src/main/webapp/search.jsp 2010-05-12 13:41:08 UTC (rev 22)
@@ -15,62 +15,67 @@
<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">
+ 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="words" size="20" value="<%=bookmarkActions.getSearchLine()%>" ><br />
- <input type="submit" value="Find">
+ <input type="text" name="words" size="20" value="<%=bookmarkActions.getSearchLine()%>" /><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);
-%>
+ <% 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=clickOnTag&tag=<%=tag%>"><%=tag%></a></FONT>
+ <FONT SIZE="<%=font%>" ><a href="bow?action=clickOnTag&tag=<%=tag%>"><%=tag%></a></FONT>
-<%
- }
- List<String> tagsSearch = bookmarkActions.getTagsSearch();
- List<Bookmark> bookmarkList = bookmarkActions.getBookmarks();
- if (!bookmarkList.isEmpty() && !tagsSearch.isEmpty()) {
-%>
- <br/><br/>Results:<br/>
-<%
- for (Bookmark bookmark : bookmarkList) {
-%>
- <br/>
- <a style="border:none;" href="bow?action=removeBookmark&bookmarkId=<%=bookmark.getWikittyId()%>">
- <IMG style="border:none;" SRC="img/remove.gif" 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="border:none;" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&tag=<%=tag%>">
- <IMG style="border:none;" SRC="img/delete.gif" ALT="Delete tag" TITLE="Delete" />
- </a>
-<%
+ <%
+ }
+ List<String> tagsSearch = bookmarkActions.getTagsSearch();
+ List<Bookmark> bookmarkList = bookmarkActions.getBookmarks();
+ if (!bookmarkList.isEmpty() && !tagsSearch.isEmpty()) {
+ %>
+ <br/><br/>Results:<br/>
+ <%
+ for (Bookmark bookmark : bookmarkList) {
+ %>
+ <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/>
+ <% }
}
- }
- }
- } else if (!tagsSearch.isEmpty() && bookmarkList.isEmpty()) {
-%>
- <br/><br/>No Result found<br/><br/>
-<%
- }
- }
-%>
+ %>
</body>
</html>
\ No newline at end of file
1
0
r21 - in trunk: . src/main/java/org/chorem/bow src/main/webapp src/main/webapp/css src/main/webapp/img
by bbrossaud@users.chorem.org 12 May '10
by bbrossaud@users.chorem.org 12 May '10
12 May '10
Author: bbrossaud
Date: 2010-05-12 12:09:44 +0200 (Wed, 12 May 2010)
New Revision: 21
Url: http://chorem.org/repositories/revision/bow/21
Log:
remove bookmark and delete tag actions work
Added:
trunk/TODO.txt
trunk/src/main/webapp/css/
trunk/src/main/webapp/css/styles.css
trunk/src/main/webapp/img/
trunk/src/main/webapp/img/delete.gif
trunk/src/main/webapp/img/remove.gif
Modified:
trunk/src/main/java/org/chorem/bow/BookmarkActions.java
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
trunk/src/main/webapp/generateToken.jsp
trunk/src/main/webapp/home.jsp
trunk/src/main/webapp/register.jsp
trunk/src/main/webapp/search.jsp
Added: trunk/TODO.txt
===================================================================
--- trunk/TODO.txt (rev 0)
+++ trunk/TODO.txt 2010-05-12 10:09:44 UTC (rev 21)
@@ -0,0 +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)
+-> 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
+-> 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/BookmarkActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-11 12:28:22 UTC (rev 20)
+++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-12 10:09:44 UTC (rev 21)
@@ -66,48 +66,51 @@
public void createTagsCloud() {
tagCloud.clear();
- if (tagsSearch.isEmpty()) {
- fillTagsCloud(); // if nothing is taped in the search field, the tags cloud must contains all tags
- } else {
- fillTagsCloudBySearch();
- }
- this.defineTValues(); // define t values for the font
+ deleteBookmarkBySearch();
+ createTagClougByBookmarks();
}
-
- /* @param bookmark user bookmark
- * @return void
- */
- protected void addBookmarkTagsToTagCloud(Bookmark bookmark) {
- Set<String> tags = bookmark.getTags(); // bookmark tags
- for (String tag : tags) {
- if (!tagsSearch.contains(tag)) { // the tags cloud mustn't contained the tags taped in the search field
- if (tagCloud.containsKey(tag)) { // check if it contains the tag
- Integer count = tagCloud.get(tag);
- ++count;
- tagCloud.put(tag, count);
- } else {
- tagCloud.put(tag, 1);
+ public void deleteBookmarkBySearch() {
+ List<Bookmark> bookmarksList = new ArrayList<Bookmark>(bookmarks);
+ for (Bookmark bookmark : bookmarksList) {
+ Iterator it = tagsSearch.iterator();
+ boolean remove = false;
+ while (it.hasNext() && remove == false) {
+ String tag = (String) it.next();
+ Set<String> tagList = bookmark.getTags();
+ if (tagList != null && !tagList.isEmpty()) {
+ if (!tagList.contains(tag)) {
+ bookmarks.remove(bookmark); // Delete bookmark which doesn't contain the tags from the search field
+ remove = true;
+ }
}
}
}
}
- public void fillTagsCloud() {
- for (Bookmark bookmark : bookmarks) {
+ public void createTagClougByBookmarks() {
+ List<Bookmark> bookmarksList = new ArrayList<Bookmark>(bookmarks);
+ for (Bookmark bookmark : bookmarksList) {
addBookmarkTagsToTagCloud(bookmark);
}
}
- public void fillTagsCloudBySearch() {
- tagCloud.clear();
- for (String tag : tagsSearch) {
- List<Bookmark> bookmarksList = new ArrayList<Bookmark>(bookmarks);
- for (Bookmark bookmark : bookmarksList) {
- if (bookmark.getTags().contains(tag) == false) {
- bookmarks.remove(bookmark); // Delete bookmark which doesn't contain the tags from the search field
- } else {
- addBookmarkTagsToTagCloud(bookmark);
+
+ /* @param bookmark user bookmark
+ * @return void
+ */
+ protected void addBookmarkTagsToTagCloud(Bookmark bookmark) {
+ Set<String> tags = bookmark.getTags(); // bookmark tags
+ if (tags != null && !tags.isEmpty()) {
+ for (String tag : tags) {
+ if (!tagsSearch.contains(tag)) { // the tags cloud mustn't contained the tags taped in the search field
+ if (tagCloud.containsKey(tag)) { // check if it contains the tag
+ Integer count = tagCloud.get(tag);
+ ++count;
+ tagCloud.put(tag, count);
+ } else {
+ tagCloud.put(tag, 1);
+ }
}
}
}
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-11 12:28:22 UTC (rev 20)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-12 10:09:44 UTC (rev 21)
@@ -11,6 +11,9 @@
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;
@@ -32,6 +35,7 @@
protected BookmarkActions bookmarkActions = new BookmarkActions();
protected User user = null;
protected TokenActions tokenActions = new TokenActions();
+ protected String error = "";
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
@@ -46,7 +50,8 @@
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
- try {
+// try {
+ error = "";
String action = request.getParameter("action");
response.setContentType("text/html");
request.setAttribute("bookmarkActions", bookmarkActions);
@@ -94,6 +99,16 @@
log.error("No Such Algorithm", ex);
request.getRequestDispatcher("error.jsp").forward(request, response);
}
+ } else if (action.equals("deleteTag")) {
+ if (log.isDebugEnabled()) {
+ log.debug("Going to actionDeleteTag");
+ }
+ this.actionDeleteTag(request, response);
+ } else if (action.equals("removeBookmark")) {
+ if (log.isDebugEnabled()) {
+ log.debug("Going to actionRemoveBookmark");
+ }
+ this.actionRemoveBookmark(request, response);
} else {
user = null;
if (log.isDebugEnabled()) {
@@ -108,11 +123,55 @@
}
request.getRequestDispatcher("home.jsp").forward(request, response);
}
- } catch (Exception eee) {
- request.getRequestDispatcher("error.jsp").forward(request, response);
+ request.setAttribute("errorMessage", error);
+// } catch (Exception eee) {
+// request.getRequestDispatcher("error.jsp").forward(request, response);
+// }
+ }
+
+ protected void actionRemoveBookmark(HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
+ String bookmarkId = request.getParameter("bookmarkId");
+ 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) {
+ bookmarkActions.setBookmarks(bookList);
+ bookmarkActions.createTagsCloud();
+ }
}
+ request.getRequestDispatcher("search.jsp").forward(request, response);
}
+
+ protected void actionDeleteTag(HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
+ String bookmarkId = request.getParameter("bookmarkId");
+ String tag = request.getParameter("tag");
+ if (tag != null && bookmarkId != null) {
+ if (!tag.isEmpty() && !bookmarkId.isEmpty()) {
+ WikittyProxy proxy = model.getProxy();
+ Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId);
+ 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) {
+ bookmarkActions.setBookmarks(bookList);
+ bookmarkActions.createTagsCloud();
+ }
+ }
+ }
+ }
+ request.getRequestDispatcher("search.jsp").forward(request, response);
+ }
+
+
/* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet error occurs
@@ -258,6 +317,7 @@
request.getRequestDispatcher("error.jsp").forward(request, response);
} else {
this.actionSearch(request, response);
+ error="Email already exist";
}
}
}
@@ -276,6 +336,7 @@
this.user = login;
this.actionSearch(request, response);
} else {
+ error = "Unknow email or incorrect password";
request.getRequestDispatcher("home.jsp").forward(request, response);
}
}
@@ -315,6 +376,7 @@
}
}
}
+ error = "Email and password must be correctly filled";
return true;
}
Added: trunk/src/main/webapp/css/styles.css
===================================================================
--- trunk/src/main/webapp/css/styles.css (rev 0)
+++ trunk/src/main/webapp/css/styles.css 2010-05-12 10:09:44 UTC (rev 21)
@@ -0,0 +1,3 @@
+test {
+
+}
\ No newline at end of file
Modified: trunk/src/main/webapp/generateToken.jsp
===================================================================
--- trunk/src/main/webapp/generateToken.jsp 2010-05-11 12:28:22 UTC (rev 20)
+++ trunk/src/main/webapp/generateToken.jsp 2010-05-12 10:09:44 UTC (rev 21)
@@ -9,7 +9,7 @@
<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%20image=new%20Image();var%20link='http://localhost:8080/bow/bow?action=addUrl&token=<%=token%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);image.src=link;window.location='';">Session</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='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 {
%>
Modified: trunk/src/main/webapp/home.jsp
===================================================================
--- trunk/src/main/webapp/home.jsp 2010-05-11 12:28:22 UTC (rev 20)
+++ trunk/src/main/webapp/home.jsp 2010-05-12 10:09:44 UTC (rev 21)
@@ -1,3 +1,5 @@
+<%String error = (String) request.getAttribute("errorMessage");%>
+
<html>
<body>
<h1>Login</h1>
@@ -6,6 +8,9 @@
password <input type=password name="password" size="20"><br />
<input type="submit" value="login">
</form>
- <a href="bow?action=registration">register</a>
+ <%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/img/delete.gif
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/webapp/img/delete.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/main/webapp/img/remove.gif
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/webapp/img/remove.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/src/main/webapp/register.jsp
===================================================================
--- trunk/src/main/webapp/register.jsp 2010-05-11 12:28:22 UTC (rev 20)
+++ trunk/src/main/webapp/register.jsp 2010-05-12 10:09:44 UTC (rev 21)
@@ -1,3 +1,5 @@
+
+<%String error = (String) request.getAttribute("errorMessage");%>
<html>
<body>
<h1>Register</h1>
@@ -7,6 +9,9 @@
password <input type=password name="password" size="20"><br />
<input type="submit" value="Register">
</form>
- <br/><br/><a href="bow?action=home">Return to the login page<a>
+ <%if (error != null && error.isEmpty() == false) {%>
+ <br/><font color="red"><%=error%></font>
+ <%}%>
+ <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-11 12:28:22 UTC (rev 20)
+++ trunk/src/main/webapp/search.jsp 2010-05-12 10:09:44 UTC (rev 21)
@@ -43,12 +43,27 @@
List<Bookmark> bookmarkList = bookmarkActions.getBookmarks();
if (!bookmarkList.isEmpty() && !tagsSearch.isEmpty()) {
%>
- <br/><br/>Results:<br/><br/>
+ <br/><br/>Results:<br/>
<%
for (Bookmark bookmark : bookmarkList) {
%>
- <a href="<%=bookmark.getLink()%>"><%=bookmark.getDescription()%></a><br/>
+ <br/>
+ <a style="border:none;" href="bow?action=removeBookmark&bookmarkId=<%=bookmark.getWikittyId()%>">
+ <IMG style="border:none;" SRC="img/remove.gif" 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="border:none;" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&tag=<%=tag%>">
+ <IMG style="border:none;" SRC="img/delete.gif" ALT="Delete tag" TITLE="Delete" />
+ </a>
+<%
+ }
+ }
}
} else if (!tagsSearch.isEmpty() && bookmarkList.isEmpty()) {
%>
1
0
Author: bbrossaud
Date: 2010-05-11 14:28:22 +0200 (Tue, 11 May 2010)
New Revision: 20
Url: http://chorem.org/repositories/revision/bow/20
Log:
added last comments
Modified:
trunk/src/main/webapp/WEB-INF/web.xml
trunk/src/main/webapp/generateToken.jsp
trunk/src/main/webapp/home.jsp
Modified: trunk/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/src/main/webapp/WEB-INF/web.xml 2010-05-11 10:18:29 UTC (rev 19)
+++ trunk/src/main/webapp/WEB-INF/web.xml 2010-05-11 12:28:22 UTC (rev 20)
@@ -13,7 +13,7 @@
<servlet-mapping>
<servlet-name>Controller</servlet-name>
- <url-pattern>/</url-pattern>
+ <url-pattern>/bow</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-11 10:18:29 UTC (rev 19)
+++ trunk/src/main/webapp/generateToken.jsp 2010-05-11 12:28:22 UTC (rev 20)
@@ -4,11 +4,12 @@
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%20image=new%20Image();var%20link='http://localhost:8080/bow/bow?action=addUrl&token=<%=token%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);image.src=link;document.body.appendChild(image);window.location=url;">Session</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%20image=new%20Image();var%20link='http://localhost:8080/bow/bow?action=addUrl&token=<%=token%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);image.src=link;window.location='';">Session</a>
<%
} else {
%>
Modified: trunk/src/main/webapp/home.jsp
===================================================================
--- trunk/src/main/webapp/home.jsp 2010-05-11 10:18:29 UTC (rev 19)
+++ trunk/src/main/webapp/home.jsp 2010-05-11 12:28:22 UTC (rev 20)
@@ -1,7 +1,7 @@
<html>
<body>
<h1>Login</h1>
- <form method="POST" action="home?action=login">
+ <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">
1
0
Author: bbrossaud
Date: 2010-05-11 12:18:29 +0200 (Tue, 11 May 2010)
New Revision: 19
Url: http://chorem.org/repositories/revision/bow/19
Log:
added the TokenActions comments
Modified:
trunk/src/main/java/org/chorem/bow/TokenActions.java
Modified: trunk/src/main/java/org/chorem/bow/TokenActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/TokenActions.java 2010-05-11 10:11:30 UTC (rev 18)
+++ trunk/src/main/java/org/chorem/bow/TokenActions.java 2010-05-11 10:18:29 UTC (rev 19)
@@ -23,10 +23,10 @@
public String generateToken()
throws NoSuchAlgorithmException {
Double rand = Math.random() * 1000000;
- int res = (int) Math.abs(rand);
+ int res = (int) Math.abs(rand); // generate a token between 0 and 1 000 000
String tokenGenerated = String.valueOf(res);
- tokenGenerated = StringUtil.encodeMD5(tokenGenerated);
- return tokenGenerated;
+ tokenGenerated = StringUtil.encodeMD5(tokenGenerated); // encode the token in MD5
+ return tokenGenerated; // return the generate token
}
public void setToken(String token) {
1
0
Author: bbrossaud
Date: 2010-05-11 12:11:30 +0200 (Tue, 11 May 2010)
New Revision: 18
Url: http://chorem.org/repositories/revision/bow/18
Log:
added the BookmarkActions comments
Modified:
trunk/src/main/java/org/chorem/bow/BookmarkActions.java
Modified: trunk/src/main/java/org/chorem/bow/BookmarkActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-11 09:14:13 UTC (rev 17)
+++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-11 10:11:30 UTC (rev 18)
@@ -20,16 +20,25 @@
*/
public class BookmarkActions {
- protected List<Bookmark> bookmarks = new ArrayList<Bookmark>();
- protected Map<String, Integer> tagsCloud = new HashMap<String, Integer>();
- protected List<String> tagsSearch = new ArrayList<String>();
+ protected List<Bookmark> bookmarks = new ArrayList<Bookmark>(); // bookmarks which contain the search tags
+ 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
protected int tmax = -1;
protected int tmin = -1;
+
+ /* @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 user bookmark user
+ * @return null if all fields are not correctly filled
+ * @return Bookmark the website bookmark
+ */
public Bookmark createBookmark(String url, String nameAndTags, User user) {
- int nameIndex = nameAndTags.indexOf('|');
- if (nameIndex < 0) {
+ int nameIndex = nameAndTags.indexOf('|'); // get the index name of the website
+ if (nameIndex < 0) { // nameAndTags ==> name|tag1 tag2 tag3...
return null;
}
Bookmark bookmark = (Bookmark) new BookmarkImpl();
@@ -37,45 +46,48 @@
String link = url.trim();
bookmark.setLink(link);
- String name = nameAndTags.substring(0, nameIndex);
+ String name = nameAndTags.substring(0, nameIndex); // get the website name
name = name.trim();
- bookmark.setDescription(name);
+ bookmark.setDescription(name); // set the description (website name)
- String tags = nameAndTags.substring(nameIndex + 1);
+ String tags = nameAndTags.substring(nameIndex + 1); // get tags, +1 because of '|'
tags = tags.trim();
- String[] tagsTab = tags.split("\\s+");
+ 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]);
+ bookmark.addTags(tagsTab[i]); // Added tag for each rank (one tag by rank)
}
- bookmark.setEmail(user.getEmail());
- bookmark.setDate(new Date());
+ bookmark.setEmail(user.getEmail()); // set the email (user name)
+ bookmark.setDate(new Date()); // set the date
return bookmark;
}
- public List<Bookmark> getBookmarks() {
- return bookmarks;
- }
-
public void createTagsCloud() {
- tagsCloud.clear();
+ tagCloud.clear();
if (tagsSearch.isEmpty()) {
- fillTagsCloud();
+ fillTagsCloud(); // if nothing is taped in the search field, the tags cloud must contains all tags
} else {
fillTagsCloudBySearch();
}
+ this.defineTValues(); // define t values for the font
}
+
+ /* @param bookmark user bookmark
+ * @return void
+ */
protected void addBookmarkTagsToTagCloud(Bookmark bookmark) {
- Set<String> tags = bookmark.getTags();
+ Set<String> tags = bookmark.getTags(); // bookmark tags
for (String tag : tags) {
- if (!tagsSearch.contains(tag)) {
- if (tagsCloud.containsKey(tag)) {
- Integer count = tagsCloud.get(tag);
+ if (!tagsSearch.contains(tag)) { // the tags cloud mustn't contained the tags taped in the search field
+ if (tagCloud.containsKey(tag)) { // check if it contains the tag
+ Integer count = tagCloud.get(tag);
++count;
- tagsCloud.put(tag, count);
+ tagCloud.put(tag, count);
} else {
- tagsCloud.put(tag, 1);
+ tagCloud.put(tag, 1);
}
}
}
@@ -88,34 +100,33 @@
}
public void fillTagsCloudBySearch() {
- tagsCloud.clear();
+ tagCloud.clear();
for (String tag : tagsSearch) {
List<Bookmark> bookmarksList = new ArrayList<Bookmark>(bookmarks);
for (Bookmark bookmark : bookmarksList) {
if (bookmark.getTags().contains(tag) == false) {
- bookmarks.remove(bookmark);
+ bookmarks.remove(bookmark); // Delete bookmark which doesn't contain the tags from the search field
} else {
addBookmarkTagsToTagCloud(bookmark);
}
}
}
- this.defineTValues();
}
protected void defineTValues() {
- Collection values = tagsCloud.values();
+ Collection values = tagCloud.values();
Iterator it = values.iterator();
- tmax = -1;
- tmin = -1;
+ tmax = -1; // correspond to the most tag frequency in the tag cloud
+ tmin = -1; // correspond to the less tag frequency in the tag cloud
int value;
while (it.hasNext()) {
value = (Integer) it.next();
- if (tmax < value) {
- tmax = value;
+ if (tmax < value) { // search the most tag frequancy
+ tmax = value;
}
if (tmin == -1) {
tmin = value;
- } else if (tmin > value) {
+ } else if (tmin > value) { // search less tag frequency
tmin = value;
}
}
@@ -136,37 +147,41 @@
}
}
+ public void reset() {
+ bookmarks.clear();
+ tagCloud.clear();
+ tagsSearch.clear();
+ tmax = -1;
+ tmin = -1;
+ }
+
+ public void setBookmarks(List<Bookmark> bookmarksList) {
+ List<Bookmark> newList = new ArrayList(bookmarksList);
+ bookmarks = newList;
+ }
+
public String getSearchLine() {
- return StringUtil.join(tagsSearch, " ", true);
+ return StringUtil.join(tagsSearch, " ", true); // return the search line created with the tags
}
public int getFont(int ti) {
int font = 1;
if (tmax > tmin) {
- font = (15 * (ti - tmin)) / (tmax - tmin);
+ font = (15 * (ti - tmin)) / (tmax - tmin); // get the font size for a tag frequency
}
return font;
}
- public void reset() {
- bookmarks.clear();
- tagsCloud.clear();
- tagsSearch.clear();
- tmax = -1;
- tmin = -1;
- }
-
public Map<String, Integer> getTagsCloud() {
- return tagsCloud;
+ return tagCloud;
}
public List<String> getTagsSearch() {
return tagsSearch;
}
- public void setBookmarks(List<Bookmark> bookmarksList) {
- List<Bookmark> newList = new ArrayList(bookmarksList);
- bookmarks = newList;
+ public List<Bookmark> getBookmarks() {
+ return bookmarks;
}
public int getTmin() {
1
0
11 May '10
Author: bbrossaud
Date: 2010-05-11 11:14:13 +0200 (Tue, 11 May 2010)
New Revision: 17
Url: http://chorem.org/repositories/revision/bow/17
Log:
added the ControllerServelet comments
Modified:
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
trunk/src/main/java/org/chorem/bow/TokenActions.java
trunk/src/main/webapp/generateToken.jsp
trunk/src/main/webapp/home.jsp
trunk/src/main/webapp/register.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-11 07:15:52 UTC (rev 16)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-11 09:14:13 UTC (rev 17)
@@ -11,7 +11,6 @@
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.List;
-import java.util.Locale;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -21,22 +20,8 @@
import org.sharengo.wikitty.Criteria;
import org.sharengo.wikitty.WikittyProxy;
import org.sharengo.wikitty.search.Search;
-import org.nuiton.i18n.I18n;
/**
- * javascript:
- * var server = new XMLHttpRequest();
- * var url=location.href;
- * var nameAndTags = prompt('Entrez le nom du lien et la liste des tags sous la forme: name|tag1 tag2 tag3', document.title+'|');
- * server.onreadystatechange = function() {
- * if(server.readyState == 4) {
- * if (server.status != 200) {
- * alert('Erreur d\'ajout au bookmark: '+ server.status + '\n\n' + url + '\n\n' + nameAndTags);
- * }
- * }
- * };
- * server.open('GET', 'http://localhost:8080/bow/bow?action=addUrl&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags), true);
- * server.send(null);
*
* @author bbrossaud
*/
@@ -48,50 +33,73 @@
protected User user = null;
protected TokenActions tokenActions = new TokenActions();
- public ControllerServlet() {
- I18n.init(Locale.FRANCE);
- }
-
@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 {
- String action = request.getParameter("action");
-
- response.setContentType("text/html");
- request.setAttribute("bookmarkActions", bookmarkActions);
- request.setAttribute("tokenActions", tokenActions);
- if (action != null) {
- if (action.equals("register")) {
- log.debug("Going to actionRegister");
- this.actionRegister(request, response);
- } else if (action.equals("registration")) {
- log.debug("Going to Register");
- request.getRequestDispatcher("register.jsp").forward(request, response);
- } else if (action.equals("login")) {
- log.debug("Going to actionLogin");
- this.actionLogin(request, response);
- } else if (action.equals("addUrl")) {
- log.debug("Going to actionAddUrl");
- this.actionAddUrl(request, response);
- } else if (action.equals("search") && user != null) {
- log.debug("Going to actionSearch");
- this.actionSearch(request, response);
- } else if (action.equals("clickOnTag") && user != null) {
- log.debug("Going to actionClickOnTag");
- this.actionClickOnTag(request, response);
- } else if (action.equals("generateToken") && user != null) {
- log.debug("Going to actionGenerateToken");
- try {
- this.actionGenerateToken(request, response);
- } catch (NoSuchAlgorithmException ex) {
- log.error("No Such Algorithm", ex);
- request.getRequestDispatcher("error.jsp").forward(request, response);
+ try {
+ 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()) {
+ log.debug("Going to actionRegister");
+ }
+ this.actionRegister(request, response);
+ } else if (action.equals("registration")) {
+ if (log.isDebugEnabled()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Going to Register");
+ }
+ }
+ request.getRequestDispatcher("register.jsp").forward(request, response);
+ } else if (action.equals("login")) {
+ if (log.isDebugEnabled()) {
+ log.debug("Going to actionLogin");
+ }
+ this.actionLogin(request, response);
+ } else if (action.equals("addUrl")) {
+ if (log.isDebugEnabled()) {
+ log.debug("Going to actionAddUrl");
+ }
+ this.actionAddUrl(request, response);
+ } else if (action.equals("search") && user != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Going to actionSearch");
+ }
+ this.actionSearch(request, response);
+ } else if (action.equals("clickOnTag") && user != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Going to actionClickOnTag");
+ }
+ this.actionClickOnTag(request, response);
+ } else if (action.equals("generateToken") && user != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Going to actionGenerateToken");
+ }
+ try {
+ this.actionGenerateToken(request, response);
+ } catch (NoSuchAlgorithmException ex) {
+ log.error("No Such Algorithm", ex);
+ request.getRequestDispatcher("error.jsp").forward(request, response);
+ }
+ } else {
+ user = null;
+ if (log.isDebugEnabled()) {
+ log.debug("Going to home");
+ }
+ request.getRequestDispatcher("home.jsp").forward(request, response);
}
} else {
user = null;
@@ -100,26 +108,26 @@
}
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);
+ } catch (Exception eee) {
+ request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
+ /* @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet error occurs
+ */
protected void actionGenerateToken(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException, NoSuchAlgorithmException {
WikittyProxy proxy = model.getProxy();
- String token = tokenActions.generateToken();
+ String token = tokenActions.generateToken(); // Generate an encoding MD5 token
Criteria criteria = Search.query().eq(Token.FQ_FIELD_TOKEN, token).criteria();
- if (proxy.findByCriteria(User.class, criteria) == null) {
+ 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);
+ proxy.store((Token) newToken); // If the token doesn't exist, it is stored
tokenActions.setToken(token);
} else {
tokenActions.setToken("");
@@ -127,23 +135,29 @@
request.getRequestDispatcher("generateToken.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)
throws IOException, ServletException {
- String url = request.getParameter("url");
- String nameAndTags = request.getParameter("nameAndTags");
- String token = request.getParameter("token");
- log.debug("URL = {" + url + "}");
+ 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 (user == null) { // If the user is null, it's maybe a bookmark addition by token
user = checkToken(url, nameAndTags, token);
}
if (user != null) {
if (!url.isEmpty() && !nameAndTags.isEmpty()) {
Bookmark bookmark = bookmarkActions.createBookmark(url, nameAndTags, user);
if (bookmark != null) {
- model.getProxy().store(bookmark);
- log.debug("Adding URL");
+ 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);
}
@@ -153,48 +167,63 @@
}
}
+ /* @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
+ * @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) {
WikittyProxy proxy = model.getProxy();
Criteria criteria = Search.query().eq(Token.FQ_FIELD_TOKEN, token).criteria();
Token DbToken = proxy.findByCriteria(Token.class, criteria);
- if (DbToken != null) {
- String userEmail = DbToken.getEmail();
- criteria = Search.query().eq(User.FQ_FIELD_EMAIL, userEmail).criteria();
+ if (DbToken != null) { // check if the token exists
+ String userEmail = DbToken.getEmail(); // the token owner user name (email)
+ criteria = Search.query().eq(User.FQ_FIELD_EMAIL, userEmail).criteria(); // retrieve user by token
return proxy.findByCriteria(User.class, criteria);
}
}
return null;
}
+ /* @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet error occurs
+ */
protected void actionClickOnTag(HttpServletRequest request, HttpServletResponse response)
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 = model.getProxy().
- findAllByCriteria(Bookmark.class, criteria).getAll();
+ 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);
+ bookmarkActions.addTag(tag); // if a new tag is selected, adding in tag list
}
}
- bookmarkActions.createTagsCloud();
+ bookmarkActions.createTagsCloud(); // create the tags cloud with the new informations
request.getRequestDispatcher("search.jsp").forward(request, response);
}
+ /* @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet error occurs
+ */
protected void actionSearch(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
- String words = request.getParameter("words");
+ 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 = model.getProxy().
- findAllByCriteria(Bookmark.class, criteria).getAll();
+ List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); // select all bookmarks by user
if (bookList != null) {
bookmarkActions.setBookmarks(bookList);
}
@@ -202,83 +231,88 @@
if (!words.isEmpty()) {
words = words.trim();
String[] tags = words.split("\\s+");
- bookmarkActions.addTags(tags);
+ bookmarkActions.addTags(tags); // add the new tags
}
}
- bookmarkActions.createTagsCloud();
+ bookmarkActions.createTagsCloud(); // create the tags cloud with the new informations
request.getRequestDispatcher("search.jsp").forward(request, response);
}
+ /* @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet error occurs
+ */
protected void actionRegister(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
- try {
- if (this.checkRegister(request, response)) {
- request.getRequestDispatcher("register.jsp").forward(request, response);
+ String email = request.getParameter("email");
+ String password = request.getParameter("password");
+ if (this.checkRegister(email, password)) { // check if all is well
+ request.getRequestDispatcher("register.jsp").forward(request, response);
+ } else {
+ WikittyProxy proxy = model.getProxy();
+ 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) {
+ request.getRequestDispatcher("error.jsp").forward(request, response);
} else {
- UserImpl newUser = new UserImpl();
- newUser.setPassword(request.getParameter("password"));
- newUser.setEmail(request.getParameter("email"));
- this.user = model.getProxy().store((User) newUser);
- if (user == null) {
- log.debug("Not put in the Databases");
- request.getRequestDispatcher("error.jsp").forward(request, response);
- } else {
- log.debug("adding to the Databases");
- this.actionSearch(request, response);
- }
+ this.actionSearch(request, response);
}
- } catch (Exception eee) {
- request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
+ /* @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet error occurs
+ */
protected void actionLogin(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
- try {
- User user = this.checkLogin(request, response);
+ String email = request.getParameter("email");
+ String password = request.getParameter("password");
+ User login = this.checkLogin(email, password); // check if the user exists
- if (user != null) {
- log.debug("User exists");
- this.user = user;
- this.actionSearch(request, response);
- } else {
- log.debug("User doesn't exist");
- request.getRequestDispatcher("home.jsp").forward(request, response);
- }
- } catch (Exception eee) {
- request.getRequestDispatcher("error.jsp").forward(request, response);
+ if (login != null) {
+ this.user = login;
+ this.actionSearch(request, response);
+ } else {
+ request.getRequestDispatcher("home.jsp").forward(request, response);
}
-
}
- protected User checkLogin(HttpServletRequest request, HttpServletResponse response)
- throws IOException, ServletException {
- String email = request.getParameter("email");
- String password = request.getParameter("password");
+ /* @param email String which contains the user name (email)
+ * @param password String which contains the user password
+ * @return null the user doesn't exist
+ * @return User the user exists
+ */
+ protected User checkLogin(String email, String password) {
- if (!email.isEmpty() && !password.isEmpty()) {
- WikittyProxy proxy = model.getProxy();
+ if (email != null && password != null) {
+ if (!email.isEmpty() && !password.isEmpty()) {
+ WikittyProxy proxy = model.getProxy();
- Criteria criteria = Search.query().eq(User.FQ_FIELD_EMAIL, email).eq(User.FQ_FIELD_PASSWORD, password).criteria();
- return proxy.findByCriteria(User.class, criteria);
+ Criteria criteria = Search.query().eq(User.FQ_FIELD_EMAIL, email).
+ eq(User.FQ_FIELD_PASSWORD, password).criteria();
+ return proxy.findByCriteria(User.class, criteria); // retrieve user by user name (email) and password
+ }
}
- log.debug("Empty password or email");
return null;
}
- protected boolean checkRegister(HttpServletRequest request, HttpServletResponse response)
- throws IOException, ServletException {
- String email = request.getParameter("email");
- String password = request.getParameter("password");
- log.debug("email={" + email + "}");
- if (!email.isEmpty() && !password.isEmpty()) {
- WikittyProxy proxy = model.getProxy();
+ /* @param email String which contains the user name (email)
+ * @param password String which contains the user password
+ * @return bool false if the user doesn't exists or true
+ */
+ protected boolean checkRegister(String email, String password) {
+ if (email != null && password != null) {
+ if (!email.isEmpty() && !password.isEmpty()) {
+ WikittyProxy proxy = model.getProxy();
- Criteria criteria = Search.query().eq(User.FQ_FIELD_EMAIL, email).criteria();
- if (proxy.findByCriteria(User.class, criteria) == null) {
- log.debug("No user with this email");
- return false;
+ Criteria criteria = Search.query().eq(User.FQ_FIELD_EMAIL, email).criteria(); // retrieve user by user name (email)
+ if (proxy.findByCriteria(User.class, criteria) == null) {
+ return false;
+ }
}
}
return true;
Modified: trunk/src/main/java/org/chorem/bow/TokenActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/TokenActions.java 2010-05-11 07:15:52 UTC (rev 16)
+++ trunk/src/main/java/org/chorem/bow/TokenActions.java 2010-05-11 09:14:13 UTC (rev 17)
@@ -6,12 +6,12 @@
import java.security.NoSuchAlgorithmException;
import org.nuiton.util.StringUtil;
-import static org.nuiton.i18n.I18n._;
/**
*
* @author bbrossaud
*/
+
public class TokenActions {
String token = "";
Modified: trunk/src/main/webapp/generateToken.jsp
===================================================================
--- trunk/src/main/webapp/generateToken.jsp 2010-05-11 07:15:52 UTC (rev 16)
+++ trunk/src/main/webapp/generateToken.jsp 2010-05-11 09:14:13 UTC (rev 17)
@@ -4,14 +4,20 @@
String token = tokenActions.getToken();
if (token != null && token.isEmpty() == false) {
%>
+<html>
+ <body>
+ Use it to add new bookmarks without authentication : <br/><br/>
-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%20image=new%20Image();var%20link='http://localhost:8080/bow/bow?action=addUrl&token=<%=token%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);image.src=link;document.body.appendChild(image);window.location=url;">Session</a>
+ <%
+ } else {
+ %>
+ Token not available, try again later ...
+ <%
+ }
+ %>
+
+ <br/><br/><a href="bow?action=search">Return to the search page</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%20image=new%20Image();var%20link='http://localhost:8080/bow/bow?action=addUrl&token=<%=token%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);image.src=link;document.body.appendChild(image);window.location=url;">Session</a>
-<%
- } else {
-%>
- Token not available, try again later ...
-<%
- }
-%>
\ No newline at end of file
+ </body>
+</html>
\ No newline at end of file
Modified: trunk/src/main/webapp/home.jsp
===================================================================
--- trunk/src/main/webapp/home.jsp 2010-05-11 07:15:52 UTC (rev 16)
+++ trunk/src/main/webapp/home.jsp 2010-05-11 09:14:13 UTC (rev 17)
@@ -4,8 +4,8 @@
<form method="POST" action="home?action=login">
email <input type="text" name="email" size="20"><br />
password <input type=password name="password" size="20"><br />
- <input type="submit" value="submit">
+ <input type="submit" value="login">
</form>
- <a href="main?action=registration">register</a>
+ <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-11 07:15:52 UTC (rev 16)
+++ trunk/src/main/webapp/register.jsp 2010-05-11 09:14:13 UTC (rev 17)
@@ -2,11 +2,11 @@
<body>
<h1>Register</h1>
- <form method="POST" action="register?action=register">
+ <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 />
- <input type="submit" value="submit">
+ <input type="submit" value="Register">
</form>
-
+ <br/><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-11 07:15:52 UTC (rev 16)
+++ trunk/src/main/webapp/search.jsp 2010-05-11 09:14:13 UTC (rev 17)
@@ -11,22 +11,22 @@
<html>
<body>
+ <a href="bow?action=logout">Logout</a><br/>
<h1>Search</h1>
- <form method="POST" action="search?action=addUrl">
+ <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="search?action=generateToken">Generate Token</a><br/><br/>
+ <br/><br/><a href="bow?action=generateToken">Generate Token</a><br/><br/>
- <form method="POST" action="search?action=search">
+ <form method="POST" action="bow?action=search">
<input type="text" name="words" size="20" value="<%=bookmarkActions.getSearchLine()%>" ><br />
<input type="submit" value="Find">
</form>
-
<% if (bookmarkActions != null) {
Map<String, Integer> tagsCloud = bookmarkActions.getTagsCloud();
Set<String> tags = tagsCloud.keySet();
@@ -35,7 +35,7 @@
int font = bookmarkActions.getFont(value);
%>
-<FONT SIZE="<%=font%>" ><a href="search?action=clickOnTag&tag=<%=tag%>"><%=tag%></a></FONT>
+<FONT SIZE="<%=font%>" ><a href="bow?action=clickOnTag&tag=<%=tag%>"><%=tag%></a></FONT>
<%
}
1
0
Author: bbrossaud
Date: 2010-05-11 09:15:52 +0200 (Tue, 11 May 2010)
New Revision: 16
Url: http://chorem.org/repositories/revision/bow/16
Log:
Bookmark addition with the javascript works now
Modified:
trunk/src/main/webapp/generateToken.jsp
Modified: trunk/src/main/webapp/generateToken.jsp
===================================================================
--- trunk/src/main/webapp/generateToken.jsp 2010-05-10 16:47:41 UTC (rev 15)
+++ trunk/src/main/webapp/generateToken.jsp 2010-05-11 07:15:52 UTC (rev 16)
@@ -7,7 +7,7 @@
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%20image=new%20Image();var%20link='http://localhost:8080/bow/bow?action=addUrl&token=<%=token%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);image.src=link;document.body.appendChild(image);document.location.href=encodeURIComponent(url);">Session</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%20image=new%20Image();var%20link='http://localhost:8080/bow/bow?action=addUrl&token=<%=token%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);image.src=link;document.body.appendChild(image);window.location=url;">Session</a>
<%
} else {
%>
1
0
10 May '10
Author: bbrossaud
Date: 2010-05-10 18:47:41 +0200 (Mon, 10 May 2010)
New Revision: 15
Url: http://chorem.org/repositories/revision/bow/15
Log:
the autobookmark almost work
Modified:
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
trunk/src/main/webapp/generateToken.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-10 12:47:12 UTC (rev 14)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-10 16:47:41 UTC (rev 15)
@@ -25,16 +25,18 @@
/**
* javascript:
- * server = new XMLHttpRequest();
- * var url=location.href;
- * var nameAndTags = prompt("Entrez le nom du lien et la liste des tags sous la forme: <name>|tag1,tag2,tag3", document.title+'|');
- * server.onreadystatechange = function() {
- * if(server.readyState == 4)
- * if (server.status != 200)
- * alert("Error d'ajout au bookmark: "+ server.status + "\n\n" + url + "\n\n" + nameAndTags);
- * };
- * server.open("GET", 'http://localhost:8080/bow?action=addUrl&url='+encodeURIComponent(url)+'&nameAndtags='+encodeURIComponent(nameAndTags), true);
- * server.send(null);
+ * var server = new XMLHttpRequest();
+ * var url=location.href;
+ * var nameAndTags = prompt('Entrez le nom du lien et la liste des tags sous la forme: name|tag1 tag2 tag3', document.title+'|');
+ * server.onreadystatechange = function() {
+ * if(server.readyState == 4) {
+ * if (server.status != 200) {
+ * alert('Erreur d\'ajout au bookmark: '+ server.status + '\n\n' + url + '\n\n' + nameAndTags);
+ * }
+ * }
+ * };
+ * server.open('GET', 'http://localhost:8080/bow/bow?action=addUrl&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags), true);
+ * server.send(null);
*
* @author bbrossaud
*/
Modified: trunk/src/main/webapp/generateToken.jsp
===================================================================
--- trunk/src/main/webapp/generateToken.jsp 2010-05-10 12:47:12 UTC (rev 14)
+++ trunk/src/main/webapp/generateToken.jsp 2010-05-10 16:47:41 UTC (rev 15)
@@ -7,8 +7,7 @@
Use it to add new bookmarks without authentication : <br/><br/>
-javascript:server%20=%20new%20XMLHttpRequest();%20url=location.href;nameAndTags%20=%20prompt("Entrez%20le%20nom%20du%20lien%20et%20la%20liste%20des%20tags%20sous%20la%20forme:%20<name>|tag1,tag2,tag3",%20document.title+'|');server.onreadystatechange%20=%20function()%20{%20if(server.readyState%20==%204)%20if%20(server.status%20!=%20200)%20alert("Error%20d'ajout%20au%20bookmark:%20"+%20server.status%20+%20"\n\n"%20+%20url%20+%20"\n\n"%20+%20nameAndTags);};server.open("GET",%20'http://localhost:8080/bow/bow?action=addUrl&token=<%=token%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags),%20true);server.send(null);
-
+<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%20image=new%20Image();var%20link='http://localhost:8080/bow/bow?action=addUrl&token=<%=token%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);image.src=link;document.body.appendChild(image);document.location.href=encodeURIComponent(url);">Session</a>
<%
} else {
%>
Modified: trunk/src/main/webapp/search.jsp
===================================================================
--- trunk/src/main/webapp/search.jsp 2010-05-10 12:47:12 UTC (rev 14)
+++ trunk/src/main/webapp/search.jsp 2010-05-10 16:47:41 UTC (rev 15)
@@ -19,12 +19,13 @@
<input type="submit" value="add">
</form>
+ <br/><br/><a href="search?action=generateToken">Generate Token</a><br/><br/>
+
<form method="POST" action="search?action=search">
<input type="text" name="words" size="20" value="<%=bookmarkActions.getSearchLine()%>" ><br />
<input type="submit" value="Find">
</form>
- <a href="search?action=generateToken">Generate Token</a><br/>
<% if (bookmarkActions != null) {
Map<String, Integer> tagsCloud = bookmarkActions.getTagsCloud();
1
0
10 May '10
Author: bbrossaud
Date: 2010-05-10 14:47:12 +0200 (Mon, 10 May 2010)
New Revision: 14
Url: http://chorem.org/repositories/revision/bow/14
Log:
added generateToken.jsp and tokenActions.java
Added:
trunk/src/main/java/org/chorem/bow/TokenActions.java
trunk/src/main/webapp/generateToken.jsp
Added: trunk/src/main/java/org/chorem/bow/TokenActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/TokenActions.java (rev 0)
+++ trunk/src/main/java/org/chorem/bow/TokenActions.java 2010-05-10 12:47:12 UTC (rev 14)
@@ -0,0 +1,35 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.chorem.bow;
+
+import java.security.NoSuchAlgorithmException;
+import org.nuiton.util.StringUtil;
+import static org.nuiton.i18n.I18n._;
+
+/**
+ *
+ * @author bbrossaud
+ */
+public class TokenActions {
+
+ String token = "";
+
+ public String getToken() {
+ return token;
+ }
+
+ public String generateToken()
+ throws NoSuchAlgorithmException {
+ Double rand = Math.random() * 1000000;
+ int res = (int) Math.abs(rand);
+ String tokenGenerated = String.valueOf(res);
+ tokenGenerated = StringUtil.encodeMD5(tokenGenerated);
+ return tokenGenerated;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+}
Added: trunk/src/main/webapp/generateToken.jsp
===================================================================
--- trunk/src/main/webapp/generateToken.jsp (rev 0)
+++ trunk/src/main/webapp/generateToken.jsp 2010-05-10 12:47:12 UTC (rev 14)
@@ -0,0 +1,18 @@
+<%@ page import="org.chorem.bow.TokenActions" %>
+
+<%TokenActions tokenActions = (TokenActions) request.getAttribute("tokenActions");
+ String token = tokenActions.getToken();
+ if (token != null && token.isEmpty() == false) {
+%>
+
+Use it to add new bookmarks without authentication : <br/><br/>
+
+javascript:server%20=%20new%20XMLHttpRequest();%20url=location.href;nameAndTags%20=%20prompt("Entrez%20le%20nom%20du%20lien%20et%20la%20liste%20des%20tags%20sous%20la%20forme:%20<name>|tag1,tag2,tag3",%20document.title+'|');server.onreadystatechange%20=%20function()%20{%20if(server.readyState%20==%204)%20if%20(server.status%20!=%20200)%20alert("Error%20d'ajout%20au%20bookmark:%20"+%20server.status%20+%20"\n\n"%20+%20url%20+%20"\n\n"%20+%20nameAndTags);};server.open("GET",%20'http://localhost:8080/bow/bow?action=addUrl&token=<%=token%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags),%20true);server.send(null);
+
+<%
+ } else {
+%>
+ Token not available, try again later ...
+<%
+ }
+%>
\ No newline at end of file
1
0