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
January 2011
- 3 participants
- 23 discussions
r169 - in trunk/src/main: resources/i18n webapp/jsp webapp/jsp/inc
by vbriand@users.chorem.org 13 Jan '11
by vbriand@users.chorem.org 13 Jan '11
13 Jan '11
Author: vbriand
Date: 2011-01-13 11:58:47 +0100 (Thu, 13 Jan 2011)
New Revision: 169
Url: http://chorem.org/repositories/revision/bow/169
Log:
The bookmark modification now works on the search page too
Modified:
trunk/src/main/resources/i18n/bow_en_GB.properties
trunk/src/main/resources/i18n/bow_fr_FR.properties
trunk/src/main/webapp/jsp/home.jsp
trunk/src/main/webapp/jsp/inc/bookmark.jsp
trunk/src/main/webapp/jsp/inc/rightMenu.jsp
trunk/src/main/webapp/jsp/search.jsp
Modified: trunk/src/main/resources/i18n/bow_en_GB.properties
===================================================================
--- trunk/src/main/resources/i18n/bow_en_GB.properties 2011-01-13 09:19:30 UTC (rev 168)
+++ trunk/src/main/resources/i18n/bow_en_GB.properties 2011-01-13 10:58:47 UTC (rev 169)
@@ -1,6 +1,7 @@
bow.action.locale.english=English
bow.action.locale.french=French
bow.bookmark.badFileFormat=
+bow.bookmarks.noBookmarks=
bow.config.alias.url.description=
bow.config.application.version.description=
bow.config.bow.addressFrom.description=
Modified: trunk/src/main/resources/i18n/bow_fr_FR.properties
===================================================================
--- trunk/src/main/resources/i18n/bow_fr_FR.properties 2011-01-13 09:19:30 UTC (rev 168)
+++ trunk/src/main/resources/i18n/bow_fr_FR.properties 2011-01-13 10:58:47 UTC (rev 169)
@@ -1,6 +1,7 @@
bow.action.locale.english=Anglais
bow.action.locale.french=Fran\u00E7ais
bow.bookmark.badFileFormat=
+bow.bookmarks.noBookmarks=
bow.config.alias.url.description=
bow.config.application.version.description=
bow.config.bow.addressFrom.description=
Modified: trunk/src/main/webapp/jsp/home.jsp
===================================================================
--- trunk/src/main/webapp/jsp/home.jsp 2011-01-13 09:19:30 UTC (rev 168)
+++ trunk/src/main/webapp/jsp/home.jsp 2011-01-13 10:58:47 UTC (rev 169)
@@ -75,7 +75,7 @@
}
}
else { %>
- <p class="nobookmarks"><s:text name="bow.home.noBookmarks" /></p>
+ <p class="nobookmarks"><s:text name="bow.bookmarks.noBookmarks" /></p>
<% } %>
</div>
@@ -101,7 +101,7 @@
}
}
else { %>
- <p class="nobookmarks"><s:text name="bow.home.noBookmarks" /></p>
+ <p class="nobookmarks"><s:text name="bow.bookmarks.noBookmarks" /></p>
<% } %>
</div>
<jsp:include page="inc/rightMenu.jsp" />
Modified: trunk/src/main/webapp/jsp/inc/bookmark.jsp
===================================================================
--- trunk/src/main/webapp/jsp/inc/bookmark.jsp 2011-01-13 09:19:30 UTC (rev 168)
+++ trunk/src/main/webapp/jsp/inc/bookmark.jsp 2011-01-13 10:58:47 UTC (rev 169)
@@ -35,84 +35,84 @@
SimpleDateFormat sdf = (SimpleDateFormat) request.getAttribute("sdf");
String url = (String) request.getAttribute("bowUrl");
String aliasUrl = BowConfig.getInstance().getServletAliasUrl();
-String search = "";
-String searchLine = request.getParameter("searchLine");
-if (searchLine != null) {
- search += "&searchLine=" + searchLine;
-}
-String fullTextLine = request.getParameter("fullTextLine");
-if (fullTextLine != null) {
- search += "&fullTextLine=" + fullTextLine;
-}
url = "toto"; //TODO: à changer
if (url != null && bookmark != null && sdf != null && bookmarkActions != null) {
String formBookmarkId = (String) request.getAttribute("formBookmarkId");
String link = bookmark.getLink();
link = link.replace("'", "\\'");
-%>
-<div class="bookmark">
- <div class="bookmarkhead">
- <a class="alias" href="<%=aliasUrl + bookmark.getAlias()%>" title="<%=bookmark.getLink()%>" onclick="window.open(this.href); return false;">
- <%=bookmark.getAlias()%>
- </a>
- <p class="date"> (<%=sdf.format(bookmark.getDate())%>)</p>
- <s:url id="editBookmark" action="modifyBookmark">
- <s:param name="bookmarkId"><%=bookmark.getWikittyId()%><%=search%></s:param>
- </s:url>
- <s:a cssClass="edit" href="%{editBookmark}" onclick="return modify('%{#request.bookmark.getDescription()}', '%{#request.bookmark.getAlias()}', '%{#request.bookmark.getTags()}', '%{#request.bookmark.getLink()}', '%{editBookmark}', '%{#request.bookmark.getWikittyId()}');"></s:a>
- <s:url id="removeBookmark" action="removeBookmark">
- <s:param name="bookmarkId"><%=bookmark.getWikittyId()%><%=search%></s:param>
- </s:url>
- <s:a cssClass="supprim" href="%{removeBookmark}"></s:a>
- </div>
- <div class="bookmarkcontenu">
- <div class="screenshot"></div>
- <div class="click"><%=bookmark.getClick()%></div>
- <div class="description">
- <h3>Description :</h3>
- <p>
- <s:url id="addClick" action="addClick">
- <s:param name="bookmarkId"><%=bookmark.getWikittyId()%></s:param>
- </s:url>
- <s:a title="" href="%{addClick}" onclick="window.open(this.href); return false;"><%=bookmark.getDescription()%></s:a>
- <!-- <%=bookmark.getLink()%>-->
- </p>
- <p class="tags">
- <strong>Tags :</strong>
- <%
- Set<String> tagList = bookmark.getTags();
-
- if (tagList != null && !tagList.isEmpty()) {
- for (String tag : tagList) {
- %>
- <s:url id="deleteTag" action="deleteTag">
- <s:param name="bookmarkId"><%=bookmark.getWikittyId()%></s:param>
- <s:param name="deleteTag"><%=tag%><%=search%></s:param>
- </s:url>
- <%
- if (formBookmarkId != null && formBookmarkId.equals(bookmark.getWikittyId())) {
- %>
- <s:a cssStyle="text-decoration: none;" href="%{deleteTag}">
- <img style="border:none;" src="img/delete.png" alt="Delete tag" title="Delete" />
- </s:a>
- <%
- } else {
- %>
- <!-- <%=bookmark.getWikittyId()%> -->
- <s:a name="" cssStyle="display:none; text-decoration: none;" href="%{deleteTag}">
- <img style="border:none;" src="img/delete.png" alt="Delete tag" title="Delete" />
- </s:a>
- <% } %>
- <s:url id="search" action="search">
- <s:param name="searchLine"><%=tag%></s:param>
- </s:url>
- <s:a href="%{search}" cssStyle="text-decoration: none"><%=tag%></s:a>
- <%
- }
- }
- %>
- </p>
- </div>
- </div>
-</div>
-<% } %>
+ %>
+ <s:set var="searchLine" value="%{#request.searchLine}" />
+ <s:set var="fullTextLine" value="%{#request.fullTextLine}" />
+
+ <div class="bookmark">
+ <div class="bookmarkhead">
+ <a class="alias" href="<%=aliasUrl + bookmark.getAlias()%>" title="<%=bookmark.getLink()%>" onclick="window.open(this.href); return false;">
+ <%=bookmark.getAlias()%>
+ </a>
+ <p class="date"> (<%=sdf.format(bookmark.getDate())%>)</p>
+ <s:url id="editBookmark" action="modifyBookmark" escapeAmp="false">
+ <s:param name="bookmarkId"><s:property value="%{#request.bookmark.getWikittyId()}" /></s:param>
+ <s:param name="searchLine"><s:property value="%{#searchLine}" /></s:param>
+ <s:param name="fullTextLine"><s:property value="%{#fullTextLine}" /></s:param>
+ </s:url>
+ <s:a cssClass="edit" href="%{editBookmark}" onclick="return modify('%{#request.bookmark.getDescription()}', '%{#request.bookmark.getAlias()}', '%{#request.bookmark.getTags()}', '%{#request.bookmark.getLink()}', '%{editBookmark}', '%{#request.bookmark.getWikittyId()}');"></s:a>
+ <s:url id="removeBookmark" action="removeBookmark" escapeAmp="false">
+ <s:param name="bookmarkId"><s:property value="%{#request.bookmark.getWikittyId()}" /></s:param>
+ <s:param name="searchLine"><s:property value="%{#searchLine}" /></s:param>
+ <s:param name="fullTextLine"><s:property value="%{#fullTextLine}" /></s:param>
+ </s:url>
+ <s:a cssClass="supprim" href="%{removeBookmark}"></s:a>
+ </div>
+ <div class="bookmarkcontenu">
+ <div class="screenshot"></div>
+ <div class="click"><%=bookmark.getClick()%></div>
+ <div class="description">
+ <h3>Description :</h3>
+ <p>
+ <s:url id="addClick" action="addClick">
+ <s:param name="bookmarkId"><%=bookmark.getWikittyId()%></s:param>
+ </s:url>
+ <s:a title="" href="%{addClick}" onclick="window.open(this.href); return false;"><%=bookmark.getDescription()%></s:a>
+ <!-- <%=bookmark.getLink()%>-->
+ </p>
+ <p class="tags">
+ <strong>Tags :</strong>
+ <%
+ Set<String> tagList = bookmark.getTags();
+
+ if (tagList != null && !tagList.isEmpty()) {
+ for (String tag : tagList) {
+ %>
+ <s:url id="deleteTag" action="deleteTag">
+ <s:param name="bookmarkId"><s:property value="%{#request.bookmark.getWikittyId()}" /></s:param>
+ <s:param name="deleteTag"><%=tag%></s:param>
+ <s:param name="searchLine"><s:property value="%{#searchLine}" /></s:param>
+ <s:param name="fullTextLine"><s:property value="%{#fullTextLine}" /></s:param>
+ </s:url>
+ <%
+ if (formBookmarkId != null && formBookmarkId.equals(bookmark.getWikittyId())) {
+ %>
+ <s:a cssStyle="text-decoration: none;" href="%{deleteTag}">
+ <img style="border:none;" src="img/delete.png" alt="Delete tag" title="Delete" />
+ </s:a>
+ <%
+ } else {
+ %>
+ <!-- <%=bookmark.getWikittyId()%> -->
+ <s:a name="" cssStyle="display:none; text-decoration: none;" href="%{deleteTag}">
+ <img style="border:none;" src="img/delete.png" alt="Delete tag" title="Delete" />
+ </s:a>
+ <% } %>
+ <s:url id="search" action="search">
+ <s:param name="searchLine"><%=tag%></s:param>
+ </s:url>
+ <s:a href="%{search}" cssStyle="text-decoration: none"><%=tag%></s:a>
+ <%
+ }
+ }
+ %>
+ </p>
+ </div>
+ </div>
+ </div>
+ <% } %>
Modified: trunk/src/main/webapp/jsp/inc/rightMenu.jsp
===================================================================
--- trunk/src/main/webapp/jsp/inc/rightMenu.jsp 2011-01-13 09:19:30 UTC (rev 168)
+++ trunk/src/main/webapp/jsp/inc/rightMenu.jsp 2011-01-13 10:58:47 UTC (rev 169)
@@ -101,8 +101,8 @@
<h2><s:text name="bow.rightMenu.extensions" /></h2>
<ul class="droite">
<li><a href="extensions/bow4chromium.crx"><img src="img/chromium.png" alt="Chromium" class="extensionIcon" />Extension pour Chromium</a></li>
- <li><strong><s:text name="bow.rightMenu.token.permanent" /></strong> <%=permanentToken%></li>
- <li><strong><s:text name="bow.rightMenu.token.temporary" /></strong> <%=temporaryToken%></li>
+ <li><strong><s:text name="bow.rightMenu.token.permanent" /></strong><%=permanentToken%></li>
+ <li><strong><s:text name="bow.rightMenu.token.temporary" /></strong><%=temporaryToken%></li>
</ul>
</div>
<div id="add" class="clearfix">
Modified: trunk/src/main/webapp/jsp/search.jsp
===================================================================
--- trunk/src/main/webapp/jsp/search.jsp 2011-01-13 09:19:30 UTC (rev 168)
+++ trunk/src/main/webapp/jsp/search.jsp 2011-01-13 10:58:47 UTC (rev 169)
@@ -33,12 +33,12 @@
<%
TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions");
BookmarkActions bookmarkActions = (BookmarkActions) request.getAttribute("bookmarkActions");
-//Preference preference = (Preference) session.getAttribute("preference");
-String searchLine = bookmarkActions.getSearchLine();
-String fullText = bookmarkActions.getFullTextLine();
if (tokenActions != null && bookmarkActions != null) {
%>
+ <s:set var="searchLine" value="%{#request.bookmarkActions.getSearchLine()}" />
+ <s:set var="fullText" value="%{#request.bookmarkActions.getFullTextLine()}" />
+
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
xmlns:jsp="http://java.sun.com/JSP/Page"
@@ -54,27 +54,28 @@
<div class="menu clearfix">
<h2><s:text name="bow.search.title" /></h2>
<s:url id="order" action="order" escapeAmp="false">
- <s:param name="searchLine"><%=searchLine%></s:param>
- <s:param name="fullTextLine"><%=fullText%></s:param>
+ <s:param name="searchLine"><s:property value="%{#searchLine}" /></s:param>
+ <s:param name="fullTextLine"><s:property value="%{#fullText}" /></s:param>
</s:url>
<s:form action="%{order}">
<p>
- <label for="type">Order By :</label>
+ <label for="type"><s:text name="bow.search.orderby" /></label>
<select id="type" name="type">
- <option value="ascName">Asc Name</option>
- <option value="descName">Desc Name</option>
- <option value="ascClick">Asc Click</option>
- <option value="descClick">Desc Click</option>
- <option value="ascDate">Asc Date</option>
- <option value="descDate">Desc Date</option>
+ <option value="ascName"><s:text name="bow.search.ascname" /></option>
+ <option value="descName"><s:text name="bow.search.descname" /></option>
+ <option value="ascClick"><s:text name="bow.search.ascclick" /></option>
+ <option value="descClick"><s:text name="bow.search.descclick" /></option>
+ <option value="ascDate"><s:text name="bow.search.ascdate" /></option>
+ <option value="descDate"><s:text name="bow.search.descdate" /></option>
</select>
<s:submit key="bow.search.submit" />
- <s:if test="%{#request.bookmarkActions.getBookmarks().size() > 0}">
+ <s:set name="bookmarksToDelete" value="%{#request.bookmarkActions.getBookmarks().size()}" />
+ <s:if test="%{#bookmarksToDelete > 0}">
<s:url id="deleteSearchResults" action="deleteSearchResults" escapeAmp="false">
- <s:param name="searchLine"><%=searchLine%></s:param>
- <s:param name="fullTextLine"><%=fullText%></s:param>
+ <s:param name="searchLine"><s:property value="%{#searchLine}" /></s:param>
+ <s:param name="fullTextLine"><s:property value="%{#fullText}" /></s:param>
</s:url>
- <s:a id="deleteSearchResultsButton" href="" onclick="deleteConfirmation('%{deleteSearchResults}', %{#request.bookmarkActions.getBookmarks().size()}); return(false);"></s:a>
+ <s:a id="deleteSearchResultsButton" href="" onclick="deleteConfirmation('%{deleteSearchResults}', %{#bookmarksToDelete}); return(false);"></s:a>
</s:if>
</p>
</s:form>
@@ -90,16 +91,17 @@
request.setAttribute("sdf", sdf);
%>
<jsp:include page="inc/bookmark.jsp" flush="true">
- <jsp:param name="searchLine" value="<%=searchLine%>" />
- <jsp:param name="fullTextLine" value="<%=fullText%>" />
+ <jsp:param name="searchLine" value="%{#searchLine}" />
+ <jsp:param name="fullTextLine" value="%{#fullText}" />
</jsp:include>
<%
}
}
else { %>
- <p class="nobookmarks">No Bookmarks</p>
+ <p class="nobookmarks"><s:text name="bow.bookmarks.noBookmarks" /></p>
<% } %>
</div>
+ <jsp:include page="inc/rightMenu.jsp" />
</body>
</html>
<% } %>
1
0
Author: vbriand
Date: 2011-01-13 10:19:30 +0100 (Thu, 13 Jan 2011)
New Revision: 168
Url: http://chorem.org/repositories/revision/bow/168
Log:
The results of a research can be removed again
Modified:
trunk/src/main/webapp/jsp/search.jsp
Modified: trunk/src/main/webapp/jsp/search.jsp
===================================================================
--- trunk/src/main/webapp/jsp/search.jsp 2011-01-07 19:02:06 UTC (rev 167)
+++ trunk/src/main/webapp/jsp/search.jsp 2011-01-13 09:19:30 UTC (rev 168)
@@ -53,7 +53,7 @@
<div id="content">
<div class="menu clearfix">
<h2><s:text name="bow.search.title" /></h2>
- <s:url id="order" action="order">
+ <s:url id="order" action="order" escapeAmp="false">
<s:param name="searchLine"><%=searchLine%></s:param>
<s:param name="fullTextLine"><%=fullText%></s:param>
</s:url>
@@ -69,18 +69,13 @@
<option value="descDate">Desc Date</option>
</select>
<s:submit key="bow.search.submit" />
- <%
- List<Bookmark> bookmarkList = bookmarkActions.getBookmarks();
- int bookmarksNb = bookmarkList.size();
-
- if (bookmarksNb > 0) {
- %>
- <s:url id="deleteSearchResult" action="deleteSearchResult">
+ <s:if test="%{#request.bookmarkActions.getBookmarks().size() > 0}">
+ <s:url id="deleteSearchResults" action="deleteSearchResults" escapeAmp="false">
<s:param name="searchLine"><%=searchLine%></s:param>
<s:param name="fullTextLine"><%=fullText%></s:param>
</s:url>
- <s:a id="deleteSearchResultsButton" href="" onclick="deleteConfirmation(%{deleteSearchResult}, <%=bookmarksNb%>); return(false);"></s:a>
- <% } %>
+ <s:a id="deleteSearchResultsButton" href="" onclick="deleteConfirmation('%{deleteSearchResults}', %{#request.bookmarkActions.getBookmarks().size()}); return(false);"></s:a>
+ </s:if>
</p>
</s:form>
</div>
1
0
r167 - in trunk/src/main: java/org/chorem/bow java/org/chorem/bow/action resources resources/i18n webapp/js webapp/jsp webapp/jsp/inc
by vbriand@users.chorem.org 07 Jan '11
by vbriand@users.chorem.org 07 Jan '11
07 Jan '11
Author: vbriand
Date: 2011-01-07 20:02:06 +0100 (Fri, 07 Jan 2011)
New Revision: 167
Url: http://chorem.org/repositories/revision/bow/167
Log:
Deleted ControllerServlet.java. The bookmark modification works again but not perfectly.
Removed:
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
Modified:
trunk/src/main/java/org/chorem/bow/action/AddAliasAction.java
trunk/src/main/java/org/chorem/bow/action/AddUrlAction.java
trunk/src/main/java/org/chorem/bow/action/EditBookmarkAction.java
trunk/src/main/java/org/chorem/bow/action/LoginAction.java
trunk/src/main/resources/i18n/bow_en_GB.properties
trunk/src/main/resources/i18n/bow_fr_FR.properties
trunk/src/main/resources/struts.xml
trunk/src/main/webapp/js/bookmark.js
trunk/src/main/webapp/jsp/inc/bookmark.jsp
trunk/src/main/webapp/jsp/inc/rightMenu.jsp
trunk/src/main/webapp/jsp/preferences.jsp
Deleted: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2011-01-07 11:19:18 UTC (rev 166)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2011-01-07 19:02:06 UTC (rev 167)
@@ -1,1431 +0,0 @@
-/*
- * #%L
- * bow
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.bow;
-
-/**
- *
- * @author bbrossaud
- */
-import java.io.IOException;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Properties;
-import javax.mail.Message;
-import javax.mail.MessagingException;
-import javax.mail.Session;
-import javax.mail.Transport;
-import javax.mail.internet.AddressException;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
-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.lang.RandomStringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.htmlparser.Node;
-import org.htmlparser.Parser;
-import org.htmlparser.util.NodeList;
-import org.htmlparser.util.ParserException;
-import org.htmlparser.util.SimpleNodeIterator;
-import org.nuiton.util.StringUtil;
-import org.nuiton.wikitty.Criteria;
-import org.nuiton.wikitty.FacetTopic;
-import org.nuiton.wikitty.PagedResult;
-import org.nuiton.wikitty.WikittyProxy;
-import org.nuiton.wikitty.search.Element;
-import org.nuiton.wikitty.search.Search;
-
-/**
- *
- * @author bbrossaud
- */
-public class ControllerServlet extends HttpServlet {
- private static final long serialVersionUID = 1L;
- private static final Log log = LogFactory.getLog(ControllerServlet.class);
- protected String version = "";
- protected String bowServletUrl = "";
-
- public ControllerServlet() throws Exception {
- BowConfig config = BowConfig.getInstance();
- version = config.getVersion();
- bowServletUrl = config.getBowUrl();
- if (bowServletUrl == null) {
- throw new Exception("No bow.url=\"SERVER URL\" in bow.properties");
- }
- bowServletUrl += config.getServletBow();
- }
-
- @Override
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws IOException, ServletException {
- 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 {
- request.setCharacterEncoding("UTF8");
- request.setAttribute("version", version);
- request.setAttribute("bowUrl", bowServletUrl);
- HttpSession session = request.getSession(true);
- User user = (User) session.getAttribute("user");
-
- String token = request.getParameter("token"); // token or not
- if (token != null && !token.isEmpty()) {
- user = checkToken(token, session); // retrieve user by token
- }
-
- String action = request.getParameter("action");
- if (action != null) {
- if (action.equals("register")) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionRegister");
- }
- actionRegister(request, response, session);
- } else if (action.equals("registration")) {
- if (log.isDebugEnabled()) {
- log.debug("Going to Register");
- }
- request.getRequestDispatcher("register.jsp").forward(request, response);
- } else if (action.equals("forgotPassword")) {
- if (log.isDebugEnabled()) {
- log.debug("Going to forgotPassword");
- }
- request.getRequestDispatcher("forgotPassword.jsp").forward(request, response);
- } else if (action.equals("login")) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionLogin");
- }
- actionLogin(request, response, session);
- } else if (action.equals("logout")) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionLogout");
- }
- actionLogout(request, response, session);
- } else if (action.equals("home")) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionHome.jsp");
- }
- actionHome(request, response, session);
- } else if (action.equals("addUrl") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionAddUrl");
- }
- actionAddUrl(request, response, user);
- } else if (action.equals("sendPassword")) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionSendPassword");
- }
- actionSendPassword(request, response);
- } else if (action.equals("modifyBookmark") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionModif");
- }
- actionModifyBookmark(request, response, user);
- } else if (action.equals("importBookmarks") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionImportBookmarks");
- }
- actionImportBookmarks(request, response, user);
- } else if (action.equals("exportBookmarks") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionExportBookmarks");
- }
- actionExportBookmarks(response, user);
- } else if (action.equals("search") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionSearch");
- }
- actionSearch(request, user);
- request.getRequestDispatcher("search.jsp").forward(request, response);
- } else if (action.equals("generateToken") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionGenerateToken");
- }
- actionGenerateToken(request, response, user, session);
- request.getRequestDispatcher("preferences.jsp").forward(request, response);
- } else if (action.equals("deleteTag") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionDeleteTag");
- }
- actionDeleteTag(request, response, user);
- } else if (action.equals("addAlias") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionAddAlias");
- }
- actionAddAlias(request, response);
- } else if (action.equals("removeBookmark") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionRemoveBookmark");
- }
- actionRemoveBookmark(request, response, user);
- } else if (action.equals("editBookmark") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionEditBookmark");
- }
- actionEditBookmark(request, response, user);
- } else if (action.equals("order") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionOrder");
- }
- actionOrder(request, response, user);
- request.getRequestDispatcher("search.jsp").forward(request, response);
- } else if (action.equals("addClick") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionAddClic");
- }
- actionAddClick(request, response);
- } else if (action.equals("temporaryXml")) {
- if (log.isDebugEnabled()) {
- log.debug("Going to temporaryXml.jsp");
- }
- request.getRequestDispatcher("temporaryXml.jsp").forward(request, response);
- } else if (action.equals("permanentXml")) {
- if (log.isDebugEnabled()) {
- log.debug("Going to permanentXml.jsp");
- }
- request.getRequestDispatcher("permanentXml.jsp").forward(request, response);
- } else if (action.equals("openSearchSuggestion") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionOpenSearchSuggestion");
- }
- actionOpenSearchSuggestion(request, response, user);
- request.getRequestDispatcher("suggestions.jsp").forward(request, response);
- } else if (action.equals("openSearchResult") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionOpenSearchResult");
- }
- actionOpenSearchResult(request, response, session, user, token);
- } else if (action.equals("fullText") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionFullText");
- }
- actionFullText(request, user);
- request.getRequestDispatcher("search.jsp").forward(request, response);
- } else if (action.equals("preferences") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionPreferences");
- }
- getBookmarksByImportDate(request, user);
- request.getRequestDispatcher("preferences.jsp").forward(request, response);
- } else if (action.equals("admin") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionAdmin");
- }
- if ((Boolean) session.getAttribute("admin")) {
- request.getRequestDispatcher("admin.jsp").forward(request, response);
- } else {
- request.getRequestDispatcher("login.jsp").forward(request, response);
- }
- } else if (action.equals("changePreferences") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionChangePreferences");
- }
- actionChangePreferences(request, session, user);
- request.getRequestDispatcher("preferences.jsp").forward(request, response);
- } else if (action.equals("deleteImport") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionDeleteImport");
- }
- actionDeleteImport(request, response, user);
- //request.getRequestDispatcher("preferences.jsp").forward(request, response);
- } else if (action.equals("reIndexation") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionReIndexation");
- }
- actionReIndexation(request, session, user);
- request.getRequestDispatcher("admin.jsp").forward(request, response);
- } else if (action.equals("deleteSearchResults") && user != null) {
- if (log.isDebugEnabled()) {
- log.debug("Going to actionDeleteSearchResults");
- }
- actionDeleteSearchResults(request, response, user);
- }
- else {
- 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) {
- log.error("Can't do action", eee);
- request.setAttribute("errorMsgUser", eee.getMessage());
- request.setAttribute("errorMsgTech", eee.toString());
- request.getRequestDispatcher("error.jsp").forward(request, response);
- }
- }
-
- /* @param request servlet request
- * @param user user information
- * @throws IOException If the redirection fails
- * @description Deletes every bookmark imported at a given date
- */
- protected void actionDeleteImport(HttpServletRequest request,
- HttpServletResponse response,
- User user) throws IOException {
- String date = request.getParameter("date");
-
- if (date != null) {
- WikittyProxy proxy = BowProxy.getInstance();
-
- if (date.matches("[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{1,3}Z")) {
- Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, Import.EXT_IMPORT).eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).
- eq(Import.FQ_FIELD_DATE, date).criteria();
- List<Import> bookmarks = proxy.findAllByCriteria(Import.class, criteria).getAll();
- List<String> ids = new ArrayList<String>();
-
- for (Import bookmark : bookmarks) {
- ids.add(bookmark.getWikittyId());
- }
- proxy.delete(ids);
- }
- response.sendRedirect("bow?action=preferences");
- }
- }
-
- /* @param request servlet request
- * @param response servlet response
- * @param user user information
- * @throws IOException If the redirection fails
- * @description Deletes the bookmarks returned after a research
- */
- protected void actionDeleteSearchResults(HttpServletRequest request, HttpServletResponse response, User user) throws IOException {
- String searchLine = request.getParameter("searchLine");
- String fullText = request.getParameter("fullTextLine");
-
- if (searchLine != null && fullText != null) {
- WikittyProxy proxy = BowProxy.getInstance();
- Criteria criteria;
- if (fullText.isEmpty()) {
- criteria = getBookmarkListCriteriaByUser(user, searchLine);
- } else {
- criteria = Search.query().keyword(fullText).eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().addFacetField(Bookmark.FQ_FIELD_TAGS);
- }
- List<Bookmark> bookmarks = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
- List<String> ids = new ArrayList<String>();
-
- for (Bookmark bookmark : bookmarks) {
- if (searchLine.isEmpty() && bookmark.getTags() == null || !searchLine.isEmpty() ||
- fullText.isEmpty() && bookmark.getTags() == null || !fullText.isEmpty()) {
- ids.add(bookmark.getWikittyId());
- }
- }
- proxy.delete(ids);
- }
- response.sendRedirect("bow?action=home");
- }
-
- /* @param request servlet request
- * @param response servlet response
- * @param user the user
- * @param token the permanent or temporary token
- * @throws ServletException if a servlet error occurs
- * @description set the openSearch result
- */
- protected void actionOpenSearchResult(HttpServletRequest request,
- HttpServletResponse response, HttpSession session, User user, String token)
- throws IOException, ServletException, NoSuchAlgorithmException {
- String searchLine = request.getParameter("searchLine");
- if (searchLine != null && searchLine.matches("^http://[^ ]*")) {
- response.sendRedirect(searchLine);
- } else if (searchLine != null
- && (searchLine.startsWith(":") || searchLine.startsWith("t:")) ) {
- // on fait une recherche sur les tags
-
- int index = searchLine.indexOf(":");
- searchLine = searchLine.substring(index+1); // suppress first ":"
-
- session.setAttribute("user", user);
- initializeToken(session, user);
- WikittyProxy proxy = BowProxy.getInstance();
- Criteria criteria = getBookmarkListCriteriaByUser(user, searchLine);
- criteria = criteria.addSortDescending(Bookmark.FQ_FIELD_CLICK);
- PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, criteria);// retrieve bookmarks by search
- BookmarkActions bookmarkActions = createBookmarkActions(request, result, searchLine);
- request.setAttribute("bookmarkActions", bookmarkActions);
- request.setAttribute("token", token);
- request.getRequestDispatcher("search.jsp").forward(request, response);
- } else if (searchLine != null && searchLine.startsWith("f:")) {
- // recherche fulltext dans bow
- String fullText = searchLine.substring(2);
-
- session.setAttribute("user", user);
- initializeToken(session, user);
- WikittyProxy proxy = BowProxy.getInstance();
- Criteria criteria;
- if (!fullText.isEmpty()) {
- criteria = Search.query().keyword(fullText).
- eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
- addFacetField(Bookmark.FQ_FIELD_TAGS);
-
- } else {
- criteria = getBookmarkListCriteriaByUser(user, null);
- }
- PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, criteria);
- BookmarkActions bookmarkActions = createBookmarkActions(request, result, null);
- request.setAttribute("bookmarkActions", bookmarkActions);
- request.setAttribute("token", token);
- request.getRequestDispatcher("search.jsp").forward(request, response);
- } else if (searchLine != null && searchLine.startsWith("a:")) {
- // on redirige vers l'alias demande
- searchLine = searchLine.substring(2);
- response.sendRedirect(BowConfig.getInstance().getAliasUrl() + searchLine);
- } else {
- // on fait une recherche sur le moteur de recherche configurer
- WikittyProxy proxy = BowProxy.getInstance();
- Preference pref = proxy.restore(Preference.class, user.getWikittyId());
-
- String searchEngineURL = pref.getSearchEngineUrlResults();
- if (searchEngineURL == null || "".equals(searchEngineURL)) {
- BowConfig config = BowConfig.getInstance();
- searchEngineURL = config.getSearchEngine();
- }
- searchEngineURL = searchEngineURL.replace("{searchTerms}", searchLine);
- searchEngineURL = response.encodeRedirectURL(searchEngineURL);
-
- response.sendRedirect(searchEngineURL);
- }
- }
-
- /* @param request servlet request
- * @param response servlet response
- * @param user the user
- * @throws ServletException if a servlet error occurs
- * @description set the openSearch suggestions
- */
- protected void actionOpenSearchSuggestion(HttpServletRequest request,
- HttpServletResponse response,
- User user)
- throws IOException, ServletException {
- if (user != null) {
- String search = request.getParameter("searchLine");
- if (search != null) {
- OpenSearchActions openSearchActions = new OpenSearchActions();
- WikittyProxy proxy = BowProxy.getInstance();
- String[] words = search.split("\\s+");
- List<String> searchLine = new ArrayList<String>(Arrays.asList(words));
- if (search.charAt(search.length() - 1) == ' ') {
- searchLine.add(""); // if the user types nothing we have to propose suggestions
- }
- Criteria criteria;
- if (searchLine.size() > 1) {
- List<String> cpy = new ArrayList<String>(searchLine);
- cpy.remove(cpy.size() - 1);
- criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).
- eq(Bookmark.FQ_FIELD_TAGS, cpy).criteria().addFacetField(Bookmark.FQ_FIELD_TAGS);
- } else {
- criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).
- criteria().addFacetField(Bookmark.FQ_FIELD_TAGS);
- }
- PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, criteria);
- List<Bookmark> bookList = result.getAll();
- List<FacetTopic> topics = result.getTopic(Bookmark.FQ_FIELD_TAGS);
- openSearchActions.setBookmarkList(bookList);
- openSearchActions.setSuggestionList(topics);
- openSearchActions.findSuggestions(searchLine);
- request.setAttribute("openSearchAction", openSearchActions);
- }
- }
- }
-
- /* @param request servlet request
- * @param response servlet response
- * @param session current session
- * @throws ServletException if a servlet error occurs
- * @description delete the session
- */
- protected void actionLogout(HttpServletRequest request,
- HttpServletResponse response,
- HttpSession session)
- throws IOException, ServletException {
- session.invalidate();
- request.getRequestDispatcher("login.jsp").forward(request, response);
- }
-
- /* @param request servlet request
- * @param response servlet response
- * @throws ServletException if a servlet error occurs
- * @description when the user click on the bookmark bowServletUrl, we
- * increment the number of click
- */
- protected void actionAddClick(HttpServletRequest request, HttpServletResponse response)
- throws IOException, ServletException {
- String bookmarkId = request.getParameter("bookmarkId");
- if (bookmarkId != null && !bookmarkId.isEmpty()) {
- WikittyProxy proxy = BowProxy.getInstance();
- Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId);
- if (bookmark != null) {
- int click = bookmark.getClick();
- ++click;
- bookmark.setClick(click);
- proxy.store(bookmark);
- String link = bookmark.getLink();
- response.sendRedirect(link);
- }
- }
- }
-
- /* @param request servlet request
- * @param response servlet response
- * @param user the user
- * @throws ServletException if a servlet error occurs
- * @description order the bookmarks by type
- */
- protected void actionOrder(HttpServletRequest request,
- HttpServletResponse response,
- User user)
- throws IOException, ServletException {
- String type = request.getParameter("type");
- String searchLine = request.getParameter("searchLine");
- Criteria baseCriteria = getBookmarkListCriteriaByUser(user, searchLine);
- if (type != null && baseCriteria != null && !type.isEmpty()) {
- WikittyProxy proxy = BowProxy.getInstance();
- PagedResult<Bookmark> result = null;
- if (type.equals("ascName")) {
- Criteria criteria = baseCriteria.addSortAscending(Bookmark.FQ_FIELD_DESCRIPTION);
- result = proxy.findAllByCriteria(Bookmark.class, criteria);
- } else if (type.equals("ascDate")) {
- Criteria criteria = baseCriteria.addSortAscending(Bookmark.FQ_FIELD_DATE);
- result = proxy.findAllByCriteria(Bookmark.class, criteria);
- } else if (type.equals("ascClick")) {
- Criteria criteria = baseCriteria.addSortAscending(Bookmark.FQ_FIELD_CLICK);
- result = proxy.findAllByCriteria(Bookmark.class, criteria);
- } else if (type.equals("descName")) {
- Criteria criteria = baseCriteria.addSortDescending(Bookmark.FQ_FIELD_DESCRIPTION);
- result = proxy.findAllByCriteria(Bookmark.class, criteria);
- } else if (type.equals("descDate")) {
- Criteria criteria = baseCriteria.addSortDescending(Bookmark.FQ_FIELD_DATE);
- result = proxy.findAllByCriteria(Bookmark.class, criteria);
- } else if (type.equals("descClick")) {
- Criteria criteria = baseCriteria.addSortDescending(Bookmark.FQ_FIELD_CLICK);
- result = proxy.findAllByCriteria(Bookmark.class, criteria);
- }
- BookmarkActions bookmarkActions = createBookmarkActions(request, result, searchLine);
- request.setAttribute("bookmarkActions", bookmarkActions);
- }
- }
-
- /* @param request servlet request
- * @param response servlet response
- * @param user the user
- * @throws ServletException if a servlet error occurs
- * @description edit the bookmark
- */
- protected void actionEditBookmark(HttpServletRequest request,
- HttpServletResponse response,
- User user)
- throws IOException, ServletException {
- String bookmarkId = request.getParameter("bookmarkId");
- if (bookmarkId != null && !bookmarkId.isEmpty()) {
- WikittyProxy proxy = BowProxy.getInstance();
- Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId);
- if (bookmark != null) {
- request.setAttribute("link", bookmark.getLink());
- request.setAttribute("name", bookmark.getDescription());
- request.setAttribute("alias", bookmark.getAlias());
- request.setAttribute("tags", BookmarkActions.getBookmarkTagsString(bookmark));
- request.setAttribute("action", "bow?action=modifyBookmark");
- request.setAttribute("bookmarkId", bookmarkId);
- }
- }
- String searchLine = request.getParameter("searchLine");
- if (searchLine == null) {
- initHomePage(request, user);
- request.getRequestDispatcher("home.jsp").forward(request, response);
- } else {
- actionSearch(request, user);
- request.getRequestDispatcher("search.jsp").forward(request, response);
- }
- }
-
- /* @param request servlet request
- * @param response servlet response
- * @param user the user
- * @throws ServletException if a servlet error occurs
- * @description remove the bookmark
- */
- protected void actionRemoveBookmark(HttpServletRequest request,
- HttpServletResponse response,
- User user)
- throws IOException, ServletException {
- String bookmarkId = request.getParameter("bookmarkId");
- if (bookmarkId != null && !bookmarkId.isEmpty()) {
- try {
- WikittyProxy proxy = BowProxy.getInstance();
- Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId);
- if (bookmark != null) {
- proxy.delete(bookmarkId);
- }
- } catch (Exception eee) {
- log.error("Can't do action", eee);
- }
- }
- redirectToTheGoodPage(request, response);
- }
-
- /* @param request servlet request
- * @param response servlet response
- * @param user the user
- * @throws ServletException if a servlet error occurs
- * @description delete the bookmark tag
- */
- protected void actionDeleteTag(HttpServletRequest request,
- HttpServletResponse response,
- User user)
- throws IOException, ServletException {
- String bookmarkId = request.getParameter("bookmarkId");
- String tag = request.getParameter("deleteTag");
- if (tag != null && bookmarkId != null) {
- if (!bookmarkId.isEmpty()) {
- WikittyProxy proxy = BowProxy.getInstance();
- Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId);
- if (bookmark != null) {
- bookmark.removeTags(tag);
- proxy.store(bookmark);
- }
- }
- }
- redirectToTheGoodPage(request, response);
- }
-
-
- /* @param request servlet request
- * @param response servlet response
- * @param user User user
- * @param session HttpSession session
- * @throws ServletException if a servlet error occurs
- * @description delete the current token and generate an another
- */
- protected void actionGenerateToken(HttpServletRequest request,
- HttpServletResponse response,
- User user,
- HttpSession session)
- throws IOException, ServletException, NoSuchAlgorithmException {
-
- WikittyProxy proxy = BowProxy.getInstance();
- Criteria criteria = Search.query().eq(Token.FQ_FIELD_EMAIL, user.getEmail()).criteria();
- Token currentToken = proxy.findByCriteria(Token.class, criteria);
- if (currentToken != null) {
- String id = currentToken.getWikittyId();
- proxy.delete(id);
- }
- TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions");
- if (tokenActions != null) {
- String token = tokenActions.generateToken(); // Generate an encoding MD5 token
- criteria = Search.query().eq(Token.FQ_FIELD_TOKEN, token).criteria();
- Token oldToken = proxy.findByCriteria(Token.class, criteria);
- if (oldToken == null) { // Check if the token already exists
- TokenImpl newToken = new TokenImpl();
- newToken.setToken(token);
- newToken.setEmail(user.getEmail());
- proxy.store((Token) newToken); // If the token doesn't exist, it is stored
- tokenActions.setPermanentToken(token);
- } else {
- tokenActions.setPermanentToken("");
- }
- }
- }
-
- protected void actionModifyBookmark(HttpServletRequest request,
- HttpServletResponse response,
- User user)
- throws IOException {
- String link = request.getParameter("url"); // bowServletUrl of the website
- String name = request.getParameter("name"); // website name
- String alias = request.getParameter("alias");
- String tags = request.getParameter("tags");
- String id = request.getParameter("bookmarkId");
- WikittyProxy proxy = BowProxy.getInstance();
- Bookmark bookmark = proxy.restore(Bookmark.class, id);
- if (bookmark != null) {
- if (alias != null && !alias.isEmpty()) {
- Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_ALIAS, alias).criteria();
- if (proxy.findByCriteria(Bookmark.class, criteria) != null) {
- alias = bookmark.getAlias();
- }
- }
- BookmarkActions.updateBookmark(bookmark, name, link, tags, alias);
- proxy.store(bookmark);
- }
- redirectToTheGoodPage(request, response);
- }
-
- /* @param request servlet request
- * @param response servlet response
- * @param user User user
- * @throws ServletException if a servlet error occurs
- * @description add a new bookmark
- */
- protected void actionAddUrl(HttpServletRequest request,
- HttpServletResponse response,
- User user)
- throws IOException, ServletException {
- addUrl(request, user);
- redirectToTheGoodPage(request, response);
- }
-
- protected void addUrl(HttpServletRequest request, User user) {
- String link = request.getParameter("url"); // bowServletUrl of the website
- String name = request.getParameter("name"); // website name
- String alias = request.getParameter("alias");
- WikittyProxy proxy = BowProxy.getInstance();
- Bookmark bookmark = null;
- if (name != null) {
- String tags = request.getParameter("tags"); // tags
- if (alias != null && !alias.isEmpty()) {
- Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_ALIAS, alias).criteria();
- if (proxy.findByCriteria(Bookmark.class, criteria) != null) {
- alias = "";
- }
- }
- bookmark = BookmarkActions.createBookmark(link, name, tags, user, alias, null);
- } else { // this part is for the bookmark addition by script
- String nameAndTags = request.getParameter("nameAndTags");
- if (nameAndTags != null) {
- bookmark = BookmarkActions.createBookmark(link, nameAndTags, user);
- }
- }
- if (bookmark != null && !bookmark.getDescription().isEmpty() && !bookmark.getEmail().isEmpty()) {
- proxy.store(bookmark); // store the bookmark if everything is ok
- if (log.isDebugEnabled()) {
- log.debug("Adding URL");
- }
- }
- }
- /* @param token String token
- * @param session HttpSession session
- * @return User
- * @description check if the token is valid and return the
- * token owner
- */
- protected User checkToken(String token, HttpSession session) {
- if (checkTemporaryToken(token, session)) {
- User user = (User) session.getAttribute("user");
- return user;
- }
- User user = checkPermanentToken(token);
- return user;
- }
-
- /* @param token String which contains the MD5 encoding token
- * @return null the token doesn't exist
- * @return User the token owner
- */
- protected User checkPermanentToken(String token) {
- if (token != null) {
- WikittyProxy proxy = BowProxy.getInstance();
- Criteria criteria = Search.query().eq(Token.FQ_FIELD_TOKEN, token).criteria();
- Token DbToken = proxy.findByCriteria(Token.class, criteria);
- if (DbToken != null) { // check if the token exists
- String userEmail = DbToken.getEmail(); // the token owner user name (email)
- criteria = Search.query().eq(User.FQ_FIELD_EMAIL, userEmail).criteria(); // retrieve user by token
- return proxy.findByCriteria(User.class, criteria);
- }
- }
- return null;
- }
-
- /* @param token String which contains the MD5 encoding token
- * @return null the token doesn't exist
- * @return User the token owner
- */
- protected boolean checkTemporaryToken(String token, HttpSession session) {
- TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions");
- if (tokenActions != null) {
- String temporaryToken = tokenActions.getTemporaryToken();
- if (temporaryToken != null) {
- if (temporaryToken.equals(token)) {
- return true;
- }
- }
- }
- return false;
- }
-
- /* @param request servlet request
- * @param response servlet response
- * @param user User user
- * @throws ServletException if a servlet error occurs
- * @description set the bookmarks and the tagCloud by search
- * or tag addition
- */
- protected void actionSearch(HttpServletRequest request, User user)
- throws IOException, ServletException {
- String searchLine = request.getParameter("searchLine");
- if (searchLine == null) {
- searchLine = "";
- }
- String fulltext = request.getParameter("fullTextLine");
- if (fulltext != null && !fulltext.isEmpty() && searchLine.isEmpty()) {
- actionFullText(request, user);
- } else {
- String tag = request.getParameter("addTag");
- if (tag != null && !tag.isEmpty()) {
- if (searchLine.isEmpty()) {
- searchLine = tag;
- } else {
- searchLine += " " + tag;
- }
- }
- WikittyProxy proxy = BowProxy.getInstance();
- Criteria criteria = getBookmarkListCriteriaByUser(user, searchLine);
- criteria = criteria.addSortDescending(Bookmark.FQ_FIELD_CLICK);
- PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, criteria); // select all bookmarks by user
- BookmarkActions bookmarkActions = createBookmarkActions(request, result, searchLine);
- request.setAttribute("bookmarkActions", bookmarkActions);
- }
- }
-
- /* @param request servlet request
- * @param result PageResult result
- * @param searchLine String searchLine
- * @return bookmarkActions the bookmarkAction
- * @description create the tagCLoud by research type
- */
- protected BookmarkActions createBookmarkActions(HttpServletRequest request,
- PagedResult<Bookmark> result,
- String searchLine) {
- String fullText = request.getParameter("fullTextLine");
- BookmarkActions bookmarkActions = new BookmarkActions();
- bookmarkActions.setFullTextLine(fullText);
- List<Bookmark> bookList = result.getAll();
- if (bookList != null) {
- bookmarkActions.setBookmarks(bookList);
- }
- if (fullText == null || fullText.isEmpty()) {
- if (searchLine != null && searchLine.isEmpty()) {
- bookmarkActions.emptySearchline();
- } else {
- bookmarkActions.addTags(searchLine); // add the new tags
- }
- }
- List<FacetTopic> topics = result.getTopic(Bookmark.FQ_FIELD_TAGS);
- bookmarkActions.createTagCloud(topics);
- return bookmarkActions;
- }
-
- /* @param request servlet request
- * @param response servlet response
- * @param session HttpSessiorn session
- * @throws ServletException if a servlet error occurs
- * @description check if the registration is correct or not
- */
- protected void actionRegister(HttpServletRequest request, HttpServletResponse response, HttpSession session)
- throws IOException, ServletException, NoSuchAlgorithmException, MessagingException {
- String email = request.getParameter("email");
- if (email != null) {
- email = email.trim();
- String password = request.getParameter("password");
- String repeatPassword = request.getParameter("repeatPassword");
- String md5;
-
- if (password == null) {
- request.setAttribute("errorMsgUser", "Invalid password, password must not be null ");
-
- } else if (!password.equals(repeatPassword)) {
- request.setAttribute("errorMsgUser", "Invalid password, you have not type twice the same password.");
-
- } else {
- md5 = StringUtil.encodeMD5(password);
- if (!checkRegister(email, md5, request)) { // check if all is well
- WikittyProxy proxy = BowProxy.getInstance();
- UserImpl newUser = new UserImpl();
- newUser.setPassword(md5);
- newUser.setEmail(email);
- User login = proxy.store((User) newUser); // store the new user
-
- if (login != null) {
- initSession(session, login);
- initHomePage(request, login);
- sendMail(email, password);
- request.getRequestDispatcher("home.jsp").forward(request, response);
-
- } else {
- request.setAttribute("errorMsgUser", "Invalid login, please choose another one");
- }
- }
- }
- request.getRequestDispatcher("register.jsp").forward(request, response);
- }
- }
-
- /* @param request servlet request
- * @param response servlet response
- * @param session HttpSession session
- * @throws ServletException if a servlet error occurs
- * @description check if the authentication is correct or not
- */
- protected void actionLogin(HttpServletRequest request,
- HttpServletResponse response,
- HttpSession session)
- throws IOException, ServletException, NoSuchAlgorithmException {
- String email = request.getParameter("email");
- if (email != null) {
- email = email.trim();
- String password = request.getParameter("password");
- String md5;
- if (password != null) {
- md5 = StringUtil.encodeMD5(password);
- User login = checkLogin(email, md5, request); // check if the user exists
- if (login != null) {
- initSession(session, login);
- initHomePage(request, login);
- request.getRequestDispatcher("home.jsp").forward(request, response);
- return;
- }
- }
- }
- request.getRequestDispatcher("login.jsp").forward(request, response);
- }
-
- protected void checkAdmin(String login, HttpSession session) {
- String[] admins = BowConfig.getInstance().getAdmins();
- if (admins != null) {
- for (String admin : admins) {
- if (login.equals(admin)) {
- session.setAttribute("admin", true);
- return;
- }
- }
- }
- session.setAttribute("admin", false);
- }
-
- /* @param session HttpSession session
- * @throws ServletException if a servlet error occurs
- * @description retrieve tokens or create there if the user are just
- * registered
- */
- protected void initializeToken(HttpSession session, User login)
- throws NoSuchAlgorithmException {
- WikittyProxy proxy = BowProxy.getInstance();
- Criteria criteria = Search.query().eq(Token.FQ_FIELD_EMAIL, login.getEmail()).criteria();
- Token token = proxy.findByCriteria(Token.class, criteria);
- TokenActions tokenActions = new TokenActions();
- if (token == null) {
- token = new TokenImpl();
- String newToken = tokenActions.generateToken();
- token.setToken(newToken);
- token.setEmail(login.getEmail());
- proxy.store(token);
- }
- tokenActions.setPermanentToken(token.getToken());
- String temporaryToken = tokenActions.generateToken();
- tokenActions.setTemporaryToken(temporaryToken);
- session.setAttribute("tokenActions", tokenActions);
- }
-
-
- /* @param email String which contains the user name (email)
- * @param password String which contains the user password
- * @return null the user doesn't exist
- * @return User the user exists
- */
- protected User checkLogin(String email,
- String password,
- HttpServletRequest request) throws NoSuchAlgorithmException {
- if (email != null && password != null) {
- if (!email.isEmpty() && !password.equals(StringUtil.encodeMD5(""))) {
- WikittyProxy proxy = BowProxy.getInstance();
- Criteria criteria = Search.query().eq(User.FQ_FIELD_EMAIL, email).
- eq(User.FQ_FIELD_PASSWORD, password).criteria();
- User user = proxy.findByCriteria(User.class, criteria);
-
- if (user == null) {
- request.setAttribute("errorMsgUser", "Unknown email or incorrect password");
- }
- return user; // retrieve user by user name (email) and password
- }
- }
- request.setAttribute("errorMsgUser", "Please enter your email address and your password");
- return null;
- }
-
-
- /* @param email String which contains the user name (email)
- * @param password String which contains the user password
- * @return boolean false if the user doesn't exist or true
- */
- protected boolean checkRegister(String email,
- String password,
- HttpServletRequest request) throws NoSuchAlgorithmException {
- if (email != null && password != null) {
- if (!email.isEmpty() && !password.equals(StringUtil.encodeMD5(""))) {
- WikittyProxy proxy = BowProxy.getInstance();
-
- Criteria criteria = Search.query().eq(User.FQ_FIELD_EMAIL, email).criteria(); // retrieve user by user name (email)
- if (proxy.findByCriteria(User.class, criteria) == null) {
- return false;
- }
- request.setAttribute("errorMsgUser", "This email address is already used");
- return true;
- }
- }
- request.setAttribute("errorMsgUser", "Email and password must be correctly filled");
- return true;
- }
-
- protected void initHomePage(HttpServletRequest request, User user) {
- WikittyProxy proxy = BowProxy.getInstance();
- Criteria criteria = getBookmarkListCriteriaByUser(user, null);
- if (criteria != null) {
- Criteria sortCriteria = criteria.addSortDescending(Bookmark.FQ_FIELD_CLICK);
- PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, sortCriteria); // select all bookmarks by user
- sortCriteria = criteria.addSortDescending(Bookmark.FQ_FIELD_DATE).setEndIndex(10);
- List<Bookmark> lastBookmarks = proxy.findAllByCriteria(Bookmark.class, sortCriteria).getAll();
- BookmarkActions bookmarkActions = createBookmarkActions(request, result, null);
- bookmarkActions.setTagSearch(null);
- List<Bookmark> bookList = bookmarkActions.getBookmarks();
- if (bookList.size() > 10) {
- bookList = bookmarkActions.getBookmarks().subList(0, 10);
- bookmarkActions.setBookmarks(bookList);
- }
- if (lastBookmarks != null) {
- bookmarkActions.setLastBookmarks(lastBookmarks);
- }
- request.setAttribute("bookmarkActions", bookmarkActions);
- }
- }
-
- protected void initSession(HttpSession session, User user) throws NoSuchAlgorithmException {
- WikittyProxy proxy = BowProxy.getInstance();
- session.setAttribute("user", user);
- Preference preference = proxy.restore(Preference.class, user.getWikittyId());
- session.setAttribute("preference", preference);
- initializeToken(session, user);
- checkAdmin(user.getEmail(), session);
- }
-
- /* @param request servlet request
- * @param user User user
- * @description initialize all for the home page
- */
- protected void actionHome(HttpServletRequest request,
- HttpServletResponse response,
- HttpSession session)
- throws ServletException, IOException, NoSuchAlgorithmException {
- User user = (User) session.getAttribute("user");
- if (user == null) {
- String token = request.getParameter("token");
- user = checkPermanentToken(token);
- if (user != null) {
- initSession(session, user);
- }
- }
- if (user != null) {
- initHomePage(request, user);
- request.getRequestDispatcher("home.jsp").forward(request, response);
- } else {
- request.getRequestDispatcher("login.jsp").forward(request, response);
- }
- }
-
- protected void createImportExtension(List<Bookmark> bookmarks) {
- if (bookmarks != null && !bookmarks.isEmpty()) {
- WikittyProxy proxy = BowProxy.getInstance();
- List<String> ids = new ArrayList<String>();
- for (Bookmark bookmark : bookmarks) {
- String id = bookmark.getWikittyId();
- ids.add(id);
- }
- Date date = new Date();
- List<Import> imports = proxy.restore(Import.class, ids);
- for (Import imp : imports) {
- imp.setDate(date);
- }
- proxy.store(imports);
- }
- }
-
- protected void getBookmarksByImportDate(HttpServletRequest request, User user) {
- WikittyProxy proxy = BowProxy.getInstance();
- Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, Import.EXT_IMPORT).eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
- addFacetField(Import.FQ_FIELD_DATE);
- List<FacetTopic> bookmarksImportDate = proxy.findAllByCriteria(Import.class, criteria).getTopic(Import.FQ_FIELD_DATE);
- request.setAttribute("bookmarksImportDate", bookmarksImportDate);
- }
-
- /* @param request servlet request
- * @param response servlet response
- * @param user User user
- * @throws ServletException if a servlet error occurs
- * @description import bookmark for an user
- */
- protected void actionImportBookmarks(HttpServletRequest request, HttpServletResponse response, User user)
- throws IOException, FileUploadException, ServletException {
- // Check that we have a file upload request
- boolean isMultipart = ServletFileUpload.isMultipartContent(request);
- if (isMultipart) {
- // 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<?> items = upload.parseRequest(request);
- for (Object obj : items) {
- FileItem item = (FileItem) obj;
- if (!item.isFormField()) {
- WikittyProxy proxy = BowProxy.getInstance();
- String content = item.getString();
- try {
- Parser parser = new Parser(content);
- NodeList list = parser.parse(null);
- List<Bookmark> bookmarks = new ArrayList<Bookmark>();
- parseHtmlToBookmarks(list, user, bookmarks, new ArrayList<String>());
- bookmarks = proxy.store(bookmarks);
- createImportExtension(bookmarks);
- initHomePage(request, user);
- request.getRequestDispatcher("home.jsp").forward(request, response);
- }
- catch (ParserException e) {
- request.setAttribute("errorMsgUser", "Bad bookmarks file format, expected Netscape-like bookmarks file");
- request.setAttribute("errorMsgTech", e.getMessage());
-
- String searchLine = request.getParameter("searchLine");
- if (searchLine == null) {
- initHomePage(request, user);
- request.getRequestDispatcher("home.jsp").forward(request, response);
- } else {
- actionSearch(request, user);
- request.getRequestDispatcher("search.jsp").forward(request, response);
- }
- }
- }
- }
- }
- }
-
- /* @param list NodeList list
- * @param bookmarks List<Bookmark> bookmarks
- * @param tagList List<String> tagList
- * @throws ParserException if a parser error occurs
- * @description parse the html by recursion and retrieve bookmarks
- */
- protected void parseHtmlToBookmarks(NodeList list, User user, List<Bookmark> bookmarks, List<String> tagList)
- throws ParserException {
- if (list != null) {
- boolean isFolder = false;
- SimpleNodeIterator it = list.elements();
- while (it.hasMoreNodes()) {
- Node node = it.nextNode();
- String plainText = node.toPlainTextString(); // the text between two heads ==> <toto>plainText</toto>
- String text = node.getText(); // the text in the head ==> <text></toto>
- if (text != null && text.startsWith("H3")) { // H3 = folder
- if (plainText != null && !plainText.isEmpty()) {
- tagList.add(plainText); // add the folder name to the tagList
- isFolder = true;
- }
- } else if (text != null && text.startsWith("A HREF")) { // HREF = new bookmarks
- Bookmark bookmark = BookmarkActions.createBookmarkFromHtml(text, plainText, user);
- BookmarkActions.addTagsToBookmark(tagList, bookmark);
- if (bookmark != null) {
- bookmarks.add(bookmark);
- }
- }
- NodeList children = node.getChildren();
- if (children != null) {
- parseHtmlToBookmarks(children, user, bookmarks, tagList); // if there is an under node = recursion
- }
- }
- if (isFolder) { // if we find a folder, we have to remove it
- int index = tagList.size() - 1;
- if (index > -1) {
- tagList.remove(index);
- }
- }
- }
- }
-
- /* @param response servlet response
- * @param user User user
- * @description export bookmarks
- */
- protected void actionExportBookmarks(HttpServletResponse response, User user)
- throws IOException {
- WikittyProxy proxy = BowProxy.getInstance();
- 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\"");
- response.setContentLength(buff.length);
- op.write(buff, 0, buff.length);
- op.flush();
- op.close();
- }
-
- /* @param request servlet request
- * @param response servlet response
- * @throws ServletException if a servlet error occurs
- * @description add an alias for one bookmark
- */
- protected void actionAddAlias(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
- String alias = request.getParameter("alias");
- if (alias != null && !alias.isEmpty()) {
- WikittyProxy proxy = BowProxy.getInstance();
- 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);
- }
- }
- }
- }
- redirectToTheGoodPage(request, response);
- }
-
- /* @param request servlet request
- * @param user User user
- * @throws ServletException if a servlet error occurs
- * @description retrieve bookmark for the full text research
- */
- protected void actionFullText(HttpServletRequest request, User user) throws IOException, ServletException {
- String fullText = request.getParameter("fullTextLine");
- if (fullText == null || fullText.isEmpty()) {
- actionSearch(request, user);
- } else {
- WikittyProxy proxy = BowProxy.getInstance();
- Criteria criteria;
- if (!fullText.isEmpty()) {
- criteria = Search.query().keyword(fullText).
- eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
- addFacetField(Bookmark.FQ_FIELD_TAGS);
-
- } else {
- criteria = getBookmarkListCriteriaByUser(user, null);
- }
- PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, criteria);
- BookmarkActions bookmarkActions = createBookmarkActions(request, result, null);
- request.setAttribute("bookmarkActions", bookmarkActions);
- }
- }
-
- /* @param request servlet request
- * @param response servlet response
- * @throws ServletException if a servlet error occurs
- * @description choose the good page
- */
- protected void redirectToTheGoodPage(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
- String searchLine = request.getParameter("searchLine");
- String fullText = request.getParameter("fullTextLine");
- if (fullText == null) {
- fullText = "";
- }
- if (searchLine != null) {
- response.sendRedirect("bow?action=search&searchLine=" + searchLine + "&fullTextLine=" + fullText);
- } else {
- response.sendRedirect("bow?action=home");
- }
- }
-
- /* @param user User user
- * @param searchLine String searchLine
- * @description return the bookmark criteria by search
- */
- protected Criteria getBookmarkListCriteriaByUser(User user, String searchLine) {
- Criteria criteria = null;
- if (user != null) {
- if (searchLine != null && !searchLine.isEmpty()) {
- String[] words = searchLine.split("\\s+"); // put the tags in an array
- List<String> tags = new ArrayList<String>(Arrays.asList(words));
- criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).
- eq(Bookmark.FQ_FIELD_TAGS, tags).criteria().addFacetField(Bookmark.FQ_FIELD_TAGS);
- } else {
- criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).
- criteria().addFacetField(Bookmark.FQ_FIELD_TAGS);
- }
- }
- return criteria;
- }
-
- protected Preference changePreference(HttpServletRequest request, HttpSession session) {
-
- Preference preference = (Preference) session.getAttribute("preference");
- // Retrieve Preference fields
- String colors = request.getParameter("colors");
- String tags = request.getParameter("tagsNb");
- String bookmarks = request.getParameter("bookmarks");
- String searchEngineSuggestions = request.getParameter("searchEngineUrlSuggestions");
- String searchEngineResults = request.getParameter("searchEngineUrlResults");
-
- preference.setColors(colors);
- preference.setTags(Integer.valueOf(tags));
- preference.setBookmarks(Integer.valueOf(bookmarks));
- preference.setSearchEngineUrlSuggestions(searchEngineSuggestions);
- preference.setSearchEngineUrlResults(searchEngineResults);
-
- return preference;
- }
-
- protected User changeUser(HttpServletRequest request, User newUser)
- throws NoSuchAlgorithmException {
- String email = request.getParameter("email");
- String newPassword = request.getParameter("newPassword");
- String currentPassword = request.getParameter("currentPassword");
- String confirmNewPassword = request.getParameter("confirmNewPassword");
-
- if (email != null && !email.isEmpty()) {
- newUser.setEmail(email);
- }
- if (newPassword != null && confirmNewPassword != null && currentPassword != null) {
- if (!newPassword.isEmpty() && !confirmNewPassword.isEmpty() && !currentPassword.isEmpty()) {
- if (newPassword.equals(confirmNewPassword)) {
- currentPassword = StringUtil.encodeMD5(currentPassword);
- if (currentPassword.equals(newUser.getPassword())) {
- String md5 = StringUtil.encodeMD5(newPassword);
- newUser.setPassword(md5);
- }
- }
- }
- }
- return newUser;
- }
-
- protected void actionChangePreferences(HttpServletRequest request, HttpSession session, User user)
- throws NoSuchAlgorithmException, AddressException, MessagingException {
-
- WikittyProxy proxy = BowProxy.getInstance();
-
- Preference preference = changePreference(request, session);
- proxy.store(preference);
-
- User newUser = proxy.restore(User.class, user.getWikittyId());
- newUser = changeUser(request, newUser);
- newUser = proxy.store(newUser);
- session.setAttribute("user", newUser);
-
- preference = proxy.restore(Preference.class, newUser.getWikittyId());
- session.setAttribute("preference", preference);
- }
-
- protected void sendMail(String email, String password)
- throws AddressException, MessagingException {
-
- BowConfig config = BowConfig.getInstance();
- String smtpServer = config.getSmtpServer();
- Properties properties = new Properties();
- properties.put("mail.smtp.host", smtpServer);
-
- Session session = Session.getDefaultInstance(properties, null);
- session.setDebug(true);
-
- Message msg = new MimeMessage(session);
-
- InternetAddress toAddress = new InternetAddress(email);
- msg.addRecipient(Message.RecipientType.TO, toAddress);
-
- String addressFrom = config.getAddressFrom();
- InternetAddress fromAddress = new InternetAddress(addressFrom);
- msg.setFrom(fromAddress);
-
- String messageSubject = "[Bow] New Password";
- msg.setSubject(messageSubject);
-
- String messageBody = "Hi,\n\n";
- messageBody += "Your new password: " + password + "\n";
- messageBody += "Your email: " + email + "\n\n";
- msg.setContent(messageBody, "text/plain");
-
- Transport.send(msg);
- }
-
- protected boolean passwordExists(String password) {
- WikittyProxy proxy = BowProxy.getInstance();
- Criteria criteria = Search.query().eq(User.FQ_FIELD_PASSWORD, password).criteria();
- List<User> users = proxy.findAllByCriteria(User.class, criteria).getAll();
- if (users != null && users.size() > 0) {
- return true;
- }
- return false;
- }
-
- protected void actionSendPassword(HttpServletRequest request, HttpServletResponse response)
- throws NoSuchAlgorithmException, AddressException, MessagingException, ServletException, IOException {
- String email = request.getParameter("email");
- if (email != null) {
- email = email.trim();
- if (!email.isEmpty()) {
- WikittyProxy proxy = BowProxy.getInstance();
- Criteria criteria = Search.query().eq(User.FQ_FIELD_EMAIL, email).criteria();
- User user = proxy.findByCriteria(User.class, criteria);
- if (user != null) {
- boolean bool = true;
- String password = "";
- String md5 = "";
- while (bool) {
- password = RandomStringUtils.randomAlphanumeric(20);
- md5 = StringUtil.encodeMD5(password);
- bool = passwordExists(md5);
- }
- sendMail(email, password);
- user.setPassword(md5);
- proxy.store(user);
- request.getRequestDispatcher("login.jsp").forward(request, response);
- } else {
- request.setAttribute("errorMsgUser", "This email address doesn't exist");
- }
- } else {
- request.setAttribute("errorMsgUser", "Please enter an email address");
- }
- }
- request.getRequestDispatcher("forgotPassword.jsp").forward(request, response);
- }
-
- protected void actionReIndexation(HttpServletRequest request, HttpSession session, User user) {
- if ((Boolean) session.getAttribute("admin")) {
- WikittyProxy proxy = BowProxy.getInstance();
- proxy.getWikittyService().syncEngin(proxy.getSecurityToken());
- }
- }
-}
Modified: trunk/src/main/java/org/chorem/bow/action/AddAliasAction.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/action/AddAliasAction.java 2011-01-07 11:19:18 UTC (rev 166)
+++ trunk/src/main/java/org/chorem/bow/action/AddAliasAction.java 2011-01-07 19:02:06 UTC (rev 167)
@@ -46,6 +46,7 @@
WikittyProxy proxy = BowProxy.getInstance();
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()) {
if (bookmarkId != null && !bookmarkId.isEmpty()) {
Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId);
Modified: trunk/src/main/java/org/chorem/bow/action/AddUrlAction.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/action/AddUrlAction.java 2011-01-07 11:19:18 UTC (rev 166)
+++ trunk/src/main/java/org/chorem/bow/action/AddUrlAction.java 2011-01-07 19:02:06 UTC (rev 167)
@@ -20,6 +20,7 @@
protected String nameAndTags;
protected Map<String, Object> session;
+
/**
* @return the link
*/
Modified: trunk/src/main/java/org/chorem/bow/action/EditBookmarkAction.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/action/EditBookmarkAction.java 2011-01-07 11:19:18 UTC (rev 166)
+++ trunk/src/main/java/org/chorem/bow/action/EditBookmarkAction.java 2011-01-07 19:02:06 UTC (rev 167)
@@ -71,13 +71,12 @@
request.setAttribute("name", bookmark.getDescription());
request.setAttribute("alias", bookmark.getAlias());
request.setAttribute("tags", BookmarkActions.getBookmarkTagsString(bookmark));
- request.setAttribute("action", "bow/modifyBookmark.action");
- request.setAttribute("bookmarkId", bookmarkId);
+ request.setAttribute("formAction", "/bow/modifyBookmark.action?bookmarkId=" + bookmarkId);
}
}
if (searchLine == null) {
BowInit.initHomePage(request, (User)session.get("user"));
- return NONE;
+ return "home";
} else {
try {
BowSearch.search(request, (User)session.get("user"));
@@ -88,7 +87,7 @@
// TODO Auto-generated catch block
e.printStackTrace();
}
- return SUCCESS;
+ return "search";
}
}
}
\ No newline at end of file
Modified: trunk/src/main/java/org/chorem/bow/action/LoginAction.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/action/LoginAction.java 2011-01-07 11:19:18 UTC (rev 166)
+++ trunk/src/main/java/org/chorem/bow/action/LoginAction.java 2011-01-07 19:02:06 UTC (rev 167)
@@ -68,20 +68,12 @@
public void setSession(Map<String, Object> session) {
this.session = session;
}
-
- public Map<String, Object> getSession() {
- return this.session;
- }
@Override
public void setServletRequest(HttpServletRequest request) {
this.servletRequest = request;
}
- public HttpServletRequest getServletRequest() {
- return this.servletRequest;
- }
-
protected User checkLogin(String email, String password) throws NoSuchAlgorithmException {
if (email != null && password != null) {
if (!email.isEmpty() && !password.equals(StringUtil.encodeMD5(""))) {
Modified: trunk/src/main/resources/i18n/bow_en_GB.properties
===================================================================
--- trunk/src/main/resources/i18n/bow_en_GB.properties 2011-01-07 11:19:18 UTC (rev 166)
+++ trunk/src/main/resources/i18n/bow_en_GB.properties 2011-01-07 19:02:06 UTC (rev 167)
@@ -1,4 +1,3 @@
-bookmarksHomePage=
bow.action.locale.english=English
bow.action.locale.french=French
bow.bookmark.badFileFormat=
@@ -44,7 +43,7 @@
bow.preferences.siteLook=
bow.preferences.submit=
bow.preferences.tagsNb=
-bow.preferences.title=
+bow.preferences.title=Preferences
bow.preferences.userInfo=
bow.register.emailAldyUsed=This email address is already used
bow.register.invalidLogin=
@@ -56,11 +55,3 @@
bow.register.submit=Register
bow.register.title=Register
bow.requiredstring=${getText(fieldKey)} is required
-colors=
-confirmNewPassword=
-currentPassword=
-email=
-newPassword=
-searchEngineUrlResults=
-searchEngineUrlSuggestions=
-tagsNb=
Modified: trunk/src/main/resources/i18n/bow_fr_FR.properties
===================================================================
--- trunk/src/main/resources/i18n/bow_fr_FR.properties 2011-01-07 11:19:18 UTC (rev 166)
+++ trunk/src/main/resources/i18n/bow_fr_FR.properties 2011-01-07 19:02:06 UTC (rev 167)
@@ -1,4 +1,3 @@
-bookmarksHomePage=
bow.action.locale.english=Anglais
bow.action.locale.french=Fran\u00E7ais
bow.bookmark.badFileFormat=
@@ -44,7 +43,7 @@
bow.preferences.siteLook=
bow.preferences.submit=
bow.preferences.tagsNb=
-bow.preferences.title=
+bow.preferences.title=Pr\u00E9f\u00E9rences
bow.preferences.userInfo=
bow.register.emailAldyUsed=Cette adresse email est d\u00E9j\u00E0 utilis\u00E9e
bow.register.invalidLogin=
@@ -56,11 +55,3 @@
bow.register.submit=S''enregistrer
bow.register.title=S''enregistrer
bow.requiredstring=${getText(fieldKey)} est obligatoire
-colors=
-confirmNewPassword=
-currentPassword=
-email=
-newPassword=
-searchEngineUrlResults=
-searchEngineUrlSuggestions=
-tagsNb=
Modified: trunk/src/main/resources/struts.xml
===================================================================
--- trunk/src/main/resources/struts.xml 2011-01-07 11:19:18 UTC (rev 166)
+++ trunk/src/main/resources/struts.xml 2011-01-07 19:02:06 UTC (rev 167)
@@ -46,15 +46,15 @@
<result type="redirectAction">home</result>
</action>
<action name="modifyBookmark" class="org.chorem.bow.action.ModifyBookmarkAction">
- <result name="home">/jsp/home.jsp</result>
<result name="search">/jsp/search.jsp</result>
+ <result type="redirectAction">home</result>
</action>
<action name="removeBookmark" class="org.chorem.bow.action.RemoveBookmarkAction">
<result type="redirectAction">home</result>
<result name="search">/jsp/search.jsp</result>
</action>
<action name="editBookmark" class="org.chorem.bow.action.EditBookmarkAction">
- <result name="home">/jsp/home.jsp</result>
+ <result name="home" type="redirectAction">home</result>
<result name="search">/jsp/search.jsp</result>
</action>
</package>
@@ -75,6 +75,7 @@
</action>
<action name="addAlias" class="org.chorem.bow.action.AddAliasAction">
<!-- La redirection change selon le type de page sur laquelle on est, donc je ne vois pas trop comment faire ça pour le moment-->
+ <result type="redirectAction">home</result>
</action>
<action name="order" class="org.chorem.bow.action.OrderAction">
<result>/jsp/search.jsp</result>
Modified: trunk/src/main/webapp/js/bookmark.js
===================================================================
--- trunk/src/main/webapp/js/bookmark.js 2011-01-07 11:19:18 UTC (rev 166)
+++ trunk/src/main/webapp/js/bookmark.js 2011-01-07 19:02:06 UTC (rev 167)
@@ -1,6 +1,6 @@
function modify(name, alias, tags, link, action, id) {
var form = document.getElementById("bookmarkForm");
- form.elements["url"].value = link;
+ form.elements["link"].value = link;
form.elements["name"].value = name;
form.elements["tags"].value = tags;
form.elements["alias"].value = alias;
Modified: trunk/src/main/webapp/jsp/inc/bookmark.jsp
===================================================================
--- trunk/src/main/webapp/jsp/inc/bookmark.jsp 2011-01-07 11:19:18 UTC (rev 166)
+++ trunk/src/main/webapp/jsp/inc/bookmark.jsp 2011-01-07 19:02:06 UTC (rev 167)
@@ -56,10 +56,10 @@
<%=bookmark.getAlias()%>
</a>
<p class="date"> (<%=sdf.format(bookmark.getDate())%>)</p>
- <s:url id="editBookmark" action="editBookmark">
+ <s:url id="editBookmark" action="modifyBookmark">
<s:param name="bookmarkId"><%=bookmark.getWikittyId()%><%=search%></s:param>
</s:url>
- <s:a cssClass="edit" href="%{editBookmark}" onclick="return modify('<%=bookmark.getDescription()%>', '<%=bookmark.getAlias()%>', '<%=BookmarkActions.getBookmarkTagsString(bookmark)%>', '<%=link%>', %{editBookmark}, '<%=bookmark.getWikittyId()%>');"></s:a>
+ <s:a cssClass="edit" href="%{editBookmark}" onclick="return modify('%{#request.bookmark.getDescription()}', '%{#request.bookmark.getAlias()}', '%{#request.bookmark.getTags()}', '%{#request.bookmark.getLink()}', '%{editBookmark}', '%{#request.bookmark.getWikittyId()}');"></s:a>
<s:url id="removeBookmark" action="removeBookmark">
<s:param name="bookmarkId"><%=bookmark.getWikittyId()%><%=search%></s:param>
</s:url>
@@ -81,6 +81,7 @@
<strong>Tags :</strong>
<%
Set<String> tagList = bookmark.getTags();
+
if (tagList != null && !tagList.isEmpty()) {
for (String tag : tagList) {
%>
Modified: trunk/src/main/webapp/jsp/inc/rightMenu.jsp
===================================================================
--- trunk/src/main/webapp/jsp/inc/rightMenu.jsp 2011-01-07 11:19:18 UTC (rev 166)
+++ trunk/src/main/webapp/jsp/inc/rightMenu.jsp 2011-01-07 19:02:06 UTC (rev 167)
@@ -75,7 +75,8 @@
if (formAlias == null)
formAlias = "alias";
if (formAction == null)
- formAction = "/bow/addUrl.action";
+ request.setAttribute("formAction", "/bow/addUrl.action");
+ //formAction = "/bow/addUrl.action";
%>
<div id="logout" xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
@@ -93,24 +94,24 @@
<li><s:a action="admin"><s:text name="bow.rightMenu.admin" /></s:a></li>
<% } %>
<li><s:a action="preferences"><s:text name="bow.preferences.title" /></s:a></li>
- <li><a title="%{getText('temporaryLinkDescription')}" 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%>/addUrl.action&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);"><s:text name="bow.rightMenu.bookmark.temporaryLink" /></a></li>
- <li><a title="%{getText('permanentLinkDescription')}" 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%>/addUrl.action&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);"><s:text name="bow.rightMenu.bookmark.permanentLink" /></a></li>
+ <li><s:a title="%{getText('bow.rightMenu.bookmark.temporaryLinkDescription')}" 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%>/addUrl.action&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);"><s:text name="bow.rightMenu.bookmark.temporaryLink" /></s:a></li>
+ <li><s:a title="%{getText('bow.rightMenu.bookmark.permanentLinkDescription')}" 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%>/addUrl.action&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);"><s:text name="bow.rightMenu.bookmark.permanentLink" /></s:a></li>
</ul>
<div id="extensions">
<h2><s:text name="bow.rightMenu.extensions" /></h2>
<ul class="droite">
<li><a href="extensions/bow4chromium.crx"><img src="img/chromium.png" alt="Chromium" class="extensionIcon" />Extension pour Chromium</a></li>
- <li><strong><s:text name="bow.rightMenu.token.permanent" /></strong> <%= permanentToken %></li>
- <li><strong><s:text name="bow.rightMenu.token.temporary" /></strong> <%= temporaryToken %></li>
+ <li><strong><s:text name="bow.rightMenu.token.permanent" /></strong> <%=permanentToken%></li>
+ <li><strong><s:text name="bow.rightMenu.token.temporary" /></strong> <%=temporaryToken%></li>
</ul>
</div>
<div id="add" class="clearfix">
<h2><s:text name="bow.rightMenu.bookmark.addModify" /></h2>
- <s:form id="bookmarkForm" action="addUrl">
- <s:textfield key="bow.rightMenu.bookmark.link" name="link" /><!-- <%=formLink%> -->
- <s:textfield key="bow.rightMenu.bookmark.alias" name="alias" /><!-- <%=formAlias%> -->
- <s:textfield key="bow.rightMenu.bookmark.name" name="name" /><!-- <%=formName%> -->
- <s:textfield key="bow.rightMenu.bookmark.tags" name="tags" /><!-- <%=formTags%> -->
+ <s:form id="bookmarkForm" action="%{#request.formAction}">
+ <s:textfield key="bow.rightMenu.bookmark.link" name="link" value="%{#request.link}" />
+ <s:textfield key="bow.rightMenu.bookmark.alias" name="alias" value="%{#request.alias}" />
+ <s:textfield key="bow.rightMenu.bookmark.name" name="name" value="%{#request.name}" />
+ <s:textfield key="bow.rightMenu.bookmark.tags" name="tags" value="%{#request.tags}" />
<s:submit key="bow.rightMenu.bookmark.submit" />
</s:form>
</div>
Modified: trunk/src/main/webapp/jsp/preferences.jsp
===================================================================
--- trunk/src/main/webapp/jsp/preferences.jsp 2011-01-07 11:19:18 UTC (rev 166)
+++ trunk/src/main/webapp/jsp/preferences.jsp 2011-01-07 19:02:06 UTC (rev 167)
@@ -95,7 +95,10 @@
%>
<div class="deleteImport deleteImport<%=bgColors[i % colorsNb]%>">
<span><%= date + " (" + bookmarkImport.getCount() + " bookmarks)" %></span>
- <a class="deleteImportButton" href="" onclick="deleteConfirmation('/bow/deleteImport.action&date=<%=dateSave%>',<%=bookmarkImport.getCount()%>,'<%=date%>'); return(false);"></a>
+ <s:url id="deleteImport" action="deleteImport">
+ <s:param name="date"><%=dateSave%></s:param>
+ </s:url>
+ <s:a cssClass="deleteImportButton" href="" onclick="deleteConfirmation('%{deleteImport}','%{#bookmarkImport!getCount}','<%=date%>'); return(false);"></s:a>
</div>
<%
i++;
@@ -109,19 +112,6 @@
}
}
%>
- <s:if test="%{#bookmarksImportDate != null && #bookmarksImportDate.size() > 0}">
- <s:iterator value="bookmarksImportDate">
- <div class="deleteImport">
- <span>(<s:property value="topicName" /> bookmarks)</span>
- <a class="deleteImportButton" href="" onclick="deleteConfirmation('/bow/deleteImport.action&date=',,''); return(false);"></a>
- </div>
- </s:iterator>
- </s:if>
- <s:else>
- <div class="deleteImport deleteImportWhite">
- <span><s:text name="bow.preferences.noImportedBookmarks" /></span>
- </div>
- </s:else>
</div>
<jsp:include page="inc/rightMenu.jsp" flush="true" />
</body>
1
0
r166 - in trunk/src/main: java/org/chorem/bow java/org/chorem/bow/action resources webapp/jsp
by vbriand@users.chorem.org 07 Jan '11
by vbriand@users.chorem.org 07 Jan '11
07 Jan '11
Author: vbriand
Date: 2011-01-07 12:19:18 +0100 (Fri, 07 Jan 2011)
New Revision: 166
Url: http://chorem.org/repositories/revision/bow/166
Log:
The bookmarks import works with Struts2.
Modified:
trunk/src/main/java/org/chorem/bow/BowBookmark.java
trunk/src/main/java/org/chorem/bow/action/ImportBookmarksAction.java
trunk/src/main/java/org/chorem/bow/action/PreferencesAction.java
trunk/src/main/resources/struts.xml
trunk/src/main/webapp/jsp/preferences.jsp
Modified: trunk/src/main/java/org/chorem/bow/BowBookmark.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BowBookmark.java 2011-01-06 17:33:35 UTC (rev 165)
+++ trunk/src/main/java/org/chorem/bow/BowBookmark.java 2011-01-07 11:19:18 UTC (rev 166)
@@ -9,6 +9,8 @@
import org.nuiton.wikitty.Criteria;
import org.nuiton.wikitty.FacetTopic;
import org.nuiton.wikitty.PagedResult;
+import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.search.Element;
import org.nuiton.wikitty.search.Search;
public class BowBookmark {
@@ -48,4 +50,13 @@
bookmarkActions.createTagCloud(topics);
return bookmarkActions;
}
+
+ static public List<FacetTopic> getBookmarksByImportDate(HttpServletRequest request, User user) {
+ WikittyProxy proxy = BowProxy.getInstance();
+ Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, Import.EXT_IMPORT).eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
+ addFacetField(Import.FQ_FIELD_DATE);
+ List<FacetTopic> bookmarksImportDate = proxy.findAllByCriteria(Import.class, criteria).getTopic(Import.FQ_FIELD_DATE);
+ request.setAttribute("bookmarksImportDate", bookmarksImportDate);
+ return bookmarksImportDate;
+ }
}
Modified: trunk/src/main/java/org/chorem/bow/action/ImportBookmarksAction.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/action/ImportBookmarksAction.java 2011-01-06 17:33:35 UTC (rev 165)
+++ trunk/src/main/java/org/chorem/bow/action/ImportBookmarksAction.java 2011-01-07 11:19:18 UTC (rev 166)
@@ -1,5 +1,6 @@
package org.chorem.bow.action;
+import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
@@ -9,10 +10,7 @@
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
-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.io.FileUtils;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.SessionAware;
import org.chorem.bow.Bookmark;
@@ -33,9 +31,54 @@
public class ImportBookmarksAction extends BowBaseAction implements SessionAware, ServletRequestAware {
private static final long serialVersionUID = -5962680416570797028L;
+ protected File upfile;
+ protected String upfileContentType;
+ protected String upfileFileName;
protected Map<String, Object> session;
protected HttpServletRequest request;
+ /**
+ * @return the upfile
+ */
+ public File getUpfile() {
+ return upfile;
+ }
+
+ /**
+ * @param upfile the upfile to set
+ */
+ public void setUpfile(File upfile) {
+ this.upfile = upfile;
+ }
+
+ /**
+ * @return the upfileContentType
+ */
+ public String getUpfileContentType() {
+ return upfileContentType;
+ }
+
+ /**
+ * @param upfileContentType the upfileContentType to set
+ */
+ public void setUpfileContentType(String upfileContentType) {
+ this.upfileContentType = upfileContentType;
+ }
+
+ /**
+ * @return the upfileFileName
+ */
+ public String getUpfileFileName() {
+ return upfileFileName;
+ }
+
+ /**
+ * @param upfileFileName the upfileFileName to set
+ */
+ public void setUpfileFileName(String upfileFileName) {
+ this.upfileFileName = upfileFileName;
+ }
+
@Override
public void setSession(Map<String, Object> session) {
this.session = session;
@@ -106,64 +149,55 @@
}
public String execute() {
- // Check that we have a file upload request
- boolean isMultipart = ServletFileUpload.isMultipartContent(request);
-
- if (isMultipart) {
- // 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<?> items;
+ User user = (User)session.get("user");
+
+ if (user != null) {
try {
- items = upload.parseRequest(request);
- } catch (FileUploadException e2) {
- // TODO Auto-generated catch block
- e2.printStackTrace();
- return ERROR;
- }
- for (Object obj : items) {
- FileItem item = (FileItem) obj;
- if (!item.isFormField()) {
- WikittyProxy proxy = BowProxy.getInstance();
- String content = item.getString();
- User user = (User)session.get("user");
+ List<?> lines;
- try {
- Parser parser = new Parser(content);
- NodeList list = parser.parse(null);
- List<Bookmark> bookmarks = new ArrayList<Bookmark>();
- parseHtmlToBookmarks(list, user, bookmarks, new ArrayList<String>());
- bookmarks = proxy.store(bookmarks);
- createImportExtension(bookmarks);
+ lines = FileUtils.readLines(upfile);
+ String content = "";
+
+ for (Object line : lines) {
+ content += (String)line;
+ }
+ WikittyProxy proxy = BowProxy.getInstance();
+
+ try {
+ Parser parser = new Parser(content);
+ NodeList list = parser.parse(null);
+ List<Bookmark> bookmarks = new ArrayList<Bookmark>();
+ parseHtmlToBookmarks(list, user, bookmarks, new ArrayList<String>());
+ bookmarks = proxy.store(bookmarks);
+ createImportExtension(bookmarks);
+ BowInit.initHomePage(request, user);
+ return SUCCESS;
+ } catch (ParserException e) {
+ request.setAttribute("errorMsgUser", getText(n_("bow.bookmark.badFileFormat")));
+ request.setAttribute("errorMsgTech", e.getMessage());
+
+ if (request.getParameter("searchLine") == null) {
BowInit.initHomePage(request, user);
return SUCCESS;
- }
- catch (ParserException e) {
- request.setAttribute("errorMsgUser", getText(n_("bow.bookmark.badFileFormat")));
- request.setAttribute("errorMsgTech", e.getMessage());
-
- if (request.getParameter("searchLine") == null) {
- BowInit.initHomePage(request, user);
- return "home";
- } else {
- try {
- BowSearch.search(request, user);
- } catch (IOException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- } catch (ServletException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- return "search";
- }
- }
+ } else {
+ try {
+ BowSearch.search(request, user);
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (ServletException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ return "search";
+ }
}
+ } catch (IOException e2) {
+ // TODO Auto-generated catch block
+ e2.printStackTrace();
}
+ return ERROR;
}
- return ERROR;
+ return LOGIN;
}
}
\ No newline at end of file
Modified: trunk/src/main/java/org/chorem/bow/action/PreferencesAction.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/action/PreferencesAction.java 2011-01-06 17:33:35 UTC (rev 165)
+++ trunk/src/main/java/org/chorem/bow/action/PreferencesAction.java 2011-01-07 11:19:18 UTC (rev 166)
@@ -1,16 +1,22 @@
package org.chorem.bow.action;
import java.security.NoSuchAlgorithmException;
+import java.util.List;
import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.SessionAware;
+import org.chorem.bow.BowBookmark;
import org.chorem.bow.BowProxy;
import org.chorem.bow.Preference;
import org.chorem.bow.User;
import org.nuiton.util.StringUtil;
+import org.nuiton.wikitty.FacetTopic;
import org.nuiton.wikitty.WikittyProxy;
-public class PreferencesAction extends BowBaseAction implements SessionAware {
+public class PreferencesAction extends BowBaseAction implements SessionAware, ServletRequestAware {
private static final long serialVersionUID = -58341106356599721L;
protected String colors;
protected String tagsNb;
@@ -22,8 +28,11 @@
protected String currentPassword;
protected String confirmNewPassword;
protected String update;
+ protected List<FacetTopic> bookmarksImportDate;
protected Map<String, Object> session;
+ protected HttpServletRequest request;
+
/**
* @return the colors
*/
@@ -164,11 +173,30 @@
this.update = update;
}
+ /**
+ * @return the bookmarksImportDate
+ */
+ public List<FacetTopic> getBookmarksImportDate() {
+ return bookmarksImportDate;
+ }
+
+ /**
+ * @param bookmarksImportDate the bookmarksImportDate to set
+ */
+ public void setBookmarksImportDate(List<FacetTopic> bookmarksImportDate) {
+ this.bookmarksImportDate = bookmarksImportDate;
+ }
+
@Override
public void setSession(Map<String, Object> session) {
this.session = session;
}
+ @Override
+ public void setServletRequest(HttpServletRequest request) {
+ this.request = request;
+ }
+
protected Preference changePreference() {
Preference preference = (Preference)session.get("preference");
@@ -203,14 +231,18 @@
}
public String execute() {
- if ((User)session.get("user") != null) {
+ User user = (User)session.get("user");
+
+ if (user != null) {
+ setBookmarksImportDate(BowBookmark.getBookmarksByImportDate(request, user));
+
if (update != null) {
WikittyProxy proxy = BowProxy.getInstance();
Preference preference = changePreference();
proxy.store(preference);
- User newUser = proxy.restore(User.class, ((User)session.get("user")).getWikittyId());
-
+ User newUser = proxy.restore(User.class, (user).getWikittyId());
+
try {
newUser = changeUser(newUser);
} catch (NoSuchAlgorithmException e) {
@@ -225,11 +257,8 @@
return "update";
} else {
Preference preference = (Preference)session.get("preference");
- User user = (User)session.get("user");
-
- if (user != null) {
- setEmail(user.getEmail());
- }
+
+ setEmail(user.getEmail());
if (preference != null) {
setColors(preference.getColors());
setTagsNb(String.valueOf(preference.getTags()));
Modified: trunk/src/main/resources/struts.xml
===================================================================
--- trunk/src/main/resources/struts.xml 2011-01-06 17:33:35 UTC (rev 165)
+++ trunk/src/main/resources/struts.xml 2011-01-07 11:19:18 UTC (rev 166)
@@ -36,11 +36,15 @@
</package>
<package name="bookmark" extends="struts-default">
- <!-- import, export -->
- <action name="*Bookmarks" method="{1}" class="org.chorem.bow.action.BookmarksAction">
- <result name="search">/jsp/search.jsp</result>
- <result>/jsp/home.jsp</result>
+ <action name="importBookmarks" class="org.chorem.bow.action.ImportBookmarksAction">
+ <result name="search" type="redirectAction">search</result>
+ <result name="error" type="redirectAction">error</result>
+ <result name="login" type="redirectAction">home</result>
+ <result type="redirectAction">home</result>
</action>
+ <action name="exportBookmarks" class="org.chorem.bow.action.ExportBookmarksAction">
+ <result type="redirectAction">home</result>
+ </action>
<action name="modifyBookmark" class="org.chorem.bow.action.ModifyBookmarkAction">
<result name="home">/jsp/home.jsp</result>
<result name="search">/jsp/search.jsp</result>
@@ -89,7 +93,6 @@
<result>/jsp/suggestions.jsp</result>
</action>
<action name="preferences" class="org.chorem.bow.action.PreferencesAction">
- <!-- Cas du getBookmarksByImportDate qu'il faudrait caler quelque part -->
<result name="login" type="redirectAction">login_input</result>
<result name="update" type="redirectAction">preferences</result>
<result>/jsp/preferences.jsp</result>
Modified: trunk/src/main/webapp/jsp/preferences.jsp
===================================================================
--- trunk/src/main/webapp/jsp/preferences.jsp 2011-01-06 17:33:35 UTC (rev 165)
+++ trunk/src/main/webapp/jsp/preferences.jsp 2011-01-07 11:19:18 UTC (rev 166)
@@ -24,131 +24,105 @@
-->
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
-<%@page import="org.chorem.bow.Preference"%>
-<%@page import="org.chorem.bow.User"%>
-<%@page import="org.chorem.bow.TokenActions"%>
-<%@page import="org.chorem.bow.BookmarkActions"%>
-<%@page import="org.chorem.bow.Bookmark" %>
<%@page import="org.chorem.bow.Import" %>
<%@page import="org.nuiton.wikitty.FacetTopic" %>
<%@page import="java.util.List" %>
-<%@page import="java.util.Date" %>
-<%
-User user = (User) session.getAttribute("user");
-Preference preference = (Preference) session.getAttribute("preference");
-TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions");
-//Boolean admin = (Boolean) session.getAttribute("admin");
-//if (admin == null) {
-// admin = false;
-//}
-int nbTags = 100;
-if (user != null && preference != null && tokenActions != null){
- int tags = preference.getTags();
- if (tags > 0) {
- nbTags = tags;
- }
- request.setAttribute("nbTags", nbTags);
-// String url = (String) request.getAttribute("bowUrl");
-// String version = (String) request.getAttribute("version");
-// String temporaryToken = tokenActions.getTemporaryToken();
-// String permanentToken = tokenActions.getPermanentToken();
- String check = preference.getColors();
- if (check == null) {
- preference.setColors("");
- }
- check = preference.getSearchEngineUrlResults();
- if (check == null) {
- preference.setSearchEngineUrlResults("");
- }
- check = preference.getSearchEngineUrlSuggestions();
- if (check == null) {
- preference.setSearchEngineUrlSuggestions("");
- }
- %>
- [[[[[<%=preference.getTags() %>]]]]]
- <html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
- xmlns:jsp="http://java.sun.com/JSP/Page"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <head>
- <title><s:text name="bow.preferences.title" /></title>
- <s:url id="css" value="/css/bookmark.css" />
- <link href="${css}" rel="stylesheet" type="text/css" />
- <s:head />
- </head>
- <body>
- <div id="content">
- <div class="menu clearfix">
- <h2><s:text name="bow.preferences.title" /></h2>
- </div>
- <s:url id="changePreferences" action="preferences">
- <s:param name="update">1</s:param>
- </s:url>
- <s:form action="%{changePreferences}">
- <div class="formFrame">
- <h3><s:text name="bow.preferences.userInfo" /></h3>
- <p>
- <s:textfield key="bow.login.email" name="email" /><br /><br /><!-- value="<%=user.getEmail()%>" -->
- <s:password key="bow.preferences.currentPassword" name="currentPassword" />
- <s:password key="bow.preferences.newPassword" name="newPassword" />
- <s:password key="bow.preferences.confirmNewPassword" name="confirmNewPassword" />
- <s:url id="generateToken" action="generateToken" />
- <s:a href="%{generateToken}" id="regenPermToken"><s:text name="bow.preferences.regenPermToken" /></s:a>
- </p>
- </div>
- <div class="formFrame">
- <h3><s:text name="bow.preferences.siteLook" /></h3>
- <p>
- <s:textfield key="bow.preferences.colors" name="colors" /><br /> <!-- value="<%=preference.getColors()%>" -->
- <s:textfield key="bow.preferences.tagsNb" name="tagsNb" /><br />
- <s:textfield key="bow.preferences.bookmarksHomePage" name="bookmarksHomePage" /><br />
- <s:textfield key="bow.preferences.searchEngineUrlSuggestions" name="searchEngineUrlSuggestions" /><br />
- <s:textfield key="bow.preferences.searchEngineUrlResults" name="searchEngineUrlResults" />
- <s:submit key="bow.preferences.submit" />
- <br /><br />
- <s:url id="home" action="home" />
- <s:a href="%{home}" id="homePage"><s:text name="bow.home.title" /></s:a>
- </p>
- </div>
- </s:form>
- <div class="menu clearfix">
- <h2><s:text name="bow.preferences.importedBookmarks" /></h2>
- </div>
- <%
- List<FacetTopic> bookmarkImportList = (List<FacetTopic>)request.getAttribute("bookmarksImportDate");
-
- if (bookmarkImportList != null) {
- if (bookmarkImportList.size() > 0) {
- String bgColors[] = {"Pink", "White"};
- int i = 0;
- int colorsNb = bgColors.length;
-
- for (FacetTopic bookmarkImport : bookmarkImportList) {
- String date = bookmarkImport.getTopicName();
- String dateSave = date;
-
- date = date.replaceAll("[^0-9:-]+", " ").trim();
- date = date.substring(0, date.lastIndexOf(' '));
- %>
- <div class="deleteImport deleteImport<%=bgColors[i % colorsNb]%>">
- <span><%= date + " (" + bookmarkImport.getCount() + " bookmarks)" %></span>
- <a class="deleteImportButton" href="" onclick="deleteConfirmation('/bow/deleteImport.action&date=<%=dateSave%>',<%=bookmarkImport.getCount()%>,'<%=date%>'); return(false);"></a>
- </div>
- <%
- i++;
- }
- } else {
- %>
- <div class="deleteImport deleteImportWhite">
- <span><s:text name="bow.preferences.noImportedBookmarks" /></span>
- </div>
- <%
- }
- }
- %>
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ xmlns:jsp="http://java.sun.com/JSP/Page"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <head>
+ <title><s:text name="bow.preferences.title" /></title>
+ <s:url id="css" value="/css/bookmark.css" />
+ <link href="${css}" rel="stylesheet" type="text/css" />
+ <s:head />
+ </head>
+ <body>
+ <s:property value="#session.put" />
+ <div id="content">
+ <div class="menu clearfix">
+ <h2><s:text name="bow.preferences.title" /></h2>
</div>
- <jsp:include page="inc/rightMenu.jsp" flush="true" />
- </body>
- </html>
-<% } %>
\ No newline at end of file
+ <s:url id="changePreferences" action="preferences">
+ <s:param name="update">1</s:param>
+ </s:url>
+ <s:form action="%{changePreferences}">
+ <div class="formFrame">
+ <h3><s:text name="bow.preferences.userInfo" /></h3>
+ <p>
+ <s:textfield key="bow.login.email" name="email" /><br /><br />
+ <s:password key="bow.preferences.currentPassword" name="currentPassword" />
+ <s:password key="bow.preferences.newPassword" name="newPassword" />
+ <s:password key="bow.preferences.confirmNewPassword" name="confirmNewPassword" />
+ <s:url id="generateToken" action="generateToken" />
+ <s:a href="%{generateToken}" id="regenPermToken"><s:text name="bow.preferences.regenPermToken" /></s:a>
+ </p>
+ </div>
+ <div class="formFrame">
+ <h3><s:text name="bow.preferences.siteLook" /></h3>
+ <p>
+ <s:textfield key="bow.preferences.colors" name="colors" /><br />
+ <s:textfield key="bow.preferences.tagsNb" name="tagsNb" /><br />
+ <s:textfield key="bow.preferences.bookmarksHomePage" name="bookmarksHomePage" /><br />
+ <s:textfield key="bow.preferences.searchEngineUrlSuggestions" name="searchEngineUrlSuggestions" /><br />
+ <s:textfield key="bow.preferences.searchEngineUrlResults" name="searchEngineUrlResults" />
+ <s:submit key="bow.preferences.submit" />
+ <br /><br />
+ <s:url id="home" action="home" />
+ <s:a href="%{home}" id="homePage"><s:text name="bow.home.title" /></s:a>
+ </p>
+ </div>
+ </s:form>
+ <div class="menu clearfix">
+ <h2><s:text name="bow.preferences.importedBookmarks" /></h2>
+ </div>
+ <%
+ List<FacetTopic> bookmarkImportList = (List<FacetTopic>)request.getAttribute("bookmarksImportDate");
+
+ if (bookmarkImportList != null) {
+ if (bookmarkImportList.size() > 0) {
+ String bgColors[] = {"Pink", "White"};
+ int i = 0;
+ int colorsNb = bgColors.length;
+
+ for (FacetTopic bookmarkImport : bookmarkImportList) {
+ String date = bookmarkImport.getTopicName();
+ String dateSave = date;
+
+ date = date.replaceAll("[^0-9:-]+", " ").trim();
+ date = date.substring(0, date.lastIndexOf(' '));
+ %>
+ <div class="deleteImport deleteImport<%=bgColors[i % colorsNb]%>">
+ <span><%= date + " (" + bookmarkImport.getCount() + " bookmarks)" %></span>
+ <a class="deleteImportButton" href="" onclick="deleteConfirmation('/bow/deleteImport.action&date=<%=dateSave%>',<%=bookmarkImport.getCount()%>,'<%=date%>'); return(false);"></a>
+ </div>
+ <%
+ i++;
+ }
+ } else {
+ %>
+ <div class="deleteImport deleteImportWhite">
+ <span><s:text name="bow.preferences.noImportedBookmarks" /></span>
+ </div>
+ <%
+ }
+ }
+ %>
+ <s:if test="%{#bookmarksImportDate != null && #bookmarksImportDate.size() > 0}">
+ <s:iterator value="bookmarksImportDate">
+ <div class="deleteImport">
+ <span>(<s:property value="topicName" /> bookmarks)</span>
+ <a class="deleteImportButton" href="" onclick="deleteConfirmation('/bow/deleteImport.action&date=',,''); return(false);"></a>
+ </div>
+ </s:iterator>
+ </s:if>
+ <s:else>
+ <div class="deleteImport deleteImportWhite">
+ <span><s:text name="bow.preferences.noImportedBookmarks" /></span>
+ </div>
+ </s:else>
+ </div>
+ <jsp:include page="inc/rightMenu.jsp" flush="true" />
+ </body>
+</html>
\ No newline at end of file
1
0
r165 - in trunk/src/main: java/org/chorem/bow/action resources webapp webapp/jsp
by vbriand@users.chorem.org 06 Jan '11
by vbriand@users.chorem.org 06 Jan '11
06 Jan '11
Author: vbriand
Date: 2011-01-06 18:33:35 +0100 (Thu, 06 Jan 2011)
New Revision: 165
Url: http://chorem.org/repositories/revision/bow/165
Log:
The preferences page works again. On the home page, the link now redirects to the bookmark page.
Added:
trunk/src/main/java/org/chorem/bow/action/PreferencesAction.java
Removed:
trunk/src/main/java/org/chorem/bow/action/ChangePreferencesAction.java
Modified:
trunk/src/main/java/org/chorem/bow/action/AddClickAction.java
trunk/src/main/java/org/chorem/bow/action/GenerateTokenAction.java
trunk/src/main/resources/struts.xml
trunk/src/main/webapp/index.jsp
trunk/src/main/webapp/jsp/preferences.jsp
Modified: trunk/src/main/java/org/chorem/bow/action/AddClickAction.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/action/AddClickAction.java 2011-01-06 14:22:41 UTC (rev 164)
+++ trunk/src/main/java/org/chorem/bow/action/AddClickAction.java 2011-01-06 17:33:35 UTC (rev 165)
@@ -7,6 +7,7 @@
public class AddClickAction extends BowBaseAction {
private static final long serialVersionUID = 8579081104294143087L;
protected String bookmarkId;
+ protected String link;
/**
* @return the bookmarkId
@@ -21,6 +22,18 @@
this.bookmarkId = bookmarkId;
}
+ /**
+ * @return the link
+ */
+ public String getLink() {
+ return link;
+ }
+ /**
+ * @param link the link to set
+ */
+ public void setLink(String link) {
+ this.link = link;
+ }
public String execute() {
if (bookmarkId != null && !bookmarkId.isEmpty()) {
WikittyProxy proxy = BowProxy.getInstance();
@@ -28,6 +41,7 @@
if (bookmark != null) {
bookmark.setClick(bookmark.getClick() + 1);
proxy.store(bookmark);
+ link = bookmark.getLink();
return SUCCESS;
}
}
Deleted: trunk/src/main/java/org/chorem/bow/action/ChangePreferencesAction.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/action/ChangePreferencesAction.java 2011-01-06 14:22:41 UTC (rev 164)
+++ trunk/src/main/java/org/chorem/bow/action/ChangePreferencesAction.java 2011-01-06 17:33:35 UTC (rev 165)
@@ -1,207 +0,0 @@
-package org.chorem.bow.action;
-
-import java.security.NoSuchAlgorithmException;
-import java.util.Map;
-
-import org.apache.struts2.interceptor.SessionAware;
-import org.chorem.bow.BowProxy;
-import org.chorem.bow.Preference;
-import org.chorem.bow.User;
-import org.nuiton.util.StringUtil;
-import org.nuiton.wikitty.WikittyProxy;
-
-public class ChangePreferencesAction extends BowBaseAction implements SessionAware {
- private static final long serialVersionUID = -1923646256914239581L;
- protected String colors;
- protected String tagsNb;
- protected String bookmarks;
- protected String searchEngineUrlSuggestions;
- protected String searchEngineUrlResults;
- protected String email;
- protected String newPassword;
- protected String currentPassword;
- protected String confirmNewPassword;
- protected Map<String, Object> session;
-
- /**
- * @return the colors
- */
- public String getColors() {
- return colors;
- }
-
- /**
- * @param colors the colors to set
- */
- public void setColors(String colors) {
- this.colors = colors;
- }
-
- /**
- * @return the tagsNb
- */
- public String getTagsNb() {
- return tagsNb;
- }
-
- /**
- * @param tagsNb the tagsNb to set
- */
- public void setTagsNb(String tagsNb) {
- this.tagsNb = tagsNb;
- }
-
- /**
- * @return the bookmarks
- */
- public String getBookmarks() {
- return bookmarks;
- }
-
- /**
- * @param bookmarks the bookmarks to set
- */
- public void setBookmarks(String bookmarks) {
- this.bookmarks = bookmarks;
- }
-
- /**
- * @return the searchEngineUrlSuggestions
- */
- public String getSearchEngineUrlSuggestions() {
- return searchEngineUrlSuggestions;
- }
-
- /**
- * @param searchEngineUrlSuggestions the searchEngineUrlSuggestions to set
- */
- public void setSearchEngineUrlSuggestions(String searchEngineUrlSuggestions) {
- this.searchEngineUrlSuggestions = searchEngineUrlSuggestions;
- }
-
- /**
- * @return the searchEngineUrlResults
- */
- public String getSearchEngineUrlResults() {
- return searchEngineUrlResults;
- }
-
- /**
- * @param searchEngineUrlResults the searchEngineUrlResults to set
- */
- public void setSearchEngineUrlResults(String searchEngineUrlResults) {
- this.searchEngineUrlResults = searchEngineUrlResults;
- }
-
- /**
- * @return the email
- */
- public String getEmail() {
- return email;
- }
-
- /**
- * @param email the email to set
- */
- public void setEmail(String email) {
- this.email = email;
- }
-
- /**
- * @return the newPassword
- */
- public String getNewPassword() {
- return newPassword;
- }
-
- /**
- * @param newPassword the newPassword to set
- */
- public void setNewPassword(String newPassword) {
- this.newPassword = newPassword;
- }
-
- /**
- * @return the currentPassword
- */
- public String getCurrentPassword() {
- return currentPassword;
- }
-
- /**
- * @param currentPassword the currentPassword to set
- */
- public void setCurrentPassword(String currentPassword) {
- this.currentPassword = currentPassword;
- }
-
- /**
- * @return the confirmNewPassword
- */
- public String getConfirmNewPassword() {
- return confirmNewPassword;
- }
-
- /**
- * @param confirmNewPassword the confirmNewPassword to set
- */
- public void setConfirmNewPassword(String confirmNewPassword) {
- this.confirmNewPassword = confirmNewPassword;
- }
-
- @Override
- public void setSession(Map<String, Object> session) {
- this.session = session;
- }
-
- protected Preference changePreference() {
- Preference preference = (Preference)session.get("preference");
-
- preference.setColors(colors);
- preference.setTags(Integer.valueOf(tagsNb));
- preference.setBookmarks(Integer.valueOf(bookmarks));
- preference.setSearchEngineUrlSuggestions(searchEngineUrlSuggestions);
- preference.setSearchEngineUrlResults(searchEngineUrlResults);
-
- return preference;
- }
-
- protected User changeUser(User newUser)
- throws NoSuchAlgorithmException {
- if (email != null && !email.isEmpty()) {
- newUser.setEmail(email);
- }
- if (newPassword != null && confirmNewPassword != null && currentPassword != null) {
- if (!newPassword.isEmpty() && !confirmNewPassword.isEmpty() && !currentPassword.isEmpty()) {
- if (newPassword.equals(confirmNewPassword)) {
- currentPassword = StringUtil.encodeMD5(currentPassword);
- if (currentPassword.equals(newUser.getPassword())) {
- String md5 = StringUtil.encodeMD5(newPassword);
- newUser.setPassword(md5);
- }
- }
- }
- }
- return newUser;
- }
-
- public String execute() {
- WikittyProxy proxy = BowProxy.getInstance();
- Preference preference = changePreference();
- proxy.store(preference);
-
- User newUser = proxy.restore(User.class, ((User)session.get("user")).getWikittyId());
- try {
- newUser = changeUser(newUser);
- } catch (NoSuchAlgorithmException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- newUser = proxy.store(newUser);
- session.put("user", newUser);
-
- preference = proxy.restore(Preference.class, newUser.getWikittyId());
- session.put("preference", preference);
- return SUCCESS;
- }
-}
\ No newline at end of file
Modified: trunk/src/main/java/org/chorem/bow/action/GenerateTokenAction.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/action/GenerateTokenAction.java 2011-01-06 14:22:41 UTC (rev 164)
+++ trunk/src/main/java/org/chorem/bow/action/GenerateTokenAction.java 2011-01-06 17:33:35 UTC (rev 165)
@@ -23,37 +23,41 @@
}
public String execute() {
- WikittyProxy proxy = BowProxy.getInstance();
User user = (User)session.get("user");
- Criteria criteria = Search.query().eq(Token.FQ_FIELD_EMAIL, user.getEmail()).criteria();
- Token currentToken = proxy.findByCriteria(Token.class, criteria);
- if (currentToken != null) {
- String id = currentToken.getWikittyId();
- proxy.delete(id);
- }
- TokenActions tokenActions = (TokenActions)session.get("tokenActions");
-
- if (tokenActions != null) {
- String token;
- try {
- token = tokenActions.generateToken(); //Generates an encoding MD5 token
- criteria = Search.query().eq(Token.FQ_FIELD_TOKEN, token).criteria();
- Token oldToken = proxy.findByCriteria(Token.class, criteria);
-
- if (oldToken == null) { //Checks if the token already exists
- TokenImpl newToken = new TokenImpl();
- newToken.setToken(token);
- newToken.setEmail(user.getEmail());
- proxy.store((Token) newToken); //If the token doesn't exist, it is stored
- tokenActions.setPermanentToken(token);
- } else {
- tokenActions.setPermanentToken("");
+
+ if (user != null) {
+ WikittyProxy proxy = BowProxy.getInstance();
+ Criteria criteria = Search.query().eq(Token.FQ_FIELD_EMAIL, user.getEmail()).criteria();
+ Token currentToken = proxy.findByCriteria(Token.class, criteria);
+ if (currentToken != null) {
+ String id = currentToken.getWikittyId();
+ proxy.delete(id);
+ }
+ TokenActions tokenActions = (TokenActions)session.get("tokenActions");
+
+ if (tokenActions != null) {
+ String token;
+ try {
+ token = tokenActions.generateToken(); //Generates an encoding MD5 token
+ criteria = Search.query().eq(Token.FQ_FIELD_TOKEN, token).criteria();
+ Token oldToken = proxy.findByCriteria(Token.class, criteria);
+
+ if (oldToken == null) { //Checks if the token already exists
+ TokenImpl newToken = new TokenImpl();
+ newToken.setToken(token);
+ newToken.setEmail(user.getEmail());
+ proxy.store((Token) newToken); //If the token doesn't exist, it is stored
+ tokenActions.setPermanentToken(token);
+ } else {
+ tokenActions.setPermanentToken("");
+ }
+ } catch (NoSuchAlgorithmException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
- } catch (NoSuchAlgorithmException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
}
+ return SUCCESS;
}
- return SUCCESS;
+ return LOGIN;
}
}
\ No newline at end of file
Added: trunk/src/main/java/org/chorem/bow/action/PreferencesAction.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/action/PreferencesAction.java (rev 0)
+++ trunk/src/main/java/org/chorem/bow/action/PreferencesAction.java 2011-01-06 17:33:35 UTC (rev 165)
@@ -0,0 +1,245 @@
+package org.chorem.bow.action;
+
+import java.security.NoSuchAlgorithmException;
+import java.util.Map;
+
+import org.apache.struts2.interceptor.SessionAware;
+import org.chorem.bow.BowProxy;
+import org.chorem.bow.Preference;
+import org.chorem.bow.User;
+import org.nuiton.util.StringUtil;
+import org.nuiton.wikitty.WikittyProxy;
+
+public class PreferencesAction extends BowBaseAction implements SessionAware {
+ private static final long serialVersionUID = -58341106356599721L;
+ protected String colors;
+ protected String tagsNb;
+ protected String bookmarksHomePage;
+ protected String searchEngineUrlSuggestions;
+ protected String searchEngineUrlResults;
+ protected String email;
+ protected String newPassword;
+ protected String currentPassword;
+ protected String confirmNewPassword;
+ protected String update;
+ protected Map<String, Object> session;
+
+ /**
+ * @return the colors
+ */
+ public String getColors() {
+ return colors;
+ }
+
+ /**
+ * @param colors the colors to set
+ */
+ public void setColors(String colors) {
+ this.colors = colors;
+ }
+
+ /**
+ * @return the tagsNb
+ */
+ public String getTagsNb() {
+ return tagsNb;
+ }
+
+ /**
+ * @param tagsNb the tagsNb to set
+ */
+ public void setTagsNb(String tagsNb) {
+ this.tagsNb = tagsNb;
+ }
+
+ /**
+ * @return the bookmarksHomePage
+ */
+ public String getBookmarksHomePage() {
+ return bookmarksHomePage;
+ }
+
+ /**
+ * @param bookmarksHomePage the bookmarksHomePage to set
+ */
+ public void setBookmarksHomePage(String bookmarksHomePage) {
+ this.bookmarksHomePage = bookmarksHomePage;
+ }
+
+ /**
+ * @return the searchEngineUrlSuggestions
+ */
+ public String getSearchEngineUrlSuggestions() {
+ return searchEngineUrlSuggestions;
+ }
+
+ /**
+ * @param searchEngineUrlSuggestions the searchEngineUrlSuggestions to set
+ */
+ public void setSearchEngineUrlSuggestions(String searchEngineUrlSuggestions) {
+ this.searchEngineUrlSuggestions = searchEngineUrlSuggestions;
+ }
+
+ /**
+ * @return the searchEngineUrlResults
+ */
+ public String getSearchEngineUrlResults() {
+ return searchEngineUrlResults;
+ }
+
+ /**
+ * @param searchEngineUrlResults the searchEngineUrlResults to set
+ */
+ public void setSearchEngineUrlResults(String searchEngineUrlResults) {
+ this.searchEngineUrlResults = searchEngineUrlResults;
+ }
+
+ /**
+ * @return the email
+ */
+ public String getEmail() {
+ return email;
+ }
+
+ /**
+ * @param email the email to set
+ */
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ /**
+ * @return the newPassword
+ */
+ public String getNewPassword() {
+ return newPassword;
+ }
+
+ /**
+ * @param newPassword the newPassword to set
+ */
+ public void setNewPassword(String newPassword) {
+ this.newPassword = newPassword;
+ }
+
+ /**
+ * @return the currentPassword
+ */
+ public String getCurrentPassword() {
+ return currentPassword;
+ }
+
+ /**
+ * @param currentPassword the currentPassword to set
+ */
+ public void setCurrentPassword(String currentPassword) {
+ this.currentPassword = currentPassword;
+ }
+
+ /**
+ * @return the confirmNewPassword
+ */
+ public String getConfirmNewPassword() {
+ return confirmNewPassword;
+ }
+
+ /**
+ * @param confirmNewPassword the confirmNewPassword to set
+ */
+ public void setConfirmNewPassword(String confirmNewPassword) {
+ this.confirmNewPassword = confirmNewPassword;
+ }
+
+ /**
+ * @return the update
+ */
+ public String getUpdate() {
+ return update;
+ }
+
+ /**
+ * @param update the update to set
+ */
+ public void setUpdate(String update) {
+ this.update = update;
+ }
+
+ @Override
+ public void setSession(Map<String, Object> session) {
+ this.session = session;
+ }
+
+ protected Preference changePreference() {
+ Preference preference = (Preference)session.get("preference");
+
+ preference.setColors(colors);
+ if ((tagsNb != null && !tagsNb.isEmpty())) {
+ preference.setTags(Integer.valueOf(tagsNb));
+ }
+ if (bookmarksHomePage != null && !bookmarksHomePage.isEmpty())
+ preference.setBookmarks(Integer.valueOf(bookmarksHomePage));
+ preference.setSearchEngineUrlSuggestions(searchEngineUrlSuggestions);
+ preference.setSearchEngineUrlResults(searchEngineUrlResults);
+
+ return preference;
+ }
+
+ protected User changeUser(User newUser)
+ throws NoSuchAlgorithmException {
+ if (email != null && !email.isEmpty()) {
+ newUser.setEmail(email);
+ }
+ if (newPassword != null && confirmNewPassword != null && currentPassword != null) {
+ if (!newPassword.isEmpty() && !confirmNewPassword.isEmpty() && !currentPassword.isEmpty()) {
+ if (newPassword.equals(confirmNewPassword)) {
+ currentPassword = StringUtil.encodeMD5(currentPassword);
+ if (currentPassword.equals(newUser.getPassword())) {
+ newUser.setPassword(StringUtil.encodeMD5(newPassword));
+ }
+ }
+ }
+ }
+ return newUser;
+ }
+
+ public String execute() {
+ if ((User)session.get("user") != null) {
+ if (update != null) {
+ WikittyProxy proxy = BowProxy.getInstance();
+ Preference preference = changePreference();
+ proxy.store(preference);
+
+ User newUser = proxy.restore(User.class, ((User)session.get("user")).getWikittyId());
+
+ try {
+ newUser = changeUser(newUser);
+ } catch (NoSuchAlgorithmException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ newUser = proxy.store(newUser);
+ session.put("user", newUser);
+
+ preference = proxy.restore(Preference.class, newUser.getWikittyId());
+ session.put("preference", preference);
+ return "update";
+ } else {
+ Preference preference = (Preference)session.get("preference");
+ User user = (User)session.get("user");
+
+ if (user != null) {
+ setEmail(user.getEmail());
+ }
+ if (preference != null) {
+ setColors(preference.getColors());
+ setTagsNb(String.valueOf(preference.getTags()));
+ setBookmarksHomePage(String.valueOf(preference.getBookmarks()));
+ setSearchEngineUrlSuggestions(preference.getSearchEngineUrlSuggestions());
+ setSearchEngineUrlResults(preference.getSearchEngineUrlResults());
+ }
+ }
+ return SUCCESS;
+ }
+ return LOGIN;
+ }
+}
Property changes on: trunk/src/main/java/org/chorem/bow/action/PreferencesAction.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/src/main/resources/struts.xml
===================================================================
--- trunk/src/main/resources/struts.xml 2011-01-06 14:22:41 UTC (rev 164)
+++ trunk/src/main/resources/struts.xml 2011-01-06 17:33:35 UTC (rev 165)
@@ -41,7 +41,6 @@
<result name="search">/jsp/search.jsp</result>
<result>/jsp/home.jsp</result>
</action>
- <!-- modify, remove, edit -->
<action name="modifyBookmark" class="org.chorem.bow.action.ModifyBookmarkAction">
<result name="home">/jsp/home.jsp</result>
<result name="search">/jsp/search.jsp</result>
@@ -64,7 +63,8 @@
<result>/jsp/search.jsp</result>
</action>
<action name="generateToken" class="org.chorem.bow.action.GenerateTokenAction">
- <result>/jsp/preferences.jsp</result>
+ <result name="login" type="redirectAction">login_input</result>
+ <result type="redirectAction">preferences</result>
</action>
<action name="deleteTag" class="org.chorem.bow.action.DeleteTagAction">
<!-- La redirection change selon le type de page sur laquelle on est, donc je ne vois pas trop comment faire ça pour le moment-->
@@ -76,8 +76,8 @@
<result>/jsp/search.jsp</result>
</action>
<action name="addClick" class="org.chorem.bow.action.AddClickAction">
- <result name="error" type="redirect">/home.action</result>
- <result type="redirect">${link}<!--???--></result>
+ <result name="error" type="redirectAction">home</result>
+ <result type="redirect">${link}</result>
</action>
<!-- temporary, permanent -->
<action name="*Xml">
@@ -88,17 +88,16 @@
<!-- Plein de types de redirections différentes, et un .forward(..., ...); que je ne sais pas comment changer -->
<result>/jsp/suggestions.jsp</result>
</action>
- <action name="preferences">
- <!-- Cas du getBookmarksByImportDate qu'il faudrait caller quelque part -->
+ <action name="preferences" class="org.chorem.bow.action.PreferencesAction">
+ <!-- Cas du getBookmarksByImportDate qu'il faudrait caler quelque part -->
+ <result name="login" type="redirectAction">login_input</result>
+ <result name="update" type="redirectAction">preferences</result>
<result>/jsp/preferences.jsp</result>
</action>
<action name="admin">
<result name="error">/jsp/login.jsp</result>
<result>/jsp/admin.jsp</result>
</action>
- <action name="changePreferences" class="org.chorem.bow.action.ChangePreferencesAction">
- <result>/jsp/preferences.jsp</result>
- </action>
<action name="deleteImport" class="org.chorem.bow.action.DeleteImportAction">
<result>/jsp/preferences.jsp</result>
</action>
Modified: trunk/src/main/webapp/index.jsp
===================================================================
--- trunk/src/main/webapp/index.jsp 2011-01-06 14:22:41 UTC (rev 164)
+++ trunk/src/main/webapp/index.jsp 2011-01-06 17:33:35 UTC (rev 165)
@@ -1 +1,8 @@
-<% response.sendRedirect("login_input.action"); %>
\ No newline at end of file
+<%@page import="org.chorem.bow.User"%>
+<%
+if ((User)session.getAttribute("user") == null) {
+ response.sendRedirect("login_input.action");
+} else {
+ response.sendRedirect("home.action");
+}
+%>
\ No newline at end of file
Modified: trunk/src/main/webapp/jsp/preferences.jsp
===================================================================
--- trunk/src/main/webapp/jsp/preferences.jsp 2011-01-06 14:22:41 UTC (rev 164)
+++ trunk/src/main/webapp/jsp/preferences.jsp 2011-01-06 17:33:35 UTC (rev 165)
@@ -66,6 +66,7 @@
preference.setSearchEngineUrlSuggestions("");
}
%>
+ [[[[[<%=preference.getTags() %>]]]]]
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
xmlns:jsp="http://java.sun.com/JSP/Page"
@@ -81,7 +82,10 @@
<div class="menu clearfix">
<h2><s:text name="bow.preferences.title" /></h2>
</div>
- <s:form action="changePreferences">
+ <s:url id="changePreferences" action="preferences">
+ <s:param name="update">1</s:param>
+ </s:url>
+ <s:form action="%{changePreferences}">
<div class="formFrame">
<h3><s:text name="bow.preferences.userInfo" /></h3>
<p>
@@ -104,7 +108,7 @@
<s:submit key="bow.preferences.submit" />
<br /><br />
<s:url id="home" action="home" />
- <a href="%{home}" id="homePage"><s:text name="bow.home.title" /></a>
+ <s:a href="%{home}" id="homePage"><s:text name="bow.home.title" /></s:a>
</p>
</div>
</s:form>
@@ -113,6 +117,7 @@
</div>
<%
List<FacetTopic> bookmarkImportList = (List<FacetTopic>)request.getAttribute("bookmarksImportDate");
+
if (bookmarkImportList != null) {
if (bookmarkImportList.size() > 0) {
String bgColors[] = {"Pink", "White"};
@@ -134,16 +139,16 @@
i++;
}
} else {
- %>
+ %>
<div class="deleteImport deleteImportWhite">
<span><s:text name="bow.preferences.noImportedBookmarks" /></span>
</div>
- <%
+ <%
}
}
%>
</div>
- <jsp:include page="/jsp/inc/rightMenu.jsp" flush="true" />
+ <jsp:include page="inc/rightMenu.jsp" flush="true" />
</body>
</html>
<% } %>
\ No newline at end of file
1
0
r164 - in trunk/src/main: java/org/chorem/bow java/org/chorem/bow/action resources resources/i18n webapp/jsp webapp/jsp/inc
by vbriand@users.chorem.org 06 Jan '11
by vbriand@users.chorem.org 06 Jan '11
06 Jan '11
Author: vbriand
Date: 2011-01-06 15:22:41 +0100 (Thu, 06 Jan 2011)
New Revision: 164
Url: http://chorem.org/repositories/revision/bow/164
Log:
The bookmarks are now removable on the home page and the normal and fulltext searches work again
Added:
trunk/src/main/java/org/chorem/bow/action/FullTextSearchAction.java
Modified:
trunk/src/main/java/org/chorem/bow/BowSearch.java
trunk/src/main/java/org/chorem/bow/action/SearchAction.java
trunk/src/main/resources/i18n/bow_en_GB.properties
trunk/src/main/resources/i18n/bow_fr_FR.properties
trunk/src/main/resources/struts.xml
trunk/src/main/webapp/jsp/home.jsp
trunk/src/main/webapp/jsp/inc/header.jsp
trunk/src/main/webapp/jsp/inc/rightMenu.jsp
trunk/src/main/webapp/jsp/preferences.jsp
trunk/src/main/webapp/jsp/register.jsp
trunk/src/main/webapp/jsp/search.jsp
Modified: trunk/src/main/java/org/chorem/bow/BowSearch.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BowSearch.java 2011-01-06 09:56:50 UTC (rev 163)
+++ trunk/src/main/java/org/chorem/bow/BowSearch.java 2011-01-06 14:22:41 UTC (rev 164)
@@ -35,9 +35,12 @@
WikittyProxy proxy = BowProxy.getInstance();
Criteria criteria = BowBookmark.getBookmarkListCriteriaByUser(user, searchLine);
criteria = criteria.addSortDescending(Bookmark.FQ_FIELD_CLICK);
- PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, criteria); //Selects all bookmarks by user
- BookmarkActions bookmarkActions = BowBookmark.createBookmarkActions(request, result, searchLine);
- request.setAttribute("bookmarkActions", bookmarkActions);
+
+ if (criteria != null) {
+ PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, criteria); //Selects all bookmarks by user
+ BookmarkActions bookmarkActions = BowBookmark.createBookmarkActions(request, result, searchLine);
+ request.setAttribute("bookmarkActions", bookmarkActions);
+ }
}
}
@@ -54,7 +57,6 @@
criteria = Search.query().keyword(fullText).
eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
addFacetField(Bookmark.FQ_FIELD_TAGS);
-
} else {
criteria = BowBookmark.getBookmarkListCriteriaByUser(user, null);
}
Added: trunk/src/main/java/org/chorem/bow/action/FullTextSearchAction.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/action/FullTextSearchAction.java (rev 0)
+++ trunk/src/main/java/org/chorem/bow/action/FullTextSearchAction.java 2011-01-06 14:22:41 UTC (rev 164)
@@ -0,0 +1,43 @@
+package org.chorem.bow.action;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.struts2.interceptor.ServletRequestAware;
+import org.apache.struts2.interceptor.SessionAware;
+import org.chorem.bow.BowSearch;
+import org.chorem.bow.User;
+
+public class FullTextSearchAction extends BowBaseAction implements SessionAware, ServletRequestAware {
+ private static final long serialVersionUID = -7736099487284993426L;
+ protected Map<String, Object> session;
+ protected HttpServletRequest request;
+
+ @Override
+ public void setServletRequest(HttpServletRequest request) {
+ this.request = request;
+ }
+
+ @Override
+ public void setSession(Map<String, Object> session) {
+ this.session = session;
+ }
+
+ public String execute() {
+ User user = (User)session.get("user");
+
+ try {
+ BowSearch.fullText(request, user);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ServletException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return SUCCESS;
+ }
+}
Property changes on: trunk/src/main/java/org/chorem/bow/action/FullTextSearchAction.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/src/main/java/org/chorem/bow/action/SearchAction.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/action/SearchAction.java 2011-01-06 09:56:50 UTC (rev 163)
+++ trunk/src/main/java/org/chorem/bow/action/SearchAction.java 2011-01-06 14:22:41 UTC (rev 164)
@@ -8,15 +8,8 @@
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.SessionAware;
-import org.chorem.bow.Bookmark;
-import org.chorem.bow.BookmarkActions;
-import org.chorem.bow.BowBookmark;
-import org.chorem.bow.BowProxy;
import org.chorem.bow.BowSearch;
import org.chorem.bow.User;
-import org.nuiton.wikitty.Criteria;
-import org.nuiton.wikitty.PagedResult;
-import org.nuiton.wikitty.WikittyProxy;
public class SearchAction extends BowBaseAction implements SessionAware, ServletRequestAware {
private static final long serialVersionUID = -2161661766242362907L;
@@ -81,36 +74,15 @@
public String execute() {
User user = (User)session.get("user");
- if (searchLine == null) {
- searchLine = "";
+ try {
+ BowSearch.search(request, user);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ServletException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
- if (fullTextLine != null && !fullTextLine.isEmpty() && searchLine.isEmpty()) {
- try {
- BowSearch.fullText(request, user);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (ServletException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- } else {
- if (addTag != null && !addTag.isEmpty()) {
- if (searchLine.isEmpty()) {
- searchLine = addTag;
- } else {
- searchLine += " " + addTag;
- }
- }
- WikittyProxy proxy = BowProxy.getInstance();
- Criteria criteria = BowBookmark.getBookmarkListCriteriaByUser(user, searchLine);
- if (criteria != null) {
- criteria = criteria.addSortDescending(Bookmark.FQ_FIELD_CLICK);
- PagedResult<Bookmark> result = proxy.findAllByCriteria(Bookmark.class, criteria); //Selects all bookmarks by user
- BookmarkActions bookmarkActions = BowBookmark.createBookmarkActions(request, result, searchLine);
- request.setAttribute("bookmarkActions", bookmarkActions);
- }
- }
return SUCCESS;
}
}
\ No newline at end of file
Modified: trunk/src/main/resources/i18n/bow_en_GB.properties
===================================================================
--- trunk/src/main/resources/i18n/bow_en_GB.properties 2011-01-06 09:56:50 UTC (rev 163)
+++ trunk/src/main/resources/i18n/bow_en_GB.properties 2011-01-06 14:22:41 UTC (rev 164)
@@ -31,6 +31,21 @@
bow.login.repeatPassword.required=Please repeat your password
bow.login.submit=Login
bow.login.title=Login
+bow.preferences.bookmarksHomePage=
+bow.preferences.colors=
+bow.preferences.confirmNewPassword=
+bow.preferences.currentPassword=
+bow.preferences.importedBookmarks=
+bow.preferences.newPassword=
+bow.preferences.noImportedBookmarks=
+bow.preferences.regenPermToken=
+bow.preferences.searchEngineUrlResults=
+bow.preferences.searchEngineUrlSuggestions=
+bow.preferences.siteLook=
+bow.preferences.submit=
+bow.preferences.tagsNb=
+bow.preferences.title=
+bow.preferences.userInfo=
bow.register.emailAldyUsed=This email address is already used
bow.register.invalidLogin=
bow.register.mailEmail=
Modified: trunk/src/main/resources/i18n/bow_fr_FR.properties
===================================================================
--- trunk/src/main/resources/i18n/bow_fr_FR.properties 2011-01-06 09:56:50 UTC (rev 163)
+++ trunk/src/main/resources/i18n/bow_fr_FR.properties 2011-01-06 14:22:41 UTC (rev 164)
@@ -31,6 +31,21 @@
bow.login.repeatPassword.required=Veuillez retaper votre mot de passe
bow.login.submit=Connexion
bow.login.title=Connexion
+bow.preferences.bookmarksHomePage=
+bow.preferences.colors=
+bow.preferences.confirmNewPassword=
+bow.preferences.currentPassword=
+bow.preferences.importedBookmarks=
+bow.preferences.newPassword=
+bow.preferences.noImportedBookmarks=
+bow.preferences.regenPermToken=
+bow.preferences.searchEngineUrlResults=
+bow.preferences.searchEngineUrlSuggestions=
+bow.preferences.siteLook=
+bow.preferences.submit=
+bow.preferences.tagsNb=
+bow.preferences.title=
+bow.preferences.userInfo=
bow.register.emailAldyUsed=Cette adresse email est d\u00E9j\u00E0 utilis\u00E9e
bow.register.invalidLogin=
bow.register.mailEmail=
Modified: trunk/src/main/resources/struts.xml
===================================================================
--- trunk/src/main/resources/struts.xml 2011-01-06 09:56:50 UTC (rev 163)
+++ trunk/src/main/resources/struts.xml 2011-01-06 14:22:41 UTC (rev 164)
@@ -8,7 +8,7 @@
<package name="myPackage" extends="struts-default">
<action name="register_*" method="{1}" class="org.chorem.bow.action.RegisterAction">
<result name="input">/jsp/register.jsp</result>
- <result type="redirect">/home.action</result>
+ <result type="redirectAction">home</result>
</action>
<action name="forgotPassword_*" method="{1}" class="org.chorem.bow.action.ForgotPasswordAction">
<result name="input">/jsp/forgotPassword.jsp</result>
@@ -20,17 +20,17 @@
</action>
<action name="login_*" method="{1}" class="org.chorem.bow.action.LoginAction">
<result name="input">/jsp/login.jsp</result>
- <result type="redirect">/home.action</result>
+ <result type="redirectAction">home</result>
</action>
<action name="logout" class="org.chorem.bow.action.LogoutAction">
- <result type="redirect">/login_input.action</result>
+ <result type="redirectAction">login_input</result>
</action>
<action name="home" class="org.chorem.bow.action.HomeAction">
- <result name="login" type="redirect">/login_input.action</result>
+ <result name="login" type="redirectAction">login_input</result>
<result>/jsp/home.jsp</result>
</action>
<action name="addUrl" class="org.chorem.bow.action.AddUrlAction">
- <result type="redirect">/home.action</result>
+ <result type="redirectAction">home</result>
<!-- La redirection change selon le type de page sur laquelle on est, donc je ne vois pas trop comment faire ça pour le moment-->
</action>
</package>
@@ -42,18 +42,27 @@
<result>/jsp/home.jsp</result>
</action>
<!-- modify, remove, edit -->
- <action name="*Bookmark" method="{1}" class="org.chorem.bow.action.BookmarkAction">
- <!-- La redirection change selon le type de page sur laquelle on est, donc je ne vois pas trop comment faire ça pour le moment-->
+ <action name="modifyBookmark" class="org.chorem.bow.action.ModifyBookmarkAction">
<result name="home">/jsp/home.jsp</result>
<result name="search">/jsp/search.jsp</result>
</action>
+ <action name="removeBookmark" class="org.chorem.bow.action.RemoveBookmarkAction">
+ <result type="redirectAction">home</result>
+ <result name="search">/jsp/search.jsp</result>
+ </action>
+ <action name="editBookmark" class="org.chorem.bow.action.EditBookmarkAction">
+ <result name="home">/jsp/home.jsp</result>
+ <result name="search">/jsp/search.jsp</result>
+ </action>
</package>
<package name="toto" extends="struts-default">
<action name="search" class="org.chorem.bow.action.SearchAction">
- <!-- Méthode actionSearch appellée dans d'autres méthodes, à voir comment organiser ça -->
<result>/jsp/search.jsp</result>
</action>
+ <action name="fullText" class="org.chorem.bow.action.FullTextSearchAction">
+ <result>/jsp/search.jsp</result>
+ </action>
<action name="generateToken" class="org.chorem.bow.action.GenerateTokenAction">
<result>/jsp/preferences.jsp</result>
</action>
@@ -97,7 +106,7 @@
<result>/jsp/admin.jsp</result>
</action>
<action name="deleteSearchResults" class="org.chorem.bow.action.DeleteSearchResultsAction">
- <result type="redirectAction">/jsp/home.jsp</result>
+ <result type="redirectAction">home</result>
</action>
</package>
</struts>
Modified: trunk/src/main/webapp/jsp/home.jsp
===================================================================
--- trunk/src/main/webapp/jsp/home.jsp 2011-01-06 09:56:50 UTC (rev 163)
+++ trunk/src/main/webapp/jsp/home.jsp 2011-01-06 14:22:41 UTC (rev 164)
@@ -66,7 +66,7 @@
request.setAttribute("bookmark", bookmark);
request.setAttribute("sdf", sdf);
%>
- <jsp:include page="/jsp/inc/bookmark.jsp" flush="true" />
+ <jsp:include page="inc/bookmark.jsp" flush="true" />
<%
++count;
if (count >= nbBookmarks) {
@@ -92,7 +92,7 @@
request.setAttribute("bookmark", bookmark);
request.setAttribute("sdf", sdf);
%>
- <jsp:include page="/jsp/inc/bookmark.jsp" flush="true" />
+ <jsp:include page="inc/bookmark.jsp" flush="true" />
<%
++count;
if (count >= nbBookmarks) {
@@ -104,7 +104,7 @@
<p class="nobookmarks"><s:text name="bow.home.noBookmarks" /></p>
<% } %>
</div>
- <jsp:include page="/jsp/inc/rightMenu.jsp" />
+ <jsp:include page="inc/rightMenu.jsp" />
</body>
</html>
<% } %>
Modified: trunk/src/main/webapp/jsp/inc/header.jsp
===================================================================
--- trunk/src/main/webapp/jsp/inc/header.jsp 2011-01-06 09:56:50 UTC (rev 163)
+++ trunk/src/main/webapp/jsp/inc/header.jsp 2011-01-06 14:22:41 UTC (rev 164)
@@ -1,3 +1,4 @@
+<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<div id="header">
- <a class="logo" href="">bow</a>
+ <a class="logo" href="/bow/">bow</a>
</div>
\ No newline at end of file
Modified: trunk/src/main/webapp/jsp/inc/rightMenu.jsp
===================================================================
--- trunk/src/main/webapp/jsp/inc/rightMenu.jsp 2011-01-06 09:56:50 UTC (rev 163)
+++ trunk/src/main/webapp/jsp/inc/rightMenu.jsp 2011-01-06 14:22:41 UTC (rev 164)
@@ -82,11 +82,9 @@
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<s:form action="logout">
- <div class="input">
- <s:submit name="bow.rightMenu.logout" />
- </div>
+ <s:submit name="bow.rightMenu.logout" />
</s:form>
- <a href="http://maven-site.chorem.org/bow/" class="help" target="_blank"><s:text name="bow.rightMenu.help" /></a>
+ <a href="http://maven-site.chorem.org/bow/" class="help" onclick="window.open(this.href); return false;"><s:text name="bow.rightMenu.help" /></a>
</div>
<div id="side">
<div id="colonneD">
@@ -101,7 +99,7 @@
<div id="extensions">
<h2><s:text name="bow.rightMenu.extensions" /></h2>
<ul class="droite">
- <li><a href="extensions/bow4chromium.crx"><img src="img/chromium.png" class="extensionIcon" /><div class="extensionName">Extension pour Chromium</div></a></li>
+ <li><a href="extensions/bow4chromium.crx"><img src="img/chromium.png" alt="Chromium" class="extensionIcon" />Extension pour Chromium</a></li>
<li><strong><s:text name="bow.rightMenu.token.permanent" /></strong> <%= permanentToken %></li>
<li><strong><s:text name="bow.rightMenu.token.temporary" /></strong> <%= temporaryToken %></li>
</ul>
@@ -109,11 +107,11 @@
<div id="add" class="clearfix">
<h2><s:text name="bow.rightMenu.bookmark.addModify" /></h2>
<s:form id="bookmarkForm" action="addUrl">
- <div class="input"><s:textfield key="bow.rightMenu.bookmark.link" name="link" /></div><!-- <%=formLink%> -->
- <div class="input"><s:textfield key="bow.rightMenu.bookmark.alias" name="alias" /></div><!-- <%=formAlias%> -->
- <div class="input"><s:textfield key="bow.rightMenu.bookmark.name" name="name" /></div><!-- <%=formName%> -->
- <div class="input"><s:textfield key="bow.rightMenu.bookmark.tags" name="tags" /></div><!-- <%=formTags%> -->
- <div class="input"><s:submit key="bow.rightMenu.bookmark.submit" /></div>
+ <s:textfield key="bow.rightMenu.bookmark.link" name="link" /><!-- <%=formLink%> -->
+ <s:textfield key="bow.rightMenu.bookmark.alias" name="alias" /><!-- <%=formAlias%> -->
+ <s:textfield key="bow.rightMenu.bookmark.name" name="name" /><!-- <%=formName%> -->
+ <s:textfield key="bow.rightMenu.bookmark.tags" name="tags" /><!-- <%=formTags%> -->
+ <s:submit key="bow.rightMenu.bookmark.submit" />
</s:form>
</div>
<div id="nuage">
@@ -126,34 +124,28 @@
<% } %>
</div>
<div class="recherche">
- <h2><label for="searchLine"><s:text name="bow.rightMenu.search" /></label></h2>
+ <h2><s:text name="bow.rightMenu.search" /></h2>
<s:form action="search">
- <div class="input">
- <s:textfield key="bow.rightMenu.find.searchLine" name="searchLine" />
- <s:submit key="bow.rightMenu.find.submit" />
- </div>
+ <s:textfield key="bow.rightMenu.find.searchLine" name="searchLine" />
+ <s:submit key="bow.rightMenu.find.submit" />
</s:form>
</div>
<div class="recherche">
- <h2><label for="fullTextLine"><s:text name="bow.rightMenu.fullTextSearch}" /></label></h2>
+ <h2><s:text name="bow.rightMenu.fullTextSearch" /></h2>
<s:form action="fullText">
- <div class="input">
- <% if (fullText != null) { %>
- <s:textfield key="bow.rightMenu.search.fullTextLine" name="fullTextLine" value="" /> <!-- <%=fullText%> -->
- <% } else { %>
- <s:textfield key="bow.rightMenu.search.fullTextLine" name="fullTextLine" />
- <% } %>
- <s:submit key="bow.rightMenu.find" />
- </div>
+ <% if (fullText != null) { %>
+ <s:textfield key="bow.rightMenu.search.fullTextLine" name="fullTextLine" value="" /> <!-- <%=fullText%> -->
+ <% } else { %>
+ <s:textfield key="bow.rightMenu.search.fullTextLine" name="fullTextLine" />
+ <% } %>
+ <s:submit key="bow.rightMenu.find" />
</s:form>
</div>
<div id="import">
<h2><s:text name="bow.rightMenu.importBookmarks" /></h2>
<s:form action="importBookmarks" enctype="multipart/form-data">
- <div class="input">
- <s:file name="upfile" size="15%" key="bow.rightMenu.import.file" /><br />
- <s:submit key="bow.rightMenu.import.submit" />
- </div>
+ <s:file name="upfile" size="15%" key="bow.rightMenu.import.file" /><br />
+ <s:submit key="bow.rightMenu.import.submit" />
</s:form>
<s:a action="exportBookmarks"><s:text name="bow.rightMenu.exportBookmarks" /></s:a>
</div>
Modified: trunk/src/main/webapp/jsp/preferences.jsp
===================================================================
--- trunk/src/main/webapp/jsp/preferences.jsp 2011-01-06 09:56:50 UTC (rev 163)
+++ trunk/src/main/webapp/jsp/preferences.jsp 2011-01-06 14:22:41 UTC (rev 164)
@@ -71,42 +71,45 @@
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<head>
- <s:url value="/css/bookmark.css" />
+ <title><s:text name="bow.preferences.title" /></title>
+ <s:url id="css" value="/css/bookmark.css" />
<link href="${css}" rel="stylesheet" type="text/css" />
<s:head />
</head>
<body>
<div id="content">
<div class="menu clearfix">
- <h2><s:property value="%{getText('preferences')}" /></h2>
+ <h2><s:text name="bow.preferences.title" /></h2>
</div>
- <s:form action="/bow/changePreferences.action">
+ <s:form action="changePreferences">
<div class="formFrame">
- <h3><s:property value="%{getText('userInfo')}" /></h3>
+ <h3><s:text name="bow.preferences.userInfo" /></h3>
<p>
- <s:textfield key="email" name="email" label="%{getText('email')}" /><br /><br /><!-- value="<%=user.getEmail()%>" -->
- <s:password key="currentPassword" name="currentPassword" label="%{getText('currentPassword')}" />
- <s:password key="newPassword" name="newPassword" label="%{getText('newPassword')}" />
- <s:password key="confirmNewPassword" name="confirmNewPassword" label="%{getText('confirmNewPassword')}" />
- <a href="/bow/generateToken.action" id="regenPermToken"><s:property value="%{getText('regenPermToken')}" /></a>
+ <s:textfield key="bow.login.email" name="email" /><br /><br /><!-- value="<%=user.getEmail()%>" -->
+ <s:password key="bow.preferences.currentPassword" name="currentPassword" />
+ <s:password key="bow.preferences.newPassword" name="newPassword" />
+ <s:password key="bow.preferences.confirmNewPassword" name="confirmNewPassword" />
+ <s:url id="generateToken" action="generateToken" />
+ <s:a href="%{generateToken}" id="regenPermToken"><s:text name="bow.preferences.regenPermToken" /></s:a>
</p>
</div>
<div class="formFrame">
- <h3><s:property value="%{getText('siteLook')}" /></h3>
+ <h3><s:text name="bow.preferences.siteLook" /></h3>
<p>
- <s:textfield key="colors" name="colors" label="%{getText('siteColor')}" /><br /> <!-- value="<%=preference.getColors()%>" -->
- <s:textfield key="tagsNb" name="tagsNb" label="%{getText('tagsNb')}" /><br />
- <s:textfield key="bookmarksHomePage" name="bookmarksHomePage" label="%{getText('bookmarksHomePage')}" /><br />
- <s:textfield key="searchEngineUrlSuggestions" name="searchEngineUrlSuggestions" label="%{getText('searchEngineUrlSuggestions')}" /><br />
- <s:textfield key="searchEngineUrlResults" name="searchEngineUrlResults" label="%{getText('searchEngineUrlResults')}" />
- <s:submit value="%{getText('changePreferences')}" />
+ <s:textfield key="bow.preferences.colors" name="colors" /><br /> <!-- value="<%=preference.getColors()%>" -->
+ <s:textfield key="bow.preferences.tagsNb" name="tagsNb" /><br />
+ <s:textfield key="bow.preferences.bookmarksHomePage" name="bookmarksHomePage" /><br />
+ <s:textfield key="bow.preferences.searchEngineUrlSuggestions" name="searchEngineUrlSuggestions" /><br />
+ <s:textfield key="bow.preferences.searchEngineUrlResults" name="searchEngineUrlResults" />
+ <s:submit key="bow.preferences.submit" />
<br /><br />
- <a href="/bow/home.action" id="homePage"><s:property value="%{getText('homePage')}" /></a>
+ <s:url id="home" action="home" />
+ <a href="%{home}" id="homePage"><s:text name="bow.home.title" /></a>
</p>
</div>
</s:form>
<div class="menu clearfix">
- <h2><s:property value="%{getText('importedBookmarks')}" /></h2>
+ <h2><s:text name="bow.preferences.importedBookmarks" /></h2>
</div>
<%
List<FacetTopic> bookmarkImportList = (List<FacetTopic>)request.getAttribute("bookmarksImportDate");
@@ -133,7 +136,7 @@
} else {
%>
<div class="deleteImport deleteImportWhite">
- <span><s:property value="%{getText('noImportedBookmarks')}" /></span>
+ <span><s:text name="bow.preferences.noImportedBookmarks" /></span>
</div>
<%
}
Modified: trunk/src/main/webapp/jsp/register.jsp
===================================================================
--- trunk/src/main/webapp/jsp/register.jsp 2011-01-06 09:56:50 UTC (rev 163)
+++ trunk/src/main/webapp/jsp/register.jsp 2011-01-06 14:22:41 UTC (rev 164)
@@ -22,7 +22,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
-->
-<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
Modified: trunk/src/main/webapp/jsp/search.jsp
===================================================================
--- trunk/src/main/webapp/jsp/search.jsp 2011-01-06 09:56:50 UTC (rev 163)
+++ trunk/src/main/webapp/jsp/search.jsp 2011-01-06 14:22:41 UTC (rev 164)
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
bow
@@ -21,7 +22,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
-->
-<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%@taglib prefix="s" uri="/struts-tags" %>
<%@page import="org.chorem.bow.BookmarkActions" %>
<%@page import="org.chorem.bow.TokenActions" %>
<%@page import="org.chorem.bow.Bookmark" %>
@@ -37,14 +39,25 @@
if (tokenActions != null && bookmarkActions != null) {
%>
- <jsp:include page="header.jsp" flush="true">
- <jsp:param name="cssFile" value="bookmark.css" />
- </jsp:include>
- <div id="main">
- <jsp:include page="errorFrame.jsp" flush="true" />
+ <html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ xmlns:jsp="http://java.sun.com/JSP/Page"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <head>
+ <title><s:text name="bow.search.title" /></title>
+ <s:url id="css" value="/css/bookmark.css" />
+ <link href="${css}" rel="stylesheet" type="text/css" />
+ <s:head />
+ </head>
+ <body>
+ <div id="content">
<div class="menu clearfix">
- <h2>Search</h2>
- <form method="post" action="bow?action=order&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>">
+ <h2><s:text name="bow.search.title" /></h2>
+ <s:url id="order" action="order">
+ <s:param name="searchLine"><%=searchLine%></s:param>
+ <s:param name="fullTextLine"><%=fullText%></s:param>
+ </s:url>
+ <s:form action="%{order}">
<p>
<label for="type">Order By :</label>
<select id="type" name="type">
@@ -55,27 +68,33 @@
<option value="ascDate">Asc Date</option>
<option value="descDate">Desc Date</option>
</select>
- <input type="submit" value="OK" />
+ <s:submit key="bow.search.submit" />
<%
List<Bookmark> bookmarkList = bookmarkActions.getBookmarks();
int bookmarksNb = bookmarkList.size();
if (bookmarksNb > 0) {
%>
- <a id="deleteSearchResultsButton" href="" onclick="deleteConfirmation('bow?action=deleteSearchResults&searchLine=<%= searchLine %>&fullTextLine=<%= fullText %>', <%=bookmarksNb%>); return(false);"></a>
+ <s:url id="deleteSearchResult" action="deleteSearchResult">
+ <s:param name="searchLine"><%=searchLine%></s:param>
+ <s:param name="fullTextLine"><%=fullText%></s:param>
+ </s:url>
+ <s:a id="deleteSearchResultsButton" href="" onclick="deleteConfirmation(%{deleteSearchResult}, <%=bookmarksNb%>); return(false);"></s:a>
<% } %>
</p>
- </form>
+ </s:form>
</div>
<div class="content">
<%
+ List<Bookmark> bookmarkList = bookmarkActions.getBookmarks();
+
if (!bookmarkList.isEmpty()) {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
for (Bookmark bookmark : bookmarkList) {
request.setAttribute("bookmark", bookmark);
request.setAttribute("sdf", sdf);
%>
- <jsp:include page="bookmark.jsp" flush="true">
+ <jsp:include page="inc/bookmark.jsp" flush="true">
<jsp:param name="searchLine" value="<%=searchLine%>" />
<jsp:param name="fullTextLine" value="<%=fullText%>" />
</jsp:include>
@@ -85,8 +104,7 @@
else { %>
<p class="nobookmarks">No Bookmarks</p>
<% } %>
- </div>
- </div>
- <jsp:include page="rightMenu.jsp" flush="true" />
- <jsp:include page="footer.jsp" flush="true" />
+ </div>
+ </body>
+</html>
<% } %>
1
0
r163 - in trunk/src/main: resources/i18n webapp/jsp webapp/jsp/inc
by vbriand@users.chorem.org 06 Jan '11
by vbriand@users.chorem.org 06 Jan '11
06 Jan '11
Author: vbriand
Date: 2011-01-06 10:56:50 +0100 (Thu, 06 Jan 2011)
New Revision: 163
Url: http://chorem.org/repositories/revision/bow/163
Log:
The bookmarks are now displayed on the home page
Modified:
trunk/src/main/resources/i18n/bow_en_GB.properties
trunk/src/main/resources/i18n/bow_fr_FR.properties
trunk/src/main/webapp/jsp/inc/bookmark.jsp
trunk/src/main/webapp/jsp/inc/bookmarkTop.jsp
trunk/src/main/webapp/jsp/inc/errorFrame.jsp
trunk/src/main/webapp/jsp/login.jsp
Modified: trunk/src/main/resources/i18n/bow_en_GB.properties
===================================================================
--- trunk/src/main/resources/i18n/bow_en_GB.properties 2011-01-05 21:58:10 UTC (rev 162)
+++ trunk/src/main/resources/i18n/bow_en_GB.properties 2011-01-06 09:56:50 UTC (rev 163)
@@ -15,6 +15,9 @@
bow.forgotPassword.emailDoesntExist=
bow.forgotpwd.submit=Send
bow.forgotpwd.title=Forgot your password?
+bow.home.latestBookmarks=
+bow.home.mostUsedBookmarks=
+bow.home.noBookmarks=
bow.home.title=
bow.label.locale.english=
bow.label.locale.french=
Modified: trunk/src/main/resources/i18n/bow_fr_FR.properties
===================================================================
--- trunk/src/main/resources/i18n/bow_fr_FR.properties 2011-01-05 21:58:10 UTC (rev 162)
+++ trunk/src/main/resources/i18n/bow_fr_FR.properties 2011-01-06 09:56:50 UTC (rev 163)
@@ -15,6 +15,9 @@
bow.forgotPassword.emailDoesntExist=
bow.forgotpwd.submit=Envoyer
bow.forgotpwd.title=Vous avez oubli\u00E9 votre mot de passe ?
+bow.home.latestBookmarks=
+bow.home.mostUsedBookmarks=
+bow.home.noBookmarks=
bow.home.title=
bow.label.locale.english=
bow.label.locale.french=
Modified: trunk/src/main/webapp/jsp/inc/bookmark.jsp
===================================================================
--- trunk/src/main/webapp/jsp/inc/bookmark.jsp 2011-01-05 21:58:10 UTC (rev 162)
+++ trunk/src/main/webapp/jsp/inc/bookmark.jsp 2011-01-06 09:56:50 UTC (rev 163)
@@ -23,6 +23,7 @@
#L%
-->
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%@taglib prefix="s" uri="/struts-tags" %>
<%@page import="org.chorem.bow.BowConfig" %>
<%@page import="org.chorem.bow.Bookmark" %>
<%@page import="java.text.SimpleDateFormat" %>
@@ -43,6 +44,7 @@
if (fullTextLine != null) {
search += "&fullTextLine=" + fullTextLine;
}
+url = "toto"; //TODO: à changer
if (url != null && bookmark != null && sdf != null && bookmarkActions != null) {
String formBookmarkId = (String) request.getAttribute("formBookmarkId");
String link = bookmark.getLink();
@@ -54,8 +56,14 @@
<%=bookmark.getAlias()%>
</a>
<p class="date"> (<%=sdf.format(bookmark.getDate())%>)</p>
- <a class="edit" href="/bow/editBookmark.action&bookmarkId=<%=bookmark.getWikittyId()%><%=search%>" onclick="return modify('<%=bookmark.getDescription()%>', '<%=bookmark.getAlias()%>', '<%=BookmarkActions.getBookmarkTagsString(bookmark)%>', '<%=link%>', 'bow/modifyBookmark.action&bookmarkId=<%=bookmark.getWikittyId()%><%=search%>', '<%=bookmark.getWikittyId()%>');"></a>
- <a class="supprim" href="/bow/removeBookmark.action&bookmarkId=<%=bookmark.getWikittyId()%><%=search%>"></a>
+ <s:url id="editBookmark" action="editBookmark">
+ <s:param name="bookmarkId"><%=bookmark.getWikittyId()%><%=search%></s:param>
+ </s:url>
+ <s:a cssClass="edit" href="%{editBookmark}" onclick="return modify('<%=bookmark.getDescription()%>', '<%=bookmark.getAlias()%>', '<%=BookmarkActions.getBookmarkTagsString(bookmark)%>', '<%=link%>', %{editBookmark}, '<%=bookmark.getWikittyId()%>');"></s:a>
+ <s:url id="removeBookmark" action="removeBookmark">
+ <s:param name="bookmarkId"><%=bookmark.getWikittyId()%><%=search%></s:param>
+ </s:url>
+ <s:a cssClass="supprim" href="%{removeBookmark}"></s:a>
</div>
<div class="bookmarkcontenu">
<div class="screenshot"></div>
@@ -63,7 +71,11 @@
<div class="description">
<h3>Description :</h3>
<p>
- <a title ="<%=bookmark.getLink()%>" href="/bow/addClick.action&bookmarkId=<%=bookmark.getWikittyId()%>" onclick="window.open(this.href); return false;"><%=bookmark.getDescription()%></a>
+ <s:url id="addClick" action="addClick">
+ <s:param name="bookmarkId"><%=bookmark.getWikittyId()%></s:param>
+ </s:url>
+ <s:a title="" href="%{addClick}" onclick="window.open(this.href); return false;"><%=bookmark.getDescription()%></s:a>
+ <!-- <%=bookmark.getLink()%>-->
</p>
<p class="tags">
<strong>Tags :</strong>
@@ -71,19 +83,29 @@
Set<String> tagList = bookmark.getTags();
if (tagList != null && !tagList.isEmpty()) {
for (String tag : tagList) {
+ %>
+ <s:url id="deleteTag" action="deleteTag">
+ <s:param name="bookmarkId"><%=bookmark.getWikittyId()%></s:param>
+ <s:param name="deleteTag"><%=tag%><%=search%></s:param>
+ </s:url>
+ <%
if (formBookmarkId != null && formBookmarkId.equals(bookmark.getWikittyId())) {
%>
- <a style="text-decoration: none;" href="/bow/deleteTag.action&bookmarkId=<%=bookmark.getWikittyId()%>&deleteTag=<%=tag%><%=search%>">
+ <s:a cssStyle="text-decoration: none;" href="%{deleteTag}">
<img style="border:none;" src="img/delete.png" alt="Delete tag" title="Delete" />
- </a>
+ </s:a>
<%
} else {
%>
- <a name="<%=bookmark.getWikittyId()%>" style="display:none; text-decoration: none;" href="/bow/deleteTag.action&bookmarkId=<%=bookmark.getWikittyId()%>&deleteTag=<%=tag%><%=search%>">
+ <!-- <%=bookmark.getWikittyId()%> -->
+ <s:a name="" cssStyle="display:none; text-decoration: none;" href="%{deleteTag}">
<img style="border:none;" src="img/delete.png" alt="Delete tag" title="Delete" />
- </a>
+ </s:a>
<% } %>
- <a href="/bow/search.action&searchLine=<%=tag%>" style="text-decoration: none"><%=tag%></a>
+ <s:url id="search" action="search">
+ <s:param name="searchLine"><%=tag%></s:param>
+ </s:url>
+ <s:a href="%{search}" cssStyle="text-decoration: none"><%=tag%></s:a>
<%
}
}
Modified: trunk/src/main/webapp/jsp/inc/bookmarkTop.jsp
===================================================================
--- trunk/src/main/webapp/jsp/inc/bookmarkTop.jsp 2011-01-05 21:58:10 UTC (rev 162)
+++ trunk/src/main/webapp/jsp/inc/bookmarkTop.jsp 2011-01-06 09:56:50 UTC (rev 163)
@@ -37,13 +37,11 @@
TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions");
BookmarkActions bookmarkActions = (BookmarkActions) request.getAttribute("bookmarkActions");
Boolean admin = (Boolean) session.getAttribute("admin");
-if (admin == null)
-{
+if (admin == null) {
admin = false;
}
-if (tokenActions != null && bookmarkActions != null)
-{
+if (tokenActions != null && bookmarkActions != null) {
String temporaryToken = tokenActions.getTemporaryToken();
String permanentToken = tokenActions.getPermanentToken();
String url = (String) request.getAttribute("bowUrl");
@@ -52,8 +50,7 @@
}
int tags = preference.getTags();
-if (preference != null && tags > 0)
-{
+if (preference != null && tags > 0) {
nbTags = tags;
}
@@ -64,43 +61,33 @@
String formAlias = (String) request.getAttribute("alias");
String formAction = (String) request.getAttribute("action");
-if (formLink == null)
-{
+if (formLink == null) {
formLink = "URL";
}
-if (formName == null)
-{
+if (formName == null) {
formName = "name";
}
-if (formTags == null)
-{
+if (formTags == null) {
formTags = "tag1 tag2...";
}
-if (formAlias == null)
-{
+if (formAlias == null) {
formAlias = "alias";
}
-if (formAction == null)
-{
+if (formAction == null) {
formAction = "bow?action=addUrl";
}
-if (tokenActions != null && bookmarkActions != null)
-{
- if (searchLine != null)
- {
+if (tokenActions != null && bookmarkActions != null) {
+ if (searchLine != null) {
String searchLine = bookmarkActions.getSearchLine();
String fullText = bookmarkActions.getFullTextLine();
- }
- else
- {
- if (preference != null && preference.getBookmarks() > 0)
- {
+ } else {
+ if (preference != null && preference.getBookmarks() > 0) {
nbBookmarks = preference.getBookmarks();
}
}
-%>
+%>
\ No newline at end of file
Modified: trunk/src/main/webapp/jsp/inc/errorFrame.jsp
===================================================================
--- trunk/src/main/webapp/jsp/inc/errorFrame.jsp 2011-01-05 21:58:10 UTC (rev 162)
+++ trunk/src/main/webapp/jsp/inc/errorFrame.jsp 2011-01-06 09:56:50 UTC (rev 163)
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
+<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
-String userError = (String) request.getAttribute("errorMsgUser");
-String techError = (String) request.getAttribute("errorMsgTech");
+String userError = (String)request.getAttribute("errorMsgUser");
+String techError = (String)request.getAttribute("errorMsgTech");
if (userError != null) {
%>
Modified: trunk/src/main/webapp/jsp/login.jsp
===================================================================
--- trunk/src/main/webapp/jsp/login.jsp 2011-01-05 21:58:10 UTC (rev 162)
+++ trunk/src/main/webapp/jsp/login.jsp 2011-01-06 09:56:50 UTC (rev 163)
@@ -24,10 +24,10 @@
</p>
</s:form>
<s:url id="localeEN" action="login_input">
- <s:param name="request_locale" >en_GB</s:param>
+ <s:param name="request_locale">en_GB</s:param>
</s:url>
<s:url id="localeFR" action="login_input">
- <s:param name="request_locale" >fr_FR</s:param>
+ <s:param name="request_locale">fr_FR</s:param>
</s:url>
<s:a href="%{localeEN}">English</s:a><br />
1
0
r162 - in trunk/src/main/webapp/extensions: . chromium chromium/css
by kmorin@users.chorem.org 05 Jan '11
by kmorin@users.chorem.org 05 Jan '11
05 Jan '11
Author: kmorin
Date: 2011-01-05 22:58:10 +0100 (Wed, 05 Jan 2011)
New Revision: 162
Url: http://chorem.org/repositories/revision/bow/162
Log:
- change add bookmark call (xhr instead of running a js script)
- layout
Modified:
trunk/src/main/webapp/extensions/bow4chromium.crx
trunk/src/main/webapp/extensions/bow4chromium.pem
trunk/src/main/webapp/extensions/chromium/css/extension.css
trunk/src/main/webapp/extensions/chromium/css/options.css
trunk/src/main/webapp/extensions/chromium/options.html
trunk/src/main/webapp/extensions/chromium/popup.html
Modified: trunk/src/main/webapp/extensions/bow4chromium.crx
===================================================================
(Binary files differ)
Modified: trunk/src/main/webapp/extensions/bow4chromium.pem
===================================================================
--- trunk/src/main/webapp/extensions/bow4chromium.pem 2011-01-05 17:40:08 UTC (rev 161)
+++ trunk/src/main/webapp/extensions/bow4chromium.pem 2011-01-05 21:58:10 UTC (rev 162)
@@ -1,16 +1,16 @@
-----BEGIN PRIVATE KEY-----
-MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAM7n867IJSfHF6egn
-sBS5kBR8rCwFbljqraMmTWY8tvZtUk6B7e0gZxMpoZy83NBbztqZMCrg1uu5Sjbes
-mfsWXQuXydapl4ROKN85MUsuaHy+TvO27Zso5GjswDo982cShioU3oidYw7ZQC/Pu
-FPmlzkzMfrIFqOA8S8lh7+XiZAgMBAAECgYAzFbfnvojV8mUXwSORDqbE2LbYAxHK
-DR6YJcyqHBJST8VfyBEhvVKG+bHf3j/XhB9nhxRLMc2j9GGmHdKKN4B/1jsJAR43L
-1ByYhp4L9ICjTGXrUz5ldl9bU3uuKIYeLaK6vKkmq+S7nlFKQDSv4X3uXEvCIZec/
-ESLcm9yiIBUQJBAO4r26CLVBTVKsg/Tmx9b7HHosyuUEv2zJzpo/SNztndpo1VOy2
-JVQC5U4IoV1BhI+q6za5oTo3rnIfTjsyoJyUCQQDeZPMEcmroUrDpvy4bhnI2idZZ
-F4H1vVmcbcxd/RCmQSYUTa2c9HyZdUxJG/dveExEkC58HP6ZSc2svb+TwrtlAkEAw
-8hXvUxrLMjiZ0PrArHGTFzwTdMI/Lj/EAnblh+wJ1XWIJ4sjE01C+hMZlUlGVURAl
-bW1wS1dmJ1BQ56d2/O5QJBAM/3LL3a1Rg9w4xCKDa7KfDQQq57ah9HmxXKI1M9BCX
-ERHy2CwT8J8xFQToYufD2WLPA9IdBgeAMgRXpNs5RSnUCQEAcKEx37eDto1LJPRh1
-nxyMzcgonNBSP2UtwGZdTeujM2KxBX4YMUuEz0u6fzlB+vD/ZM9af1IxYzDaH0mZc
-6c=
+MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMkSF9yn8GdHkNaI2
+fh8b+eGwe/YAia1DjKlf9/G00CZQ+iW893FXLcfm+Oy8pIt1fAiCe7wYJDMd0UIZ/
+RKFVY9b8edA3+aQgKp+6JFOR/Acfc1gIdnpR17tq0sRzku+pdpNjNU6oNJlVMUSbJ
+DFD7G4bp8Pk2ICwQzfB2EmhxzAgMBAAECgYBcB3f8erFB1DOqvcBmRy5A3iDt0gRK
+CxyQecdpeOs/6eZ3EoBTxP2Go2UKduEnnusImcvKHSNVowAEDLDn0vCoVE2Sl+lz0
+Qv71P5TDycOhi8ih88PeOjfYDQXMapfnymC8Z/pqaQuYx8B17D3T/mgPtRcFp64oi
+y48lkCM/+dIQJBAO5iV7TEvNxbucr/VuWh3GDyVkFbP19CoSA8lSwAQbhhyxXmnd4
+gVkEATyQV5ZsSlV9MaxlaYZOSMrmRNnxCHFcCQQDX7d53lvmutburHJaihGed7C5c
+oMxiteqUUjET0yjzOYBXhQQF+4FB9LrTd+m71STgoYprXd5cRhAPFV2EP69FAkEAh
+dpEgyVBIr6CeYCci34yX2FTm4kf8V5ZWN+Lp1RRkrWesiJ3HGWt6PvCdHGzJjruEr
++3F1pPlewufVITdPwuKwJAEpelvzBdwWBej2Y/xjCWZ2+tskYaMyms0CafmTBmZ0L
+9PQv0A7vbLl2vNIQvuP+qVDk0nPgRLGrP+SyCx99f7QJBAJz8/LMTJpZxsesIJFqe
+E3fn6XTc7erciuJhsX+iKgKCgpXxe4qXOVUQ0EW2NmOit0ucSAtL7ov0I2vmZ2Qtg
+to=
-----END PRIVATE KEY-----
Modified: trunk/src/main/webapp/extensions/chromium/css/extension.css
===================================================================
--- trunk/src/main/webapp/extensions/chromium/css/extension.css 2011-01-05 17:40:08 UTC (rev 161)
+++ trunk/src/main/webapp/extensions/chromium/css/extension.css 2011-01-05 21:58:10 UTC (rev 162)
@@ -36,7 +36,7 @@
margin-bottom: 20px;
}
-button {
+input[type="button"] {
float: right;
background: url('/img/fdboutonV.jpg') repeat-x;
color: #FFFFFF;
@@ -48,14 +48,14 @@
}
.labels {
- margin-top: 5px;
+ margin-top: 10px;
}
.inputs {
width: 100%;
}
-input {
+input[type="text"] {
width: 100%;
}
Modified: trunk/src/main/webapp/extensions/chromium/css/options.css
===================================================================
--- trunk/src/main/webapp/extensions/chromium/css/options.css 2011-01-05 17:40:08 UTC (rev 161)
+++ trunk/src/main/webapp/extensions/chromium/css/options.css 2011-01-05 21:58:10 UTC (rev 162)
@@ -23,166 +23,139 @@
*/
@charset "utf-8";
/* CSS Document */
-*{
- padding:0;
- margin:0;
+* {
+ padding: 0;
+ margin: 0;
}
-body{
- font-size:10px;
- font-family:Verdana, Arial, Helvetica, sans-serif;
+body {
+ font-size: 10px;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
}
-.clearfix{
- height:1%;
+#wrap {
+ clear: both;
+ float: left;
+ overflow-x: hidden;
+ overflow-y: visible;
+ position: relative;
+ width: 100%;
+ background-color: #9EDCF8;
}
-.clearfix:after{
- content:".";
- height:0;
- line-height:0;
- display:block;
- visibility:hidden;
- clear:both;
+#footer {
+ background-color: #804561;
+ padding-top: 30px;
}
-#wrap{
- clear:both;
- float:left;
- overflow-x:hidden;
- overflow-y:visible;
- position:relative;
- width:100%;
- background-color:#9EDCF8;
+#footer a {
+ color: #bf8a9c;
}
-#main div[class="menu clearfix"] h2{
- color:#9edcf8;
- font-size:18px;
- font-weight:normal;
- float:left;
+#footer p {
+ font-size: 14px;
+ text-align: center;
+ line-height: 50px;
}
-#main .menu form{
- float:right;
- color:#9edcf8;
- font-size:12px;
+#header {
+ background: #FFFFFF url('/img/fondhead.jpg') repeat-x;
+ width: 100%;
+ float: left;
+ height: 100px;
+ clear: both;
+ margin: 0 auto;
+ position: relative;
}
-#footer{
- background-color:#804561;
- padding-top:30px;
+#header a.logo {
+ background: url('/img/logobow.jpg');
+ width: 290px;
+ height: 100px;
+ text-indent: -99999px;
+ display: block;
}
-#footer a{
- color:#bf8a9c;
-}
-
-#footer p{
- font-size:14px;
- text-align:center;
- line-height:50px;
-}
-
-#header{
- background:#FFFFFF url('/img/fondhead.jpg') repeat-x;
- width:100%;
- float:left;
- height:100px;
- clear:both;
- margin:0 auto;
+#main {
+ width: 1004px;
+ margin: 0 auto;
position: relative;
+ clear: both;
}
-#header a.logo{
- background:url('/img/logobow.jpg');
- width:290px;
- height:100px;
- text-indent:-99999px;
- display:block;
-}
-
-#main{
- width:1004px;
- margin:0 auto;
- position:relative;
- clear:both;
-}
-
-#main .menu{
- margin-top: 25px;
-}
-
#page {
- width:100%;
- margin:0 auto;
- clear:both;
+ width: 100%;
+ margin: 0 auto;
+ clear: both;
}
-#content{
- width:1004px;
- position:relative;
- margin:0 auto;
- padding-top:20px;
+#content {
+ width: 1004px;
+ position: relative;
+ margin: 0 auto;
+ padding-top: 20px;
}
-#formFrame{
- width:225px;
- height:315px;
- background:url('/img/fondconnexion.jpg') no-repeat;
- position:relative;
- margin:100px auto;
- padding:10px 70px;
+#formFrame {
+ width: 225px;
+ height: 315px;
+ background: url('/img/fondconnexion.jpg') no-repeat;
+ position: relative;
+ margin: 100px auto;
+ padding: 10px 70px;
}
-#formFrame h1{
- color:#804561;
- width:225px;
- position:relative;
- margin:15px auto;
+#formFrame h1 {
+ color: #804561;
+ width: 225px;
+ position: relative;
+ margin: 15px auto;
}
-#formFrame div div{
- color:#804561;
- font-size:16px;
- font-weight:bold;
- width:225px;
+#formFrame div div {
+ color: #804561;
+ font-size: 16px;
+ font-weight: bold;
+ width: 225px;
}
.label {
- margin-top:30px;
+ margin-top: 30px;
}
.buttons {
- margin-top:30px;
+ position: absolute;
+ top: 250px;
+ text-align: center;
}
-#formFrame input[type="text"]{
- width:225px;
+#formFrame input[type="text"] {
+ width: 225px;
}
-#formFrame a{
+#formFrame a {
position: absolute;
- color:#804561;
- left:75px;
- font-weight:bold;
+ color: #804561;
+ left: 75px;
+ font-weight: bold;
font-size: 12px;
}
-#formFrame #register{
- bottom:50px;
- font-size:14px;
+#formFrame .message {
+ width: 100%;
+ color: green;
+ font-size: 12px;
+ text-align: center;
+ margin-top: 30px;
}
-button {
- float:right;
- margin-top:20px;
- background:url('/img/fdboutonV.jpg') repeat-x;
- height:31px;
- color:#FFFFFF;
- font-weight:bold;
- border:none;
- width:auto;
+#formFrame input[type="button"] {
+ background: url('/img/fdboutonV.jpg') repeat-x;
+ height: 31px;
+ color: #FFFFFF;
+ font-weight: bold;
+ border: none;
+ width: auto;
padding: 5px;
- cursor:pointer;
+ cursor: pointer;
}
Modified: trunk/src/main/webapp/extensions/chromium/options.html
===================================================================
--- trunk/src/main/webapp/extensions/chromium/options.html 2011-01-05 17:40:08 UTC (rev 161)
+++ trunk/src/main/webapp/extensions/chromium/options.html 2011-01-05 21:58:10 UTC (rev 162)
@@ -45,10 +45,11 @@
var sessionTokenId = sessionTokenIdInput.value;
localStorage["sessionTokenId"] = sessionTokenId;
- alert(chrome.i18n.getMessage("optionSavedMessage"));
+ var formMessage = document.getElementById("formMessage");
+ formMessage.innerHTML = chrome.i18n.getMessage("optionSavedMessage");
}
- // Restores select box state to saved value from localStorage.
+ // Restores values from localStorage.
function restore_options() {
var permanentTokenId = localStorage["permanentTokenId"];
var sessionTokenId = localStorage["sessionTokenId"];
@@ -73,7 +74,7 @@
title.innerHTML = chrome.i18n.getMessage("optionTitle");
var saveOptionButton = document.getElementById("saveOptionButton");
- saveOptionButton.innerHTML = chrome.i18n.getMessage("saveOptionButton");
+ saveOptionButton.value = chrome.i18n.getMessage("saveOptionButton");
var licenseLink = document.getElementById("licenseLink");
licenseLink.innerHTML = chrome.i18n.getMessage("licenseLink");
@@ -117,8 +118,9 @@
<input type="text" name="permanentTokenIdInput" id="permanentTokenIdInput" />
</div>
<div class="buttons">
- <button type="button" id="saveOptionButton" onclick="save_options()"></button>
+ <input type="button" id="saveOptionButton" onclick="save_options()" />
</div>
+ <div class="message" id="formMessage"></div>
</div>
</div>
</div>
@@ -126,7 +128,7 @@
</div>
<div id="footer">
<p>
- <a shape="rect" id="bow_website" href="#">bow</a>
+ <a shape="rect" id="bow_website" href="#" target="_blank">bow</a>
<a shape="rect" href="http://www.chorem.org/projects/list_files/bow">0.3-SNAPSHOT</a> -
<a shape="rect" href="http://www.gnu.org/licenses/agpl.html" id="licenseLink"></a> -
<span title="Copyright">©2010 - 2011</span>
Modified: trunk/src/main/webapp/extensions/chromium/popup.html
===================================================================
--- trunk/src/main/webapp/extensions/chromium/popup.html 2011-01-05 17:40:08 UTC (rev 161)
+++ trunk/src/main/webapp/extensions/chromium/popup.html 2011-01-05 21:58:10 UTC (rev 162)
@@ -54,12 +54,15 @@
var tagsValue = tagsInput.value;
//BOW_URL is defined in properties.js
- var link = BOW_URL + "/bow?action=addUrl&token=" + tokenId + "&url=" + encodeURIComponent(url) + "&name=" + encodeURIComponent(nameValue) + "&alias=" + encodeURIComponent(aliasValue) + "&tags=" + encodeURIComponent(tagsValue);
+ var link = BOW_URL + "/bow?action=addUrl&token=" + tokenId
+ + "&url=" + encodeURIComponent(url)
+ + "&name=" + encodeURIComponent(nameValue)
+ + "&alias=" + encodeURIComponent(aliasValue)
+ + "&tags=" + encodeURIComponent(tagsValue);
- var script = document.createElement('script');
- script.src = link;
- script.type = 'text/javascript';
- document.body.appendChild(script);
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", link, true);
+ xhr.send();
};
function init() {
@@ -83,7 +86,7 @@
var sessionTokenId = localStorage["sessionTokenId"];
var sessionTokenButton = document.getElementById("sessionTokenButton");
if (!isEmpty(sessionTokenId)) {
- sessionTokenButton.innerHTML = chrome.i18n.getMessage("sessionTokenButton");
+ sessionTokenButton.value = chrome.i18n.getMessage("sessionTokenButton");
} else {
sessionTokenButton.style.visibility = "hidden";
}
@@ -91,7 +94,7 @@
var permanentTokenId = localStorage["permanentTokenId"];
var permanentTokenButton = document.getElementById("permanentTokenButton");
if (!isEmpty(permanentTokenId)) {
- permanentTokenButton.innerHTML = chrome.i18n.getMessage("permanentTokenButton");
+ permanentTokenButton.value = chrome.i18n.getMessage("permanentTokenButton");
} else {
permanentTokenButton.style.visibility = "hidden";
}
@@ -132,8 +135,8 @@
<input id="tagsInput" name="tagsInput" type="text" />
</div>
<div id="buttons">
- <button id="permanentTokenButton" onclick="bookmarkPermanent()" type="button"></button>
- <button id="sessionTokenButton" onclick="bookmarkSession()" type="button"></button>
+ <input id="permanentTokenButton" onclick="bookmarkPermanent()" type="button" />
+ <input id="sessionTokenButton" onclick="bookmarkSession()" type="button" />
</div>
</body>
</html>
1
0
05 Jan '11
Author: kmorin
Date: 2011-01-05 18:40:08 +0100 (Wed, 05 Jan 2011)
New Revision: 161
Url: http://chorem.org/repositories/revision/bow/161
Log:
- layout
Modified:
trunk/src/main/webapp/extensions/bow4chromium.crx
trunk/src/main/webapp/extensions/bow4chromium.pem
trunk/src/main/webapp/extensions/chromium/css/extension.css
Modified: trunk/src/main/webapp/extensions/bow4chromium.crx
===================================================================
(Binary files differ)
Modified: trunk/src/main/webapp/extensions/bow4chromium.pem
===================================================================
--- trunk/src/main/webapp/extensions/bow4chromium.pem 2011-01-05 13:08:40 UTC (rev 160)
+++ trunk/src/main/webapp/extensions/bow4chromium.pem 2011-01-05 17:40:08 UTC (rev 161)
@@ -1,16 +1,16 @@
-----BEGIN PRIVATE KEY-----
-MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBALrlCv8Iof1JnkgI3
-RNY5wkX+sCmrNetsMlkFZPmlmrvzkpiF4yz9ND5SL+DkfJ1z2cNQ0OcYE47IOrPac
-HLKDeArqp1L2pWNXStYNyvEgYeeIiLgOa7MsxgZHEDKssQ/hCSaenFTi4ny2exrS/
-hRDZLZc4q4SDKhkW77qdBzTFrAgMBAAECgYBDA1uFBMhotJvvglYa2NbGmPWNXHY/
-Q4VPQPbHuHeY0nGqlC+TgPc4cxoVqYyMXpfGgKfst0aE5oiwCT0HgtvhJaWiYLoIN
-FIx2fo6l2vh5yoBGsoCEeVddIpsLVE+vLmmlTexrpOH/IpjZQwGO0TWE71PjtXpWD
-P+DL2FpJH2qQJBAOoxfWjaqGh3ZFMAiRY4lV+T8roGU5cTftSCgAr8xHdVkVdPgBA
-UTCXMBhJF3SPVvs0QjSZKnNpsd+cKp0I7jiUCQQDMTBZDxD+Q9s8r/9IR/IQMqrDv
-lrzNFbDFTn40AWctNBGPxNoWmyDPt6I1fJ47lY/V4nAiGxVfZBwbxa12uMRPAkEAh
-N1Q9fTfiGz72O871wSBEjmAgrNmJxbjZLMo65Ld74n3LB6pW/X4AZWPeDx0qojwd6
-zFN40rEexp1gVAQR5ClQJBAJHrfrOkhqqqPst0i70hGchaWsqmZfAuH/at2+KVZfa
-ZjDmeJw+iecsjpI6DlhmE+BmTBPi3U4qw3IrRpNZ5nm0CQQDousvMfCfh7kdSoaIt
-5WOajqt+FAF6AeMsc+Yg7Qeu4w7XkMOTQFqTMuVjLdnQQy6BxGfhuAnKxaXlBxJwM
-LzF
+MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAM7n867IJSfHF6egn
+sBS5kBR8rCwFbljqraMmTWY8tvZtUk6B7e0gZxMpoZy83NBbztqZMCrg1uu5Sjbes
+mfsWXQuXydapl4ROKN85MUsuaHy+TvO27Zso5GjswDo982cShioU3oidYw7ZQC/Pu
+FPmlzkzMfrIFqOA8S8lh7+XiZAgMBAAECgYAzFbfnvojV8mUXwSORDqbE2LbYAxHK
+DR6YJcyqHBJST8VfyBEhvVKG+bHf3j/XhB9nhxRLMc2j9GGmHdKKN4B/1jsJAR43L
+1ByYhp4L9ICjTGXrUz5ldl9bU3uuKIYeLaK6vKkmq+S7nlFKQDSv4X3uXEvCIZec/
+ESLcm9yiIBUQJBAO4r26CLVBTVKsg/Tmx9b7HHosyuUEv2zJzpo/SNztndpo1VOy2
+JVQC5U4IoV1BhI+q6za5oTo3rnIfTjsyoJyUCQQDeZPMEcmroUrDpvy4bhnI2idZZ
+F4H1vVmcbcxd/RCmQSYUTa2c9HyZdUxJG/dveExEkC58HP6ZSc2svb+TwrtlAkEAw
+8hXvUxrLMjiZ0PrArHGTFzwTdMI/Lj/EAnblh+wJ1XWIJ4sjE01C+hMZlUlGVURAl
+bW1wS1dmJ1BQ56d2/O5QJBAM/3LL3a1Rg9w4xCKDa7KfDQQq57ah9HmxXKI1M9BCX
+ERHy2CwT8J8xFQToYufD2WLPA9IdBgeAMgRXpNs5RSnUCQEAcKEx37eDto1LJPRh1
+nxyMzcgonNBSP2UtwGZdTeujM2KxBX4YMUuEz0u6fzlB+vD/ZM9af1IxYzDaH0mZc
+6c=
-----END PRIVATE KEY-----
Modified: trunk/src/main/webapp/extensions/chromium/css/extension.css
===================================================================
--- trunk/src/main/webapp/extensions/chromium/css/extension.css 2011-01-05 13:08:40 UTC (rev 160)
+++ trunk/src/main/webapp/extensions/chromium/css/extension.css 2011-01-05 17:40:08 UTC (rev 161)
@@ -19,28 +19,30 @@
* #L%
*/
body {
- width: 300px;
- font-size:14px;
- font-family:Verdana, Arial, Helvetica, sans-serif;
- font-weight:bold;
- background-color:#9EDCF8;
- color:#804561;
+ width: 330px;
+ height: 288px;
+ font-size: 12px;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-weight: bold;
+ background: #9EDCF8 url('/img/fondconnexion.jpg') no-repeat;
+ color: #804561;
padding: 5px 10px 5px 10px;
}
h1 {
- font-size:18px;
+ font-size: 18px;
width: 100%;
text-align: center;
+ margin-bottom: 20px;
}
button {
- float:right;
- background:url('/img/fdboutonV.jpg') repeat-x;
- color:#FFFFFF;
- font-weight:bold;
- border:none;
- width:auto;
+ float: right;
+ background: url('/img/fdboutonV.jpg') repeat-x;
+ color: #FFFFFF;
+ font-weight: bold;
+ border: none;
+ width: auto;
padding: 5px;
cursor: pointer;
}
@@ -59,7 +61,7 @@
#buttons {
width: 100%;
- margin-top: 10px;
+ margin-top: 30px;
height: 30px;
text-align: center;
text-color: red;
1
0
05 Jan '11
Author: kmorin
Date: 2011-01-05 14:08:40 +0100 (Wed, 05 Jan 2011)
New Revision: 160
Url: http://chorem.org/repositories/revision/bow/160
Log:
- forgot to externalize the logo link in the options
Modified:
trunk/src/main/webapp/extensions/bow4chromium.crx
trunk/src/main/webapp/extensions/bow4chromium.pem
trunk/src/main/webapp/extensions/chromium/options.html
Modified: trunk/src/main/webapp/extensions/bow4chromium.crx
===================================================================
(Binary files differ)
Modified: trunk/src/main/webapp/extensions/bow4chromium.pem
===================================================================
--- trunk/src/main/webapp/extensions/bow4chromium.pem 2011-01-05 13:01:02 UTC (rev 159)
+++ trunk/src/main/webapp/extensions/bow4chromium.pem 2011-01-05 13:08:40 UTC (rev 160)
@@ -1,16 +1,16 @@
-----BEGIN PRIVATE KEY-----
-MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBANbNmpzgPf3vX1821
-TD++YmnC0D82s7nZ4jDXiYgQWUbf/nr1scPQqdKKWAmemqt29WICDYXhyvbyG/o3P
-meM2rgxV75hRjlRgtkVzXyMGiVsj/4piNPEAMByuW9A7x3UMilMEy45sHyp62gd2t
-JE6firpD86gFXk0316N1k2NCBAgMBAAECgYAQhAiCTV+W2cPcf0vPE5u+MMDVw1tT
-k0lLo7Hmfo5opr+lSLPf5FV8pWAfC3ZYI3wGpAn1lsOG5MQ5jo8HBlnvlqT2MJmX6
-wcWD/4dx7YxLP0JyvPig48t4HBhSfQCZKASwO/6clM1Mj9XpQPB/sN+TP6h5ikaGB
-7Ya9xQrtn47QJBAPzX+iBVlO0T1+JevImu76GpW9EBF48YiqDBaoALB8/Hf9yDln3
-vjajjJlwiAElfdQHfgC/cfAo+YZ5xx9UDrxsCQQDZfA8qLYIB5j67N6KEZf5Ny0cE
-9k7jzITYaaqsA2hdpNn6++U1WA97ri4jmHp3rXBGa3Hlvk4ELWvSunkg8gyTAkA/6
-YAqaDeq7dcmO3hA/V1Jafvxiusfmr6AACQhlag112H0pbaGwuT2CeUKaPXVljGHda
-17a6pXFImseWpf5/x9AkB3RS733Y8vxXpfp+orm9e0CCgBk6a+DPpJyOE9hnzk5jR
-ZDW2tLIcJOAO7p7J6EZbCN8h1y0Dzz4kTPwqQw82bAkEAuVFyoPRwCMFJQ3UZGa5V
-LNgk8srKActA6D/YqEWvNyondvjjotwYIwS+II0VR6wbe+98JTZEhZ2iDBKsN2PP6
-A==
+MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBALrlCv8Iof1JnkgI3
+RNY5wkX+sCmrNetsMlkFZPmlmrvzkpiF4yz9ND5SL+DkfJ1z2cNQ0OcYE47IOrPac
+HLKDeArqp1L2pWNXStYNyvEgYeeIiLgOa7MsxgZHEDKssQ/hCSaenFTi4ny2exrS/
+hRDZLZc4q4SDKhkW77qdBzTFrAgMBAAECgYBDA1uFBMhotJvvglYa2NbGmPWNXHY/
+Q4VPQPbHuHeY0nGqlC+TgPc4cxoVqYyMXpfGgKfst0aE5oiwCT0HgtvhJaWiYLoIN
+FIx2fo6l2vh5yoBGsoCEeVddIpsLVE+vLmmlTexrpOH/IpjZQwGO0TWE71PjtXpWD
+P+DL2FpJH2qQJBAOoxfWjaqGh3ZFMAiRY4lV+T8roGU5cTftSCgAr8xHdVkVdPgBA
+UTCXMBhJF3SPVvs0QjSZKnNpsd+cKp0I7jiUCQQDMTBZDxD+Q9s8r/9IR/IQMqrDv
+lrzNFbDFTn40AWctNBGPxNoWmyDPt6I1fJ47lY/V4nAiGxVfZBwbxa12uMRPAkEAh
+N1Q9fTfiGz72O871wSBEjmAgrNmJxbjZLMo65Ld74n3LB6pW/X4AZWPeDx0qojwd6
+zFN40rEexp1gVAQR5ClQJBAJHrfrOkhqqqPst0i70hGchaWsqmZfAuH/at2+KVZfa
+ZjDmeJw+iecsjpI6DlhmE+BmTBPi3U4qw3IrRpNZ5nm0CQQDousvMfCfh7kdSoaIt
+5WOajqt+FAF6AeMsc+Yg7Qeu4w7XkMOTQFqTMuVjLdnQQy6BxGfhuAnKxaXlBxJwM
+LzF
-----END PRIVATE KEY-----
Modified: trunk/src/main/webapp/extensions/chromium/options.html
===================================================================
--- trunk/src/main/webapp/extensions/chromium/options.html 2011-01-05 13:01:02 UTC (rev 159)
+++ trunk/src/main/webapp/extensions/chromium/options.html 2011-01-05 13:08:40 UTC (rev 160)
@@ -86,6 +86,9 @@
var bow_website_link = document.links["bow_website"];
bow_website_link.href = BOW_URL;
+
+ var bow_logo_link = document.links["bow_logo"];
+ bow_logo_link.href = BOW_URL;
}
//-->
</script>
@@ -94,7 +97,7 @@
<div id="wrap">
<div id="page">
<div id="header">
- <a class="logo" href="http://bow.chorem.org">bow</a>
+ <a class="logo" id="bow_logo" href="#">bow</a>
</div>
<div id="main">
<div id="content">
1
0