Author: tchemit Date: 2010-12-30 12:25:14 +0100 (Thu, 30 Dec 2010) New Revision: 2001 Url: http://nuiton.org/repositories/revision/nuiton-utils/2001 Log: Evolution #1189: Introduce nuiton-rss module Added: trunk/nuiton-rss/ trunk/nuiton-rss/LICENSE.txt trunk/nuiton-rss/README.txt trunk/nuiton-rss/changelog.txt trunk/nuiton-rss/pom.xml trunk/nuiton-rss/src/ trunk/nuiton-rss/src/license/ trunk/nuiton-rss/src/license/THIRD-PARTY.properties trunk/nuiton-rss/src/main/ trunk/nuiton-rss/src/main/java/ trunk/nuiton-rss/src/main/java/org/ trunk/nuiton-rss/src/main/java/org/nuiton/ trunk/nuiton-rss/src/main/java/org/nuiton/rss/ trunk/nuiton-rss/src/main/java/org/nuiton/rss/BaseServlet.java trunk/nuiton-rss/src/main/java/org/nuiton/rss/ConfigInitializer.java trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedData.java trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedEntryComparator.java trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedHTMLRenderer.java trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedRenderer.java trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedRendererConfig.java trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedType.java trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedURLResolver.java trunk/nuiton-rss/src/main/java/org/nuiton/rss/Field.java trunk/nuiton-rss/src/main/java/org/nuiton/rss/HTMLCleaner.java trunk/nuiton-rss/src/main/java/org/nuiton/rss/HTMLScriptCleaner.java trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSConfig.java trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGenerator.java trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGeneratorConfig.java trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGeneratorServlet.java trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSHelper.java trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSIOUtil.java trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSServlet.java trunk/nuiton-rss/src/main/java/org/nuiton/rss/SimpleFeedURLResolver.java trunk/nuiton-rss/src/main/resources/ trunk/nuiton-rss/src/main/resources/fckeditor/ trunk/nuiton-rss/src/main/resources/fckeditor/editor/ trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/ trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/ trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/README.txt trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/button.rss.gif trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.html trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.js trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fckplugin.js trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/ trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/en.js trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/fr.js trunk/nuiton-rss/src/main/resources/fckeditor/myfckconfig.js trunk/nuiton-rss/src/main/resources/log4j.properties trunk/nuiton-rss/src/main/webapp/ trunk/nuiton-rss/src/main/webapp/WEB-INF/ trunk/nuiton-rss/src/main/webapp/WEB-INF/web.xml trunk/nuiton-rss/src/main/webapp/feed.css trunk/nuiton-rss/src/main/webapp/feeds.txt trunk/nuiton-rss/src/main/webapp/index.html trunk/nuiton-rss/src/main/webapp/rssgenerator.js trunk/nuiton-rss/src/main/webapp/rssinclude.js trunk/nuiton-rss/src/main/webapp/testFck.html trunk/nuiton-rss/src/main/webapp/testGenerator.html trunk/nuiton-rss/src/main/webapp/testRender.html trunk/nuiton-rss/src/site/ trunk/nuiton-rss/src/site/apt/ trunk/nuiton-rss/src/site/apt/index.apt trunk/nuiton-rss/src/site/site_fr.xml trunk/nuiton-rss/src/test/ trunk/nuiton-rss/src/test/java/ trunk/nuiton-rss/src/test/java/org/ trunk/nuiton-rss/src/test/java/org/nuiton/ trunk/nuiton-rss/src/test/java/org/nuiton/rss/ trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSGeneratorHelperTest.java trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSTest.java trunk/nuiton-rss/src/test/java/resources/ trunk/nuiton-rss/src/test/java/resources/log4j.properties Modified: trunk/pom.xml Property changes on: trunk/nuiton-rss ___________________________________________________________________ Added: svn:ignore + target velocity.log maven.log .eclipse .classpath *.iml *.ipr *.iws .settings .project Added: trunk/nuiton-rss/LICENSE.txt =================================================================== --- trunk/nuiton-rss/LICENSE.txt (rev 0) +++ trunk/nuiton-rss/LICENSE.txt 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,166 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. + Property changes on: trunk/nuiton-rss/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/nuiton-rss/README.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/nuiton-rss/changelog.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/pom.xml =================================================================== --- trunk/nuiton-rss/pom.xml (rev 0) +++ trunk/nuiton-rss/pom.xml 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,237 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Nuiton Utils :: Nuiton RSS + $Id$ + $HeadURL$ + %% + Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <!-- ************************************************************* --> + <!-- *** POM Relationships *************************************** --> + <!-- ************************************************************* --> + + <parent> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-utils-parent</artifactId> + <version>2.0-SNAPSHOT</version> + </parent> + + <artifactId>nuiton-rss</artifactId> + + <dependencies> + + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>commons-beanutils</groupId> + <artifactId>commons-beanutils</artifactId> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.jdom</groupId> + <artifactId>jdom</artifactId> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>rome</groupId> + <artifactId>rome</artifactId> + <scope>compile</scope> + <exclusions> + <exclusion> + <groupId>jdom</groupId> + <artifactId>jdom</artifactId> + </exclusion> + </exclusions> + </dependency> + + <!-- Test--> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + + <!--Provided--> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <scope>provided</scope> + </dependency> + + </dependencies> + + + <!-- ************************************************************* --> + <!-- *** Project Information ************************************* --> + <!-- ************************************************************* --> + + <name>Nuiton Utils :: Nuiton RSS</name> + <description>Servlet pouvant etre appeler depuis du JS pour recuperer un + flux RSS + </description> + <inceptionYear>2008</inceptionYear> + + <!-- ************************************************************* --> + <!-- *** Build Settings ****************************************** --> + <!-- ************************************************************* --> + + <packaging>war</packaging> + + <properties> + + <!-- extra files to include in release --> + <redmine.releaseFiles>${redmine.libReleaseFiles}</redmine.releaseFiles> + + </properties> + + <build> + + <plugins> + + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <configuration> + <outputDirectory>${project.build.directory}/lib</outputDirectory> + </configuration> + </plugin> + + </plugins> + + <pluginManagement> + <plugins> + + <plugin> + <artifactId>maven-war-plugin</artifactId> + <configuration> + <webappDirectory>target/nuitonrss</webappDirectory> + </configuration> + </plugin> + + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifest> + <addClasspath>true</addClasspath> + <classpathPrefix>lib/</classpathPrefix> + </manifest> + </archive> + </configuration> + </plugin> + + </plugins> + + </pluginManagement> + </build> + + <!-- ************************************************************* --> + <!-- *** Build Environment ************************************** --> + <!-- ************************************************************* --> + + <profiles> + <profile> + <id>reporting</id> + <activation> + <property> + <name>performRelease</name> + <value>true</value> + </property> + </activation> + + <reporting> + <plugins> + <plugin> + <artifactId>maven-javadoc-plugin</artifactId> + <configuration> + <quiet>true</quiet> + <links> + <link>http://java.sun.com/javase/6/docs/api/</link> + </links> + </configuration> + </plugin> + </plugins> + </reporting> + + </profile> + + <!-- create assemblies at release time --> + <profile> + <id>assembly-profile</id> + <activation> + <property> + <name>performRelease</name> + <value>true</value> + </property> + </activation> + <build> + <plugins> + + <!-- launch in a release the assembly automaticly --> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <executions> + <execution> + <id>create-assemblies</id> + <phase>verify</phase> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + <configuration> + <attach>false</attach> + <descriptorRefs> + <descriptorRef>deps</descriptorRef> + <descriptorRef>full</descriptorRef> + </descriptorRefs> + </configuration> + </plugin> + + </plugins> + + </build> + </profile> + + </profiles> + +</project> Property changes on: trunk/nuiton-rss/pom.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/license/THIRD-PARTY.properties =================================================================== --- trunk/nuiton-rss/src/license/THIRD-PARTY.properties (rev 0) +++ trunk/nuiton-rss/src/license/THIRD-PARTY.properties 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,13 @@ +# Generated by org.nuiton.license.plugin.AddThirdPartyMojo +#------------------------------------------------------------------------------- +# Already used licenses in project : +# - BSD License +# - Common Public License Version 1.0 +# - The Apache Software License, Version 2.0 +#------------------------------------------------------------------------------- +# Please fill the missing licenses for dependencies : +# +# +#Thu Dec 30 12:16:27 CET 2010 +javax.servlet--servlet-api--2.5--jar=Sun Microsystems, Inc. Binary Code License Agreement for the JDK 5.0 +org.jdom--jdom--1.1--jar=Apache Software License Like Property changes on: trunk/nuiton-rss/src/license/THIRD-PARTY.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/BaseServlet.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/BaseServlet.java (rev 0) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/BaseServlet.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,136 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +import java.io.*; + +import javax.servlet.*; +import javax.servlet.http.*; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * <p> + * Servlet de base + * @param <D> la classe de l'object de delegation + * + * @author chemit + */ +public abstract class BaseServlet<D> extends HttpServlet { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + protected static final Log log = LogFactory.getLog(BaseServlet.class); + /** L'objet de delegation du metier de la servlet */ + protected transient D delegate; + private static final long serialVersionUID = 1L; + + /** + * + * @return the new delegate object to be used by servlet + * @throws Exception if any problem while instanciation + */ + protected abstract D newDelegate() throws Exception; + + /** + * + * @return a new ConfigInitializer to be used in + * {@link #init(ServletConfig, boolean)} method to prepare + * default config. + */ + protected abstract ConfigInitializer<ServletConfig,? > newConfigInitializer(); + + /** + * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. + * @param request servlet request + * @param response servlet response + * @throws IOException TODO + * @throws ServletException TODO + */ + protected abstract void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException; + + @Override + public void init(ServletConfig config) throws ServletException { + init(config, true); + } + + protected void init(ServletConfig config, boolean initConfig) throws ServletException { + try { + super.init(config); + if (initConfig) { + // init de la configuration par defaut depuis la config de servlet + newConfigInitializer().init(config); + } + // instanciate delegate + delegate = newDelegate(); + } catch (Exception eee) { + log.warn("Can't configure Servlet", eee); + if (eee instanceof ServletException) { + throw (ServletException) eee; + } + throw new ServletException("Can't configure Servlet", eee); + } + } + + protected Integer convertToInt(String parameter) { + Integer result = null; + try { + result = Integer.parseInt(parameter); + } catch (Exception eee) { + log.debug("Can't convert to int: '" + parameter + "'", eee); + } + return result; + } + // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code."> + /** + * Handles the HTTP <code>GET</code> method. + * @param request servlet request + * @param response servlet response + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP <code>POST</code> method. + * @param request servlet request + * @param response servlet response + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + */ + @Override + public String getServletInfo() { + return "RSS Servlet"; + } + // </editor-fold> +} Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/BaseServlet.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/ConfigInitializer.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/ConfigInitializer.java (rev 0) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/ConfigInitializer.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,82 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +import org.apache.commons.beanutils.BeanUtils; + +/** + * + * @author tony + * + * @param <S> la classe source de la configuration + * @param <D> la classe destination de la configuration + */ +public abstract class ConfigInitializer<S,D> { + + + /** + * + * @param config l'object source contenant les configs + * @param fullConfigName le nom complet de la propriete recherchee + * @return la valeur de la propriete ou null si non trouve + */ + protected abstract String getConfigValue(S config, String fullConfigName); + + public abstract void init(S config) ; + + /** + * Initialise RSSConfig. + * @param prefix + * @param klass la class de la configuration de destination + * @param config la configuration source + * @param keys + */ + public void init(String prefix,Class<D> klass, S config, String... keys) { + try { + String prefixConfig = getConfigValue(config, prefix); + prefixConfig = prefixConfig == null ? "" : prefixConfig.trim(); + + D instance = klass.newInstance(); + for (String key : keys) { + loadConfig(config, instance, prefixConfig, key); + } + } catch (InstantiationException ex) { + throw new RuntimeException(ex); + } catch (IllegalAccessException ex) { + throw new RuntimeException(ex); + } + } + + protected void loadConfig(S config, D instance, String prefix, String configName) { + String value = getConfigValue(config, prefix + configName); + if (value != null && !"".equals(value)) { + try { + BeanUtils.setProperty(instance, configName, value); + } catch (Exception ex) { + throw new IllegalStateException("could not load property " + configName + " from config " + config + " for reason : " + ex.getMessage()); + } + } + } +} Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/ConfigInitializer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedData.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedData.java (rev 0) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedData.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,119 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +import com.sun.syndication.feed.synd.SyndFeed; +import java.net.URL; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * <p> + * Represente une URL demandee. Cette objet est conserve durant le temps de vie + * de la JVM pour permettre de mutualiser la recuperation et la transformation en + * HTML. + * </p> + * <p> + * Lorsque l'on demande le HTML et que l'url n'a pas encore ete recuperee ou + * est trop ancienne alors on lance la recuperation. Si deux threads demandent + * la recuperation, le deuxieme est mis en attente et profitera de la recuperation + * de l'autre. + * </p> + * + * @author poussin + */ +public class FeedData { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + private static final Log log = LogFactory.getLog(FeedData.class); + + /** url du feed */ + protected URL url; + /** les champs que l'on souhaite visualiser pour le feed */ + protected FeedRendererConfig rendererConfig; + /** Le nombre d'item que l'on souhaite visualiser pour le feed */ + protected int nbItem = -1; + + protected SyndFeed feed; + protected long lastRetrived; + + public FeedData(URL url, int nbItem, String representation) { + this(url); + this.nbItem = nbItem; + rendererConfig = new FeedRendererConfig(representation); + } + + public FeedData(URL url) { + this.url = url; + } + + public long getLastRetrived() { + return lastRetrived; + } + + public URL getUrl() { + return url; + } + + public FeedRendererConfig getRendererConfig() { + return rendererConfig; + } + + public void setRendererConfig(FeedRendererConfig rendererConfig) { + this.rendererConfig = rendererConfig; + } + + public int getNbItem() { + return nbItem; + } + + public void setNbItem(int nbItem) { + this.nbItem = nbItem; + } + + /** + * Retourne la representation HTML du RSS + * + * @return la representation HTML du RSS + */ + public SyndFeed getFeed() { + if (feed == null || lastRetrived + RSSConfig.TIME_FORCE_RETRIEVED < System.currentTimeMillis()) { + forceRetrived(); + } + + return feed; + } + + synchronized protected void forceRetrived() { + if (lastRetrived + RSSConfig.TIME_FORCE_RETRIEVED < System.currentTimeMillis()) { + try { + feed = RSSIOUtil.readFeed(url); + lastRetrived = System.currentTimeMillis(); + } catch (Exception eee) { + log.warn("Can't get feed: " + url, eee); + } + } + } +} Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedData.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedEntryComparator.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedEntryComparator.java (rev 0) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedEntryComparator.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,40 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +import com.sun.syndication.feed.synd.SyndEntry; +import java.util.Comparator; + +/** + * Comparator of entry base on his publication date + * @author tony + */ +public class FeedEntryComparator implements Comparator<SyndEntry> { + + public int compare(SyndEntry o1, SyndEntry o2) { + return o1.getPublishedDate().compareTo(o2.getPublishedDate()); + } + +} Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedEntryComparator.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedHTMLRenderer.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedHTMLRenderer.java (rev 0) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedHTMLRenderer.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,237 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +import com.sun.syndication.feed.synd.SyndEntry; +import com.sun.syndication.feed.synd.SyndFeed; + +import java.util.Arrays; +import java.util.EnumMap; +import java.util.HashSet; +import java.util.Set; +import org.apache.commons.beanutils.BeanUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * + * @author poussin + */ +public class FeedHTMLRenderer implements FeedRenderer { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + private static final Log log = LogFactory.getLog(FeedHTMLRenderer.class); + + private static final String FEED_CSS_PREFIX ="feed-"; + private static final String FEED_ITEM_CSS_PREFIX ="feedItem-"; + + /** tous les HTMLCleaner a utiliser pour nettoyer les chaines */ + protected Set<HTMLCleaner> cleaners = new HashSet<HTMLCleaner>(); + + protected EnumMap<Field, String> templates = new EnumMap<Field, String>(Field.class); + protected EnumMap<Field, String> classnames = new EnumMap<Field, String>(Field.class); + protected EnumMap<Field, String> feedProperties = new EnumMap<Field, String>(Field.class); + protected EnumMap<Field, String> itemProperties = new EnumMap<Field, String>(Field.class); + + /** + * + * @param cleaners La liste des cleaners a utiliser par defaut. Si aucun + * cleaner n'est passer en argument HTMLScriptCleaner est automatiquement + * ajoute + */ + public FeedHTMLRenderer(HTMLCleaner ... cleaners) { + if (cleaners.length == 0) { + addHTMLCleaner(new HTMLScriptCleaner()); + } + for (HTMLCleaner cleaner : cleaners) { + addHTMLCleaner(cleaner); + } + + templates.put(Field.NAME, "<span class=\"%1$s\">%2$s</span>\n"); + templates.put(Field.LINK, "<a class=\"%1$s\" href=\"%2$s\">%3$s</a>"); + templates.put(Field.IMAGE, "<span class=\"%1$s\"><img src=\"%2$s\"/></span>\n"); + templates.put(Field.DESCRIPTION, "<span class=\"%1$s\">%2$s</span>\n"); + templates.put(Field.AUTHOR, "<span class=\"%1$s\">%2$s</span>\n"); + //Probleme de conversion FIXME + templates.put(Field.TIME, "<span class=\"%1$s\">%2$s</span>\n"); + //templates.put(Field.TIME, "<span class=\"%1$s\">%2$tF</span>\n"); + + classnames.put(Field.NAME, "name"); + classnames.put(Field.LINK, "link"); + classnames.put(Field.IMAGE, "image"); + classnames.put(Field.DESCRIPTION, "description"); + classnames.put(Field.AUTHOR, "author"); + classnames.put(Field.TIME, "time"); + + feedProperties.put(Field.NAME, "title"); + feedProperties.put(Field.LINK, "link"); + // cela engendre des NPE... + feedProperties.put(Field.IMAGE, "image.url"); + feedProperties.put(Field.DESCRIPTION, "description"); + feedProperties.put(Field.AUTHOR, "author"); + feedProperties.put(Field.TIME, "publishedDate"); + + itemProperties.put(Field.NAME, "title"); + itemProperties.put(Field.LINK, "link"); + itemProperties.put(Field.IMAGE, null); + itemProperties.put(Field.DESCRIPTION, "description.value"); + itemProperties.put(Field.AUTHOR, "author"); + itemProperties.put(Field.TIME, "publishedDate"); + } + + + public FeedHTMLRenderer() { + this(new HTMLCleaner[0]); + } + + /** + * Supprime tous les cleaners de code html + */ + public void clearCleaners() { + cleaners.clear(); + } + + /** + * Ajoute un nouveau cleaner de code HTML + * @param cleaner cleaner to add + */ + public void addHTMLCleaner(HTMLCleaner cleaner) { + cleaners.add(cleaner); + } + + public String render(FeedRendererConfig config, SyndFeed feed, SyndEntry[] items) { + + StringBuffer sbGlobal= new StringBuffer(); + + StringBuffer sbTemp= new StringBuffer(); + for (Field f : config.getFeedFieldOrder()) { + renderField(f, FEED_CSS_PREFIX,feedProperties, feed,sbTemp); + } + + String tmp = sbTemp.toString(); + if (!"".equals(tmp)) { + sbGlobal.append("<div class='rss-feed'>\n").append(tmp).append("</div>\n"); + } + sbGlobal.append("<ul class='rss-items'>\n"); + sbTemp = new StringBuffer(); + for (SyndEntry item : items) { + sbTemp.append( "<li>\n"); + for (Field f : config.getItemFieldOrder()) { + renderField(f, FEED_ITEM_CSS_PREFIX,itemProperties,item,sbTemp); + } + sbTemp.append("</li>\n"); + } + sbGlobal.append(sbTemp.toString()).append("</ul>\n"); + + return sbGlobal.toString(); + } + + protected void renderField(Field f, String cssPrefix, EnumMap<Field, String> properties,Object src,StringBuffer buffer) { + + if (f== Field.LINK) { + // do nothing, link should not be called alone but inside name field only + return; + } + String template = templates.get(f); + String classname = cssPrefix + classnames.get(f); + String prop = properties.get(f); + + if ("".equals(prop)) { + return; + } + + String result; + Object value = null; + try { + + value = BeanUtils.getProperty(src, prop); + if (f == Field.NAME) { + //special case, we must first render link + String templateLink = templates.get(Field.LINK); + String classnameLink = "feed-" + classnames.get(Field.LINK); + String propLink = properties.get(Field.LINK); + Object value2 = BeanUtils.getProperty(src, propLink); + value = render(templateLink, classnameLink, value2, value); + } + + result = render(template, classname, value); + + if (result != null && buffer != null) { + buffer.append(result); + } + } catch (Exception eee) { + log.warn("Can't get feed property value for property " + prop + ", value:" + value); + } + + } + + /** + * Permet de rendre un element du feed + * + * @param template le template pour rendre l'element + * @param classname la class de l'element html (pour une utilisation CSS) + * @param value la valeur de l'element + * @return le code HTML + */ + protected String render(String template, String classname, Object value) { + StringBuffer sb = new StringBuffer(); + if (value != null && !"".equals(value)) { + if (value instanceof String) { + // si value est une chaine, on la nettoie avec les cleaners enregistrer + for (HTMLCleaner cleaner : cleaners) { + value = cleaner.clean((String)value); + } + } + sb.append(renderTemplate(template, classname, value)); + } + return sb.toString(); + } + + protected String render(String template, String classname, Object value,Object value2) { + StringBuffer sb = new StringBuffer(); + if (value != null && !"".equals(value)) { + if (value instanceof String) { + // si value est une chaine, on la nettoie avec les cleaners enregistrer + for (HTMLCleaner cleaner : cleaners) { + value = cleaner.clean((String)value); + } + } + sb.append(renderTemplate(template, classname, value,value2)); + } + return sb.toString(); + } + + protected String renderTemplate(String template,Object... args) { + try { + String result; + result = String.format(template, args); + return result; + } catch (Exception e) { + log.warn("could not format template "+template+" with args : "+ Arrays.toString(args)); + return ""; + } + } + +} Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedHTMLRenderer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedRenderer.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedRenderer.java (rev 0) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedRenderer.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,45 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +import com.sun.syndication.feed.synd.SyndEntry; +import com.sun.syndication.feed.synd.SyndFeed; + +/** + * + * @author poussin + */ +public interface FeedRenderer { + + /** + * Retourne une chaine qui est la representation du feed et de ces items + * + * @param config la configuration a utiliser pour rendre le feed + * @param feed le feed a representer + * @param items la liste des items du feed a prendre en compte + * @return la representation souhaitee + */ + String render(FeedRendererConfig config, SyndFeed feed, SyndEntry[] items); +} Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedRenderer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedRendererConfig.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedRendererConfig.java (rev 0) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedRendererConfig.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,120 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +import java.util.ArrayList; +import java.util.List; + +/** + * <p> + * Permet de spcecifier les champs a rendre, cet objet peut etre converti + * en une representation chaine pour etre facilement transportable. + * </p> + * <p> + * Exemple de representation texte: ndat-ndat. Le premier block represente le + * feed le second les items. S'il n'y a qu'un block cela veut dire qu'il ne + * faut pas reprensenter le feed mais seulement les items. L'ordre des lettres + * determine l'ordre du rendu. + * <li>n: name pour demander le nom ou titre du feed ou de l'item + * <li>i: image + * <li>d: description + * <li>a: author + * <li>t: time pour demander la date du feed ou de l'item + * </p> + * + * @author poussin + */ +public class FeedRendererConfig { + + protected String feedString = "indat"; + protected List<Field> feedList; + protected String itemString = "indat"; + protected List<Field> itemList; + + public FeedRendererConfig() { + } + + public FeedRendererConfig(String representation) { + setString(representation); + } + + protected List<Field> createList(String value) { + List<Field> result = new ArrayList<Field>(); + for (char c : value.toCharArray()) { + Field field = Field.valueOf(c); + if (field!=null) { + result.add(field); + } + } + return result; + } + + public List<Field> getFeedFieldOrder() { + if (feedList == null) { + feedList = createList(feedString); + } + return feedList; + } + + public List<Field> getItemFieldOrder() { + if (itemList == null) { + itemList = createList(itemString); + } + return itemList; + } + + /** + * Permet de modifier la representation souhaitee + * + * @param f la nouvelle representation par ex: n-na + */ + public void setString(String f) { + String [] fi = f.split("-"); + if (fi.length > 1) { + feedString = fi[0]; + itemString = fi[1]; + } else { + feedString = ""; + itemString = fi[0]; + } + feedList = null; + itemList = null; + } + + /** + * Permet de retourner la representation string + * + * @return par ex: n-nad + */ + public String getString() { + String result = ""; + if (!"".equals(feedString)) { + result = feedString + "-"; + } + result += itemString; + return result; + } + +} Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedRendererConfig.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedType.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedType.java (rev 0) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedType.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,53 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +/** + * Enumeration of known feed's type. + * + * Used to generate some feed files. + * + * @author tony + */ +public enum FeedType { + + RSS_0_90("rss_0.90"), + RSS_0_91("rss_0.91"), + RSS_0_92("rss_0.92"), + RSS_0_93("rss_0.93"), + RSS_1_0("rss_1.0"), + RSS_2_0("rss_2.0"), + ATOM_0_3("atom_0.3"), + ATOM_1_0("atom_1.0"); + private String type; + + public String getType() { + return type; + } + + private FeedType(String type) { + this.type = type; + } +} Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedType.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedURLResolver.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedURLResolver.java (rev 0) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedURLResolver.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,39 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +import java.net.MalformedURLException; + +/** + * Permet de convertir une chaine en une URL. Le resolver le plus simple + * peut créer une URL avec la chaine, mais un autre resolver peut utiliser + * cette chaine comme cle dans une base de données pour recuperer la bonne URL. + * + * @author poussin + */ +public interface FeedURLResolver { + + FeedData resolv(String ask) throws MalformedURLException; +} Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/FeedURLResolver.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/Field.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/Field.java (rev 0) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/Field.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,64 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +/** + * Enumeration des champs disponibles pour le renderer + * + * @author poussin + */ +public enum Field { + + NAME('n'), IMAGE('i'), DESCRIPTION('d'), AUTHOR('a'), TIME('t'),LINK('l'),CATEGORY('c'); + + /** le caractere utilise pour la version compactee d'une configuration de renderer */ + private char c; + + Field(char c) { + this.c= c; + } + + public char getC() { + return c; + } + + public static Field valueOf(char c) { + for (Field field : values()) { + if (field.c==c){ + return field; + } + } + return null; + } + + public static Field[] getFeedFields() { + return new Field[]{NAME,IMAGE,DESCRIPTION,AUTHOR,TIME,LINK}; + } + + public static Field[] getItemFields() { + return new Field[]{NAME,DESCRIPTION,AUTHOR,TIME,LINK}; + } +} + Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/Field.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/HTMLCleaner.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/HTMLCleaner.java (rev 0) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/HTMLCleaner.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,36 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +/** + * Permet de nettoyer une chaine avant incorporation dans du HTML + * + * @author poussin + */ +public interface HTMLCleaner { + + String clean(String s); + +} Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/HTMLCleaner.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/HTMLScriptCleaner.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/HTMLScriptCleaner.java (rev 0) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/HTMLScriptCleaner.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,39 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +/** + * Supprime les balises <script.*</script> de la chaine + * + * @author poussin + */ +public class HTMLScriptCleaner implements HTMLCleaner { + + public String clean(String s) { + String result = s.replaceAll("(?i)(?s)<script.*?</script>", ""); + return result; + } + +} Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/HTMLScriptCleaner.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSConfig.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSConfig.java (rev 0) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSConfig.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,87 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +/** + * Default configuration for {@link RSSHelper}. + * + * @author poussin + */ +public class RSSConfig { + + /** + * la propriete de configuration qui definit le prefix a jouter pour scruter la configuration + */ + private static final String CONFIGURATION_PREFIX_PROPERTY = RSSServlet.class.getSimpleName() + "_configuration_prefix"; + + + /** Temps a partir duquel on reforce une recuperation */ + public static long TIME_FORCE_RETRIEVED = 5 * 60 * 1000; + public static FeedRendererConfig DEFAULT_RENDERER_CONFIG = new FeedRendererConfig("n-natd"); + public static int DEFAULT_NB_ITEM = 7; + public static Class<? extends FeedRenderer> DEFAULT_RENDERER_CLASS = FeedHTMLRenderer.class; + public static Class<? extends FeedURLResolver> DEFAULT_RESOLVER_CLASS = SimpleFeedURLResolver.class; + + public void setTIME_FORCE_RETRIEVED(long TIME_FORCE_RETRIEVED) { + RSSConfig.TIME_FORCE_RETRIEVED = TIME_FORCE_RETRIEVED; + } + + public void setDEFAULT_RENDERER_CONFIG(String DEFAULT_RENDERER_CONFIG) { + RSSConfig.DEFAULT_RENDERER_CONFIG = new FeedRendererConfig(DEFAULT_RENDERER_CONFIG); + } + + public void setDEFAULT_NBITEM(int DEFAULT_NBITEM) { + RSSConfig.DEFAULT_NB_ITEM = DEFAULT_NBITEM; + } + + public void setDEFAULT_RENDERER_CLASS(Class<? extends FeedRenderer> DEFAULT_RENDERER_CLASS) { + RSSConfig.DEFAULT_RENDERER_CLASS = DEFAULT_RENDERER_CLASS; + } + + public void setDEFAULT_RESOLVER_CLASS(Class<? extends FeedURLResolver> DEFAULT_RESOLVER_CLASS) { + RSSConfig.DEFAULT_RESOLVER_CLASS = DEFAULT_RESOLVER_CLASS; + } + + /** + * + * @param <S> la classe source de la configuration + */ + public static abstract class RSSConfigInitializer<S> extends ConfigInitializer<S,RSSConfig > { + + /** + * Initialise RSSConfig. + * @param config la configuration source + */ + public void init(S config) { + RSSHelper.log.info("with source "+config); + super.init(CONFIGURATION_PREFIX_PROPERTY,RSSConfig.class, config, + "TIME_FORCE_RETRIEVED", + "DEFAULT_RENDERER_CONFIG", + "DEFAULT_NB_ITEM", + "DEFAULT_RENDERER_CLASS", + "DEFAULT_RESOLVER_CLASS"); + } + } +} Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSConfig.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGenerator.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGenerator.java (rev 0) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGenerator.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,331 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +import com.sun.syndication.feed.synd.SyndEntry; +import com.sun.syndication.feed.synd.SyndFeed; +import com.sun.syndication.io.FeedException; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.channels.FileChannel; +import java.nio.channels.FileLock; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.EnumMap; +import java.util.EnumSet; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * generator of rss feeds to be stored in a file + * @author tony + */ +public class RSSGenerator { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static final Log log = LogFactory.getLog(RSSGenerator.class); + /** date formater use to save date in feed and entries */ + public static final DateFormat DATE_PARSER = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); + + /** + * + * @return une nouvelle instance de RssHelper en utilisant les implantations + * definies dans RSSGeneratorConfig. + * @throws Exception pour tout pb lors de l'instanciation des objects + */ + public static RSSGenerator newDefaultInstance() throws Exception { + RSSGenerator helper = new RSSGenerator(); + return helper; + } + + + /** dictonnary of field <-> property for feed */ + protected final EnumMap<Field, String> feedProperties; + /** dictonnary of field <-> property for entry */ + protected final EnumMap<Field, String> itemProperties; + /** directory where feeds are stored */ + protected final File generatorDirectory; + /** feed format to use **/ + protected final FeedType format; + /** number of feed to use by default */ + protected final int nbItems; + + protected RSSGenerator() { + this(null); + } + + protected RSSGenerator(EnumMap<Field, String> feedProperties, EnumMap<Field, String> itemProperties, File generatorDirectory,FeedType format,int nbItems) { + this.feedProperties = feedProperties; + this.itemProperties = itemProperties; + this.generatorDirectory = generatorDirectory; + this.format=format; + this.nbItems=nbItems; + } + + protected RSSGenerator(File generatorDirectory) { + + feedProperties = new EnumMap<Field, String>(Field.class); + feedProperties.put(Field.NAME, "title"); + feedProperties.put(Field.LINK, "link"); + // cela engendre des NPE... + feedProperties.put(Field.IMAGE, "image.url"); + feedProperties.put(Field.DESCRIPTION, "description"); + feedProperties.put(Field.AUTHOR, "author"); + feedProperties.put(Field.TIME, "publishedDate"); + feedProperties.put(Field.CATEGORY, "categories"); + + itemProperties = new EnumMap<Field, String>(Field.class); + itemProperties.put(Field.NAME, "title"); + itemProperties.put(Field.LINK, "link"); + itemProperties.put(Field.IMAGE, null); + itemProperties.put(Field.DESCRIPTION, "description.value"); + itemProperties.put(Field.AUTHOR, "author"); + itemProperties.put(Field.TIME, "publishedDate"); + + this.generatorDirectory = generatorDirectory==null?new File(RSSGeneratorConfig.GENERATOR_DIRECTORY):generatorDirectory; + format =FeedType.valueOf(RSSGeneratorConfig.DEFAULT_GENERATOR_FORMAT); + nbItems = RSSGeneratorConfig.DEFAULT_GENERATOR_NB_ITEM; + } + + /** + * + * @param url location where to create the file + * @param type fromat of feed to create + * @param values properties of the feed + * @throws ParseException if pb while parsing date + * @throws IOException if io pb + * @throws FeedException if pb while creating feed + */ + public void createFeedFile(URL url, FeedType type, Map<Field, Object> values) throws IOException, FeedException, ParseException { + if (url == null) { + throw new NullPointerException("can not create a feed with null url"); + } + if (type == null) { + throw new NullPointerException("can not create a feed with null feedtype"); + } + if (values == null || values.isEmpty()) { + //TODO Should check mandatory values (title, link,...) + throw new NullPointerException("can not create a feed with null nor empty values dictonnary"); + } + File f = getFile(url); + + if (f.exists()) { + throw new IllegalStateException("feed already existing in " + f.getName()); + } + + // make sure parent exists + f.getParentFile().mkdirs(); + + // block until can acquire lock + FileLock lock = acquireLock(f); + + try { + + SyndFeed feed = RSSIOUtil.createFeed(feedProperties, type, values); + + RSSIOUtil.saveFeed(f, feed); + + } catch (FeedException e) { + // file must not be created + f.delete(); + throw e; + } catch (ParseException e) { + // file must not be created + f.delete(); + throw e; + } finally { + releaseLock(f, lock); + } + } + + /** + * Add a item to an existing feed file. + * + * @param url location of feed to used + * @param nbEntries number of maximum entries to be written in feed file + * @param values dictionnary of properties to write + * @throws FeedException if feed pb + * @throws IOException if io pb + * @throws ParseException if dateparser pb + */ + public void addItemToFeedFile(URL url, int nbEntries, Map<Field, Object> values) throws IOException, FeedException, ParseException { + if (url == null) { + throw new NullPointerException("can not add a feed's entry with null url"); + } + if (values == null || values.isEmpty()) { + //TODO Should check mandatory values (title, link,...) + throw new NullPointerException("can not add a feed's entry with null nor empty values dictonnary"); + } + File f = getFile(url); + + if (!f.exists()) { + throw new FileNotFoundException("file not existing " + f); + } + + // block until can acquire lock + FileLock lock = acquireLock(f); + + try { + // get feed + SyndFeed feed = RSSIOUtil.readFeed(url); + + // create item + SyndEntry item = RSSIOUtil.createFeedItem(itemProperties, values); + + // add item + feed = RSSIOUtil.addItemToFeed(feed, item, nbEntries, values); + + // save feed into a tmp file + File tmpFile = new File(f.getAbsolutePath() + "-tmp_" + System.nanoTime()); + + RSSIOUtil.saveFeed(tmpFile, feed); + + // move tmpFile to real file + tmpFile.renameTo(f); + } finally { + releaseLock(f, lock); + } + } + + public void deleteFeedFile(URL toURL) { + File f = getFile(toURL); + if (f.exists() && !f.delete()) { + throw new IllegalStateException("could not delete feed " + f.getName()); + } + } +/** + * + * @param url + * @param values + * @return the set of modified fields. + * @throws IOException + * @throws FeedException + * @throws ParseException + */ + public EnumSet<Field> updateFeedFile(URL url,Map<Field,Object> values) throws IOException, FeedException, ParseException { + if (url == null) { + throw new NullPointerException("can not add a feed's entry with null url"); + } + if (values == null || values.isEmpty()) { + //TODO Should check mandatory values (title, link,...) + throw new NullPointerException("can not add a feed's entry with null nor empty values dictonnary"); + } + File f = getFile(url); + + if (!f.exists()) { + throw new FileNotFoundException("file not existing " + f); + } + + // block until can acquire lock + FileLock lock = acquireLock(f); + + try { + + SyndFeed feed =RSSIOUtil.readFeed(url); + + // update feed and keep trace of modified fields + EnumSet<Field> modifieds = RSSIOUtil.updateFeed(feed,feedProperties, values); + + // save feed into a tmp file + File tmpFile = new File(f.getAbsolutePath() + "-tmp_" + System.nanoTime()); + + RSSIOUtil.saveFeed(tmpFile, feed); + + // move tmpFile to real file + tmpFile.renameTo(f); + + // feed link has changed + return modifieds; + } finally { + releaseLock(f, lock); + } + } + + public FeedType getFormat() { + return format; + } + + public File getFeedFile(String name) { + return new File(getGeneratorDirectory(),name+".xml"); + } + + public int getNbItems() { + return nbItems; + } + + /** + * Obtain the file from his url location. + * + * @param url location of the file + * @return the file + * @throws IllegalStateException if uri is not sytax valid + */ + protected File getFile(URL url) throws IllegalStateException { + try { + return new File(url.toURI()); + } catch (URISyntaxException e) { + throw new IllegalStateException("could not obtain file from url " + url, e); + } + } + + protected FileLock acquireLock(File f) throws IOException { + File lockFile = getWriteFileLock(f); + + /*if (!lockFile.exists()) lockFile.createNewFile(); */ + // open file for writing only + FileChannel channel = new RandomAccessFile(lockFile, "rw").getChannel(); + + // block until can acquire lock + + return channel.lock(); + } + + protected File getWriteFileLock(File f) { + return new File(f.getParentFile(), f.getName() + ".wlock"); + } + + protected void releaseLock(File f, FileLock lock) throws IOException { + // release lock + lock.release(); + // close channel + lock.channel().close(); + // delete file lock + File lockFile = getWriteFileLock(f); + // delete lock file + lockFile.delete(); + } + + public File getGeneratorDirectory() { + return generatorDirectory; + } + +} Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGenerator.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGeneratorConfig.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGeneratorConfig.java (rev 0) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGeneratorConfig.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,89 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +import java.io.File; + +/** + * + * Default Configuration for {@link RSSGenerator}. + * + * @author chemit + */ +public class RSSGeneratorConfig { + + /** + * la propriete de configuration qui definit le prefix a jouter pour scruter la configuration + */ + private static final String CONFIGURATION_PREFIX_PROPERTY = RSSGeneratorServlet.class.getSimpleName() + "_configuration_prefix"; + /** nombre d'items max à ecrire dans le fichier du flux */ + public static int DEFAULT_GENERATOR_NB_ITEM = 100; + /** le format par défaut duflux à générer */ + public static String DEFAULT_GENERATOR_FORMAT = "RSS_2_0"; + /** le répertoire où générer les flux */ + public static String GENERATOR_DIRECTORY = "/tmp/rssinclude"; + /** le caractère séparateur des listes de métas (categorie par exemple) */ + public static String DEFAULT_LIST_SEPARATOR = ";"; + + public void setDEFAULT_GENERATOR_NB_ITEM(int DEFAULT_GENERATOR_NB_ITEM) { + RSSGeneratorConfig.DEFAULT_GENERATOR_NB_ITEM = DEFAULT_GENERATOR_NB_ITEM; + } + + public void setDEFAULT_GENERATOR_FORMAT(String DEFAULT_GENERATOR_FORMAT) { + RSSGeneratorConfig.DEFAULT_GENERATOR_FORMAT = DEFAULT_GENERATOR_FORMAT; + } + + public void setGENERATOR_DIRECTORY(String GENERATOR_DIRECTORY) { + RSSGeneratorConfig.GENERATOR_DIRECTORY = GENERATOR_DIRECTORY; + } + + public void setDEFAULT_LIST_SEPARATOR(String DEFAULT_LIST_SEPARATOR) { + RSSGeneratorConfig.DEFAULT_LIST_SEPARATOR = DEFAULT_LIST_SEPARATOR; + } + /** + * + * @param <S> la classe source de la configuration + */ + public static abstract class RssGeneratorConfigInitializer<S> extends ConfigInitializer<S,RSSGeneratorConfig> { + + /** + * Initialise RSSGeneratorConfig. + * @param config la configuration source + */ + public void init(S config) { + RSSGenerator.log.info("with source "+config); + + super.init(CONFIGURATION_PREFIX_PROPERTY,RSSGeneratorConfig.class, config, + "DEFAULT_GENERATOR_NB_ITEM", + "DEFAULT_GENERATOR_FORMAT", + "DEFAULT_LIST_SEPARATOR", + "GENERATOR_DIRECTORY"); + + // create delegate directory + new File(GENERATOR_DIRECTORY).mkdirs(); + + } + } +} Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGeneratorConfig.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGeneratorServlet.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGeneratorServlet.java (rev 0) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGeneratorServlet.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,244 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +import com.sun.syndication.feed.synd.SyndFeed; +import com.sun.syndication.io.FeedException; +import java.io.*; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import javax.servlet.*; +import javax.servlet.http.*; + +/** + * <p> + * Servlet permettant de generer des flux generes par RSSGenerator et de + * les publier. + * + * @author chemit + */ +public class RSSGeneratorServlet extends BaseServlet<RSSGenerator> { + + private static final long serialVersionUID = 1L; + + public void doCreateFeed(HttpServletRequest request, HttpServletResponse response, String feedName, File file) throws ServletException, IOException { + String type = request.getParameter("feedType"); + FeedType feedType = null; + if (type != null) { + try { + feedType = FeedType.valueOf(type); + } catch (Exception e) { + feedType = null; + } + } + if (feedType == null) { + feedType = delegate.getFormat(); + } + String description = request.getParameter("feedDescription"); + String link = request.getParameter("feedLink"); + String author = request.getParameter("feedAuthor"); + String categories = request.getParameter("feedCategories"); + Map<Field, Object> values = new HashMap<Field, Object>(); + values.put(Field.NAME, feedName); + addFieldValue(Field.DESCRIPTION, description, values); + addFieldValue(Field.LINK, link, values); + addFieldValue(Field.AUTHOR, author, values); + addFieldValue(Field.CATEGORY, categories, values); + values.put(Field.TIME, RSSGenerator.DATE_PARSER.format(new Date())); + try { + delegate.createFeedFile(file.toURI().toURL(), feedType, values); + } catch (Exception ex) { + throw new ServletException(ex); + } + + String redirect = request.getParameter("from"); + if (redirect != null) { + response.sendRedirect(redirect); + } + } + + public void doDeleteFeed(HttpServletRequest request, HttpServletResponse response, String feedName, File file) throws ServletException, IOException { + try { + delegate.deleteFeedFile(file.toURI().toURL()); + } catch (Exception ex) { + throw new ServletException(ex); + } + + String redirect = request.getParameter("from"); + if (redirect != null) { + response.sendRedirect(redirect); + } + } + + public void doAddItem(HttpServletRequest request, HttpServletResponse response, String feedName, File file) throws ServletException, IOException { + + Integer nbItems = convertToInt(request.getParameter("nbItems")); + if (nbItems == null) { + nbItems = RSSGeneratorConfig.DEFAULT_GENERATOR_NB_ITEM; + } + String description = request.getParameter("itemDescription"); + String link = request.getParameter("itemLink"); + String author = request.getParameter("itemAuthor"); + String name = request.getParameter("itemName"); + + Map<Field, Object> values = new HashMap<Field, Object>(); + addFieldValue(Field.NAME, name, values); + addFieldValue(Field.DESCRIPTION, description, values); + addFieldValue(Field.LINK, link, values); + addFieldValue(Field.AUTHOR, author, values); + values.put(Field.TIME, RSSGenerator.DATE_PARSER.format(new Date())); + try { + delegate.addItemToFeedFile(file.toURI().toURL(), nbItems, values); + } catch (Exception ex) { + throw new ServletException(ex); + } + + String redirect = request.getParameter("from"); + if (redirect != null) { + response.sendRedirect(redirect); + } + } + + public void doList(HttpServletResponse response) throws IOException { + // obtain the list of known feeds + File[] files = delegate.getGeneratorDirectory().listFiles(new FileFilter() { + + public boolean accept(File pathname) { + return pathname.isFile() && pathname.getName().endsWith(".xml"); + } + }); + response.setContentType("text/xml;charset=UTF-8"); + PrintWriter out = response.getWriter(); + + try { + if (files.length > 0) { + String format = "<option value=\"%1$s\">%1$s</option>"; + for (File f : files) { + String name = f.getName(); + out.println(String.format(format, name.substring(0, name.length() - 4))); + } + } else { + out.println("<span class='error'>no feed generated</span>"); + } + } finally { + out.close(); + } + } + + public void doShow(File file, String feedName, HttpServletResponse response) throws ServletException, IOException { + // no action, just publication + if (!file.exists()) { + throw new ServletException("could not find feed " + feedName); + } + response.setContentType("text/xml;charset=UTF-8"); + PrintWriter out = response.getWriter(); + try { + SyndFeed feed = RSSIOUtil.readFeed(file.toURI().toURL()); + RSSIOUtil.saveFeed(out, feed); + } catch (IllegalArgumentException ex) { + throw new ServletException(ex); + } catch (FeedException ex) { + throw new ServletException(ex); + } finally { + out.close(); + } + } + + @Override + protected ConfigInitializer<ServletConfig, ?> newConfigInitializer() { + return new RSSGeneratorConfig.RssGeneratorConfigInitializer<ServletConfig>() { + + protected String getConfigValue(ServletConfig config, String fullConfigName) { + return config.getInitParameter(fullConfigName); + } + }; + } + + @Override + protected RSSGenerator newDelegate() throws Exception { + return RSSGenerator.newDefaultInstance(); + } + + /** + * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. + * @param request servlet request + * @param response servlet response + * @throws IOException TODO + * @throws ServletException TODO + */ + @Override + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + String action = request.getParameter("action"); + if (action == null) { + action = ""; + } + action = action.trim().toLowerCase(); + if ("list".equals(action)) { + doList(response); + return; + } + + String feedName = request.getParameter("feedName"); + + if (feedName == null || "".equals(feedName)) { + throw new ServletException("could not find feedName parameter"); + } + //feedName =new String(feedName.getBytes(),0,feedName.length(),Charset.forName("utf-8")); + File file = new File(delegate.getGeneratorDirectory(), feedName + ".xml"); + + if ("show".equals(action)) { + doShow(file, feedName, response); + return; + } + + if ("create".equals(action)) { + doCreateFeed(request, response, feedName, file); + return; + } + + if ("delete".equals(action)) { + doDeleteFeed(request, response, feedName, file); + return; + } + + if ("additem".equals(action)) { + doAddItem(request, response, feedName, file); + return; + } + + throw new ServletException("action '" + action + "' is unknown "); + + } + + protected void addFieldValue(Field field, String value, Map<Field, Object> values) { + if (value != null && !"".equals(value.trim())) { + values.put(field, value); + } + } +} Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGeneratorServlet.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSHelper.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSHelper.java (rev 0) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSHelper.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,151 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +import com.sun.syndication.feed.synd.SyndEntry; +import com.sun.syndication.feed.synd.SyndFeed; +import org.apache.commons.collections.map.ReferenceMap; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.net.MalformedURLException; +import java.util.List; + +/** + * @author poussin + */ +public class RSSHelper { + + /** + * to use log facility, just put in your code: log.info(\"...\"); + */ + static final Log log = LogFactory.getLog(RSSHelper.class); + + /** + * @return une nouvelle instance de RssHelper en utilisant les implantations + * definies dans RSSConfig. + * @throws Exception pour tout pb lors de l'instanciation des objects + */ + public static RSSHelper newDefaultInstance() throws Exception { + FeedURLResolver r = RSSConfig.DEFAULT_RESOLVER_CLASS.newInstance(); + FeedRenderer rr = RSSConfig.DEFAULT_RENDERER_CLASS.newInstance(); + RSSHelper helper = new RSSHelper(r, rr); + return helper; + } + + /** + * La classe permettant de resoudre les urls + */ + protected FeedURLResolver resolver; + /** + * on utilise des soft reference pour eviter de trop utiliser la memoire + * key: String, value: FeedData + */ + protected ReferenceMap feeds = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.SOFT); + protected FeedRenderer renderer; + + /** + * Utilise un SimpleFeedURLResolver comme resolver de feed + */ + public RSSHelper() { + this(new SimpleFeedURLResolver(), new FeedHTMLRenderer(new HTMLScriptCleaner())); + } + + public RSSHelper(FeedURLResolver resolver, FeedRenderer renderer) { + this.resolver = resolver; + this.renderer = renderer; + } + + public void setResolver(FeedURLResolver resolver) { + this.resolver = resolver; + } + + public void setRenderer(FeedRenderer renderer) { + this.renderer = renderer; + } + + public FeedRenderer getRenderer() { + return renderer; + } + + public FeedURLResolver getResolver() { + return resolver; + } + + public void removeFeed(String feedName) { + feeds.remove(feedName); + } + + /** + * Permet de recuperer un certain nombre d'item du feed demande + * + * @param feedName nom du feed souhaite, l'url sera resolu avec le FeedURLResolver + * @param representation indique les champs en sortie souhaites (ex: n-nt) + * @param nbItem le nombre d'item du feed souhaite + * @param forceReload un flag pour forcer la relecture du feed + * @return le code html representant le feed + */ + public String getHTML(String feedName, String representation, Integer nbItem, boolean forceReload) { + try { + FeedData feed = (FeedData) feeds.get(feedName); + if (forceReload || feed == null || feed.getLastRetrived() + RSSConfig.TIME_FORCE_RETRIEVED < System.currentTimeMillis()) { + feed = resolver.resolv(feedName); + if (feed == null) { + log.warn("could not find feed for " + feedName); + return "<span class='feed-error'>No feed found for " + feedName + "</span>"; + } + feeds.put(feedName, feed); + } + + FeedRendererConfig c; + if (representation != null) { + c = new FeedRendererConfig(representation); + } else { + c = feed.getRendererConfig(); + } + + int nb; + if (nbItem != null) { + nb = nbItem; + } else { + nb = feed.getNbItem(); + } + + SyndFeed sf = feed.getFeed(); + //TODO Deal with NPE... if feed is null + List<?> syndEntries = sf.getEntries(); + if (nb >= 0 && syndEntries.size() >= nb) { + syndEntries = syndEntries.subList(syndEntries.size() - nb, syndEntries.size()); + } + SyndEntry[] items = syndEntries.toArray(new SyndEntry[syndEntries.size()]); + + String result = renderer.render(c, sf, items); + return result; + } catch (MalformedURLException eee) { + log.warn("Can't resolv feed url: " + feedName, eee); + return "<span class='feed-error'>" + eee.getMessage() + "</span>"; + } + } +} Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSIOUtil.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSIOUtil.java (rev 0) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSIOUtil.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,253 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +import com.sun.syndication.feed.synd.SyndCategory; +import com.sun.syndication.feed.synd.SyndCategoryImpl; +import com.sun.syndication.feed.synd.SyndContent; +import com.sun.syndication.feed.synd.SyndContentImpl; +import com.sun.syndication.feed.synd.SyndEntry; +import com.sun.syndication.feed.synd.SyndEntryImpl; +import com.sun.syndication.feed.synd.SyndFeed; +import com.sun.syndication.feed.synd.SyndFeedImpl; +import com.sun.syndication.io.FeedException; +import com.sun.syndication.io.SyndFeedInput; +import com.sun.syndication.io.SyndFeedOutput; +import com.sun.syndication.io.XmlReader; +import java.io.File; +import java.io.IOException; +import java.io.Writer; +import java.lang.IllegalArgumentException; +import java.net.URL; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.EnumMap; +import java.util.EnumSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import org.apache.commons.beanutils.BeanUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * helper to read or save a feed + * @author tony + */ +public class RSSIOUtil { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static final Log log = LogFactory.getLog(RSSIOUtil.class); + + /** + * Load a feed from his url + * @param url location of feed + * @return the java pojo feed + * @throws IllegalArgumentException + * @throws FeedException + * @throws IOException + */ + public static SyndFeed readFeed(URL url) throws IllegalArgumentException, FeedException, IOException { + SyndFeedInput input = new SyndFeedInput(); + SyndFeed feed = input.build(new XmlReader(url)); + return feed; + } + + /** + * save a feed into a file. + * @param file + * @param feed + * @throws IOException + * @throws FeedException + */ + public static void saveFeed(File file, SyndFeed feed) throws IOException, FeedException { + SyndFeedOutput output = new SyndFeedOutput(); + output.output(feed, file); + } + + /** + * save a feed into a writer. + * @param writer + * @param feed + * @throws IOException + * @throws FeedException + */ + public static void saveFeed(Writer writer, SyndFeed feed) throws IOException, FeedException { + SyndFeedOutput output = new SyndFeedOutput(); + output.output(feed, writer); + } + + public static SyndFeed createFeed(EnumMap<Field, String> feedProperties, FeedType type, Map<Field, Object> values) throws ParseException { + SyndFeed feed = new SyndFeedImpl(); + feed.setFeedType(type.getType()); + feed.setEncoding("utf-8"); + fillFeed(values, feedProperties, feed, false); + return feed; + } + + public static EnumSet<Field> updateFeed(URL url, EnumMap<Field, String> feedProperties, Map<Field, Object> values) throws ParseException, IllegalArgumentException, FeedException, IOException { + SyndFeed feed = RSSIOUtil.readFeed(url); + return updateFeed(feed, feedProperties, values); + } + + public static EnumSet<Field> updateFeed(SyndFeed feed, EnumMap<Field, String> feedProperties, Map<Field, Object> values) throws ParseException, IllegalArgumentException, FeedException, IOException { + EnumSet<Field> modifieds = fillFeed(values, feedProperties, feed, true); + return modifieds; + } + + @SuppressWarnings({"unchecked"}) + protected static SyndFeed addItemToFeed(SyndFeed feed, SyndEntry item, int nbEntries, Map<Field, Object> values) throws IOException, IllegalArgumentException, FeedException, ParseException { + List<SyndEntry> entries = feed.getEntries(); + if (!entries.isEmpty()) { + // always sort by publication date + Collections.sort(entries, new FeedEntryComparator()); + // keep only nbEntries -1 entries + while (entries.size() > nbEntries - 1) { + entries.remove(0); + } + } + entries.add(item); + if (log.isDebugEnabled()) { + log.debug("new item " + item); + } + return feed; + } + + public static SyndEntry createFeedItem(EnumMap<Field, String> itemProperties, Map<Field, Object> values) throws ParseException { + + SyndEntry feedEntry = new SyndEntryImpl(); + + for (Entry<Field, Object> entry : values.entrySet()) { + Field field = entry.getKey(); + String name = itemProperties.get(field); + if (name == null) { + // this field is not managed + log.warn("the field " + field + " is not managed in item"); + continue; + } + Object value = entry.getValue(); + Object realValue; + switch (field) { + case TIME: + realValue = RSSGenerator.DATE_PARSER.parse((String) value); + break; + case DESCRIPTION: + //TODO Deal with xml content ? + SyndContent description = new SyndContentImpl(); + description.setType("text/plain"); + feedEntry.setDescription(description); + realValue = String.valueOf(value); + break; + default: + realValue = value; + } + setFieldValue(feedEntry, name, realValue); + } + + return feedEntry; + } + + protected static EnumSet<Field> fillFeed(Map<Field, Object> values, EnumMap<Field, String> feedProperties, SyndFeed feed, boolean treateModfied) throws ParseException { + EnumSet<Field> modifieds = EnumSet.noneOf(Field.class); + + for (Entry<Field, Object> entry : values.entrySet()) { + Field field = entry.getKey(); + String name = feedProperties.get(field); + if (name == null) { + // this field is not managed + log.warn("the field " + field + " is not managed in feed"); + continue; + } + Object value = entry.getValue(); + Object realValue; + switch (field) { + case TIME: + realValue = RSSGenerator.DATE_PARSER.parse((String) value); + break; + case CATEGORY: + List<String> categoriesAsList = new ArrayList<String>(); + if (value instanceof List) { + categoriesAsList = (List) value; + } else { + // categories as String + String cats = String.valueOf(value); + String[] categories = cats.split(RSSGeneratorConfig.DEFAULT_LIST_SEPARATOR); + categoriesAsList = Arrays.asList(categories); + } + realValue = new ArrayList<SyndCategory>(); + for (String cat : categoriesAsList) { + SyndCategory scat = new SyndCategoryImpl(); + scat.setName(cat); + ((List) realValue).add(scat); + } + break; + default: + realValue = value; + } + if (treateModfied) { + Object oldValue = getFieldValue(feed, name); + if (oldValue == null) { + if (realValue != null) { + modifieds.add(field); + } + } else { + if (!oldValue.equals(realValue)) { + modifieds.add(field); + } + } + } + setFieldValue(feed, name, realValue); + } + return modifieds; + } + + protected static void setFieldValue(Object dst, String name, Object value) { + if (value == null) { + // null value is not managed + log.warn("null value for field " + name + " is not managed"); + return; + } + try { + BeanUtils.setProperty(dst, name, value); + } catch (Exception ex) { + log.warn("could not access property " + name, ex); + } + } + + protected static Object getFieldValue(Object dst, String name) { + try { + return BeanUtils.getProperty(dst, name); + } catch (Exception ex) { + log.warn("could not access property " + name, ex); + return null; + } + } + + protected RSSIOUtil() { + // no instance + } +} Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSIOUtil.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSServlet.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSServlet.java (rev 0) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSServlet.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,179 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +import java.io.*; + +import javax.servlet.*; +import javax.servlet.http.*; + +/** + * <p> + * Servlet permettant de retourner un feed RSSHelper en une representation HTML. + * Si la servlet est appele sans parametre alors le code JS permettant d'utiliser + * cette servlet en Ajax est retourne. + * </p><p> + * Sinon la servlet peut prendre en parametre: + * <li> feedName: le nom du feed souhaite + * <li> nbItem: le nombre d'item du feed a retourner + * <li> feedRepr: le chaine permettant de connaitre les champs du feed voulu + * </p><p> + * Utilisation dans une page HTML. Dans le header ajouter + * <pre> + * <script src="url/to/RSSServlet"></script> + * </pre> + * Dans le corps placer un element div avec un id particulier. + * Et soit a la fin de la page soit juste apres le div, ajouter le script + * <pre> + * rssinclude('feedName', 'divid', 5, 'n-n'); + * </pre> + * </p> + * @author poussin + */ +public class RSSServlet extends BaseServlet<RSSHelper> { + + /** + * Le code JavaScript a utilise dans les pages clientes + * + * Provient du fichier rssinclude.js + * cat rssinclude.js |sed 's/"/\\"/g' |sed -re 's/^(.*)$/"\1\\n" +/' + */ + protected static String js = + "function rssincludeUpdateDiv(div, background) {\n" + + " // mettre background a false est utile lorsque l'on appelle la methode\n" + + " // depuis une fenetre que l'on ferme ensuite\n" + + " var serlvetUrl = \"%1$s\"; \n" + + " win = window;\n" + + " var xhr = null;\n" + + " var error=null;\n" + + " var feedName = div.getAttribute(\"feedName\");\n" + + " if (!feedName) // pas de feed name, fatal error\n" + + " error = \"<span class='feed-error'>Aucun feed name detecte...</span>\"; \n" + + " else if(win.XMLHttpRequest) // Firefox, Opera detected\n" + + " xhr = new win.XMLHttpRequest();\n" + + " else if(win.ActiveXObject) // Internet Explorer detected\n" + + " xhr = new win.ActiveXObject(\"Microsoft.XMLHTTP\");\n" + + " else // XMLHttpRequest non supporte par le navigateur\n" + + " error = \"<span class='feed-error'>Votre navigateur ne supporte pas les objets XMLHTTPRequest...</span>\"; \n" + + " if (!!error) { div.innerHTML = error; return; } \n" + + " \n" + + " var nbItem = div.getAttribute(\"nbItem\");\n" + + " var feedRepr = div.getAttribute(\"feedRepr\"); \n" + + " var forceReload = div.getAttribute(\"forceReload\"); \n" + + " var url = serlvetUrl+(serlvetUrl.indexOf('?')>-1?'&':'?')+\"feedName=\" + escape(feedName); \n" + + " if (!!nbItem) {url += '&nbItem=' + escape(nbItem);} \n" + + " if (!!feedRepr) {url += '&feedRepr=' + escape(feedRepr);}\n" + + " if (!!forceReload) {url += '&forceReload=true';}\n" + + "\n" + + " xhr.open(\"GET\", url, !!background);\n" + + " xhr.onreadystatechange = function() {\n" + + " if(xhr.readyState == 1) div.innerHTML = \"Chargement du flux '\"+feedName+\"'\";\n" + + " if(xhr.readyState == 4) div.innerHTML = xhr.responseText;\n" + + " }\n" + + " xhr.send(null);\n" + + "}\n" + + "var initRss =function () {\n" + + " var divs = document.getElementsByTagName(\"div\"); \n" + + " var i = 0;var max=divs.length; \n" + + " var toTreate = [];\n" + + " while (i < max) {\n" + + " var div = divs[i++];\n" + + " if (div.getAttribute('name')=='rssinclude') toTreate[toTreate.length] = div;\n" + + " }\n" + + " i=0;max = toTreate.length;\n" + + " while (i<max) rssincludeUpdateDiv(toTreate[i++], true);" + + "}\n" + + "if (window.addEventListener) window.addEventListener( 'load', initRss,false);\n" + + "else if (window.attachEvent) window.attachEvent( 'onload', initRss);"; + + private static final long serialVersionUID = 1L; + + /** + * @param url current url to add in script + * @return the rssinclude script, patched with url + */ + public static String getJs(String url) { + String code = String.format(js, url); + return code; + } + + public void doJs(HttpServletResponse response, HttpServletRequest request) throws IOException { + // on renvoie le code js + response.setContentType("text/plain;charset=UTF-8"); + PrintWriter out = response.getWriter(); + try { + String code = getJs(request.getRequestURL().toString()); + out.println(code); + } finally { + out.close(); + } + } + + public void doRender(HttpServletResponse response, HttpServletRequest request, String feedName) throws IOException { + response.setContentType("text/html;charset=UTF-8"); + PrintWriter out = response.getWriter(); + try { + String feedRepr = request.getParameter("feedRepr"); + Integer nbItem = convertToInt(request.getParameter("nbItem")); + boolean forceReload = "true".equalsIgnoreCase(request.getParameter("forceReload")); + out.println(delegate.getHTML(feedName, feedRepr, nbItem, forceReload)); + } finally { + out.close(); + } + } + + @Override + protected ConfigInitializer<ServletConfig,? > newConfigInitializer() { + return new RSSConfig.RSSConfigInitializer<ServletConfig>() { + + protected String getConfigValue(ServletConfig config, String fullConfigName) { + return config.getInitParameter(fullConfigName); + } + }; + } + + @Override + protected RSSHelper newDelegate() throws Exception { + return RSSHelper.newDefaultInstance(); + } + + /** + * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. + * @param request servlet request + * @param response servlet response + * @throws IOException TODO + * @throws ServletException TODO + */ + @Override + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + String feedName = request.getParameter("feedName"); + if (feedName == null || "".equals(feedName)) { + doJs(response, request); + } else { + doRender(response, request, feedName); + } + } +} Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSServlet.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/java/org/nuiton/rss/SimpleFeedURLResolver.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/SimpleFeedURLResolver.java (rev 0) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/SimpleFeedURLResolver.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,45 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +import java.net.MalformedURLException; +import java.net.URL; + +/** + * Par defaut retourne un FeedData ou la chaine passer est convertie en URL, + * le nombre d'item est positionne a -1 et le renderer a n-natd + * @author poussin + */ +public class SimpleFeedURLResolver implements FeedURLResolver { + + public FeedData resolv(String ask) throws MalformedURLException { + URL url = new URL(ask); + FeedData result = new FeedData(url); + result.setNbItem(RSSConfig.DEFAULT_NB_ITEM); + result.setRendererConfig(RSSConfig.DEFAULT_RENDERER_CONFIG); + return result; + } + +} Property changes on: trunk/nuiton-rss/src/main/java/org/nuiton/rss/SimpleFeedURLResolver.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/README.txt =================================================================== --- trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/README.txt (rev 0) +++ trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/README.txt 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,15 @@ +This plugin was developped by Code Lutin + +Installation Instructions +1. Copy rssinclude directory into "editor/plugins/" + +2. Copy myfckconfig.js in fckeditor root path and customize it (or merge the + content in your already customized config...) + +3. To create an editor use this code + +var oFCKeditor = new FCKeditor( 'editorName' ) ; +oFCKeditor.Config["CustomConfigurationsPath"] = oFCKeditor.BasePath+"/myfckconfig.js"; +oFCKeditor.Create() ; + +Please let me know if you experience any issues. Property changes on: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/README.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/button.rss.gif =================================================================== (Binary files differ) Property changes on: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/button.rss.gif ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.html =================================================================== --- trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.html (rev 0) +++ trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.html 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,163 @@ +<!-- + #%L + Nuiton Utils :: Nuiton RSS + + $Id$ + $HeadURL$ + %% + Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> +<!-- + * FCKeditor - The text editor for internet + * Copyright (C) 2003-2004 Frederico Caldeira Knabben + * + * Licensed under the terms of the GNU Lesser General Public License: + * http://www.opensource.org/licenses/lgpl-license.php + * + * For further information visit: + * http://www.fckeditor.net/ + * + * File Name: fck_image.html + * Image Properties dialog window. + * + * Version: 2.0 Beta 2 + * Modified: 2004-06-19 00:24:56 + * + * File Authors: + * hmlyons (hmlyons@users.sourceforge.net) + * Andrey Grebnev (andrey.grebnev@blandware.com) +--> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> + <head> + <title>Rss Include Properties</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <meta name="robots" content="noindex, nofollow"> + <script src="../../dialog/common/fck_dialog_common.js" type="text/javascript"></script> + <script src="fck_rssinclude.js" type="text/javascript"></script> + <link href="../../dialog/common/fck_dialog_common.css" rel="stylesheet" type="text/css" /> + <style type="text/css">div.rssinclude { background-color: #ffff00; }</style> + <script type="text/javascript"> + <!-- + document.writeln(FCK.TempBaseTag); + --> + </script> + </head> + <body scroll="no"> + <div id="divInfo"> + <table cellspacing="1" cellpadding="1" border="0" width="100%" height="100%"> + <tr> + <td> + <table cellspacing="0" cellpadding="0" width="100%" border="0"> + <tr> + <td valign="top" width="100%"> + <span fckLang="DlgRssincludeFeedName">name or URL</span><br> + <div id="divFeedName" style="margin-top:2"> + <input style="width: 100%" type="text" id="txtFeedName" onblur="updatePreview();"> + </div> + <a id="editFeed" href='#' fckLang="DlgRssincludeFeedNameEdit" target="_editFeed">Edit</a> + <a id="addFeed" href='#' fckLang="DlgRssincludeFeedNameAdd" target="_addFeed">Add</a> + <script type="text/javascript"> + <!-- + var editWidget = document.getElementById('editFeed'); + var addWidget = document.getElementById('addFeed'); + + if (!FCKConfig.RssCanEditFeed) { + editWidget.style.display='none'; + } else { + editWidget.href='#'; + /** lors de la sortie, on fixe l'url du lien edit pour ce qui est selectionné */ + editWidget.onclick = function changeEdit() { + var input = document.getElementById("txtFeedName"); + editWidget.href = FCKConfig.RssEditURL+ escape(input.value); + }; + + } + if (!FCKConfig.RssCanAddFeed) { + addWidget.style.display='none'; + } else { + addWidget.href = FCKConfig.RssAddURL; + } + --> + </script> + </td> + </tr> + </table> + <hr width="100%" color="#000000" size="2"> + </td> + </tr> + <tr height="100%"> + <td valign="top"> + <table cellspacing="0" cellpadding="0" width="100%" border="0" height="100%"> + <tr> + <td height="140" valign="top"> + <br> + <table cellspacing="2" cellpadding="1" border="0"> + <tr> + <td><span fckLang="DlgRssincludeNbItem">Item's number</span> </td> + <td><input type="text" size="3" id="txtNbItem" onblur="updatePreview();"></td> + </tr> + <tr> + <td><span fckLang="DlgRssincludeFeedRepr">feed representation</span> </td> + <td><input type="text" size="10" id="txtFeedRepr" onblur="updatePreview();"></td> + </tr> + </table> + </td> + <td> </td> + <td width="100%" valign="top"> + <table cellpadding="0" cellspacing="0"> + <tr> + <td><span fckLang="DlgImgPreview">Preview</span></td> + </tr> + <tr> + <td valign="top"> + <div class="ImagePreviewArea"> + <div + id="rssincludePreview" + name="rssinclude" + class="rssinclude"> + </div> + + Magnus es, domine, et laudabilis + valde: magna virtus tua, et sapientiae tuae non est numerus. et laudare te vult + homo, aliqua portio creaturae tuae, et homo circumferens mortalitem suam, + circumferens testimonium peccati sui et testimonium, quia superbis resistis: et + tamen laudare te vult homo, aliqua portio creaturae tuae.tu excitas, ut laudare + te delectet, quia fecisti nos ad te et inquietum est cor nostrum, donec + requiescat in te. da mihi, domine, scire et intellegere, utrum sit prius + invocare te an laudare te, et scire te prius sit an invocare te. sed quis te + invocat nesciens te? aliud enim pro alio potest invocare nesciens. an potius + invocaris, ut sciaris? quomodo autem invocabunt, in quem non crediderunt? aut + quomodo credent sine praedicante? et laudabunt dominum qui requirunt eum. + quaerentes enim inveniunt eum et invenientes laudabunt eum. quaeram te, domine, + invocans te, et invocem te credens in te: praedicatus enim es nobis. invocat + te, domine, fides mea, quam dedisti mihi, quam inspirasti mihi per humanitatem + filii tui, per ministerium praedicatoris tui. + </div> + </td> + </tr> + </table> + </td> + </tr> + </table> + </td> + </tr> + </table> + </div> + </body> +</html> Property changes on: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.html ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.js =================================================================== --- trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.js (rev 0) +++ trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.js 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,159 @@ +var dialog = window.parent; +var oEditor = dialog.InnerDialogLoaded(); +var FCK = oEditor.FCK; +var FCKLang = oEditor.FCKLang; +var FCKConfig = oEditor.FCKConfig; +var FCKTools = oEditor.FCKTools; + +// Set the language direction. +window.document.dir = oEditor.FCKLang.Dir; + +// load rssinclude script +document.writeln("<script type=\"text/javascript\" src=\""+FCKConfig.RssScriptURL+"\"></script>"); + +// Recuperation du feed selectionne +var oRss = dialog.Selection.GetSelectedElement(); + +// Un peu de travail au chargement de la page +window.onload = function() +{ + // Translate the dialog box texts. + oEditor.FCKLanguageManager.TranslatePage(document); + + // chargement de la combo avec les feeds configures + LoadCombo(); + + // Load the selected element information (if any). + LoadSelection(); + + // Activate the "OK" button. + window.parent.SetOkButton( true ); + + SelectField( 'txtFeedName' ); +} + +/** + * Remplace le textfield de saisie du nom d'un feed par une combo. + * Cela n'est fait que si le serveur peut etre contacte + */ +function LoadCombo() { + var xhr = null; + if(window.XMLHttpRequest) // Firefox + xhr = new window.XMLHttpRequest(); + else if(window.ActiveXObject) // Internet Explorer + xhr = new window.ActiveXObject("Microsoft.XMLHTTP"); + + if (xhr) { + xhr.open("GET", FCKConfig.RssKnownFeedsURL, true); + xhr.onreadystatechange = function() { + if(xhr.readyState == 4 && xhr.status == 200) /* 200 : code HTTP pour OK */ + { + var content = '<select style="WIDTH: 100%" id="txtFeedName" onblur="updatePreview(this);">'+ + xhr.responseText + '</select>'; + document.getElementById("divFeedName").innerHTML = content; + if (oRss) { + // on selectionne l'ancienne valeur + GetE('txtFeedName').value = GetAttribute( oRss, 'feedname', '' ); + } + } + } + xhr.send(null); + } +} + +/** + * Chargement du feed que l'on re-edite + */ +function LoadSelection() { + if (! oRss) return; + GetE('txtFeedName').value = GetAttribute( oRss, 'feedname', '' ); + GetE('txtNbItem').value = GetAttribute( oRss, 'nbitem', '' ); + GetE('txtFeedRepr').value = GetAttribute( oRss, 'feedrepr', '' ); + + updatePreview(); +} + +/** + * Fonction appeler lors de la validation + */ +function Ok() +{ + if ( GetE('txtFeedName').value.length == 0 ) + { + GetE('txtFeedName').focus(); + + alert( oEditor.FCKLang.DlgRssincludeAlertFeedName ); + return false ; + } + + oEditor.FCKUndo.SaveUndoStep(); + if ( !oRss ) + { + oRss = FCK.InsertElement( 'DIV' ) ; + if (!detectScript()) { + // add script to editor only once + oScript = FCK.InsertElement('SCRIPT'); + SetAttribute( oScript, 'src', FCKConfig.RssScriptURL); + } + } + updateRss( oRss ); + + // rssincludeUpdateDiv(oRss, false); + return true; +} + +/** + * Detection de la presence ou non du script rssinclude dans l'edition + */ +function detectScript() { + var scripts = FCK.GetXHTML(); + return (scripts.indexOf("src=\""+FCKConfig.RssScriptURL+"\"")!=-1); +} + +/** + * Mise a jour d'un div avec les informations trouvees dans l'interface + */ +function updateRss(e){ + e.contentEditable = false; + + SetAttribute( e, 'class', 'rssinclude'); + SetAttribute( e, 'contentEditable', 'false'); + SetAttribute( e, 'name', 'rssinclude'); + SetAttribute( e, 'feedname', GetE('txtFeedName').value ); + SetAttribute( e, 'nbitem', GetE('txtNbItem').value ); + SetAttribute( e, 'feedrepr', GetE('txtFeedRepr').value ); + //SetAttribute( e, 'forceReload', 'true' ); + e.innerHTML = 'RSS ' + GetE('txtFeedName').value + ' (items:'+GetE('txtNbItem').value+')'; +} + +// L'element servant a la preview +var ePreview ; + +/** + * Mise a jour du flux dans la preview + * @param combo la combo utilisee (undefined si uniquement un input) + */ +function updatePreview(combo){ + + if ( !ePreview ) { + ePreview = GetE('rssincludePreview'); + } + + if ( ! ePreview) { + return; + } + + if ( GetE('txtFeedName').value.length == 0 ) { + ePreview.innerHTML = 'Invalid RSS'; + } else { + if (!!combo) { + // mise à jour des champs à partir de l'option selectionne + var index = combo.options.selectedIndex; + var option = combo.options[index]; + GetE('txtNbItem').value = GetAttribute( option, 'nbitem', '' ) + GetE('txtFeedRepr').value = GetAttribute( option, 'feedrepr', '' ) + } + updateRss(ePreview); + rssincludeUpdateDiv(ePreview, true); + } +} Property changes on: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.js ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fckplugin.js =================================================================== --- trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fckplugin.js (rev 0) +++ trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fckplugin.js 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,53 @@ +// Register the related commands. +var dialogPath = FCKConfig.PluginsPath + 'rssinclude/fck_rssinclude.html'; +var rssincludeDialogCmd = new FCKDialogCommand( FCKLang["DlgRssincludeTitle"], FCKLang["DlgRssincludeTitle"], dialogPath, 480, 470 ); +FCKCommands.RegisterCommand( 'rssinclude', rssincludeDialogCmd ) ; + +// Create the Rssinclude toolbar button. +var oRssincludeItem = new FCKToolbarButton( 'rssinclude', FCKLang["DlgRssincludeTitle"]) ; +oRssincludeItem.IconPath = FCKConfig.PluginsPath + 'rssinclude/button.rss.gif' ; + +FCKToolbarItems.RegisterItem( 'rssinclude', oRssincludeItem ) ; +// 'Rssinclude' is the name used in the Toolbar config. + +FCK.ContextMenu.RegisterListener( { + AddItems : function( menu, tag, tagName ) { + var e = tag; + if (! (e && e.nodeName == 'DIV' && e.getAttribute('name') == 'rssinclude' )) { + var selection = FCKSelection.GetSelection() ; + var range = selection.getRangeAt(0) ; + e = range.endContainer ; + while (e && (e.nodeName != 'DIV' || e.getAttribute('name') != 'rssinclude')) { + e = e.parentNode; + } + } + + // under what circumstances do we display this option + if (!!e && e.nodeName == 'DIV' && e.getAttribute('name') == 'rssinclude' ) { + FCKSelection.SelectNode(e); + // when the option is displayed, show a separator the command + menu.AddSeparator() ; + // the command needs the registered command name, the title for the context menu, and the icon path + menu.AddItem( 'rssinclude', FCKLang.DlgRssincludeTitle, oRssincludeItem.IconPath ) ; + } + } +} ); + +/** +OnClick = function( e ) +{ + if ( e.target.tagName == 'DIV' && e.target.getAttribute('class') == 'rssinclude' ) + FCKSelection.SelectNode( e.target ) ; +} + +FCK.EditorDocument.addEventListener( 'click', OnClick, true ) ; +**/ + +OnDoubleClick = function( e ) { + if ( e.tagName == 'DIV' && e.getAttribute('name') == 'rssinclude' ) { + FCKSelection.SelectNode(e); + FCKCommands.GetCommand( 'rssinclude' ).Execute() ; + } +} + +FCK.RegisterDoubleClickHandler( OnDoubleClick, 'DIV' ) ; Property changes on: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/fckplugin.js ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/en.js =================================================================== --- trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/en.js (rev 0) +++ trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/en.js 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,9 @@ +// Rssinclude Dialog +FCKLang["DlgRssincludeTitle"] = "Rss Include"; +FCKLang["DlgRssincludeFeedName"] = "name or URL" ; +FCKLang["DlgRssincludeFeedNameEdit"] = "Edit" ; +FCKLang["DlgRssincludeFeedNameAdd"] = "Add" ; +FCKLang["DlgRssincludeNbItem"] = "item's number" ; +FCKLang["DlgRssincludeFeedRepr"] = "Feed representation" ; +FCKLang["DlgRssincludeAlertFeedName"] = "Please input the feed name or feed URL" +FCKLang["DlgRssincludeLoading"] = "Loading rss..." Property changes on: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/en.js ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/fr.js =================================================================== --- trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/fr.js (rev 0) +++ trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/fr.js 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,9 @@ +// Rssinclude Dialog +FCKLang["DlgRssincludeTitle"] = "Rss Include"; +FCKLang["DlgRssincludeFeedName"] = "nom ou URL" ; +FCKLang["DlgRssincludeFeedNameEdit"] = "Edition" ; +FCKLang["DlgRssincludeFeedNameAdd"] = "Ajout" ; +FCKLang["DlgRssincludeNbItem"] = "nombre d'item" ; +FCKLang["DlgRssincludeFeedRepr"] = "Feed representation" ; +FCKLang["DlgRssincludeAlertFeedName"] = "Veuillez entrer un nom ou une URL pour le feed" +FCKLang["DlgRssincludeLoading"] = "Chargement du rss..." Property changes on: trunk/nuiton-rss/src/main/resources/fckeditor/editor/plugins/rssinclude/lang/fr.js ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/resources/fckeditor/myfckconfig.js =================================================================== --- trunk/nuiton-rss/src/main/resources/fckeditor/myfckconfig.js (rev 0) +++ trunk/nuiton-rss/src/main/resources/fckeditor/myfckconfig.js 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,65 @@ +/* + * FCKeditor - The text editor for Internet - http://www.fckeditor.net + * Copyright (C) 2003-2008 Frederico Caldeira Knabben + * + * == BEGIN LICENSE == + * + * Licensed under the terms of any of the following licenses at your + * choice: + * + * - GNU General Public License Version 2 or later (the "GPL") + * http://www.gnu.org/licenses/gpl.html + * + * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") + * http://www.gnu.org/licenses/lgpl.html + * + * - Mozilla Public License Version 1.1 or later (the "MPL") + * http://www.mozilla.org/MPL/MPL-1.1.html + * + * == END LICENSE == + * + * Editor configuration settings. + * + * Follow this link for more information: + * http://wiki.fckeditor.net/Developer%27s_Guide/Configuration/Configurations_S... + */ + +FCKConfig.Plugins.Add("rssinclude", "en,fr"); + +FCKConfig.ToolbarSets["Default"] = [ + ['Source','DocProps','-','Save','NewPage','Preview','-','Templates'], + ['Cut','Copy','Paste','PasteText','PasteWord','-','Print','SpellCheck'], + ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'], + ['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'], + '/', + ['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'], + ['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote'], + ['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'], + ['Link','Unlink','Anchor'], + ['rssinclude', 'Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak'], + '/', + ['Style','FontFormat','FontName','FontSize'], + ['TextColor','BGColor'], + ['FitWindow','ShowBlocks','-','About'] // No comma for the last row. +] ; + +// to authorize user to add a new feed +FCKConfig.RssCanAddFeed = false; + +// to authorize user to edit a known feed +FCKConfig.RssCanEditFeed = false; + +// url to render a feed +FCKConfig.RssRenderURL = '/nuitonrss-2.4/RSSServlet&feedName=' ; + +// url to obtain rssinclude script +FCKConfig.RssScriptURL = '/nuitonrss-2.4/RSSServlet' ; + +// url to obtain known feeds as a list of html options +FCKConfig.RssKnownFeedsURL = '/nuitonrss-2.4/feeds.txt' ; + +// url to create a new feed +FCKConfig.RssAddURL = ''; + +// url to edit a known feed +FCKConfig.RssEditURL = '' ; Property changes on: trunk/nuiton-rss/src/main/resources/fckeditor/myfckconfig.js ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/resources/log4j.properties =================================================================== --- trunk/nuiton-rss/src/main/resources/log4j.properties (rev 0) +++ trunk/nuiton-rss/src/main/resources/log4j.properties 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,33 @@ +### +# #%L +# Nuiton Utils :: Nuiton RSS +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin +# %% +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser 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 Lesser Public License for more details. +# +# You should have received a copy of the GNU General Lesser Public +# License along with this program. If not, see +# <http://www.gnu.org/licenses/lgpl-3.0.html>. +# #L% +### +# Global logging configuration +log4j.rootLogger=ERROR, stdout +# Console output... +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n +#log4j.appender.stdout.layout.ConversionPattern=%%c=%c %%C=%C %%d=%d %%F=%F %%l=%l %%L=%L %%m=%m %%M=%M %%p=%p %%r=%r %%t=%t %%x=%x %%X=%X +# package level +log4j.logger.org.nuiton.rss=INFO Property changes on: trunk/nuiton-rss/src/main/resources/log4j.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/webapp/WEB-INF/web.xml =================================================================== --- trunk/nuiton-rss/src/main/webapp/WEB-INF/web.xml (rev 0) +++ trunk/nuiton-rss/src/main/webapp/WEB-INF/web.xml 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Nuiton Utils :: Nuiton RSS + + $Id$ + $HeadURL$ + %% + Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> + + +<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee + http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> + + <display-name>RSSServlet</display-name> + + <servlet> + <servlet-name>RSSServlet</servlet-name> + <servlet-class>org.nuiton.rss.RSSServlet</servlet-class> + </servlet> + <servlet-mapping> + <servlet-name>RSSServlet</servlet-name> + <url-pattern>/RSSServlet</url-pattern> + </servlet-mapping> + <servlet> + <servlet-name>RSSGeneratorServlet</servlet-name> + <servlet-class>org.nuiton.rss.RSSGeneratorServlet</servlet-class> + </servlet> + <servlet-mapping> + <servlet-name>RSSGeneratorServlet</servlet-name> + <url-pattern>/RSSGeneratorServlet</url-pattern> + </servlet-mapping> + +</web-app> Property changes on: trunk/nuiton-rss/src/main/webapp/WEB-INF/web.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/webapp/feed.css =================================================================== --- trunk/nuiton-rss/src/main/webapp/feed.css (rev 0) +++ trunk/nuiton-rss/src/main/webapp/feed.css 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,109 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +.rssinclude { + border: 1px dotted black; +} + +.rss-feed { + display: block; +} + +.rss-items { + clear: both; + display: block; +} + +.rss-items li { + clear: both; + display: block; +} + +.feed-name { + font-weight: bold; + color: blue; + display: block; +} + +.feed-link { + font-size: 10px; +} + +.feed-time{ + font-size: 10px; + clear: both; + display: block; +} + +.feed-image { + /*float: right;*/ + border: 1px dotted black; + margin: 0 0 15px 20px; +} + +.feed-description { + clear: both; + display: block; + font-style: italic; + color: green; + font-size: 10px; +} + +.feed-author { + color: black; + font-size: 10px; +} + +.feedItem-name { + font-weight: bold; + color: red; + display: block; + clear: both; + font-size: 10px; +} + +.feedItem-link { + font-size: 10px; +} + +.feedItem-description { + font-style: italic; + color: gray; + font-size: 10px; + clear: both; + display: block; +} + +.feedItem-author { + color: black; + font-size: 10px; + clear: both; + display: block; +} + +.feedItem-time{ + font-size: 10px; + clear: both; + display: block; +} Property changes on: trunk/nuiton-rss/src/main/webapp/feed.css ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/webapp/feeds.txt =================================================================== --- trunk/nuiton-rss/src/main/webapp/feeds.txt (rev 0) +++ trunk/nuiton-rss/src/main/webapp/feeds.txt 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,7 @@ +<option value="http://www.lemondeinformatique.fr/flux-rss/open-source/rss.xml" nbitem="1" feedrepr="indat-natd">le monde informatique</option> +<option value="http://www.lemonde.fr/rss/sequence/0,2-3208,1-0,0.xml" nbitem="2" feedrepr="indat-natd">le monde</option> +<option value="http://blog.developpez.com/xmlsrv/rss2.php?blog=42" nbitem="3" feedrepr="indat-natd">developpez.com</option> +<option value="http://formats-ouverts.org/rss.php" nbitem="4" feedrepr="indat-natd">formats ouverts</option> +<option value="http://www.h2database.com/html/newsfeed-rss.xml" nbitem="5" feedrepr="indat-natd">h2</option> +<option value="http://www.opensi.org/news.rss" nbitem="6" feedrepr="indat-natd">opensi</option> + Property changes on: trunk/nuiton-rss/src/main/webapp/feeds.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/webapp/index.html =================================================================== --- trunk/nuiton-rss/src/main/webapp/index.html (rev 0) +++ trunk/nuiton-rss/src/main/webapp/index.html 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,45 @@ +<!-- + #%L + Nuiton Utils :: Nuiton RSS + + $Id$ + $HeadURL$ + %% + Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> +<!-- + Document : test + Created on : 18 avr. 2008, 11:46:56 + Author : poussin +--> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> + <title>Page de tests</title> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +</head> + <body> + <h1>NuitonRSS tests index</h1> + <ul> + <li><a href="testRender.html" target="render">Test de rendu</a></li> + <li><a href="testGenerator.html" target="generator">Test de génération de flux</a></li> + <li><a href="testFck.html" target="fck">Test du plugin rssinclude dans fckeditor 2.6</a> (*)</li> + </ul> + <p>(*) required a FCKEditor 2.6 available on / apache path (means /fckeditor points to fckeditor root directory)</p> +</body> +</html> Property changes on: trunk/nuiton-rss/src/main/webapp/index.html ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/webapp/rssgenerator.js =================================================================== --- trunk/nuiton-rss/src/main/webapp/rssgenerator.js (rev 0) +++ trunk/nuiton-rss/src/main/webapp/rssgenerator.js 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,47 @@ +function rssgeneratorUpdateDiv(divs) { + var serlvetUrl = "RSSGeneratorServlet?action=list"; + win = window; + var xhr = null; + var error=null; + if(win.XMLHttpRequest) // Firefox, Opera detected + xhr = new win.XMLHttpRequest(); + else if(win.ActiveXObject) // Internet Explorer detected + xhr = new win.ActiveXObject("Microsoft.XMLHTTP"); + else // XMLHttpRequest non supporte par le navigateur + error = "<span class='feed-error'>Votre navigateur ne supporte pas les objets XMLHTTPRequest...</span>"; + if (!!error) { updateDiv(divs,false,error); return; } + + xhr.open("GET", serlvetUrl, true); + xhr.onreadystatechange = function() { + if(xhr.readyState == 1) { updateDiv(divs,false,"Chargement de la liste des feeds en cours..."); } + else if(xhr.readyState == 4) { updateDiv(divs,true,xhr.responseText); } + } + xhr.send(null); +} + +var initRssGenerator =function () { + var divs = document.getElementsByTagName("div"); + var i = 0;var max=divs.length; + var toTreate = []; + while (i < max) { + var div = divs[i++]; + if (div.getAttribute('name')=='rssgeneratorlist') toTreate[toTreate.length] = div; + } + rssgeneratorUpdateDiv(toTreate); +} +var updateDiv= function(divs,select,text) { + var i=0; + var max = divs.length; + while (i<max) { + var divText=text; + var div = divs[i++]; + if (!!select && text.indexOf("error")==-1) { + var name = div.getAttribute("action"); + divText = "<select name='"+name+"' length='50'>" + text+"</select>" + } + div.innerHTML =divText; + } +} +// load initRssGenerator +if (window.addEventListener) window.addEventListener( 'load', initRssGenerator,false); +else if (window.attachEvent) window.attachEvent( 'onload', initRssGenerator); Property changes on: trunk/nuiton-rss/src/main/webapp/rssgenerator.js ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/webapp/rssinclude.js =================================================================== --- trunk/nuiton-rss/src/main/webapp/rssinclude.js (rev 0) +++ trunk/nuiton-rss/src/main/webapp/rssinclude.js 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,49 @@ +function rssincludeUpdateDiv(div, background) { + // mettre background a false est utile lorsque l'on appelle la methode + // depuis une fenetre que l'on ferme ensuite + //var serlvetUrl = "%1$1"; + var serlvetUrl = "http://localhost:8083/nuitonrss-2.4/RSSServlet"; + win = window; + var xhr = null; + var error=null; + var feedName = div.getAttribute("feedName"); + if (!feedName) // pas de feed name, fatal error + error = "<span class='feed-error'>Aucun feed name detecte...</span>"; + else if(win.XMLHttpRequest) // Firefox, Opera detected + xhr = new win.XMLHttpRequest(); + else if(win.ActiveXObject) // Internet Explorer detected + xhr = new win.ActiveXObject("Microsoft.XMLHTTP"); + else // XMLHttpRequest non supporte par le navigateur + error = "<span class='feed-error'>Votre navigateur ne supporte pas les objets XMLHTTPRequest...</span>"; + if (!!error) { div.innerHTML = error; return; } + + var nbItem = div.getAttribute("nbItem"); + var feedRepr = div.getAttribute("feedRepr"); + var forceReload = div.getAttribute("forceReload"); + var url = serlvetUrl+(serlvetUrl.indexOf('?')>-1?'&':'?')+"feedName=" + escape(feedName); + if (!!nbItem) {url += '&nbItem=' + escape(nbItem);} + if (!!feedRepr) {url += '&feedRepr=' + escape(feedRepr);} + if (!!forceReload) {url += '&forceReload=true';} + + xhr.open("GET", url, !!background); + xhr.onreadystatechange = function() { + if(xhr.readyState == 1) div.innerHTML = "Chargement du flux '"+feedName+"' en cours..."; + if(xhr.readyState == 4) div.innerHTML = xhr.responseText; + } + xhr.send(null); +} + +var initRss =function () { + var divs = document.getElementsByTagName("div"); + var i = 0;var max=divs.length; + var toTreate = []; + while (i < max) { + var div = divs[i++]; + if (div.getAttribute('name')=='rssinclude') toTreate[toTreate.length] = div; + } + i=0;max = toTreate.length; + while (i<max) rssincludeUpdateDiv(toTreate[i++], true); +} +if (window.addEventListener) window.addEventListener( 'load', initRss,false); +else if (window.attachEvent) window.attachEvent( 'onload', initRss); + Property changes on: trunk/nuiton-rss/src/main/webapp/rssinclude.js ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/webapp/testFck.html =================================================================== --- trunk/nuiton-rss/src/main/webapp/testFck.html (rev 0) +++ trunk/nuiton-rss/src/main/webapp/testFck.html 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,72 @@ +<!-- + #%L + Nuiton Utils :: Nuiton RSS + + $Id$ + $HeadURL$ + %% + Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> +<!-- + Document : test + Created on : 18 avr. 2008, 11:46:56 + Author : poussin +--> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> + <title>Page de test plugin FCKEditor rss</title> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <!--link href="feed.css" rel="stylesheet" type="text/css" /--> + <script type="text/javascript" src="/fckeditor/fckeditor.js"></script> + <style type="text/css">div.rssinclude { background-color: #ffff00; }</style> +</head> +<body> +<h1>Test plugin FCKEditor RSS (*)</h1> +<form name="EditPostView" action="#" method="GET"> + <script type="text/javascript"> + <!-- + var oFCKeditor = new FCKeditor( 'rssTest' ) ; + oFCKeditor.Config["CustomConfigurationsPath"] = oFCKeditor.BasePath+"/myfckconfig.js"; + + var content = "<div contenteditable='false' class=\"rssinclude\" name=\"rssinclude\" feedname=\"http://www.lemondeinformatique.fr/flux-rss/open-source/rss.xml\" nbitem=\"2\" feedrepr=\"n-n\">RSS http://www.lemondeinformatique.fr/flux-rss/open-source/rss.xml (items:2)</div><br></br>"; + //content+="<div contenteditable='false' name=\"rssinclude\" class=\"rssinclude\" feedname=\"http://www.lemonde.fr/rss/sequence/0,2-3208,1-0,0.xml\" nbitem=\"2\" feedrepr=\"indat-natd\" \">RSS http://www.lemonde.fr/rss/sequence/0,2-3208,1-0,0.xml (items:2)</div><br/>"; + //content+="<div contenteditable='false' name=\"rssinclude\" class=\"rssinclude\" feedname=\"http://blog.developpez.com/xmlsrv/rss2.php?blog=42\" nbitem=\"3\" feedRepr=\"indat-natd\" \">RSS http://blog.developpez.com/xmlsrv/rss2.php?blog=42 (items:3)</div><br/>"; + //content+="<div contenteditable='false' name=\"rssinclude\" class=\"rssinclude\" feedname=\"http://formats-ouverts.org/rss.php\" nbitem=\"4\" feedrepr=\"indat-natd\" \">RSS http://formats-ouverts.org/rss.php (items:4)</div><br/>"; + //content+="<div contenteditable='false' name=\"rssinclude\" class=\"rssinclude\" feedname=\"http://www.h2database.com/html/newsfeed-rss.xml\" nbitem=\"5\" feedRepr=\"indat-natd\" \">RSS http://www.h2database.com/html/newsfeed-rss.xml (items:5)</div><br/>"; + //content+="<div contenteditable='false' name=\"rssinclude\" class=\"rssinclude\" feedname=\"http://www.opensi.org/news.rss\" nbitem=\"6\" feedrepr=\"indat-natd\" \">RSS http://www.opensi.org/news.rss (items:6)</div>"; + content += "<s"+"cript src=\"/nuitonrss-2.4/RSSServlet\"></scri"+"pt><hr/><p>content...</p>"; + oFCKeditor.Value = content; + oFCKeditor.Create() ; + --> + </script> + <hr/> + <input type="submit" value="envoyer"> +</form> +<p>(*) required a FCKEditor 2.6 available on / apache path (means /fckeditor points to fckeditor root directory)</p> +<p>add custom config like this code : + <pre> +var oFCKeditor = new FCKeditor( 'rssTest' ) ; +oFCKeditor.Config["CustomConfigurationsPath"] = oFCKeditor.BasePath+"/myfckconfig.js"; +oFCKeditor.Create() ; + </pre> +</p> + + +</body> +</html> Property changes on: trunk/nuiton-rss/src/main/webapp/testFck.html ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/webapp/testGenerator.html =================================================================== --- trunk/nuiton-rss/src/main/webapp/testGenerator.html (rev 0) +++ trunk/nuiton-rss/src/main/webapp/testGenerator.html 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,132 @@ +<!-- + #%L + Nuiton Utils :: Nuiton RSS + + $Id$ + $HeadURL$ + %% + Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> +<!-- + Document : test + Created on : 18 avr. 2008, 11:46:56 + Author : poussin +--> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> + <head> + <title>Page de test de génération de flux rss</title> + <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> + <style type="text/css"> + .error {color:red; display:block;} + fieldset {height:140px;} + iframe { width:100%;height:400px;} + </style> + <script src="rssgenerator.js"></script> + <script> + var doAction=function(action) { + var form = document.feeds; + form.action.value=action; + if (action=='show'){ + //form.method='get'; + form.target='content'; + } else { + //form.action.value=action; + //form.method='post'; + form.target=''; + } + return true; + } + </script> + </head> + <body> + <h1>Test RSS Generator</h1> + <table width="100%"> + <tr> + <td width="50%" valign="top"> + <form method="post" action="RSSGeneratorServlet"> + <fieldset> + <legend> <input type="submit" value="create a new feed"> </legend> + <input type="hidden" name="action" value="create"> + <input type="hidden" name="from" value="testGenerator.html"> + <table> + <tr> + <td>feedName (*) :</td> + <td><input name="feedName" type="text" size="50"></td> + </tr> + <tr> + <td>feedDescription (*) : </td> + <td><input name="feedDescription" type="text" size="50"></td> + </tr> + <tr> + <td>feedLink (*) : </td> + <td><input name="feedLink" type="text" size="50"></td> + </tr> + <tr> + <td>feedAuthor : </td> + <td><input name="feedAuthor" type="text" size="50"></td> + </tr> + <tr> + <td>feedCategories : </td> + <td><input name="feedCategories" type="text" size="50"></td> + </tr> + <tr><td style="font-size:11px">(*) Mandatory field</td></tr> + </table> + </fieldset> + </form> + </td> + <td width="50%" valign="top"> + <form name="feeds" method="post" action="RSSGeneratorServlet"> + <fieldset> + <legend> <input type="submit" value="add item to feed" onclick="return doAction('addItem');"> + <input type="submit" value="delete feed" onclick="return doAction('delete');"> + <input type="submit" value="show feed" onclick="return doAction('show');"> </legend> + <input type="hidden" name="from" value="testGenerator.html"> + <input type="hidden" name="action" value=""> + <table> + <tr> + <td>feedName :</td> + <td> + <div name="rssgeneratorlist" action="feedName"></div> + </td> + </tr> + <tr> + <td>itemName :</td> + <td><input name="itemName" type="text" size="50"></td> + </tr> + <tr> + <td>itemDescription: </td> + <td><input name="itemDescription" type="text" size="50"></td> + </tr> + <tr> + <td>itemLink : </td> + <td><input name="itemLink" type="text" size="50"></td> + </tr> + <tr> + <td>itemAuthor : </td> + <td><input name="itemAuthor" type="text" size="50"></td> + </tr> + </table> + </fieldset> + </form> + </td> + </tr> + </table> + <iframe name="content" scrolling="yes" frameborder="1"></iframe> + </body> +</html> Property changes on: trunk/nuiton-rss/src/main/webapp/testGenerator.html ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/main/webapp/testRender.html =================================================================== --- trunk/nuiton-rss/src/main/webapp/testRender.html (rev 0) +++ trunk/nuiton-rss/src/main/webapp/testRender.html 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,47 @@ +<!-- + #%L + Nuiton Utils :: Nuiton RSS + + $Id$ + $HeadURL$ + %% + Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> +<!-- + Document : test + Created on : 18 avr. 2008, 11:46:56 + Author : poussin +--> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> + <title>Page de test rss</title> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <link href="feed.css" rel="stylesheet" type="text/css" /> + <script src="RSSServlet"></script> +</head> + <body> + <h1>Test RSS</h1> + <div name="rssinclude" class="rssinclude" feedName="http://www.lemondeinformatique.fr/flux-rss/open-source/rss.xml" nbItem="1" feedRepr="indat-natd"></div> + <div name="rssinclude" class="rssinclude" feedName="http://www.lemonde.fr/rss/sequence/0,2-3208,1-0,0.xml" nbItem="2" feedRepr="indat-natd"></div> + <div name="rssinclude" class="rssinclude" feedName="http://blog.developpez.com/xmlsrv/rss2.php?blog=42" nbItem="3" feedRepr="indat-natd"></div> + <div name="rssinclude" class="rssinclude" feedName="http://formats-ouverts.org/rss.php" nbItem="4" feedRepr="indat-natd"></div> + <div name="rssinclude" class="rssinclude" feedName="http://www.h2database.com/html/newsfeed-rss.xml" nbItem="5" feedRepr="indat-natd"></div> + <div name="rssinclude" class="rssinclude" feedName="http://www.opensi.org/news.rss" nbItem="6" feedRepr="indat-natd"></div> +</body> +</html> Property changes on: trunk/nuiton-rss/src/main/webapp/testRender.html ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/site/apt/index.apt =================================================================== --- trunk/nuiton-rss/src/site/apt/index.apt (rev 0) +++ trunk/nuiton-rss/src/site/apt/index.apt 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,50 @@ +~~~ +~~ #%L +~~ Nuiton Utils :: Nuiton RSS +~~ +~~ $Id$ +~~ $HeadURL$ +~~ %% +~~ Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin +~~ %% +~~ This program is free software: you can redistribute it and/or modify +~~ it under the terms of the GNU Lesser 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 Lesser Public License for more details. +~~ +~~ You should have received a copy of the GNU General Lesser Public +~~ License along with this program. If not, see +~~ <http://www.gnu.org/licenses/lgpl-3.0.html>. +~~ #L% +~~~ + ---- + Nuiton RSS + ---- + ---- + 2009-08-23 + ---- + +Présentation + + A faire... + +Utilisation +=========== + + A faire ... + +-------------------------------------------------------------------------------- + <script src="nuitonrss.js"> + rss("rss1", "url", max, login, password) + </script> + <div id="rss1"></div> +-------------------------------------------------------------------------------- + +- si pas de fichier html pour l'url demandée ou plus vielle que N + - récupération de de l'url et sauvegarde en html +- renvoi du html \ No newline at end of file Property changes on: trunk/nuiton-rss/src/site/apt/index.apt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/site/site_fr.xml =================================================================== --- trunk/nuiton-rss/src/site/site_fr.xml (rev 0) +++ trunk/nuiton-rss/src/site/site_fr.xml 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Nuiton Utils :: Nuiton RSS + + $Id$ + $HeadURL$ + %% + Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> + + +<project name="${project.name}"> + + <bannerLeft> + <name>${project.name}</name> + <href>index.html</href> + </bannerLeft> + + <body> + + <breadcrumbs> + <item name="${project.name}" href="index.html"/> + </breadcrumbs> + + <menu ref="parent"/> + + <menu name="Utilisateur"> + <item name="Accueil" href="index.html"/> + </menu> + + <menu name="Téléchargement"> + <item + href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}.jar" + name="Librairie (jar)"/> + <item + href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}-javadoc.jar" + name="Javadoc (jar)"/> + <item + href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}-sources.jar" + name="Sources (jar)"/> + </menu> + + <menu ref="reports"/> + + </body> +</project> Property changes on: trunk/nuiton-rss/src/site/site_fr.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSGeneratorHelperTest.java =================================================================== --- trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSGeneratorHelperTest.java (rev 0) +++ trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSGeneratorHelperTest.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,236 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +import java.io.File; +import java.net.MalformedURLException; +import java.text.ParseException; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import com.sun.syndication.feed.synd.SyndCategory; +import com.sun.syndication.feed.synd.SyndEntry; +import com.sun.syndication.feed.synd.SyndFeed; + +/** + * + * @author tony + */ +public class RSSGeneratorHelperTest { + + private static Log log = LogFactory.getLog(RSSGeneratorHelperTest.class); + + static RSSGenerator helper; + static File f; + + @Before + public void setUp() throws Exception { + if (helper == null) { + helper = RSSGenerator.newDefaultInstance(); + } + if (f == null) { + f = getFeedFile(); + } + } + + @Test + public void testCreateFeed() throws Exception { + + Map<Field, Object> values = new HashMap<Field, Object>(); + values.put(Field.NAME, "feedName : " + f.getName()); + values.put(Field.DESCRIPTION, "feedDescription : " + f.getName()); + values.put(Field.LINK, f.toURI().toURL() + ""); + values.put(Field.AUTHOR, "feed author"); + values.put(Field.CATEGORY, Arrays.asList("categorie1","categorie2")); + values.put(Field.TIME, RSSGenerator.DATE_PARSER.format(new Date())); + + Assert.assertFalse(f.exists()); + if (log.isInfoEnabled()) { + log.info("feedFile : " + f); + } + helper.createFeedFile(f.toURI().toURL(), helper.getFormat(), values); + // no lock + Assert.assertFalse(helper.getWriteFileLock(f).exists()); + // file exist + Assert.assertTrue(f.exists()); + + SyndFeed feed = RSSIOUtil.readFeed(f.toURI().toURL()); + + if (log.isDebugEnabled()) { + log.debug(feed); + } + + Assert.assertEquals(feed.getFeedType(), helper.getFormat().getType()); + Assert.assertEquals(feed.getLink(), values.get(Field.LINK)); + Assert.assertEquals(feed.getTitle(), values.get(Field.NAME)); + Assert.assertEquals(feed.getDescription(), values.get(Field.DESCRIPTION)); + Assert.assertEquals(feed.getAuthor(), values.get(Field.AUTHOR)); + List<?> cats = (List<?>) values.get(Field.CATEGORY); + for (Object o : feed.getCategories()) { + SyndCategory cat = (SyndCategory) o; + Assert.assertTrue(cats.contains(cat.getName())); + } + Assert.assertEquals(feed.getPublishedDate(), RSSGenerator.DATE_PARSER.parse((String) values.get(Field.TIME))); + + } + + @Test + public void testCreateFeedAlreadyExisting() throws Exception { + + Map<Field, Object> values = new HashMap<Field, Object>(); + values.put(Field.NAME, "feedName : " + f.getName()); + values.put(Field.DESCRIPTION, "feedDescription : " + f.getName()); + values.put(Field.LINK, f.toURI().toURL() + ""); + values.put(Field.TIME, RSSGenerator.DATE_PARSER.format(new Date())); + + Assert.assertTrue(f.exists()); + + try { + helper.createFeedFile(f.toURI().toURL(), helper.getFormat(), values); + // file already exist, can not reach this code + Assert.fail(); + } catch (IllegalStateException e) { + Assert.assertTrue(true); + } + // no write lock + Assert.assertFalse(helper.getWriteFileLock(f).exists()); + + } + + @Test + public void testAddFeedEntry() throws Exception { + Assert.assertTrue(f.exists()); + Map<Field, Object> values = createEntry(0); + + helper.addItemToFeedFile(f.toURI().toURL(), 2, values); + + SyndFeed feed = RSSIOUtil.readFeed(f.toURI().toURL()); + + List entries = feed.getEntries(); + Assert.assertEquals(1, entries.size()); + + if (log.isDebugEnabled()) { + log.debug(feed); + } + + SyndEntry entry = (SyndEntry) entries.get(0); + + assertEntry(entry, values); + } + + @Test + public void testAddFeedEntryToMax() throws Exception { + + Assert.assertTrue(f.exists()); + SyndFeed feed = RSSIOUtil.readFeed(f.toURI().toURL()); + + List entries = feed.getEntries(); + Assert.assertEquals(1, entries.size()); + SyndEntry firsEntry = (SyndEntry) entries.get(0); + + Map<Field, Object> values; + + int nbMaxEntries = 10; + + for (int i = 1; i < nbMaxEntries; i++) { + values = createEntry(i); + helper.addItemToFeedFile(f.toURI().toURL(), nbMaxEntries, values); + feed = RSSIOUtil.readFeed(f.toURI().toURL()); + + entries = feed.getEntries(); + Assert.assertEquals(i + 1, entries.size()); + + SyndEntry entry = (SyndEntry) entries.get(i); + + assertEntry(entry, values); + } + + // feed file contains max items + + values = createEntry(nbMaxEntries); + + helper.addItemToFeedFile(f.toURI().toURL(), nbMaxEntries, values); + + feed = RSSIOUtil.readFeed(f.toURI().toURL()); + + entries = feed.getEntries(); + + Assert.assertEquals(nbMaxEntries, entries.size()); + + SyndEntry entry = (SyndEntry) entries.get(nbMaxEntries - 1); + + assertEntry(entry, values); + + // check orginal first entry is no more present + entry = (SyndEntry) entries.get(0); + Assert.assertFalse(firsEntry.getTitle().equals(entry.getTitle())); + } + + @Test + public void testCleanFile() throws Exception { + try { + Assert.assertNotNull(f); + Assert.assertTrue(f.exists()); + // lock is delete + Assert.assertFalse(helper.getWriteFileLock(f).exists()); + } finally { + if (f != null) { + f.deleteOnExit(); + } + } + } + + protected void assertEntry(SyndEntry entry, Map<Field, Object> values) throws ParseException { + Assert.assertEquals(entry.getLink(), values.get(Field.LINK)); + Assert.assertEquals(entry.getTitle(), values.get(Field.NAME)); + Assert.assertEquals(entry.getDescription().getValue(), values.get(Field.DESCRIPTION)); + Assert.assertEquals(entry.getAuthor(), values.get(Field.AUTHOR)); + Assert.assertEquals(entry.getPublishedDate(), RSSGenerator.DATE_PARSER.parse((String) values.get(Field.TIME))); + } + + protected File getFeedFile() { + return helper.getFeedFile(getClass().getSimpleName() + "-" + System.nanoTime()); + } + + protected Map<Field, Object> createEntry(int number) throws MalformedURLException { + Map<Field, Object> values = new HashMap<Field, Object>(); + values.put(Field.NAME, "entryName : " + f.getName() + "-" + number); + values.put(Field.DESCRIPTION, "entryDescription : " + f.getName() + "-" + number); + values.put(Field.AUTHOR, "author-" + number); + values.put(Field.LINK, f.toURI().toURL() + "/entry-" + number); + values.put(Field.TIME, RSSGenerator.DATE_PARSER.format(new Date())); + return values; + } + +} Property changes on: trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSGeneratorHelperTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSTest.java =================================================================== --- trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSTest.java (rev 0) +++ trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSTest.java 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,112 @@ +/* + * #%L + * Nuiton Utils :: Nuiton RSS + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.rss; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.beanutils.BeanUtils; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * + * @author poussin + */ +public class RSSTest { + + @Test + public void testBeanUtils() throws Exception { +// RSSConfig.class.getField("TIME_FORCE_RETRIEVED").set(null, 10); + System.out.println("TIME:" + RSSConfig.TIME_FORCE_RETRIEVED); + System.out.println("RENDER:" + RSSConfig.DEFAULT_RENDERER_CLASS); + BeanUtils.setProperty(new RSSConfig(), "TIME_FORCE_RETRIEVED", "10"); + BeanUtils.setProperty(new RSSConfig(), "DEFAULT_RENDERER_CLASS", FeedRenderer.class.getName()); + System.out.println("TIME:" + RSSConfig.TIME_FORCE_RETRIEVED); + System.out.println("RENDER:" + RSSConfig.DEFAULT_RENDERER_CLASS); + Assert.assertEquals("java.lang.String", BeanUtils.getProperty("Object", "class.name")); + } + + @Test + public void testCleaner() throws Exception { + String s = "debut<Script src='toto.js'>et du script</scRipt>milieu<scripT>encore du code\n</script>fin"; + + HTMLCleaner cleaner = new HTMLScriptCleaner(); + Assert.assertEquals("debutmilieufin", cleaner.clean(s)); + } + + @Test + public void testRendererConfig() throws Exception { + FeedRendererConfig c = new FeedRendererConfig("indat-ndat"); + + List<Field> l1 = new ArrayList<Field>(); + l1.add(Field.IMAGE); + l1.add(Field.NAME); + l1.add(Field.DESCRIPTION); + l1.add(Field.AUTHOR); + l1.add(Field.TIME); + + List<Field> l2 = new ArrayList<Field>(); + l2.add(Field.NAME); + l2.add(Field.DESCRIPTION); + l2.add(Field.AUTHOR); + l2.add(Field.TIME); + + Assert.assertEquals(l1, c.getFeedFieldOrder()); + Assert.assertEquals(l2, c.getItemFieldOrder()); + Assert.assertEquals("indat-ndat", c.getString()); + } + + /** + * Test of getHTML method, of class RSSHelper. + * TODO do the test, for the moment, do not launch it... + * @throws Exception if any pb + */ + @Ignore + public void testGetHTML() throws Exception { + System.out.println("getHTML"); + String feedName = "http://localhost/rss/rss_1.0.xml"; + String feedRepr = "n-ndat"; + int nbItem = -1; + RSSHelper instance = new RSSHelper(); + String expResult = ""; + String result = instance.getHTML(feedName, feedRepr, nbItem,false); + System.out.println("***" + result); + result = instance.getHTML(feedName, feedRepr, nbItem,false); + System.out.println("***" + result); + + Thread.sleep(2000); + + result = instance.getHTML(feedName, feedRepr, nbItem,false); + System.out.println("***" + result); + result = instance.getHTML(feedName, feedRepr, nbItem,false); + System.out.println("***" + result); + // assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. +// fail("The test case is a prototype."); + } + +} Property changes on: trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-rss/src/test/java/resources/log4j.properties =================================================================== --- trunk/nuiton-rss/src/test/java/resources/log4j.properties (rev 0) +++ trunk/nuiton-rss/src/test/java/resources/log4j.properties 2010-12-30 11:25:14 UTC (rev 2001) @@ -0,0 +1,31 @@ +### +# #%L +# Nuiton Utils :: Nuiton RSS +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin +# %% +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser 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 Lesser Public License for more details. +# +# You should have received a copy of the GNU General Lesser Public +# License along with this program. If not, see +# <http://www.gnu.org/licenses/lgpl-3.0.html>. +# #L% +### +# Global logging configuration +log4j.rootLogger=DEBUG, stdout + +# Console output... +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n Property changes on: trunk/nuiton-rss/src/test/java/resources/log4j.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-12-30 10:43:20 UTC (rev 2000) +++ trunk/pom.xml 2010-12-30 11:25:14 UTC (rev 2001) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2004 - 2010 CodeLutin + Copyright (C) 2004 - 2010 CodeLutin, Tony Chemit %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -43,8 +43,9 @@ <modules> <module>nuiton-utils</module> + <module>nuiton-validator</module> <module>nuiton-utils-extra</module> - <module>nuiton-validator</module> + <module>nuiton-rss</module> </modules> <dependencyManagement> @@ -103,6 +104,33 @@ <version>${aspectwerkzVersion}</version> </dependency> + <dependency> + <groupId>org.jdom</groupId> + <artifactId>jdom</artifactId> + <version>1.1</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>rome</groupId> + <artifactId>rome</artifactId> + <version>0.9</version> + <scope>compile</scope> + <exclusions> + <exclusion> + <groupId>jdom</groupId> + <artifactId>jdom</artifactId> + </exclusion> + </exclusions> + </dependency> + + <!--Provided--> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.5</version> + <scope>provided</scope> + </dependency> + </dependencies> </dependencyManagement>