1 package be
.nikiroo
.gofetch
.support
;
3 import java
.io
.IOException
;
5 import java
.util
.AbstractMap
;
6 import java
.util
.ArrayList
;
8 import java
.util
.Map
.Entry
;
10 import org
.jsoup
.nodes
.Document
;
11 import org
.jsoup
.nodes
.Element
;
12 import org
.jsoup
.nodes
.Node
;
15 * Support <a href="https://www.toolinux.com/">https://www.toolinux.com/</a>.
19 public class TooLinux
extends BasicSupport
{
21 public String
getDescription() {
22 return "TooLinux: Actualité généraliste sur Linux et les logiciels libres";
26 protected List
<Entry
<URL
, String
>> getUrls() throws IOException
{
27 List
<Entry
<URL
, String
>> urls
= new ArrayList
<Entry
<URL
, String
>>();
28 urls
.add(new AbstractMap
.SimpleEntry
<URL
, String
>(new URL(
29 "https://www.toolinux.com/"), ""));
34 protected List
<Element
> getArticles(Document doc
) {
35 return doc
.getElementsByClass("hentry");
39 protected String
getArticleId(Document doc
, Element article
) {
40 return ""; // We use the date
44 protected String
getArticleTitle(Document doc
, Element article
) {
45 Element titleElement
= article
.getElementsByClass("entry-title")
47 if (titleElement
!= null) {
48 return titleElement
.text();
55 protected String
getArticleAuthor(Document doc
, Element article
) {
60 protected String
getArticleDate(Document doc
, Element article
) {
61 Element dateElement
= article
.getElementsByClass("published").first();
62 if (dateElement
!= null) {
63 return dateElement
.attr("title");
70 protected String
getArticleCategory(Document doc
, Element article
,
71 String currentCategory
) {
76 protected String
getArticleDetails(Document doc
, Element article
) {
81 protected String
getArticleIntUrl(Document doc
, Element article
) {
82 Element urlElement
= article
.getElementsByTag("a").first();
83 if (urlElement
!= null) {
84 return urlElement
.absUrl("href");
91 protected String
getArticleExtUrl(Document doc
, Element article
) {
96 protected String
getArticleContent(Document doc
, Element article
) {
97 Element content
= article
.getElementsByClass("introduction").first();
98 if (content
!= null) {
99 return content
.text();
106 protected Element
getFullArticle(Document doc
) {
107 return doc
.getElementById("content");
111 protected List
<Element
> getFullArticleCommentPosts(Document doc
, URL intUrl
) {
116 protected ElementProcessor
getElementProcessorFullArticle() {
117 return new BasicElementProcessor() {
119 public boolean ignoreNode(Node node
) {
120 if ("notes".equals(node
.attr("class"))) {
129 protected List
<Element
> getCommentCommentPosts(Document doc
,
135 protected String
getCommentId(Element post
) {
140 protected String
getCommentAuthor(Element post
) {
145 protected String
getCommentTitle(Element post
) {
150 protected String
getCommentDate(Element post
) {
155 protected Element
getCommentContentElement(Element post
) {
160 protected ElementProcessor
getElementProcessorComment() {