allow pagination for search keywords
authorNiki Roo <niki@nikiroo.be>
Sat, 13 Apr 2019 11:52:34 +0000 (13:52 +0200)
committerNiki Roo <niki@nikiroo.be>
Sat, 13 Apr 2019 11:52:34 +0000 (13:52 +0200)
src/be/nikiroo/fanfix/reader/cli/CliReader.java
src/be/nikiroo/fanfix/searchable/BasicSearchable.java
src/be/nikiroo/fanfix/searchable/Fanfiction.java

index bce2e2a456c09c1d3650fe01c7d5bb618273ee43..701ea481e40bf3ae6e2dba8a2d46d69f01b3a35e 100644 (file)
@@ -104,7 +104,7 @@ class CliReader extends BasicReader {
        @Override
        public void search(SupportType searchOn, String keywords, int page,
                        int item, boolean sync) throws IOException {
        @Override
        public void search(SupportType searchOn, String keywords, int page,
                        int item, boolean sync) throws IOException {
-
+               // TODO
        }
 
        @Override
        }
 
        @Override
index ebc509611856b0a6f6d699a64c7a96592a68428a..979bf5ecee225e2656afb8b862adb3c98b7e307f 100644 (file)
@@ -96,13 +96,16 @@ public abstract class BasicSearchable {
         * 
         * @param search
         *            the term to search for
         * 
         * @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
         */
         * 
         * @return a list of stories that satisfy that search term
         * 
         * @throws IOException
         *             in case of I/O error
         */
-       abstract public List<MetaData> search(String search) throws IOException;
+       abstract public List<MetaData> search(String search, int page)
+                       throws IOException;
 
        /**
         * Search for the given tag and return a list of stories satisfying this
 
        /**
         * Search for the given tag and return a list of stories satisfying this
@@ -113,7 +116,7 @@ public abstract class BasicSearchable {
         * <p>
         * URL is guaranteed to be usable, LUID will always be NULL.
         * 
         * <p>
         * 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
         *            the tag to search for
         * @param page
         *            the page to use for result pagination (see
index 28c0d1be02613d8840f67ce55426ea7c71c98ad8..90f25eec473ba3657aac8de15224161b2faace11 100644 (file)
@@ -141,10 +141,10 @@ class Fanfiction extends BasicSearchable {
        }
 
        @Override
        }
 
        @Override
-       public List<MetaData> search(String search) throws IOException {
+       public List<MetaData> 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="
                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
        }
 
        @Override
@@ -193,11 +193,8 @@ class Fanfiction extends BasicSearchable {
         *            the document
         * 
         * @return the number of pages or -1 if unknown
         *            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) {
                int pages = -1;
 
                if (doc != null) {