Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for ebooks #63

Merged
merged 14 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install linux dependencies
run: |
sudo apt-get update && sudo apt-get upgrade
sudo apt-get -y install libreoffice
sudo apt-get -y install libreoffice calibre
- name: Setup ffmpeg
uses: FedericoCarboni/setup-ffmpeg@v3
id: setup-ffmpeg
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ FROM debian:trixie-slim AS release
WORKDIR /

RUN apt-get update \
&& apt-get install -y --no-install-recommends default-jre libreoffice libreoffice-java-common ffmpeg \
&& apt-get install -y --no-install-recommends default-jre libreoffice libreoffice-java-common ffmpeg calibre \
&& apt-get autoremove -y \
&& apt-get purge -y --auto-remove \
&& rm -rf /var/lib/apt/lists/*
Expand Down
5 changes: 4 additions & 1 deletion pkg/files/document_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/danvergara/morphos/pkg/files/documents"
"github.com/danvergara/morphos/pkg/files/ebooks"
)

// DocumentFactory implements the FileFactory interface.
Expand All @@ -28,7 +29,9 @@ func (d *DocumentFactory) NewFile(f string) (File, error) {
return documents.NewXlsx(d.filename), nil
case documents.CSV:
return documents.NewCsv(d.filename), nil
case ebooks.EpubMimeType, ebooks.EPUB:
return ebooks.NewEpub(d.filename), nil
default:
return nil, fmt.Errorf("type file file %s not recognized", f)
return nil, fmt.Errorf("type file %s not recognized", f)
}
}
5 changes: 5 additions & 0 deletions pkg/files/documents/documents.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ const (
XLSX = "xlsx"
XLSXMIMEType = "vnd.openxmlformats-officedocument.spreadsheetml.sheet"

EpubMimeType = "epub+zip"
EPUB = "epub"

imageMimeType = "image/"
imageType = "image"

documentMimeType = "application/"
tesxtMimeType = "text/"
documentType = "document"

ebookType = "ebook"
)
13 changes: 13 additions & 0 deletions pkg/files/documents/documents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ func TestPDFTConvertTo(t *testing.T) {
input input
expected expected
}{
{
name: "pdf to epub",
input: input{
filename: "testdata/bitcoin.pdf",
mimetype: "application/pdf",
targetFileType: "Ebook",
targetFormat: "epub",
documenter: documents.NewPdf("bitcoin.pdf"),
},
expected: expected{
mimetype: "application/zip",
},
},
{
name: "pdf to jpeg",
input: input{
Expand Down
Loading
Loading