Skip to content

Commit

Permalink
Fixed the issue of cover image being stretched (Issue #19)
Browse files Browse the repository at this point in the history
  • Loading branch information
babluboy committed Feb 10, 2018
1 parent ca7edce commit 1a5bfa6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
13 changes: 13 additions & 0 deletions data/scripts/com.github.babluboy.bookworm.htmlscripts.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion po/com.github.babluboy.bookworm.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down
19 changes: 12 additions & 7 deletions src/contentHandler.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -237,14 +242,14 @@ public class BookwormApp.contentHandler {

//add onload javascript and css to body tag
if(pageContent.str.index_of("<BODY") != -1){
pageContent.assign(pageContent.str.replace("<BODY", currentBookwormScripts + "<BODY " +
pageContent.assign(pageContent.str.replace("<BODY", currentBookwormScripts + "<BODY " +
BookwormApp.Bookworm.onLoadJavaScript.str));
}else if (pageContent.str.index_of("<body") != -1){
pageContent.assign(pageContent.str.replace("<body", currentBookwormScripts + "<body " +
pageContent.assign(pageContent.str.replace("<body", currentBookwormScripts + "<body " +
BookwormApp.Bookworm.onLoadJavaScript.str));
}else{
pageContent.assign(currentBookwormScripts + "<BODY " +
BookwormApp.Bookworm.onLoadJavaScript.str + ">" +
pageContent.assign(currentBookwormScripts + "<BODY " +
BookwormApp.Bookworm.onLoadJavaScript.str + ">" +
pageContent.str + "</BODY>");
}
//debug(pageContent.str);
Expand All @@ -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++;
}
Expand Down

0 comments on commit 1a5bfa6

Please sign in to comment.