Skip to content

Commit

Permalink
Correct workdir path
Browse files Browse the repository at this point in the history
  • Loading branch information
rahmanusta committed Oct 17, 2022
1 parent b4e2ebe commit b3f7d2d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
Expand Up @@ -13,6 +13,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.UUID;
Expand Down Expand Up @@ -109,7 +110,7 @@ private ConverterResult convert(Document document, String text, AsciidoctorConfi
Attributes attributes = configBean.getAsciiDocAttributes(document.getAttributes());
attributes.setAttribute("preview", true);

var workdir = controller.getCurrent().currentTab().getParentOrWorkdir();
Path workdir = controller.getCurrent().currentTab().getParentOrWorkdir();

Options options = Options.builder()
.backend(backend)
Expand Down
Expand Up @@ -70,7 +70,7 @@ public DocBookConverter(Current current, AsciidocConverterProvider converterProv
public void convert(boolean askPath, Consumer<String>... nextStep) {

Path currentTabPath = current.currentPath().get();
Path currentTabPathDir = currentTabPath.getParent();
Path workdir = current.currentTab().getParentOrWorkdir();

String asciidoc = current.currentEditorValue();

Expand All @@ -85,7 +85,7 @@ public void convert(boolean askPath, Consumer<String>... nextStep) {
Attributes attributes = docbookConfigBean.getAsciiDocAttributes(asciidoc);

Options options = Options.builder()
.baseDir(docbookPath.getParent().toFile())
.baseDir(workdir.toFile())
.toFile(docbookPath.toFile())
.backend("docbook5")
.safe(safe)
Expand Down
Expand Up @@ -78,6 +78,7 @@ private void produceEpub3(boolean askPath, boolean isTemp) {
threadService.runTaskLater(() -> {
final Path epubPath = directoryService.getSaveOutputPath(ExtensionFilters.EPUB, askPath);
File destFile = epubPath.toFile();
Path workdir = current.currentTab().getParentOrWorkdir();

indikatorService.startProgressBar();
logger.debug("Epub conversion started");
Expand All @@ -87,7 +88,7 @@ private void produceEpub3(boolean askPath, boolean isTemp) {
attributes.setExperimental(true);

Options options = Options.builder()
.baseDir(destFile.getParentFile())
.baseDir(workdir.toFile())
.toFile(destFile)
.backend("epub3")
.safe(SafeMode.UNSAFE)
Expand Down
Expand Up @@ -64,17 +64,17 @@ public void convert(boolean askPath, Consumer<String>... nextStep) {

Path htmlBookPath = directoryService.getSaveOutputPath(ExtensionFilters.HTML, askPath);
File destFile = htmlBookPath.toFile();
Path workdir = current.currentTab().getParentOrWorkdir();

indikatorService.startProgressBar();
logger.debug("HTML conversion started");

final String asciidoc = current.currentEditorValue();
Path path = current.currentPath().get();

Attributes attributes = htmlConfigBean.getAsciiDocAttributes(asciidoc);

Options options = Options.builder()
.baseDir(destFile.getParentFile())
.baseDir(workdir.toFile())
.toFile(destFile)
.backend(htmlConfigBean.getBackend())
.headerFooter(htmlConfigBean.getHeader_footer())
Expand Down
Expand Up @@ -68,14 +68,16 @@ public void convert(boolean askPath, Consumer<String>... nextStep) {

File destFile = pdfPath.toFile();

Path workdir = current.currentTab().getParentOrWorkdir();

indikatorService.startProgressBar();
logger.debug("PDF conversion started");

try {
SafeMode safe = convertSafe(pdfConfigBean.getSafe());
Attributes attributes = pdfConfigBean.getAsciiDocAttributes(asciidoc);
Options options = Options.builder()
.baseDir(destFile.getParentFile())
.baseDir(workdir.toFile())
.toFile(destFile)
.backend("pdf")
.safe(safe)
Expand Down
Expand Up @@ -47,7 +47,7 @@ default ImageInfo getImageInfo(Environment environment, Map<String, Object> attr
boolean isDataUri = parent.getDocument().hasAttribute("data-uri");
imagePath = Paths.get(docdir).resolve(imagesDir).resolve(imageTarget).toString();
if (isPreview && !isDataUri) {
imageTarget += "?cache" + imageMd5; // for html cache
imageTarget += "?cache=" + imageMd5; // for html cache
}
}

Expand Down

0 comments on commit b3f7d2d

Please sign in to comment.