+++ /dev/null
-target
-.classpath
-.project
--- /dev/null
+target
+.classpath
+.project
--- /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>
+ <dependency>
+ <groupId>org.jsoup</groupId>
+ <artifactId>jsoup</artifactId>
+ <version>1.10.3</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
+#!/bin/bash
+
+set -e
+
+DEST_DIR=`realpath $1`
+TMP_DIR="/tmp/$$.tmp"
+
+mkdir -p "$TMP_DIR"
+
+cd $TMP_DIR
+git clone https://git.wpitchoune.net/pnews.git
+
+cd pnews
+
+mvn clean install
+
+target/pnews.sh
+
+cp -p *html style.css $DEST_DIR
+
+rm -rf "$TMP_DIR"
--- /dev/null
+package pnews;
+
+import java.util.Date;
+
+public class Article {
+ public final String title;
+ public final String description;
+ public final String thumbnail;
+ public final String link;
+ public final Category category;
+ public final Date publicationDate;
+ public final String website;
+
+ public Article(String link, Category category, String title, String description, String thumbnail, Date publicationDate, String website) {
+ this.link = link;
+ this.title = title;
+ this.description = description;
+ this.thumbnail = thumbnail;
+ this.category = category;
+ this.publicationDate = publicationDate;
+ this.website = website;
+ }
+}
--- /dev/null
+package pnews;
+
+public enum Category {
+ TOP("top"),
+ FRANCE("france"),
+ SPORT("sport"),
+ EUROPE("europe"),
+ ECO("eco"),
+ ESSONNE("essonne"),
+ TECHNOLOGIE("technologie");
+
+ private final String id;
+
+ private Category(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+}
--- /dev/null
+package pnews;
+
+import java.util.List;
+
+public class HTML {
+ private static void appendA(StringBuffer buf, String child, String href, String cl) {
+ buf.append("<a href='");
+ buf.append(href);
+ buf.append("'");
+ if (cl != null) {
+ buf.append(" class='");
+ buf.append(cl);
+ buf.append('\'');
+ }
+ 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 appendP(StringBuffer buf, String child) {
+ buf.append("<p>");
+ buf.append(child);
+ buf.append("</p>\n");
+ }
+
+ private static void append(StringBuffer buf, Article a) {
+ buf.append("<div class='article'>\n");
+
+ buf.append("<h2>");
+ if (a.thumbnail != null) {
+ buf.append("<img class='left' src='");
+ buf.append(a.thumbnail);
+ buf.append("'/>\n");
+ }
+ appendA(buf, a.title, a.link, null);
+ buf.append("</h2>\n");
+
+ buf.append("<div class='article-info'>" + a.website + " - " + a.publicationDate + "</div>");
+
+ if (a.description != null) {
+ buf.append("<p>");
+ buf.append(a.description);
+ buf.append("</p>");
+ }
+
+ buf.append("</div>\n");
+ }
+
+ private static void appendMenu(StringBuffer buf, Category catActive) {
+ String cl;
+
+ buf.append("<nav>\n");
+ buf.append("<ul>\n");
+
+ for (Category cat: Category.values()) {
+ buf.append("<li>");
+
+ if (cat.equals(catActive))
+ cl = "active";
+ else
+ cl = null;
+
+ appendA(buf, cat.getId(), cat.getId() + ".html", cl);
+ buf.append("</li>");
+ }
+
+ buf.append("</ul>\n");
+ buf.append("</nav>\n");
+ }
+
+ public static String toHTML(List<Article> articles, Category catActive) {
+ StringBuffer buf;
+
+ buf = new StringBuffer();
+ buf.append("<!DOCTYPE html>\n");
+ buf.append("<html lang='fr'>\n");
+ buf.append("<head>\n");
+ buf.append("<meta charset=\"UTF-8\">\n");
+ buf.append("<link rel='stylesheet' href='style.css' />\n");
+ buf.append("<title>PNews</title>\n");
+ buf.append("</head>\n");
+ buf.append("<body>\n");
+
+ appendMenu(buf, catActive);
+
+ for (Article e: articles)
+ 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.MalformedURLException;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+
+import org.jsoup.Jsoup;
+
+import com.rometools.rome.feed.synd.SyndEnclosure;
+import com.rometools.rome.feed.synd.SyndEntry;
+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 final Logger LOG = Logger.getLogger(Main.class.getName());
+
+ static {
+ TrustManager[] mgrs;
+ SSLContext sc;
+
+ mgrs = new TrustManager[]{
+ new X509TrustManager() {
+ public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+
+ public void checkClientTrusted(X509Certificate[] certs, String authType) {
+ }
+
+ public void checkServerTrusted(X509Certificate[] certs, String authType) {
+ }
+ }
+ };
+
+ try {
+ sc = SSLContext.getInstance("SSL");
+
+ sc.init(null, mgrs, new java.security.SecureRandom());
+ SSLContext.setDefault(sc);
+ } catch (NoSuchAlgorithmException | KeyManagementException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static void addArticles(Category cat, SyndFeed feed, List<Article> articles) {
+ String thumbnail;
+ String desc;
+ Date date;
+
+ for (SyndEntry entry: feed.getEntries()) {
+ thumbnail = null;
+ for (SyndEnclosure e: entry.getEnclosures()) {
+ if (e.getType().startsWith("image/"))
+ thumbnail = e.getUrl();
+ break;
+ }
+
+ if (entry.getDescription() != null) {
+ desc = Jsoup.parse(entry.getDescription().getValue()).text();
+ } else {
+ desc = null;
+ LOG.severe("No description for " + feed.getTitle() + " - " + entry.getTitle());
+ }
+
+ date = entry.getPublishedDate();
+ if (date == null)
+ date = entry.getUpdatedDate();
+
+ articles.add(new Article(entry.getLink(),
+ cat,
+ entry.getTitle(),
+ desc,
+ thumbnail,
+ date,
+ feed.getTitle()));
+ }
+ }
+
+ private static SyndFeed getSyndFeed(String u) throws IllegalArgumentException, FeedException, MalformedURLException, IOException {
+ try (XmlReader reader = new XmlReader(new URL(u))) {
+ return new SyndFeedInput().build(reader);
+ }
+ }
+
+ private static Map<Category, String[]> getFeeds() {
+ Map<Category, String[]> result;
+
+ result = new HashMap<>();
+
+ result.put(Category.TOP,
+ new String[] {
+ "http://www.francetvinfo.fr/titres.rss",
+ "http://www.france24.com/fr/actualites/rss",
+ "https://www.franceinter.fr/rss/a-la-une.xml",
+ "http://www.rfi.fr/general/rss",
+ "http://www.cnews.fr/rss/une",
+ "http://www.bfmtv.com/rss/info/flux-rss/flux-toutes-les-actualites/"
+ });
+
+ result.put(Category.SPORT,
+ new String[] { "http://www.france24.com/fr/sports/rss" });
+
+ result.put(Category.FRANCE,
+ new String[] { "http://www.france24.com/fr/france/rss",
+ "http://www.rfi.fr/france/rss"});
+
+ result.put(Category.EUROPE,
+ new String[] { "http://www.france24.com/fr/europe/rss" });
+
+ result.put(Category.ECO,
+ new String[] { "http://www.france24.com/fr/economie/rss",
+ "http://www.rfi.fr/economie/rss" });
+
+ result.put(Category.ESSONNE,
+ new String[] { "https://www.essonneinfo.fr/feed/" });
+
+ result.put(Category.TECHNOLOGIE,
+ new String[] { "http://feeds.feedburner.com/lesnumeriques/news",
+ "http://www.zdnet.fr/feeds/rss/actualites/"});
+
+ return result;
+ }
+
+ private static List<Article> getArticles(Category cat) throws IllegalArgumentException, MalformedURLException, FeedException, IOException {
+ List<Article> articles;
+ String[] feeds;
+ Set<String> links;
+
+ articles = new ArrayList<>();
+
+ feeds = getFeeds().get(cat);
+
+ if (feeds != null)
+ for (String str: feeds)
+ addArticles(cat, getSyndFeed(str), articles);
+ else
+ LOG.severe("No feed for category " + cat);
+
+ links = new HashSet<>(articles.size());
+ for (Article a: articles) {
+ if (links.contains(a.link))
+ LOG.severe(a.link + "is not uniq");
+ else
+ links.add(a.link);
+ }
+
+ articles.sort(new Comparator<Article> () {
+ @Override
+ public int compare(Article o1, Article o2) {
+ return o2.publicationDate.compareTo(o1.publicationDate);
+ }
+ });
+
+ return articles;
+ }
+
+ private static void writeHTMLFile(Category cat) throws IllegalArgumentException, MalformedURLException, FeedException, IOException {
+ List<Article> articles;
+ String html;
+ File f;
+
+ articles = getArticles(cat);
+
+ html = HTML.toHTML(articles, cat);
+
+ f = new File(cat.getId() + ".html");
+
+ try (BufferedWriter writer = Files.newBufferedWriter(f.toPath(), StandardCharsets.UTF_8)) {
+ writer.write(html);
+ }
+ }
+
+ public static void main(String[] args) throws IllegalArgumentException, FeedException, IOException {
+ System.out.println("pnews");
+
+ for (Category cat: Category.values())
+ writeHTMLFile(cat);
+
+ 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
--- /dev/null
+a {
+ text-decoration: none;
+ color: black;
+}
+
+body {
+ margin: 0 0 0 0;
+ padding: 1em 1em 1em 1em;
+ background-color: #eee;
+ font-family: sans-serif;
+ font-size: 100%;
+}
+
+nav {
+ font-size: 125%;
+ margin: 0 0 0 0;
+ padding: 0 0 0 0;
+}
+
+a.active {
+ text-decoration: none;
+ border-bottom: 4px solid black;
+}
+
+div {
+ margin: 0em 0em 0em 0em;
+ padding: 0 0 0 0;
+}
+
+div.article {
+ margin-bottom: 1em;
+}
+
+.article-info {
+ font-size: 80%;
+ color: #bbb;
+}
+
+img {
+ margin: 0em 1em 1em 0em;
+ padding: 0 0 0 0;
+ width: 8em;
+}
+
+p {
+ margin: 1em 1em 1em 1em;
+ padding: 0 0 0 0;
+}
+
+.left {
+ float: left;
+}
+
+h2 {
+ clear: left;
+ margin: 0 0 0 0;
+ padding: 0 0 0 0;
+}
+
+nav {
+ font-size: 120%;
+}
+
+nav ul {
+ list-style-type: none;
+ padding: 0 0 0 0;
+}
+
+nav ul li {
+ display: inline;
+ margin: 0em 1em 0 0;
+ padding: 0 0 0 0;
+ text-transform: uppercase;
+}
+++ /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>
- <dependency>
- <groupId>org.jsoup</groupId>
- <artifactId>jsoup</artifactId>
- <version>1.10.3</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
-#!/bin/bash
-
-set -e
-
-DEST_DIR=`realpath $1`
-TMP_DIR="/tmp/$$.tmp"
-
-mkdir -p "$TMP_DIR"
-
-cd $TMP_DIR
-git clone https://git.wpitchoune.net/pnews.git
-
-cd pnews
-
-mvn clean install
-
-target/pnews.sh
-
-cp -p *html style.css $DEST_DIR
-
-rm -rf "$TMP_DIR"
+++ /dev/null
-package pnews;
-
-import java.util.Date;
-
-public class Article {
- public final String title;
- public final String description;
- public final String thumbnail;
- public final String link;
- public final Category category;
- public final Date publicationDate;
- public final String website;
-
- public Article(String link, Category category, String title, String description, String thumbnail, Date publicationDate, String website) {
- this.link = link;
- this.title = title;
- this.description = description;
- this.thumbnail = thumbnail;
- this.category = category;
- this.publicationDate = publicationDate;
- this.website = website;
- }
-}
+++ /dev/null
-package pnews;
-
-public enum Category {
- TOP("top"),
- FRANCE("france"),
- SPORT("sport"),
- EUROPE("europe"),
- ECO("eco"),
- ESSONNE("essonne"),
- TECHNOLOGIE("technologie");
-
- private final String id;
-
- private Category(String id) {
- this.id = id;
- }
-
- public String getId() {
- return id;
- }
-}
+++ /dev/null
-package pnews;
-
-import java.util.List;
-
-public class HTML {
- private static void appendA(StringBuffer buf, String child, String href, String cl) {
- buf.append("<a href='");
- buf.append(href);
- buf.append("'");
- if (cl != null) {
- buf.append(" class='");
- buf.append(cl);
- buf.append('\'');
- }
- 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 appendP(StringBuffer buf, String child) {
- buf.append("<p>");
- buf.append(child);
- buf.append("</p>\n");
- }
-
- private static void append(StringBuffer buf, Article a) {
- buf.append("<div class='article'>\n");
-
- buf.append("<h2>");
- if (a.thumbnail != null) {
- buf.append("<img class='left' src='");
- buf.append(a.thumbnail);
- buf.append("'/>\n");
- }
- appendA(buf, a.title, a.link, null);
- buf.append("</h2>\n");
-
- buf.append("<div class='article-info'>" + a.website + " - " + a.publicationDate + "</div>");
-
- if (a.description != null) {
- buf.append("<p>");
- buf.append(a.description);
- buf.append("</p>");
- }
-
- buf.append("</div>\n");
- }
-
- private static void appendMenu(StringBuffer buf, Category catActive) {
- String cl;
-
- buf.append("<nav>\n");
- buf.append("<ul>\n");
-
- for (Category cat: Category.values()) {
- buf.append("<li>");
-
- if (cat.equals(catActive))
- cl = "active";
- else
- cl = null;
-
- appendA(buf, cat.getId(), cat.getId() + ".html", cl);
- buf.append("</li>");
- }
-
- buf.append("</ul>\n");
- buf.append("</nav>\n");
- }
-
- public static String toHTML(List<Article> articles, Category catActive) {
- StringBuffer buf;
-
- buf = new StringBuffer();
- buf.append("<!DOCTYPE html>\n");
- buf.append("<html lang='fr'>\n");
- buf.append("<head>\n");
- buf.append("<meta charset=\"UTF-8\">\n");
- buf.append("<link rel='stylesheet' href='style.css' />\n");
- buf.append("<title>PNews</title>\n");
- buf.append("</head>\n");
- buf.append("<body>\n");
-
- appendMenu(buf, catActive);
-
- for (Article e: articles)
- 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.MalformedURLException;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Logger;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-
-import org.jsoup.Jsoup;
-
-import com.rometools.rome.feed.synd.SyndEnclosure;
-import com.rometools.rome.feed.synd.SyndEntry;
-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 final Logger LOG = Logger.getLogger(Main.class.getName());
-
- static {
- TrustManager[] mgrs;
- SSLContext sc;
-
- mgrs = new TrustManager[]{
- new X509TrustManager() {
- public java.security.cert.X509Certificate[] getAcceptedIssuers() {
- return null;
- }
-
- public void checkClientTrusted(X509Certificate[] certs, String authType) {
- }
-
- public void checkServerTrusted(X509Certificate[] certs, String authType) {
- }
- }
- };
-
- try {
- sc = SSLContext.getInstance("SSL");
-
- sc.init(null, mgrs, new java.security.SecureRandom());
- SSLContext.setDefault(sc);
- } catch (NoSuchAlgorithmException | KeyManagementException e) {
- e.printStackTrace();
- }
- }
-
- private static void addArticles(Category cat, SyndFeed feed, List<Article> articles) {
- String thumbnail;
- String desc;
- Date date;
-
- for (SyndEntry entry: feed.getEntries()) {
- thumbnail = null;
- for (SyndEnclosure e: entry.getEnclosures()) {
- if (e.getType().startsWith("image/"))
- thumbnail = e.getUrl();
- break;
- }
-
- if (entry.getDescription() != null) {
- desc = Jsoup.parse(entry.getDescription().getValue()).text();
- } else {
- desc = null;
- LOG.severe("No description for " + feed.getTitle() + " - " + entry.getTitle());
- }
-
- date = entry.getPublishedDate();
- if (date == null)
- date = entry.getUpdatedDate();
-
- articles.add(new Article(entry.getLink(),
- cat,
- entry.getTitle(),
- desc,
- thumbnail,
- date,
- feed.getTitle()));
- }
- }
-
- private static SyndFeed getSyndFeed(String u) throws IllegalArgumentException, FeedException, MalformedURLException, IOException {
- try (XmlReader reader = new XmlReader(new URL(u))) {
- return new SyndFeedInput().build(reader);
- }
- }
-
- private static Map<Category, String[]> getFeeds() {
- Map<Category, String[]> result;
-
- result = new HashMap<>();
-
- result.put(Category.TOP,
- new String[] {
- "http://www.francetvinfo.fr/titres.rss",
- "http://www.france24.com/fr/actualites/rss",
- "https://www.franceinter.fr/rss/a-la-une.xml",
- "http://www.rfi.fr/general/rss",
- "http://www.cnews.fr/rss/une",
- "http://www.bfmtv.com/rss/info/flux-rss/flux-toutes-les-actualites/"
- });
-
- result.put(Category.SPORT,
- new String[] { "http://www.france24.com/fr/sports/rss" });
-
- result.put(Category.FRANCE,
- new String[] { "http://www.france24.com/fr/france/rss",
- "http://www.rfi.fr/france/rss"});
-
- result.put(Category.EUROPE,
- new String[] { "http://www.france24.com/fr/europe/rss" });
-
- result.put(Category.ECO,
- new String[] { "http://www.france24.com/fr/economie/rss",
- "http://www.rfi.fr/economie/rss" });
-
- result.put(Category.ESSONNE,
- new String[] { "https://www.essonneinfo.fr/feed/" });
-
- result.put(Category.TECHNOLOGIE,
- new String[] { "http://feeds.feedburner.com/lesnumeriques/news",
- "http://www.zdnet.fr/feeds/rss/actualites/"});
-
- return result;
- }
-
- private static List<Article> getArticles(Category cat) throws IllegalArgumentException, MalformedURLException, FeedException, IOException {
- List<Article> articles;
- String[] feeds;
- Set<String> links;
-
- articles = new ArrayList<>();
-
- feeds = getFeeds().get(cat);
-
- if (feeds != null)
- for (String str: feeds)
- addArticles(cat, getSyndFeed(str), articles);
- else
- LOG.severe("No feed for category " + cat);
-
- links = new HashSet<>(articles.size());
- for (Article a: articles) {
- if (links.contains(a.link))
- LOG.severe(a.link + "is not uniq");
- else
- links.add(a.link);
- }
-
- articles.sort(new Comparator<Article> () {
- @Override
- public int compare(Article o1, Article o2) {
- return o2.publicationDate.compareTo(o1.publicationDate);
- }
- });
-
- return articles;
- }
-
- private static void writeHTMLFile(Category cat) throws IllegalArgumentException, MalformedURLException, FeedException, IOException {
- List<Article> articles;
- String html;
- File f;
-
- articles = getArticles(cat);
-
- html = HTML.toHTML(articles, cat);
-
- f = new File(cat.getId() + ".html");
-
- try (BufferedWriter writer = Files.newBufferedWriter(f.toPath(), StandardCharsets.UTF_8)) {
- writer.write(html);
- }
- }
-
- public static void main(String[] args) throws IllegalArgumentException, FeedException, IOException {
- System.out.println("pnews");
-
- for (Category cat: Category.values())
- writeHTMLFile(cat);
-
- 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
+++ /dev/null
-a {
- text-decoration: none;
- color: black;
-}
-
-body {
- margin: 0 0 0 0;
- padding: 1em 1em 1em 1em;
- background-color: #eee;
- font-family: sans-serif;
- font-size: 100%;
-}
-
-nav {
- font-size: 125%;
- margin: 0 0 0 0;
- padding: 0 0 0 0;
-}
-
-a.active {
- text-decoration: none;
- border-bottom: 4px solid black;
-}
-
-div {
- margin: 0em 0em 0em 0em;
- padding: 0 0 0 0;
-}
-
-div.article {
- margin-bottom: 1em;
-}
-
-.article-info {
- font-size: 80%;
- color: #bbb;
-}
-
-img {
- margin: 0em 1em 1em 0em;
- padding: 0 0 0 0;
- width: 8em;
-}
-
-p {
- margin: 1em 1em 1em 1em;
- padding: 0 0 0 0;
-}
-
-.left {
- float: left;
-}
-
-h2 {
- clear: left;
- margin: 0 0 0 0;
- padding: 0 0 0 0;
-}
-
-nav {
- font-size: 120%;
-}
-
-nav ul {
- list-style-type: none;
- padding: 0 0 0 0;
-}
-
-nav ul li {
- display: inline;
- margin: 0em 1em 0 0;
- padding: 0 0 0 0;
- text-transform: uppercase;
-}