From 1a5bfa68ec611bc70c3ac5164cd1ca91633e3138 Mon Sep 17 00:00:00 2001 From: Siddhartha Das Date: Sat, 10 Feb 2018 16:54:58 +0000 Subject: [PATCH] Fixed the issue of cover image being stretched (Issue #19) --- ...m.github.babluboy.bookworm.htmlscripts.txt | 13 +++++++++++++ po/com.github.babluboy.bookworm.pot | 2 +- src/contentHandler.vala | 19 ++++++++++++------- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/data/scripts/com.github.babluboy.bookworm.htmlscripts.txt b/data/scripts/com.github.babluboy.bookworm.htmlscripts.txt index 209b2983..8e85a6c0 100644 --- a/data/scripts/com.github.babluboy.bookworm.htmlscripts.txt +++ b/data/scripts/com.github.babluboy.bookworm.htmlscripts.txt @@ -143,6 +143,19 @@ /* Control text alignment */ text-align: $READING_TEXT_ALIGN; } + + /* Re-size and center cover images for the title page (first or second page)*/ + $TITLE_PAGE_IMAGE { + margin-top: auto !important; + margin-bottom: auto !important; + margin-left: auto !important; + margin-right: auto !important; + width:auto; + height:auto; + max-width:50vh !important; + max-height:70vh !important; + } + /* Set style for two page view */ .two_page { -webkit-column-count: 2; diff --git a/po/com.github.babluboy.bookworm.pot b/po/com.github.babluboy.bookworm.pot index 44201339..253e2f5a 100644 --- a/po/com.github.babluboy.bookworm.pot +++ b/po/com.github.babluboy.bookworm.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-02-09 21:42+0000\n" +"POT-Creation-Date: 2018-02-10 16:45+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/src/contentHandler.vala b/src/contentHandler.vala index 39a45248..f7a65fa9 100644 --- a/src/contentHandler.vala +++ b/src/contentHandler.vala @@ -130,6 +130,11 @@ public class BookwormApp.contentHandler { StringBuilder pageContent = new StringBuilder(pageContentStr); BookwormApp.Bookworm.onLoadJavaScript.assign("onload=\""); string currentBookwormScripts = BookwormApp.Bookworm.bookwormScripts; + + //For the Title Page (first or second page), resize height and width of images + if(aBook.getBookPageNumber() < 2 && (pageContentStr.contains("image") || pageContentStr.contains("img"))) { + currentBookwormScripts = currentBookwormScripts.replace("$TITLE_PAGE_IMAGE", "* "); + } //Set background and font colour based on profile string[] profileColorList = settings.list_of_profile_colors.split (","); if(BookwormApp.Constants.BOOKWORM_READING_MODE[2] == BookwormApp.Bookworm.settings.reading_profile){ @@ -237,14 +242,14 @@ public class BookwormApp.contentHandler { //add onload javascript and css to body tag if(pageContent.str.index_of("" + + pageContent.assign(currentBookwormScripts + "" + pageContent.str + ""); } //debug(pageContent.str); @@ -256,14 +261,14 @@ public class BookwormApp.contentHandler { int searchResultCount = 1; BookwormApp.Bookworm.searchResultsMap.clear(); //execute search - bookSearchResults.assign(BookwormApp.Utils.execute_sync_command(BookwormApp.Constants.SEARCH_SCRIPT_LOCATION + - " \"" + BookwormApp.Bookworm.aContentFileToBeSearched.str + "\" \"" + + bookSearchResults.assign(BookwormApp.Utils.execute_sync_command(BookwormApp.Constants.SEARCH_SCRIPT_LOCATION + + " \"" + BookwormApp.Bookworm.aContentFileToBeSearched.str + "\" \"" + BookwormApp.AppHeaderBar.headerSearchBar.get_text() + "\"")); //process search results if(bookSearchResults.str.strip().length > 0){ string[] individualLines = bookSearchResults.str.strip().split ("\n",-1); foreach ( string individualLine in individualLines) { - BookwormApp.Bookworm.searchResultsMap.set(searchResultCount.to_string() + BookwormApp.Bookworm.searchResultsMap.set(searchResultCount.to_string() +"~~"+BookwormApp.Bookworm.aContentFileToBeSearched.str, individualLine.strip()); searchResultCount++; }