X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fgofetch%2Fsupport%2FLWN.java;h=08c9d5a91cdc52bc3bbf61e336d6522c8a9f1451;hb=5c056aade2e020276e039f81acba7bcb2b12e87f;hp=e25bc92d519ed0d340b2d99695bfc167164ff5bf;hpb=2527107526aea628df09c3ad53432e9a5480fcd7;p=gofetch.git diff --git a/src/be/nikiroo/gofetch/support/LWN.java b/src/be/nikiroo/gofetch/support/LWN.java index e25bc92..08c9d5a 100644 --- a/src/be/nikiroo/gofetch/support/LWN.java +++ b/src/be/nikiroo/gofetch/support/LWN.java @@ -28,8 +28,7 @@ public class LWN extends BasicSupport { @Override public List list() throws IOException { // TODO: comments + do not get comment for [$] stories - // + update body on getComment (global change, also LinuxToday) - + List list = new ArrayList(); URL url = new URL("https://lwn.net/"); @@ -45,35 +44,33 @@ public class LWN extends BasicSupport { if (listings.size() == 0) { continue; } - + Element listing = listings.get(0); if (listing.children().size() < 2) { continue; } - String title = titles.get(0).text(); String details = listing.children().get(0).text(); String body = ""; // All but the first and two last children - for (int i = 1 ; i < listing.children().size() - 2; i++) { + for (int i = 1; i < listing.children().size() - 2; i++) { Element e = listing.children().get(i); body = body.trim() + " " + e.text().trim(); } body = body.trim(); - + String author = ""; int pos = details.indexOf(" by "); if (pos >= 0) { author = details.substring(pos + " by ".length()).trim(); } - + String date = ""; pos = details.indexOf(" Posted "); if (pos >= 0) { date = details.substring(pos + " Posted ".length()).trim(); } - String id = ""; String intUrl = ""; @@ -83,32 +80,26 @@ public class LWN extends BasicSupport { intUrl = idElem.absUrl("href"); pos = intUrl.indexOf("#Comments"); if (pos >= 0) { - intUrl = intUrl.substring(0, pos -1); + intUrl = intUrl.substring(0, pos - 1); } id = intUrl.replaceAll("[^0-9]", ""); } - list.add(new Story(getType(), id, title, details, intUrl, extUrl, body)); + list.add(new Story(getType(), id, title, details, intUrl, extUrl, + body)); } return list; } @Override - public List getComments(Story story) throws IOException { - List comments = new ArrayList(); - + public void fetch(Story story) throws IOException { /* - URL url = new URL(story.getUrlInternal()); - InputStream in = open(url); - Document doc = DataUtil.load(in, "UTF-8", url.toString()); - Elements listing = doc.getElementsByTag("main"); - if (listing.size() > 0) { - comments.addAll(getComments(listing.get(0))); - } - */ - - return comments; + * URL url = new URL(story.getUrlInternal()); InputStream in = + * open(url); Document doc = DataUtil.load(in, "UTF-8", url.toString()); + * Elements listing = doc.getElementsByTag("main"); if (listing.size() > + * 0) { comments.addAll(getComments(listing.get(0))); } + */ } private List getComments(Element listing) {