Commit | Line | Data |
---|---|---|
cd555a1e NR |
1 | package be.nikiroo.gofetch.support; |
2 | ||
3 | import java.io.IOException; | |
cd555a1e | 4 | import java.net.URL; |
3e62b034 | 5 | import java.util.AbstractMap; |
cd555a1e NR |
6 | import java.util.ArrayList; |
7 | import java.util.List; | |
3e62b034 | 8 | import java.util.Map.Entry; |
cd555a1e | 9 | |
cd555a1e NR |
10 | import org.jsoup.nodes.Document; |
11 | import org.jsoup.nodes.Element; | |
12 | import org.jsoup.nodes.Node; | |
cd555a1e | 13 | |
b34d1f35 NR |
14 | /** |
15 | * Support <a href="https://www.toolinux.com/">https://www.toolinux.com/</a>. | |
16 | * | |
17 | * @author niki | |
18 | */ | |
cd555a1e NR |
19 | public class TooLinux extends BasicSupport { |
20 | @Override | |
21 | public String getDescription() { | |
b34d1f35 | 22 | return "TooLinux: Actualité généraliste sur Linux et les logiciels libres"; |
cd555a1e NR |
23 | } |
24 | ||
25 | @Override | |
3e62b034 NR |
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 | } | |
cd555a1e | 32 | |
3e62b034 NR |
33 | @Override |
34 | protected List<Element> getArticles(Document doc) { | |
35 | return doc.getElementsByClass("hentry"); | |
36 | } | |
cd555a1e | 37 | |
3e62b034 NR |
38 | @Override |
39 | protected String getArticleId(Document doc, Element article) { | |
40 | return ""; // We use the date | |
41 | } | |
cd555a1e | 42 | |
3e62b034 NR |
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 | } | |
cd555a1e | 50 | |
3e62b034 NR |
51 | return ""; |
52 | } | |
cd555a1e | 53 | |
3e62b034 NR |
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.text(); | |
cd555a1e NR |
64 | } |
65 | ||
3e62b034 NR |
66 | return ""; |
67 | } | |
cd555a1e | 68 | |
3e62b034 NR |
69 | @Override |
70 | protected String getArticleCategory(Document doc, Element article, | |
71 | String currentCategory) { | |
72 | return ""; | |
73 | } | |
cd555a1e | 74 | |
3e62b034 NR |
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"); | |
cd555a1e | 85 | } |
3e62b034 NR |
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; | |
cd555a1e NR |
162 | } |
163 | } |