in reply to Re^2: Using a git filter to Cache HTML Resources Locally
in thread Using a git filter to Cache HTML Resources Locally
You can just invoke the linked htmlrescache program ashtmlrescache clean my/file.html
Sorry, that's not quite right: git filters are provided the files on STDIN and must output on STDOUT, the filename on the command line is only informative for the script - because filters can be used on files that are being added/deleted, git doesn't make any guarantees that the file even exists. In fact, git filters aren't normally even given the filename, I had to specify %f in the git filter setting. My script just uses the filename to calculate the path of the cache directory relative to the file.
However, your comment served as the inspiration to update the script so that it now supports new options: -i for inplace editing (use -IEXT to specify an extension for the backup file; uses $^I under the hood), and -G to disable the use of git, so paths are resolved relative to the current working directory instead of the git working directory. So thank you for that! :-)
So now you can do:
$ htmlrescache -GI.bak smudge my/file.html # cache HTML resources $ mv my/file.html.bak my/file.html # restore original file
or
$ htmlrescache -Gi smudge my/file.html # cache HTML resources $ htmlrescache -Gi clean my/file.html # restore original URLs
|
|---|