This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository bow. See http://git.chorem.org/bow.git commit 2ed827771826047996d6003f1a7fdcda3a2c86ec Author: Benjamin POUSSIN <poussin@codelutin.com> Date: Fri Jul 17 18:30:14 2015 +0200 fixes #1262: add support to track bookmark add throw atom feed --- .../java/org/chorem/bow/action/AtomAction.java | 117 +++++++++++++++++++ bow-ui/src/main/resources/struts.xml | 8 +- bow-ui/src/main/webapp/WEB-INF/jsp/atom.jsp | 129 +++++++++++++++++++++ 3 files changed, 253 insertions(+), 1 deletion(-) diff --git a/bow-ui/src/main/java/org/chorem/bow/action/AtomAction.java b/bow-ui/src/main/java/org/chorem/bow/action/AtomAction.java new file mode 100644 index 0000000..c262307 --- /dev/null +++ b/bow-ui/src/main/java/org/chorem/bow/action/AtomAction.java @@ -0,0 +1,117 @@ +/* + * #%L + * BOW UI + * %% + * Copyright (C) 2010 - 2015 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.action; + +import java.util.List; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.bow.BookmarkUtils; +import org.chorem.bow.BowBookmark; +import org.chorem.bow.BowProxy; +import org.chorem.bow.BowSearchResult; +import org.chorem.bow.BowSession; +import org.chorem.bow.BowUser; +import org.nuiton.wikitty.query.WikittyQuery; +import org.nuiton.wikitty.query.WikittyQueryMaker; +import org.nuiton.wikitty.query.WikittyQueryResult; + +/** + * Handles RSS flux demande + * - tagLine + * - fullTextLine + * - count: number of bookmark to retrieve + * + * @author poussin + * @version $Revision$ + * <p/> + * Last update: $Date$ + * by : $Author$ + */ +public class AtomAction extends BowBaseAction { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + private static final Log log = LogFactory.getLog(AtomAction.class); + + private static final long serialVersionUID = 1L; + + protected int count = 15; + + protected List<BowBookmark> bookmarks; + + protected String date; + + protected String redirectTo = "/"; + + public String getRedirectTo() { + return redirectTo; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public List<BowBookmark> getBookmarks() { + return bookmarks; + } + + public String getDate() { + return date; + } + + @Override + public String execute() throws Exception { + if (log.isDebugEnabled()) { + log.debug(String.format("Rss for tags='%' fulltext='%s' count='%s'" + tagLine, fullTextLine, count)); + } + String result = SUCCESS; + try { + + BowSession session = getBowSession(); + + BowUser user = session.getUser(); + BowProxy proxy = session.getProxy(); + + WikittyQuery criteria = BookmarkUtils.getBookmarkListCriteriaByUser( + user, tagLine, fullTextLine, "descDate", 0); + criteria.setLimit(count); + WikittyQueryResult<String> bookmarksId = proxy.findAllByQuery(criteria); + bookmarks = proxy.restore(BowBookmark.class, bookmarksId.getAll(), "WikittyAuthorisation.owner"); + date = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(System.currentTimeMillis()); + + if (log.isDebugEnabled()) { + log.debug(String.format("Rss found='%s'" + bookmarks.size())); + } + + } catch (Exception eee) { + addActionError(t("bow.error.internal")); + log.error(eee.getMessage(), eee); + result = ERROR; + } + return result; + } + +} diff --git a/bow-ui/src/main/resources/struts.xml b/bow-ui/src/main/resources/struts.xml index 862542c..39718af 100644 --- a/bow-ui/src/main/resources/struts.xml +++ b/bow-ui/src/main/resources/struts.xml @@ -109,7 +109,13 @@ </action> </package> - <package name="login" extends="loginArea"> + <package name="atom" extends="publicArea"> + <action name="atom" class="org.chorem.bow.action.AtomAction"> + <result>/WEB-INF/jsp/atom.jsp</result> + </action> + </package> + + <package name="login" extends="loginArea"> <action name="register_*" method="{1}" class="org.chorem.bow.action.login.RegisterAction"> <result name="input">/WEB-INF/jsp/register.jsp</result> <result type="redirectAction">home</result> diff --git a/bow-ui/src/main/webapp/WEB-INF/jsp/atom.jsp b/bow-ui/src/main/webapp/WEB-INF/jsp/atom.jsp new file mode 100644 index 0000000..ccc8f97 --- /dev/null +++ b/bow-ui/src/main/webapp/WEB-INF/jsp/atom.jsp @@ -0,0 +1,129 @@ +<?xml version="1.0" encoding="utf-8"?> +<%-- + #%L + BOW UI + %% + Copyright (C) 2010 - 2015 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% + --%> +<%@page contentType="application/atom+xml; charset=UTF-8" pageEncoding="UTF-8"%> +<%@taglib prefix="s" uri="/struts-tags" %> +<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> +<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> +<%@taglib uri="/WEB-INF/bowutils" prefix="u" %> +<feed xmlns="http://www.w3.org/2005/Atom"> + <s:set name="bowDomain" value="config.bowUrl"/> + + <title>Bow</title> + <subtitle>tag='${tagLine}' search='${fullTextLine}'</subtitle> + + <s:url var="bowUrl" action="home" escapeAmp="false"> + <s:param name="token" value="%{bowSession.permanentToken}" /> + <s:param name="tagLine" value="%{tagLine}" /> + <s:param name="fullTextLine" value="%{fullTextLine}" /> + </s:url> + <s:url var="atomUrl" action="atom" escapeAmp="false"> + <s:param name="token" value="%{bowSession.permanentToken}" /> + <s:param name="tagLine" value="%{tagLine}" /> + <s:param name="fullTextLine" value="%{fullTextLine}" /> + <s:param name="count" value="%{count}" /> + </s:url> + <link rel="alternate" type="text/html" href="${bowDomain}${bowUrl}"/> + <link rel="self" type="application/atom+xml" href="${bowDomain}${atomUrl}"/> + + <updated>${date}</updated> + <author> + <name>${bowSession.user.login}</name> + </author> + <id>${bowDomain}${bowUrl}</id> + <s:url var="favicon" value="/img/favicon.png" /> + <icon>${bowDomain}${favicon}</icon> + + <s:iterator value="bookmarks" var="bookmark"> + <s:set name="bookmark" value="bookmark"/> + <entry> + <title><s:property value="%{#bookmark.link}" /></title> + <s:url var="bookmarkUrl" action="home" escapeAmp="false"> + <s:param name="token" value="%{bowSession.permanentToken}" /> + <s:param name="fullTextLine" value="%{#bookmark.link}" /> + </s:url> + <link rel="alternate" type="text/html" href="${bowDomain}${bookmarkUrl}"/> + <link href="${bookmark.link}"/> + <id>${bowDomain}${bookmark.wikittyId}</id> + <updated><fmt:formatDate value="${bookmark.creationDate}" pattern="yyyy-MM-dd'T'HH:mm:ssZ" /></updated> + <author> + <name><s:property value="%{#bookmark.getOwner(false).login}" /></name> + </author> + <content type="xhtml"> + <div xmlns="http://www.w3.org/1999/xhtml"> + <span class="left"> + <s:set var="favicon" value="#bookmark.favicon"/> + <c:if test="${fn:length(favicon) > 0}"> + <img class="favicon" src="data:image/png;base64,${u:base64(favicon)}"/> + </c:if> + + <span class="left date"><fmt:formatDate value="${bookmark.creationDate}" pattern="yyyy-MM-dd" /></updated></span> + + <c:if test="${not empty bookmark.privateAlias}"> + <span class="left"> + <s:a cssClass="alias" href="%{config.aliasUrl + #bookmark.wikittyId}.action" + title="%{#bookmark.link}" target="_blank"> + alias: ${bookmark.privateAlias} + </s:a> + </span> + </c:if> + <c:if test="${not empty bookmark.publicAlias}"> + <span class="left"> + <s:a cssClass="alias" href="%{config.aliasUrl + #bookmark.publicAlias}.action" + title="%{#bookmark.link}" target="_blank"> + alias public: ${bookmark.publicAlias} + </s:a> + </span> + </c:if> + </span> + + <div class="description"> + <p> + <s:a href="%{config.aliasUrl + #bookmark.wikittyId}.action">${bookmark.link}</s:a> + </p> + <h3><s:text name="bow.bookmark.description" /> :</h3> + <p> + ${bookmark.description} + </p> + <p class="tags"> + <strong><s:text name="bow.bookmark.tags" /> :</strong> + <s:iterator value="#bookmark.labels" var="tag"> + <s:url var="search" action="home" escapeAmp="false"> + <s:param name="addTag" value="%{#tag}"/> + <s:param name="tagLine" value="%{tagLine}"/> + <s:param name="fullTextLine" value="%{fullTextLine}"/> + <s:param name="order" value="%{order}"/> + <%-- on ne met pas 'first', il faut repartir de 0 --%> + </s:url> + <a href="${bowDomain}${search}" cssClass="tag"><s:property value="%{#tag}"/></a> + </s:iterator> + </p> + </div> + </div> + </content> + <s:iterator value="#bookmark.labels" var="tag"> + <category term="${tag}" /> + </s:iterator> + </entry> + </s:iterator> + +</feed> \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.