Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneswilm committed Sep 20, 2024
1 parent 9486099 commit 7e2bfee
Show file tree
Hide file tree
Showing 13 changed files with 636 additions and 496 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {EpubBookExporter} from "../../books/exporter/epub"
import {HTMLBookExporter, SingleFileHTMLBookExporter} from "../../books/exporter/html"
import {
HTMLBookExporter,
SingleFileHTMLBookExporter
} from "../../books/exporter/html"
import {LatexBookExporter} from "../../books/exporter/latex"
import {commitFile, commitZipContents} from "./tools"

Expand All @@ -10,13 +13,10 @@ export class EpubBookGithubExporter extends EpubBookExporter {
}

download(blob) {
return () => commitFile(
this.repo,
blob,
"book.epub"
).then(
response => [response]
)
return () =>
commitFile(this.repo, blob, "book.epub").then(response => [
response
])
}
}

Expand All @@ -27,13 +27,14 @@ export class UnpackedEpubBookGithubExporter extends EpubBookExporter {
}

createZip() {
return () => commitZipContents(
this.repo,
this.outputList,
this.binaryFiles,
this.includeZips,
"epub/"
)
return () =>
commitZipContents(
this.repo,
this.outputList,
this.binaryFiles,
this.includeZips,
"epub/"
)
}
}

Expand All @@ -44,13 +45,14 @@ export class HTMLBookGithubExporter extends HTMLBookExporter {
}

createZip() {
return () => commitZipContents(
this.repo,
this.outputList,
this.binaryFiles,
this.includeZips,
"html/"
)
return () =>
commitZipContents(
this.repo,
this.outputList,
this.binaryFiles,
this.includeZips,
"html/"
)
}
}

Expand All @@ -61,13 +63,14 @@ export class SingleFileHTMLBookGithubExporter extends SingleFileHTMLBookExporter
}

createZip() {
return () => commitZipContents(
this.repo,
this.outputList,
this.binaryFiles,
this.includeZips,
"uhtml/"
)
return () =>
commitZipContents(
this.repo,
this.outputList,
this.binaryFiles,
this.includeZips,
"uhtml/"
)
}
}

Expand All @@ -78,12 +81,13 @@ export class LatexBookGithubExporter extends LatexBookExporter {
}

createZip() {
return () => commitZipContents(
this.repo,
this.textFiles,
this.httpFiles,
[],
"latex/"
)
return () =>
commitZipContents(
this.repo,
this.textFiles,
this.httpFiles,
[],
"latex/"
)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import {addAlert, Dialog, escapeText} from "../../common"
import {EpubBookGithubExporter, UnpackedEpubBookGithubExporter, HTMLBookGithubExporter, LatexBookGithubExporter, SingleFileHTMLBookGithubExporter} from "./book_exporters"
import {
EpubBookGithubExporter,
UnpackedEpubBookGithubExporter,
HTMLBookGithubExporter,
LatexBookGithubExporter,
SingleFileHTMLBookGithubExporter
} from "./book_exporters"
import {promiseChain, commitTree} from "./tools"

export class GithubBookProcessor {
Expand All @@ -12,11 +18,9 @@ export class GithubBookProcessor {
}

init() {
return this.getCommitMessage().then(
commitMessage => this.publishBook(commitMessage)
).catch(
() => {}
)
return this.getCommitMessage()
.then(commitMessage => this.publishBook(commitMessage))
.catch(() => {})
}

getCommitMessage() {
Expand All @@ -26,7 +30,9 @@ export class GithubBookProcessor {
text: gettext("Submit"),
classes: "fw-dark",
click: () => {
const commitMessage = dialog.dialogEl.querySelector(".commit-message").value || gettext("Update from Fidus Writer")
const commitMessage =
dialog.dialogEl.querySelector(".commit-message")
.value || gettext("Update from Fidus Writer")
dialog.close()
resolve(commitMessage)
}
Expand All @@ -45,7 +51,9 @@ export class GithubBookProcessor {
height: 150,
body: `<p>
${gettext("Updating")}: ${escapeText(this.book.title)}
<input type="text" class="commit-message" placeholder="${gettext("Enter commit message")}" >
<input type="text" class="commit-message" placeholder="${gettext(
"Enter commit message"
)}" >
</p>`,
buttons
})
Expand All @@ -69,9 +77,7 @@ export class GithubBookProcessor {
new Date(this.book.updated * 1000),
this.userRepo
)
commitInitiators.push(
epubExporter.init()
)
commitInitiators.push(epubExporter.init())
}

if (this.bookRepo.export_unpacked_epub) {
Expand All @@ -85,9 +91,7 @@ export class GithubBookProcessor {
new Date(this.book.updated * 1000),
this.userRepo
)
commitInitiators.push(
unpackedEpubExporter.init()
)
commitInitiators.push(unpackedEpubExporter.init())
}

if (this.bookRepo.export_html) {
Expand All @@ -101,9 +105,7 @@ export class GithubBookProcessor {
new Date(this.book.updated * 1000),
this.userRepo
)
commitInitiators.push(
htmlExporter.init()
)
commitInitiators.push(htmlExporter.init())
}

if (this.bookRepo.export_unified_html) {
Expand All @@ -117,9 +119,7 @@ export class GithubBookProcessor {
new Date(this.book.updated * 1000),
this.userRepo
)
commitInitiators.push(
unifiedHtmlExporter.init()
)
commitInitiators.push(unifiedHtmlExporter.init())
}

if (this.bookRepo.export_latex) {
Expand All @@ -131,26 +131,46 @@ export class GithubBookProcessor {
new Date(this.book.updated * 1000),
this.userRepo
)
commitInitiators.push(
latexExporter.init()
)
commitInitiators.push(latexExporter.init())
}
return Promise.all(commitInitiators).then(commitFunctions => promiseChain(commitFunctions.flat()).then(
responses => {
return Promise.all(commitInitiators).then(commitFunctions =>
promiseChain(commitFunctions.flat()).then(responses => {
const responseCodes = responses.flat()
if (responseCodes.every(code => code === 304)) {
addAlert("info", gettext("Book already up to date in repository."))
addAlert(
"info",
gettext("Book already up to date in repository.")
)
} else if (responseCodes.every(code => code === 400)) {
addAlert("error", gettext("Could not publish book to repository."))
addAlert(
"error",
gettext("Could not publish book to repository.")
)
} else if (responseCodes.find(code => code === 400)) {
addAlert("error", gettext("Could not publish some parts of book to repository."))
addAlert(
"error",
gettext(
"Could not publish some parts of book to repository."
)
)
} else {
// The responses looks fine, but we are not done yet.
commitTree(responseCodes.filter(response => typeof(response) === "object"), commitMessage, this.userRepo).then(
() => addAlert("info", gettext("Book published to repository successfully!"))
commitTree(
responseCodes.filter(
response => typeof response === "object"
),
commitMessage,
this.userRepo
).then(() =>
addAlert(
"info",
gettext(
"Book published to repository successfully!"
)
)
)
}
}
))
})
)
}
}
Loading

0 comments on commit 7e2bfee

Please sign in to comment.