I tested the 'served html from NAS' part extensively, but I never once thought to run the shell scripts directly on the NAS box.
Like the AIR apps, they were only designed and tested on PCs connected to the NAS (OS X and a VM with Ubuntu Linux). I suppose some kinda masochist could hypothetically run them directly on the NAS... because you apparently did just that
. They crawl through a couple of thousand files a minute on my slow, old DiskStation, over smb, which was 'fine' for me, because I don't have that many 'thousands' of anything.
I'll make most of your changes, test and commit soon-ish.
As for perl... well, I have a problem. Inserting the content into the files, inline, where those 'magic keys' exist.
I went to all the trouble to convert the long list of 'bits of html file', from earlier versions, into mostly one file, though I ended up dragging some of the CSS back out, because it was more convenient for 'customizing' it. I did all of that in the Adobe AIR apps first, then went back and tried to figure out how to do it in the shell script.
I use sed for most of my regex needs, but it doesn't work so well for multiline substitutions, like that. The only workable examples I found online to merge a file into another file on matches were based on 'perl one liners'. I suppose I could have just written the whole thing in perl or python, but I'd have to... learn perl or python.
As for the trailing %27, that's an apostrophe/single-quote. Something is probably working just subtly different in sed, or how sh is interpreting quotes. I think we could get away with removing that %27 from the uri_escape function, because all of my XML attributes are double-quoted (so a single quote in the path won't 'break' it).