Bow-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- 617 discussions
14 Jan '11
Author: vbriand
Date: 2011-01-14 15:25:43 +0100 (Fri, 14 Jan 2011)
New Revision: 173
Url: http://chorem.org/repositories/revision/bow/173
Log:
Fixed the major design issue when logged in
Modified:
trunk/src/main/webapp/WEB-INF/decorators/main.jsp
trunk/src/main/webapp/jsp/home.jsp
trunk/src/main/webapp/jsp/preferences.jsp
trunk/src/main/webapp/jsp/search.jsp
Modified: trunk/src/main/webapp/WEB-INF/decorators/main.jsp
===================================================================
--- trunk/src/main/webapp/WEB-INF/decorators/main.jsp 2011-01-14 13:24:54 UTC (rev 172)
+++ trunk/src/main/webapp/WEB-INF/decorators/main.jsp 2011-01-14 14:25:43 UTC (rev 173)
@@ -23,11 +23,14 @@
<body id="page-home">
<div id="wrap">
<div id="page">
- <%@include file="/jsp/inc/header.jsp" %>
+ <%@include file="/jsp/inc/header.jsp" %>
<div id="main">
- <%@include file="/jsp/inc/errorFrame.jsp" %>
- <decorator:body />
- </div>
+ <%@include file="/jsp/inc/errorFrame.jsp" %>
+ <decorator:body />
+ </div>
+ <s:if test="#session.user">
+ <jsp:include page="/jsp/inc/rightMenu.jsp" />
+ </s:if>
</div>
</div>
<%@include file="/jsp/inc/footer.jsp" %>
Modified: trunk/src/main/webapp/jsp/home.jsp
===================================================================
--- trunk/src/main/webapp/jsp/home.jsp 2011-01-14 13:24:54 UTC (rev 172)
+++ trunk/src/main/webapp/jsp/home.jsp 2011-01-14 14:25:43 UTC (rev 173)
@@ -104,7 +104,6 @@
<p class="nobookmarks"><s:text name="bow.bookmarks.noBookmarks" /></p>
<% } %>
</div>
- <jsp:include page="inc/rightMenu.jsp" />
</body>
</html>
<% } %>
Modified: trunk/src/main/webapp/jsp/preferences.jsp
===================================================================
--- trunk/src/main/webapp/jsp/preferences.jsp 2011-01-14 13:24:54 UTC (rev 172)
+++ trunk/src/main/webapp/jsp/preferences.jsp 2011-01-14 14:25:43 UTC (rev 173)
@@ -39,7 +39,6 @@
<s:head />
</head>
<body>
- <s:property value="#session.put" />
<div id="content">
<div class="menu clearfix">
<h2><s:text name="bow.preferences.title" /></h2>
@@ -113,6 +112,5 @@
}
%>
</div>
- <jsp:include page="inc/rightMenu.jsp" flush="true" />
</body>
</html>
\ No newline at end of file
Modified: trunk/src/main/webapp/jsp/search.jsp
===================================================================
--- trunk/src/main/webapp/jsp/search.jsp 2011-01-14 13:24:54 UTC (rev 172)
+++ trunk/src/main/webapp/jsp/search.jsp 2011-01-14 14:25:43 UTC (rev 173)
@@ -50,7 +50,6 @@
<s:head />
</head>
<body>
- <div id="content">
<div class="menu clearfix">
<h2><s:text name="bow.search.title" /></h2>
<s:url id="order" action="order" escapeAmp="false">
@@ -101,7 +100,6 @@
<p class="nobookmarks"><s:text name="bow.bookmarks.noBookmarks" /></p>
<% } %>
</div>
- <jsp:include page="inc/rightMenu.jsp" />
</body>
</html>
<% } %>
1
0
r172 - in trunk/src/main: java/org/chorem/bow/action resources resources/i18n webapp/jsp/inc
by vbriand@users.chorem.org 14 Jan '11
by vbriand@users.chorem.org 14 Jan '11
14 Jan '11
Author: vbriand
Date: 2011-01-14 14:24:54 +0100 (Fri, 14 Jan 2011)
New Revision: 172
Url: http://chorem.org/repositories/revision/bow/172
Log:
Fixed all bugs when editing a bookmark
Modified:
trunk/src/main/java/org/chorem/bow/action/ModifyBookmarkAction.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/inc/bookmark.jsp
trunk/src/main/webapp/jsp/inc/rightMenu.jsp
Modified: trunk/src/main/java/org/chorem/bow/action/ModifyBookmarkAction.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/action/ModifyBookmarkAction.java 2011-01-13 18:04:39 UTC (rev 171)
+++ trunk/src/main/java/org/chorem/bow/action/ModifyBookmarkAction.java 2011-01-14 13:24:54 UTC (rev 172)
@@ -9,24 +9,24 @@
public class ModifyBookmarkAction extends BowBaseAction {
private static final long serialVersionUID = 8197008295267924063L;
- protected String url;
+ protected String link;
protected String name;
protected String alias;
protected String tags;
protected String bookmarkId;
/**
- * @return the url
+ * @return the link
*/
- public String getUrl() {
- return url;
+ public String getLink() {
+ return link;
}
/**
- * @param url the url to set
+ * @param url the linkto set
*/
- public void setUrl(String url) {
- this.url = url;
+ public void setLink(String link) {
+ this.link = link;
}
/**
@@ -97,7 +97,7 @@
alias = bookmark.getAlias();
}
}
- BookmarkActions.updateBookmark(bookmark, name, url, tags, alias);
+ BookmarkActions.updateBookmark(bookmark, name, link, tags, alias);
proxy.store(bookmark);
}
return SUCCESS;
Modified: trunk/src/main/resources/i18n/bow_en_GB.properties
===================================================================
--- trunk/src/main/resources/i18n/bow_en_GB.properties 2011-01-13 18:04:39 UTC (rev 171)
+++ trunk/src/main/resources/i18n/bow_en_GB.properties 2011-01-14 13:24:54 UTC (rev 172)
@@ -1,6 +1,8 @@
bow.action.locale.english=English
bow.action.locale.french=French
bow.bookmark.badFileFormat=
+bow.bookmark.description=Description
+bow.bookmark.tags=Tags
bow.bookmarks.noBookmarks=No bookmarks
bow.config.alias.url.description=
bow.config.application.version.description=
@@ -70,6 +72,7 @@
bow.rightMenu.fullTextSearch=Full text search
bow.rightMenu.import.submit=Import
bow.rightMenu.importBookmarks=Import bookmarks
+bow.rightMenu.logout=Logout
bow.rightMenu.search=Search
bow.rightMenu.token.permanent=Permanent token id
bow.rightMenu.token.temporary=Session token id
Modified: trunk/src/main/resources/i18n/bow_fr_FR.properties
===================================================================
--- trunk/src/main/resources/i18n/bow_fr_FR.properties 2011-01-13 18:04:39 UTC (rev 171)
+++ trunk/src/main/resources/i18n/bow_fr_FR.properties 2011-01-14 13:24:54 UTC (rev 172)
@@ -1,6 +1,8 @@
bow.action.locale.english=Anglais
bow.action.locale.french=Fran\u00E7ais
bow.bookmark.badFileFormat=
+bow.bookmark.description=Description
+bow.bookmark.tags=Tags
bow.bookmarks.noBookmarks=Pas de marque-page
bow.config.alias.url.description=
bow.config.application.version.description=
@@ -70,6 +72,7 @@
bow.rightMenu.fullTextSearch=Recherche full text
bow.rightMenu.import.submit=Importer
bow.rightMenu.importBookmarks=Importer des marque-pages
+bow.rightMenu.logout=D\u00E9connexion
bow.rightMenu.search=Recherche
bow.rightMenu.token.permanent=Token permanent
bow.rightMenu.token.temporary=Token session
Modified: trunk/src/main/resources/struts.xml
===================================================================
--- trunk/src/main/resources/struts.xml 2011-01-13 18:04:39 UTC (rev 171)
+++ trunk/src/main/resources/struts.xml 2011-01-14 13:24:54 UTC (rev 172)
@@ -4,6 +4,7 @@
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
+ <constant name="struts.ognl.allowStaticMethodAccess" value="true" />
<package name="myPackage" extends="struts-default">
<action name="register_*" method="{1}" class="org.chorem.bow.action.RegisterAction">
Modified: trunk/src/main/webapp/jsp/inc/bookmark.jsp
===================================================================
--- trunk/src/main/webapp/jsp/inc/bookmark.jsp 2011-01-13 18:04:39 UTC (rev 171)
+++ trunk/src/main/webapp/jsp/inc/bookmark.jsp 2011-01-14 13:24:54 UTC (rev 172)
@@ -43,11 +43,15 @@
<s:set var="searchLine" value="%{#request.searchLine}" />
<s:set var="fullTextLine" value="%{#request.fullTextLine}" />
<s:set var="wikittyId" value="%{#request.bookmark.getWikittyId()}" />
+ <s:set var="bookmarkLink" value="%{#request.bookmark.getLink()}" />
+ <s:set var="bookmarkAlias" value="%{#request.bookmark.getAlias()}" />
+ <s:set var="bookmarkDescription" value="%{#request.bookmark.getDescription()}" />
+ <s:set var="bookmarkClicks" value="%{#request.bookmark.getClick()}" />
<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()%>
+ <s:property value="%{#bookmarkAlias}" />
</a>
<p class="date"> (<%=sdf.format(bookmark.getDate())%>)</p>
<s:url id="editBookmark" action="modifyBookmark" escapeAmp="false">
@@ -55,7 +59,7 @@
<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}', '%{#wikittyId}');"></s:a>
+ <s:a cssClass="edit" href="%{editBookmark}" onclick="return modify('%{#bookmarkDescription}', '%{#bookmarkAlias}', '%{@org.chorem.bow.BookmarkActions@getBookmarkTagsString(#request.bookmark)}', '%{#bookmarkLink}', '%{editBookmark}', '%{#wikittyId}');"></s:a>
<s:url id="removeBookmark" action="removeBookmark" escapeAmp="false">
<s:param name="bookmarkId"><s:property value="%{#wikittyId}" /></s:param>
<s:param name="searchLine"><s:property value="%{#searchLine}" /></s:param>
@@ -65,17 +69,17 @@
</div>
<div class="bookmarkcontenu">
<div class="screenshot"></div>
- <div class="click"><%=bookmark.getClick()%></div>
+ <div class="click"><s:property value="%{#bookmarkClicks}" /></div>
<div class="description">
- <h3>Description :</h3>
+ <h3><s:text name="bow.bookmark.description" /> :</h3>
<p>
<s:url id="addClick" action="addClick">
- <s:param name="bookmarkId"><%=bookmark.getWikittyId()%></s:param>
+ <s:param name="bookmarkId"><s:property value="%{#wikittyId}" /></s:param>
</s:url>
- <s:a title="%{#request.bookmark.getLink()}" href="%{addClick}" onclick="window.open(this.href); return false;"><%=bookmark.getDescription()%></s:a>
+ <s:a title="%{#bookmarkLink}" href="%{addClick}" onclick="window.open(this.href); return false;"><s:property value="%{#bookmarkDescription}" /></s:a>
</p>
<p class="tags">
- <strong>Tags :</strong>
+ <strong><s:text name="bow.bookmark.tags" /> :</strong>
<%
Set<String> tagList = bookmark.getTags();
Modified: trunk/src/main/webapp/jsp/inc/rightMenu.jsp
===================================================================
--- trunk/src/main/webapp/jsp/inc/rightMenu.jsp 2011-01-13 18:04:39 UTC (rev 171)
+++ trunk/src/main/webapp/jsp/inc/rightMenu.jsp 2011-01-14 13:24:54 UTC (rev 172)
@@ -65,7 +65,7 @@
String formName = (String)request.getAttribute("name");
String formTags = (String)request.getAttribute("tags");
String formAlias = (String)request.getAttribute("alias");
-String formAction = (String)request.getAttribute("formAction"); //TODO : modifier le nom action en formAction parce que sinon ça fait tout péter
+String formAction = (String)request.getAttribute("formAction");
if (formLink == null)
formLink = "URL";
@@ -84,7 +84,7 @@
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<s:form action="logout">
- <s:submit name="bow.rightMenu.logout" />
+ <s:submit key="bow.rightMenu.logout" />
</s:form>
<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>
@@ -109,7 +109,7 @@
<div id="add" class="clearfix">
<h2><s:text name="bow.rightMenu.bookmark.addModify" /></h2>
<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.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}" />
1
0
r171 - in trunk/src/main: resources resources/i18n 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 19:04:39 +0100 (Thu, 13 Jan 2011)
New Revision: 171
Url: http://chorem.org/repositories/revision/bow/171
Log:
The tags can now be removed
Modified:
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/inc/bookmark.jsp
trunk/src/main/webapp/jsp/inc/tagsCloud.jsp
Modified: trunk/src/main/resources/i18n/bow_en_GB.properties
===================================================================
--- trunk/src/main/resources/i18n/bow_en_GB.properties 2011-01-13 15:11:42 UTC (rev 170)
+++ trunk/src/main/resources/i18n/bow_en_GB.properties 2011-01-13 18:04:39 UTC (rev 171)
@@ -60,6 +60,7 @@
bow.rightMenu.bookmark.link=URL
bow.rightMenu.bookmark.name=DESC
bow.rightMenu.bookmark.permanentLink=Bookmark add link (permanent)
+bow.rightMenu.bookmark.submit=Save
bow.rightMenu.bookmark.tags=TAGS
bow.rightMenu.bookmark.temporaryLink=Bookmark add link (session)
bow.rightMenu.chromiumExtension=Chromium extension
@@ -72,3 +73,4 @@
bow.rightMenu.search=Search
bow.rightMenu.token.permanent=Permanent token id
bow.rightMenu.token.temporary=Session token id
+bow.search.title=Search
Modified: trunk/src/main/resources/i18n/bow_fr_FR.properties
===================================================================
--- trunk/src/main/resources/i18n/bow_fr_FR.properties 2011-01-13 15:11:42 UTC (rev 170)
+++ trunk/src/main/resources/i18n/bow_fr_FR.properties 2011-01-13 18:04:39 UTC (rev 171)
@@ -60,6 +60,7 @@
bow.rightMenu.bookmark.link=URL
bow.rightMenu.bookmark.name=DESC
bow.rightMenu.bookmark.permanentLink=Ajouter un bookmark (permanent)
+bow.rightMenu.bookmark.submit=Sauvegarder
bow.rightMenu.bookmark.tags=TAGS
bow.rightMenu.bookmark.temporaryLink=Ajouter un bookmark (session)
bow.rightMenu.chromiumExtension=Extension pour chromium
@@ -72,3 +73,4 @@
bow.rightMenu.search=Recherche
bow.rightMenu.token.permanent=Token permanent
bow.rightMenu.token.temporary=Token session
+bow.search.title=Recherche
Modified: trunk/src/main/resources/struts.xml
===================================================================
--- trunk/src/main/resources/struts.xml 2011-01-13 15:11:42 UTC (rev 170)
+++ trunk/src/main/resources/struts.xml 2011-01-13 18:04:39 UTC (rev 171)
@@ -31,7 +31,7 @@
</action>
<action name="addUrl" class="org.chorem.bow.action.AddUrlAction">
<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-->
+ <!-- TODO: changer pour rediriger selon la page sur laquelle on se trouvait (home, search, ...)-->
</action>
</package>
@@ -71,10 +71,11 @@
<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-->
+ <!-- TODO: changer pour rediriger selon la page sur laquelle on se trouvait (home, search, ...)-->
+ <result type="redirectAction">home</result>
</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-->
+ <!-- TODO: changer pour rediriger selon la page sur laquelle on se trouvait (home, search, ...)-->
<result type="redirectAction">home</result>
</action>
<action name="order" class="org.chorem.bow.action.OrderAction">
@@ -90,7 +91,7 @@
</action>
<!-- Suggestion, Result -->
<action name="openSearch*" method="{1}" class="org.chorem.bow.action.OpenSearchAction">
- <!-- Plein de types de redirections différentes, et un .forward(..., ...); que je ne sais pas comment changer -->
+ <!-- TODO: changer pour rediriger selon la page sur laquelle on se trouvait (home, search, ...)-->
<result>/jsp/suggestions.jsp</result>
</action>
<action name="preferences" class="org.chorem.bow.action.PreferencesAction">
Modified: trunk/src/main/webapp/jsp/inc/bookmark.jsp
===================================================================
--- trunk/src/main/webapp/jsp/inc/bookmark.jsp 2011-01-13 15:11:42 UTC (rev 170)
+++ trunk/src/main/webapp/jsp/inc/bookmark.jsp 2011-01-13 18:04:39 UTC (rev 171)
@@ -42,6 +42,7 @@
%>
<s:set var="searchLine" value="%{#request.searchLine}" />
<s:set var="fullTextLine" value="%{#request.fullTextLine}" />
+ <s:set var="wikittyId" value="%{#request.bookmark.getWikittyId()}" />
<div class="bookmark">
<div class="bookmarkhead">
@@ -50,13 +51,13 @@
</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="bookmarkId"><s:property value="%{#wikittyId}" /></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:a cssClass="edit" href="%{editBookmark}" onclick="return modify('%{#request.bookmark.getDescription()}', '%{#request.bookmark.getAlias()}', '%{#request.bookmark.getTags()}', '%{#request.bookmark.getLink()}', '%{editBookmark}', '%{#wikittyId}');"></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="bookmarkId"><s:property value="%{#wikittyId}" /></s:param>
<s:param name="searchLine"><s:property value="%{#searchLine}" /></s:param>
<s:param name="fullTextLine"><s:property value="%{#fullTextLine}" /></s:param>
</s:url>
@@ -71,8 +72,7 @@
<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()%>-->
+ <s:a title="%{#request.bookmark.getLink()}" href="%{addClick}" onclick="window.open(this.href); return false;"><%=bookmark.getDescription()%></s:a>
</p>
<p class="tags">
<strong>Tags :</strong>
@@ -82,8 +82,8 @@
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:url id="deleteTag" action="deleteTag" escapeAmp="false">
+ <s:param name="bookmarkId"><s:property value="%{#wikittyId}" /></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>
@@ -97,10 +97,9 @@
<%
} 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>
+ <a name="<s:property value='%{#wikittyId}' />" style="display:none; text-decoration: none;" href="<s:property value='%{#deleteTag}' />">
+ <img style="border:none;" src="img/delete.png" alt="Delete tag" title="Delete" />
+ </a>
<% } %>
<s:url id="search" action="search">
<s:param name="searchLine"><%=tag%></s:param>
Modified: trunk/src/main/webapp/jsp/inc/tagsCloud.jsp
===================================================================
--- trunk/src/main/webapp/jsp/inc/tagsCloud.jsp 2011-01-13 15:11:42 UTC (rev 170)
+++ trunk/src/main/webapp/jsp/inc/tagsCloud.jsp 2011-01-13 18:04:39 UTC (rev 171)
@@ -21,6 +21,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
-->
+<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
+<%@taglib prefix="s" uri="/struts-tags" %>
<%@page import="org.chorem.bow.BookmarkActions" %>
<%@page import="java.util.List" %>
<%@page import="org.nuiton.wikitty.FacetTopic" %>
@@ -40,7 +42,12 @@
String tagName = tag.getTopicName();
int font = bookmarkActions.getFont(value);
%>
- <a href="/bow/search.action&addTag=<%=tagName%><%=search%>" title="<%=value%> result<%=(value != 1 ? "s" : "")%>" class="tag" style="font-size: <%=font%>px;"><%=tagName%></a>
+ <s:url id="search" action="search" escapeAmp="false">
+ <s:param name="addTag"><%=tagName%></s:param>
+ <s:param name="searchLine"><s:property value="%{#request.searchLine}" /></s:param>
+ </s:url>
+ <!-- title="??value?? result??(value != 1 ? \"s\" : \"\")??" style="font-size: ??font??px;"-->
+ <s:a href="%{#search}" class="tag"><%=tagName%></s:a>
<%
++count;
if (count >= nbTags) {
1
0
r170 - in trunk/src/main: java/org/chorem/bow java/org/chorem/bow/action resources/i18n 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 16:11:42 +0100 (Thu, 13 Jan 2011)
New Revision: 170
Url: http://chorem.org/repositories/revision/bow/170
Log:
Fixed the links to add bookmarks. Added some translations. Fixed various bugs.
Modified:
trunk/src/main/java/org/chorem/bow/BowInit.java
trunk/src/main/java/org/chorem/bow/action/BowBaseAction.java
trunk/src/main/java/org/chorem/bow/action/ImportBookmarksAction.java
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/rightMenu.jsp
Modified: trunk/src/main/java/org/chorem/bow/BowInit.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BowInit.java 2011-01-13 10:58:47 UTC (rev 169)
+++ trunk/src/main/java/org/chorem/bow/BowInit.java 2011-01-13 15:11:42 UTC (rev 170)
@@ -51,8 +51,12 @@
static public void initSession(Map<String, Object> session, User user) throws NoSuchAlgorithmException {
WikittyProxy proxy = BowProxy.getInstance();
Preference preference = proxy.restore(Preference.class, user.getWikittyId());
+ BowConfig config = BowConfig.getInstance();
+
session.put("user", user);
session.put("preference", preference);
+ session.put("version", config.getVersion());
+ session.put("bowUrl", config.getBowUrl());
initializeToken(session, user);
checkAdmin(session, user.getEmail());
}
Modified: trunk/src/main/java/org/chorem/bow/action/BowBaseAction.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/action/BowBaseAction.java 2011-01-13 10:58:47 UTC (rev 169)
+++ trunk/src/main/java/org/chorem/bow/action/BowBaseAction.java 2011-01-13 15:11:42 UTC (rev 170)
@@ -12,7 +12,7 @@
private static final long serialVersionUID = 1L;
public static final String UNTRANSLATED_MARKER = "???";
private static final Log log = LogFactory.getLog(BowBaseAction.class);
-
+
@Override
public String getText(String aTextName) {
String value = super.getText(aTextName);
Modified: trunk/src/main/java/org/chorem/bow/action/ImportBookmarksAction.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/action/ImportBookmarksAction.java 2011-01-13 10:58:47 UTC (rev 169)
+++ trunk/src/main/java/org/chorem/bow/action/ImportBookmarksAction.java 2011-01-13 15:11:42 UTC (rev 170)
@@ -152,51 +152,54 @@
User user = (User)session.get("user");
if (user != null) {
- try {
- List<?> lines;
+ if (upfile != null) {
+ try {
+ List<?> lines;
- 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) {
+ 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;
- } 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 (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;
+ } 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();
}
- } catch (IOException e2) {
- // TODO Auto-generated catch block
- e2.printStackTrace();
+ return ERROR;
}
- return ERROR;
+ return SUCCESS;
}
return LOGIN;
}
Modified: trunk/src/main/resources/i18n/bow_en_GB.properties
===================================================================
--- trunk/src/main/resources/i18n/bow_en_GB.properties 2011-01-13 10:58:47 UTC (rev 169)
+++ trunk/src/main/resources/i18n/bow_en_GB.properties 2011-01-13 15:11:42 UTC (rev 170)
@@ -1,7 +1,7 @@
bow.action.locale.english=English
bow.action.locale.french=French
bow.bookmark.badFileFormat=
-bow.bookmarks.noBookmarks=
+bow.bookmarks.noBookmarks=No bookmarks
bow.config.alias.url.description=
bow.config.application.version.description=
bow.config.bow.addressFrom.description=
@@ -15,10 +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.home.latestBookmarks=The latest added bookmarks
+bow.home.mostUsedBookmarks=The most used bookmarks
+bow.home.title=Home
bow.label.locale.english=
bow.label.locale.french=
bow.login.authenticationFailure=
@@ -52,7 +51,24 @@
bow.register.mailHi=
bow.register.mailPwd=
bow.register.mailSubject=
-bow.register.pwdDontMatch=Passwords don't match
+bow.register.pwdDontMatch=Passwords don''t match
bow.register.submit=Register
bow.register.title=Register
bow.requiredstring=${getText(fieldKey)} is required
+bow.rightMenu.bookmark.addModify=Add / Modify
+bow.rightMenu.bookmark.alias=ALIAS
+bow.rightMenu.bookmark.link=URL
+bow.rightMenu.bookmark.name=DESC
+bow.rightMenu.bookmark.permanentLink=Bookmark add link (permanent)
+bow.rightMenu.bookmark.tags=TAGS
+bow.rightMenu.bookmark.temporaryLink=Bookmark add link (session)
+bow.rightMenu.chromiumExtension=Chromium extension
+bow.rightMenu.exportBookmarks=Export bookmarks
+bow.rightMenu.extensions=Extensions
+bow.rightMenu.find.submit=Find
+bow.rightMenu.fullTextSearch=Full text search
+bow.rightMenu.import.submit=Import
+bow.rightMenu.importBookmarks=Import bookmarks
+bow.rightMenu.search=Search
+bow.rightMenu.token.permanent=Permanent token id
+bow.rightMenu.token.temporary=Session token id
Modified: trunk/src/main/resources/i18n/bow_fr_FR.properties
===================================================================
--- trunk/src/main/resources/i18n/bow_fr_FR.properties 2011-01-13 10:58:47 UTC (rev 169)
+++ trunk/src/main/resources/i18n/bow_fr_FR.properties 2011-01-13 15:11:42 UTC (rev 170)
@@ -1,7 +1,7 @@
bow.action.locale.english=Anglais
bow.action.locale.french=Fran\u00E7ais
bow.bookmark.badFileFormat=
-bow.bookmarks.noBookmarks=
+bow.bookmarks.noBookmarks=Pas de marque-page
bow.config.alias.url.description=
bow.config.application.version.description=
bow.config.bow.addressFrom.description=
@@ -15,10 +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.home.latestBookmarks=Les derniers marque-pages ajout\u00E9s
+bow.home.mostUsedBookmarks=Les marque-pages les plus utilis\u00E9s
+bow.home.title=Accueil
bow.label.locale.english=
bow.label.locale.french=
bow.login.authenticationFailure=
@@ -56,3 +55,20 @@
bow.register.submit=S''enregistrer
bow.register.title=S''enregistrer
bow.requiredstring=${getText(fieldKey)} est obligatoire
+bow.rightMenu.bookmark.addModify=Ajouter / Modifier
+bow.rightMenu.bookmark.alias=ALIAS
+bow.rightMenu.bookmark.link=URL
+bow.rightMenu.bookmark.name=DESC
+bow.rightMenu.bookmark.permanentLink=Ajouter un bookmark (permanent)
+bow.rightMenu.bookmark.tags=TAGS
+bow.rightMenu.bookmark.temporaryLink=Ajouter un bookmark (session)
+bow.rightMenu.chromiumExtension=Extension pour chromium
+bow.rightMenu.exportBookmarks=Exporter les marque-pages
+bow.rightMenu.extensions=Extensions
+bow.rightMenu.find.submit=Rechercher
+bow.rightMenu.fullTextSearch=Recherche full text
+bow.rightMenu.import.submit=Importer
+bow.rightMenu.importBookmarks=Importer des marque-pages
+bow.rightMenu.search=Recherche
+bow.rightMenu.token.permanent=Token permanent
+bow.rightMenu.token.temporary=Token session
Modified: trunk/src/main/webapp/jsp/inc/bookmark.jsp
===================================================================
--- trunk/src/main/webapp/jsp/inc/bookmark.jsp 2011-01-13 10:58:47 UTC (rev 169)
+++ trunk/src/main/webapp/jsp/inc/bookmark.jsp 2011-01-13 15:11:42 UTC (rev 170)
@@ -33,10 +33,9 @@
Bookmark bookmark = (Bookmark) request.getAttribute("bookmark");
BookmarkActions bookmarkActions = (BookmarkActions) request.getAttribute("bookmarkActions");
SimpleDateFormat sdf = (SimpleDateFormat) request.getAttribute("sdf");
-String url = (String) request.getAttribute("bowUrl");
String aliasUrl = BowConfig.getInstance().getServletAliasUrl();
-url = "toto"; //TODO: à changer
-if (url != null && bookmark != null && sdf != null && bookmarkActions != null) {
+
+if (bookmark != null && sdf != null && bookmarkActions != null) {
String formBookmarkId = (String) request.getAttribute("formBookmarkId");
String link = bookmark.getLink();
link = link.replace("'", "\\'");
Modified: trunk/src/main/webapp/jsp/inc/rightMenu.jsp
===================================================================
--- trunk/src/main/webapp/jsp/inc/rightMenu.jsp 2011-01-13 10:58:47 UTC (rev 169)
+++ trunk/src/main/webapp/jsp/inc/rightMenu.jsp 2011-01-13 15:11:42 UTC (rev 170)
@@ -33,6 +33,7 @@
<%@page import="org.chorem.bow.TokenActions" %>
<%@page import="org.nuiton.wikitty.FacetTopic" %>
<%@page import="org.chorem.bow.Bookmark" %>
+<%@page import="org.chorem.bow.BowConfig" %>
<%@page import="org.chorem.bow.Preference" %>
<%
TokenActions tokenActions = (TokenActions)session.getAttribute("tokenActions");
@@ -44,7 +45,7 @@
String temporaryToken = tokenActions.getTemporaryToken();
String permanentToken = tokenActions.getPermanentToken();
-String url = (String) request.getAttribute("bowUrl");
+
int nbTags = 100;
Preference preference = (Preference)session.getAttribute("preference");
if (preference != null) {
@@ -94,15 +95,15 @@
<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><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>
+ <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='%{#session.bowUrl}addUrl.action?token=%{#session.tokenActions.getTemporaryToken()}&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='%{#session.bowUrl}addUrl.action?token=%{#session.tokenActions.getPermanentToken()}&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><a href="extensions/bow4chromium.crx"><img src="img/chromium.png" alt="Chromium" class="extensionIcon" /><s:text name="bow.rightMenu.chromiumExtension" /></a></li>
+ <li><strong><s:text name="bow.rightMenu.token.permanent" /> :</strong><br /><s:property value="%{#session.tokenActions.getPermanentToken()}" /></li>
+ <li><strong><s:text name="bow.rightMenu.token.temporary" /> :</strong><br /><s:property value="%{#session.tokenActions.getTemporaryToken()}" /></li>
</ul>
</div>
<div id="add" class="clearfix">
@@ -127,7 +128,7 @@
<div class="recherche">
<h2><s:text name="bow.rightMenu.search" /></h2>
<s:form action="search">
- <s:textfield key="bow.rightMenu.find.searchLine" name="searchLine" />
+ <s:textfield name="searchLine" />
<s:submit key="bow.rightMenu.find.submit" />
</s:form>
</div>
@@ -135,17 +136,17 @@
<h2><s:text name="bow.rightMenu.fullTextSearch" /></h2>
<s:form action="fullText">
<% if (fullText != null) { %>
- <s:textfield key="bow.rightMenu.search.fullTextLine" name="fullTextLine" value="" /> <!-- <%=fullText%> -->
+ <s:textfield name="fullTextLine" value="" /> <!-- <%=fullText%> -->
<% } else { %>
- <s:textfield key="bow.rightMenu.search.fullTextLine" name="fullTextLine" />
+ <s:textfield name="fullTextLine" />
<% } %>
- <s:submit key="bow.rightMenu.find" />
+ <s:submit key="bow.rightMenu.find.submit" />
</s:form>
</div>
<div id="import">
<h2><s:text name="bow.rightMenu.importBookmarks" /></h2>
<s:form action="importBookmarks" enctype="multipart/form-data">
- <s:file name="upfile" size="15%" key="bow.rightMenu.import.file" /><br />
+ <s:file name="upfile" size="15%" /><br />
<s:submit key="bow.rightMenu.import.submit" />
</s:form>
<s:a action="exportBookmarks"><s:text name="bow.rightMenu.exportBookmarks" /></s:a>
1
0
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