From 8ffc8b73e96e80657545f7d713cd065cf7ede786 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sat, 13 Apr 2019 13:52:34 +0200 Subject: [PATCH] allow pagination for search keywords --- src/be/nikiroo/fanfix/reader/cli/CliReader.java | 2 +- src/be/nikiroo/fanfix/searchable/BasicSearchable.java | 7 +++++-- src/be/nikiroo/fanfix/searchable/Fanfiction.java | 9 +++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/be/nikiroo/fanfix/reader/cli/CliReader.java b/src/be/nikiroo/fanfix/reader/cli/CliReader.java index bce2e2a..701ea48 100644 --- a/src/be/nikiroo/fanfix/reader/cli/CliReader.java +++ b/src/be/nikiroo/fanfix/reader/cli/CliReader.java @@ -104,7 +104,7 @@ class CliReader extends BasicReader { @Override public void search(SupportType searchOn, String keywords, int page, int item, boolean sync) throws IOException { - + // TODO } @Override diff --git a/src/be/nikiroo/fanfix/searchable/BasicSearchable.java b/src/be/nikiroo/fanfix/searchable/BasicSearchable.java index ebc5096..979bf5e 100644 --- a/src/be/nikiroo/fanfix/searchable/BasicSearchable.java +++ b/src/be/nikiroo/fanfix/searchable/BasicSearchable.java @@ -96,13 +96,16 @@ public abstract class BasicSearchable { * * @param search * the term to search for + * @param page + * the page to use for result pagination, index is 1-based * * @return a list of stories that satisfy that search term * * @throws IOException * in case of I/O error */ - abstract public List search(String search) throws IOException; + abstract public List search(String search, int page) + throws IOException; /** * Search for the given tag and return a list of stories satisfying this @@ -113,7 +116,7 @@ public abstract class BasicSearchable { *

* URL is guaranteed to be usable, LUID will always be NULL. * - * @param tagId + * @param tag * the tag to search for * @param page * the page to use for result pagination (see diff --git a/src/be/nikiroo/fanfix/searchable/Fanfiction.java b/src/be/nikiroo/fanfix/searchable/Fanfiction.java index 28c0d1b..90f25ee 100644 --- a/src/be/nikiroo/fanfix/searchable/Fanfiction.java +++ b/src/be/nikiroo/fanfix/searchable/Fanfiction.java @@ -141,10 +141,10 @@ class Fanfiction extends BasicSearchable { } @Override - public List search(String search) throws IOException { + public List search(String search, int page) throws IOException { String encoded = URLEncoder.encode(search.toLowerCase(), "utf-8"); return getStories(BASE_URL + "search/?ready=1&type=story&keywords=" - + encoded, null, null); + + encoded + "&ppage=" + page, null, null); } @Override @@ -193,11 +193,8 @@ class Fanfiction extends BasicSearchable { * the document * * @return the number of pages or -1 if unknown - * - * @throws IOException - * in case of I/O errors */ - private int getPages(Document doc) throws IOException { + private int getPages(Document doc) { int pages = -1; if (doc != null) { -- 2.27.0