+++ /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-core</artifactId>
- <version>1.0</version>
- <packaging>jar</packaging>
- <name>pnews-core</name>
-
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <maven.compiler.source>1.7</maven.compiler.source>
- <maven.compiler.target>1.7</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"),
- PEOPLE("people");
-
- 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, "redirect?url="+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(), 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
-a {
- text-decoration: none;
- color: black;
-}
-
-body {
- margin: 0 0 0 0;
- padding: 1em 1em 1em 1em;
- background-color: #eee;
- font-family: sans-serif;
-}
-
-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 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
-#!/bin/bash
-
-set -e
-
-SDIR=`dirname $0`
-
-java -classpath rome-1.8.0.jar -jar $SDIR/pnews-1.0.jar
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>pnews</groupId>
- <artifactId>pnews-core</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
<groupId>com.rometools</groupId>
<artifactId>rome</artifactId>
<version>1.8.0</version>
--- /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"),
+ PEOPLE("people");
+
+ 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, "redirect?url="+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(), 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
+a {
+ text-decoration: none;
+ color: black;
+}
+
+body {
+ margin: 0 0 0 0;
+ padding: 1em 1em 1em 1em;
+ background-color: #eee;
+ font-family: sans-serif;
+}
+
+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 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;
+}