Skip to content

Commit

Permalink
add automated MOBI format support to the generator
Browse files Browse the repository at this point in the history
  • Loading branch information
imjagpul committed Dec 30, 2022
1 parent 615b73c commit 639d88a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docker/generator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ RUN apt-get update && apt-get install -y \
libwww-perl \
dos2unix

# Copy kindlegen for Linux from another docker image (for MOBI conversions).
COPY --from=wiltonsr/kindlegen /kindlegen /usr/local/bin/kindlegen

# Copy in code
COPY web /var/www/web
COPY standalone/tools/epubgen2 /var/www/standalone/tools/epubgen2
Expand Down
30 changes: 30 additions & 0 deletions standalone/tools/epubgen2/epubgen2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ COVER_FILENAME=cover.jpg #a jpg file name to serve as cover (it has to exist in
RUBRICS_CODE=1960
RUBRICS=Rubrics%201960
RUBRICS_NAME=
OPTIONAL_KINDLEGEN_PATH=/usr/local/bin/kindlegen #full path to kindlegen executable, if exists, used to convert the resulting EPUB files to MOBI format as well

#constants
#supported rubrics as in Eofficium.pl
Expand Down Expand Up @@ -680,10 +681,39 @@ createEPUBs() {
echo -e "\e[1m:: Finished the creation of EPUBs\e[0m"
}


#################################################################################################################
# MOBI format
#################################################################################################################

convertMOBIMonth() {
EPUB_FILENAME="$EPUBDIR/breviarium$YEAR-$MONTH$RUBRICS_NAME.epub"
$OPTIONAL_KINDLEGEN_PATH $EPUB_FILENAME
}

convertMOBIYear() {
EPUB_FILENAME="$EPUBDIR/breviarium$YEAR$RUBRICS_NAME.epub"
$OPTIONAL_KINDLEGEN_PATH $EPUB_FILENAME
}

createMOBIs() {
if [[ ! -e "$OPTIONAL_KINDLEGEN_PATH" ]]
then
echo "\e[1m:: KindleGen not found in $OPTIONAL_KINDLEGEN_PATH, skipping the conversion to of MOBI format. \e[0m"
else
echo -e "\e[1m:: Starting the conversion to MOBI format for each month\e[0m"
foreachMonthInRange convertMOBIMonth
echo -e "\e[1m:: Starting the conversion to MOBI format for each year\e[0m"
foreachYear convertMOBIYear
echo -e "\e[1m:: Finished the conversion to MOBI format\e[0m"
fi
}

#################################################################################################################
# launch
#################################################################################################################
generateHours #generate the main HTML files
generateTOCs #generate Table Of Content main HTML pages (used by both EPUB and MOBI formats)
generateOPF #generate OPF files (descriptors needed both for the EPUB and for the kindlegen to generate MOBI)
createEPUBs
createMOBIs

0 comments on commit 639d88a

Please sign in to comment.