Skip to content

Conversation

@eitsupi
Copy link
Contributor

@eitsupi eitsupi commented Mar 3, 2021

Early steps in a approach to solving #19 with a html file server.

I'm using go-http-file-server on this trial basis now.

  1. Upload a pdf file {filename.pdf} to the file server localhost:8080.
    image
  2. Open the url http://localhost:5000/paper2html?url=http://htmlserver:8080/{filename.pdf}.
    image

@ktaaaki
Copy link
Owner

ktaaaki commented Mar 4, 2021

To omit the step 2 (pasting the request url into the browser), you can automatically convert a pdf triggered by the addition of the pdf to the file server.

The code to convert a pdf from folder monitoring is as follows.

class PdfFileEventHandler(PatternMatchingEventHandler):
    def __init__(self, patterns=("*.pdf",), ignore_patterns=None, ignore_directories=True, case_sensitive=False,
                 debug=False):
        super().__init__(patterns, ignore_patterns, ignore_directories, case_sensitive)
        self.debug = debug

    def on_any_event(self, event):
        if not os.path.exists(event.src_path):
            return

        n_div_paragraph = math.inf
        line_margin_rate = None
        verbose = self.debug
        Paper.n_div_paragraph = n_div_paragraph
        paper2html(event.src_path, cache_dir, line_margin_rate, verbose)

See watchdog_part branch for details.

@eitsupi
Copy link
Contributor Author

eitsupi commented Mar 4, 2021

@ktaaaki It looks work!
GIF

However, it seems that extra triggers can generate extra files (test-0 and test-1).
image

@ktaaaki
Copy link
Owner

ktaaaki commented Mar 6, 2021

That was because the file system watcher is different from my environment.
I fixed this bug in watchdog_part.

@eitsupi
Copy link
Contributor Author

eitsupi commented Mar 6, 2021

@ktaaaki I tried the latest watchdog_part d703c58 and It seems that no extra files are generated anymore!

But, I found another bug.
go-http-file-server can't open directories which contain %2F(/) in them names generated by online pdf files.
image

open ↑ directory.

image

This is a bug in go-http-file-server, but I think it can cause the same problem in other environments.

@ktaaaki
Copy link
Owner

ktaaaki commented Mar 6, 2021

Percent encoded slashes may make those errors.
OK, I renamed the name of the directory and changed structure of tree of output directories.

This reverts commit 08cd130.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants