Skip to content

Commit

Permalink
Merge pull request BloomBooks#523 from BloomBooks/BL12833
Browse files Browse the repository at this point in the history
Add download formats query parameter for app-hosted mode (BL-12833)
  • Loading branch information
JohnThomson authored Nov 6, 2023
2 parents c5e7a0c + 062e105 commit f3df089
Show file tree
Hide file tree
Showing 14 changed files with 317 additions and 218 deletions.
29 changes: 21 additions & 8 deletions src/components/BookDetail/ArtifactHelper.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import { Book, ArtifactType } from "../../model/Book";
import { Book } from "../../model/Book";
import {
ArtifactVisibilitySettings,
ArtifactVisibilitySettingsGroup,
} from "../../model/ArtifactVisibilitySettings";
import { IntlShape } from "react-intl";

// The order here matters. See ArtifactVisibilityPanel.getExistingArtifactTypeKeys().
export enum ArtifactType {
pdf = "pdf",
epub = "epub",
bloomReader = "bloomReader",
readOnline = "readOnline",
shellbook = "shellbook",
bloomSource = "bloomSource",
}

export function getArtifactUrl(book: Book, artifactType: ArtifactType): string {
let url;
switch (artifactType) {
Expand Down Expand Up @@ -82,13 +92,13 @@ export function getArtifactDownloadAltText(
defaultMessage:
"Download BloomPUB for Bloom Reader or BloomPub Viewer",
});
case ArtifactType.readOnline:
return "";
case ArtifactType.shellbook:
return l10n.formatMessage({
id: "book.detail.translateButton.download",
defaultMessage: "Download into Bloom Editor",
});
default:
return "";
}
}

Expand Down Expand Up @@ -167,11 +177,14 @@ function getDownloadUrl(book: Book, fileType: string): string | undefined {
const bookName = getBookNamePartOfUrl(book.baseUrl);

if (bookName) {
if (fileType === "bloompub") {
const fileExt =
book.bloomPUBVersion && book.bloomPUBVersion >= 1
? ".bloompub"
: ".bloomd";
if (fileType === "bloompub" || fileType === "bloomSource") {
let fileExt = `.${fileType}`;
if (fileType === "bloompub") {
fileExt =
book.bloomPUBVersion && book.bloomPUBVersion >= 1
? ".bloompub"
: ".bloomd";
}
return harvesterBaseUrl + bookName + fileExt;
}
return harvesterBaseUrl + fileType + "/" + bookName + "." + fileType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import readIcon from "../../../assets/Read.svg";
import translationIcon from "../../../assets/Translation.svg";
import { commonUI } from "../../../theme";
import { useGetLoggedInUser } from "../../../connection/LoggedInUser";
import { ArtifactType } from "../../../model/Book";
import { getArtifactDownloadAltText } from "../ArtifactHelper";
import { ArtifactType, getArtifactDownloadAltText } from "../ArtifactHelper";
import { useIntl } from "react-intl";

const useStyles = makeStyles(() =>
Expand Down
Loading

0 comments on commit f3df089

Please sign in to comment.