Trim details to allow incomplete parts in HTML
[gofetch.git] / src / be / nikiroo / gofetch / support / Pipedot.java
index 1bd5173b331e6e2ee69552efaa77e964a1e3fe20..edbb8047df8f57b18661ff8b15a0ffb62e0f70f2 100644 (file)
@@ -31,11 +31,11 @@ public class Pipedot extends BasicSupport {
                List<Story> list = new ArrayList<Story>();
 
                URL url = new URL("https://pipedot.org/");
-               InputStream in = open(url);
+               InputStream in = downloader.open(url);
                Document doc = DataUtil.load(in, "UTF-8", url.toString());
-               Elements stories = doc.getElementsByClass("story");
-               for (Element story : stories) {
-                       Elements titles = story.getElementsByTag("h1");
+               Elements articles = doc.getElementsByClass("story");
+               for (Element article : articles) {
+                       Elements titles = article.getElementsByTag("h1");
                        if (titles.size() == 0) {
                                continue;
                        }
@@ -43,7 +43,7 @@ public class Pipedot extends BasicSupport {
                        Element title = titles.get(0);
 
                        String id = "";
-                       for (Element idElem : story.getElementsByTag("a")) {
+                       for (Element idElem : article.getElementsByTag("a")) {
                                if (idElem.attr("href").startsWith("/pipe/")) {
                                        id = idElem.attr("href").substring("/pipe/".length());
                                        break;
@@ -53,7 +53,7 @@ public class Pipedot extends BasicSupport {
                        String intUrl = null;
                        String extUrl = null;
 
-                       Elements links = story.getElementsByTag("a");
+                       Elements links = article.getElementsByTag("a");
                        if (links.size() > 0) {
                                intUrl = links.get(0).absUrl("href");
                        }
@@ -68,13 +68,13 @@ public class Pipedot extends BasicSupport {
                        }
 
                        String details = "";
-                       Elements detailsElements = story.getElementsByTag("div");
+                       Elements detailsElements = article.getElementsByTag("div");
                        if (detailsElements.size() > 0) {
                                details = detailsElements.get(0).text();
                        }
 
                        String body = "";
-                       for (Element elem : story.children()) {
+                       for (Element elem : article.children()) {
                                String tag = elem.tag().toString();
                                if (!tag.equals("header") && !tag.equals("footer")) {
                                        body = elem.text();
@@ -82,8 +82,8 @@ public class Pipedot extends BasicSupport {
                                }
                        }
 
-                       list.add(new Story(getType(), id, title.text(), details, intUrl,
-                                       extUrl, body));
+                       list.add(new Story(getType(), id, title.text(), "", "", "",
+                                       details, intUrl, extUrl, body));
                }
 
                return list;
@@ -94,7 +94,7 @@ public class Pipedot extends BasicSupport {
                List<Comment> comments = new ArrayList<Comment>();
 
                URL url = new URL(story.getUrlInternal());
-               InputStream in = open(url);
+               InputStream in = downloader.open(url);
                Document doc = DataUtil.load(in, "UTF-8", url.toString());
                Elements listing = doc.getElementsByTag("main");
                if (listing.size() > 0) {
@@ -142,12 +142,7 @@ public class Pipedot extends BasicSupport {
        }
 
        private List<String> toLines(Element element) {
-               return toLines(element, new QuoteProcessor() {
-                       @Override
-                       public String processText(String text) {
-                               return text;
-                       }
-
+               return toLines(element, new BasicElementProcessor() {
                        @Override
                        public boolean detectQuote(Node node) {
                                if (node instanceof Element) {
@@ -160,11 +155,6 @@ public class Pipedot extends BasicSupport {
 
                                return false;
                        }
-
-                       @Override
-                       public boolean ignoreNode(Node node) {
-                               return false;
-                       }
                });
        }
 }