Fix some IDs and update utils
[gofetch.git] / src / be / nikiroo / gofetch / support / TooLinux.java
... / ...
CommitLineData
1package be.nikiroo.gofetch.support;
2
3import java.io.IOException;
4import java.net.URL;
5import java.util.AbstractMap;
6import java.util.ArrayList;
7import java.util.List;
8import java.util.Map.Entry;
9
10import org.jsoup.nodes.Document;
11import org.jsoup.nodes.Element;
12import org.jsoup.nodes.Node;
13
14/**
15 * Support <a href="https://www.toolinux.com/">https://www.toolinux.com/</a>.
16 *
17 * @author niki
18 */
19public class TooLinux extends BasicSupport {
20 @Override
21 public String getDescription() {
22 return "TooLinux: Actualité généraliste sur Linux et les logiciels libres";
23 }
24
25 @Override
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/"), ""));
30 return urls;
31 }
32
33 @Override
34 protected List<Element> getArticles(Document doc) {
35 return doc.getElementsByClass("hentry");
36 }
37
38 @Override
39 protected String getArticleId(Document doc, Element article) {
40 return ""; // We use the date
41 }
42
43 @Override
44 protected String getArticleTitle(Document doc, Element article) {
45 Element titleElement = article.getElementsByClass("entry-title")
46 .first();
47 if (titleElement != null) {
48 return titleElement.text();
49 }
50
51 return "";
52 }
53
54 @Override
55 protected String getArticleAuthor(Document doc, Element article) {
56 return "";
57 }
58
59 @Override
60 protected String getArticleDate(Document doc, Element article) {
61 Element dateElement = article.getElementsByClass("published").first();
62 if (dateElement != null) {
63 return dateElement.attr("title");
64 }
65
66 return "";
67 }
68
69 @Override
70 protected String getArticleCategory(Document doc, Element article,
71 String currentCategory) {
72 return "";
73 }
74
75 @Override
76 protected String getArticleDetails(Document doc, Element article) {
77 return "";
78 }
79
80 @Override
81 protected String getArticleIntUrl(Document doc, Element article) {
82 Element urlElement = article.getElementsByTag("a").first();
83 if (urlElement != null) {
84 return urlElement.absUrl("href");
85 }
86
87 return "";
88 }
89
90 @Override
91 protected String getArticleExtUrl(Document doc, Element article) {
92 return "";
93 }
94
95 @Override
96 protected String getArticleContent(Document doc, Element article) {
97 Element content = article.getElementsByClass("introduction").first();
98 if (content != null) {
99 return content.text();
100 }
101
102 return "";
103 }
104
105 @Override
106 protected Element getFullArticle(Document doc) {
107 return doc.getElementById("content");
108 }
109
110 @Override
111 protected List<Element> getFullArticleCommentPosts(Document doc, URL intUrl) {
112 return null;
113 }
114
115 @Override
116 protected ElementProcessor getElementProcessorFullArticle() {
117 return new BasicElementProcessor() {
118 @Override
119 public boolean ignoreNode(Node node) {
120 if ("notes".equals(node.attr("class"))) {
121 return true;
122 }
123 return false;
124 }
125 };
126 }
127
128 @Override
129 protected List<Element> getCommentCommentPosts(Document doc,
130 Element container) {
131 return null;
132 }
133
134 @Override
135 protected String getCommentId(Element post) {
136 return null;
137 }
138
139 @Override
140 protected String getCommentAuthor(Element post) {
141 return null;
142 }
143
144 @Override
145 protected String getCommentTitle(Element post) {
146 return null;
147 }
148
149 @Override
150 protected String getCommentDate(Element post) {
151 return null;
152 }
153
154 @Override
155 protected Element getCommentContentElement(Element post) {
156 return null;
157 }
158
159 @Override
160 protected ElementProcessor getElementProcessorComment() {
161 return null;
162 }
163}