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
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 28 May '10
by bbrossaud@users.chorem.org 28 May '10
28 May '10
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
28 May '10
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
28 May '10
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 28 May '10
by bbrossaud@users.chorem.org 28 May '10
28 May '10
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 27 May '10
by bbrossaud@users.chorem.org 27 May '10
27 May '10
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 27 May '10
by bbrossaud@users.chorem.org 27 May '10
27 May '10
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 25 May '10
by bbrossaud@users.chorem.org 25 May '10
25 May '10
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