Staticfy icon indicating copy to clipboard operation
Staticfy copied to clipboard

Staticfy folder

Open Olamyy opened this issue 8 years ago • 2 comments

I've always been able to run staticfy *path* where path is a directory containing html files but for some reason, it doesn't seem to be working now.

I keep getting an IsADirectoryError error.

screen shot 2018-02-09 at 7 57 32 pm

Going through the traceback, I noticed the error comes up in the get_elements function which attempts to open a file so it's only logical for it to raise an error if a directory is passed. screen shot 2018-02-09 at 7 59 09 pm

My suggestion would be to run a check on what is being passed.

Olamyy avatar Feb 09 '18 19:02 Olamyy

Yeah. I removed the option to staticfy a folder directly. That option should be down to the programmer/user of the library.

Now it just prints to stdout which makes it more flexible as the end user can do anything they want with the output, instead of forcing it to a file.

The Good news is you can easily use bash to get the old behaviour. for example

for i in folder/*.html; do staticfy $i | install -D /dev/stdin staticfy/$i; done

Another reason I did this was to enable everyone write plugins that operate on the output from staticfy without invoking any of the internal functions of the library. You can just call staticfy with subprocess or os.system, capture the output and then do any extra transformation on the output string.

I've written a crude posthtml to django templates plugin already.

danidee10 avatar Feb 09 '18 21:02 danidee10

Very soon I'll rewrite the core (Flask, Laravel and Django transformation) as core plugins. There's an open issue here https://github.com/danidee10/Staticfy/issues/4. It can only be solved when the code for the current frameworks are isolated into different functions/files.

danidee10 avatar Feb 09 '18 21:02 danidee10