Just wanted to make sure this shows up in forum searches:
Custom HTML Prompt with resources in a Package (.pkg) file
The “Macro Spotlight” macro (above) has the following features, that might be of interest to other macro developers:
The Macro’s HTML file, and its resource sub-folders like .css and .js, are all inside a Package (.pkg) file. In my opinion this makes it easier for the user to move the Resources to another location, and less likely that the user might delete a resource.
Accomplishing this is trivial:
a) Take the folder that contains your HTML file(s) and its resources subfolders, like.css, and rename the folder with the .pkg extension.
b) Inside the macro, treat the .pkg file just like the folder. It actually still is just a folder. So you can use it in paths, like (pardon any typos): /Users/Dan/Documents/MyFolder.pkg/MyPrompt.html. And if you test for its existence, remember that it is still a folder, so check for a folder’s existence, not a file’s.
It shows one way to ask the user to tell us where the resources package is located, so the user can move it around and our macro wont break.
I feel like there’s probably a slightly better way of doing this than the “Choose Folder” prompt I use, but it works. If someone has any ideas for a better solution, lt me know.
I’m constantly amazed at the things Peter has given us the ability to do. KM really is a propeller-head’s dream.
Thanks again. That was the goal.
A couple of things I can’t figure out how to make easily modifiable:
Right now I automatically strip out leading “palette sort” numbers like “30)”, etc. I wish I could come up with a way for the user to specify how to do this themselves. I thought about having a “Set Variable to Text” action where the user could specify a Regex, but that’s hard to do, because special character sequences like slash-n get treated as newlines in the editor.
I’d love a way for the user to specify macros to filter out. Currently, I filter out macros whose names contain “---------”, because I use them as separators in Palettes. But again, I wish I could make it easy for the user to specify one or more Regexes to be used as filters.