--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>pnews</groupId>
+ <artifactId>pnews</artifactId>
+ <version>1.0</version>
+ <packaging>jar</packaging>
+ <name>pnews</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.rometools</groupId>
+ <artifactId>rome</artifactId>
+ <version>1.8.0</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.10</version>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>3.0.1</version>
+ <executions>
+ <execution>
+ <id>copy-resources</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${basedir}/target/</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/scripts</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.0.2</version>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <mainClass>pnews.Main</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.6</version>
+ <executions>
+ <execution>
+ <id>fix-shell-permissions</id>
+ <phase>process-resources</phase>
+ <configuration>
+ <target>
+ <chmod file="target/pnews.sh" perm="755"/>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+package pnews;
+
+import java.util.List;
+
+import com.rometools.rome.feed.synd.SyndEntry;
+import com.rometools.rome.feed.synd.SyndFeed;
+
+public class HTML {
+ private static void appendA(StringBuffer buf, String child, String href) {
+ buf.append("<a href='");
+ buf.append(href);
+ buf.append("'>");
+ buf.append(child);
+ buf.append("</a>");
+ }
+
+ private static void appendDiv(StringBuffer buf, String child) {
+ buf.append("<div>");
+ buf.append(child);
+ buf.append("</div>\n");
+ }
+
+ private static void append(StringBuffer buf, SyndEntry entry) {
+ buf.append("<div>");
+ appendA(buf, entry.getTitle(), entry.getLink());
+ buf.append("</div>\n");
+
+ appendDiv(buf, entry.getPublishedDate().toString());
+ appendDiv(buf, entry.getDescription().getValue());
+ }
+
+ public static void append(StringBuffer buf, SyndFeed feed) {
+ for (SyndEntry e: feed.getEntries()) {
+ append(buf, e);
+ }
+ }
+
+ public static String toHTML(List<SyndFeed> feeds) {
+ StringBuffer buf;
+
+ buf = new StringBuffer();
+ buf.append("<!DOCTYPE html>\n");
+ buf.append("<html>\n");
+ buf.append("<head>\n");
+ buf.append("<meta charset=\"UTF-8\">\n");
+ buf.append("</head>\n");
+ buf.append("<body>\n");
+
+ for (SyndFeed e: feeds)
+ append(buf, e);
+
+ buf.append("</body>\n");
+ buf.append("</html>\n");
+
+ return buf.toString();
+ }
+}
--- /dev/null
+package pnews;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.rometools.rome.feed.synd.SyndCategory;
+import com.rometools.rome.feed.synd.SyndFeed;
+import com.rometools.rome.io.FeedException;
+import com.rometools.rome.io.SyndFeedInput;
+import com.rometools.rome.io.XmlReader;
+
+public class Main {
+ private static void println(SyndFeed feed) {
+ System.out.println(feed.getTitle());
+ for (SyndCategory cat: feed.getCategories()) {
+ System.out.println(cat.getName());
+ }
+ System.out.println(feed.getFeedType());
+ }
+
+ public static void main(String[] args) throws IllegalArgumentException, FeedException, IOException {
+ URL url;
+ String html;
+ List<SyndFeed> feeds;
+ SyndFeed feed;
+ String[] urls = new String[] {
+ "http://www.france24.com/fr/france/rss",
+ "https://www.lesechos.fr/rss/rss_une_titres.xml"
+ };
+
+ System.out.println("pnews");
+
+ feeds = new ArrayList<>(urls.length);
+ for (String u: urls) {
+ url = new URL(u);
+
+ try (XmlReader reader = new XmlReader(url)) {
+ feed = new SyndFeedInput().build(reader);
+ println(feed);
+ feeds.add(feed);
+ };
+ }
+
+
+ html = HTML.toHTML(feeds);
+
+ try (BufferedWriter writer = Files.newBufferedWriter(new File("pnews.html").toPath(), StandardCharsets.UTF_8)) {
+ writer.write(html);
+ }
+
+
+ System.out.println("done");
+ }
+}
\ No newline at end of file
--- /dev/null
+#!/bin/bash
+
+set -e
+
+SDIR=`dirname $0`
+
+java -classpath rome-1.8.0.jar -jar $SDIR/pnews-1.0.jar