[Discussion] Open Sourcing An Action Group

I have open source projects on GitHub. (md2pptx and mdpre, but that is by the by.)

I would like to open source an action group that is really only useful in the context of these projects - and hence incorporate it into one of the projects (probably md2pptx).

My question is: Assuming I want others to participate in developing this action group, what would be a good way to develop / package / distribute it?

I would say putting it in the Action Directory is not a great idea - though releases of it could end up there. Not a great idea because I don’t see people being able to do all the Git things with something in the Action Directory.

So, is there a good packaging etc mechanism? Any other concerns ‘ tips?

1 Like

At present one Drafts user must be the publisher.

I am wondering if i red Stephen had a solution to create Action Groups via Code on the Mac

A direct distribution via Github CI would be great.

1 Like

I should probably take a look at the flat file form of an exported Action Group:

  • Confecting it might be easy enough.
  • I don’t know about importing from, say, GitHub.

Anyhow, it’s worth experimenting with.

Here’s a few thoughts on this.

  1. The file format for an action group (and an action) export looks to be in a binary rather than a plain text format - which was why I’d previously chosen to work with modifying actions from Drafts via the installation URL.
  2. The installation URL has some URL encoded JSON data, but beyond that it isn’t that tricky to work with.
  3. The Action Wizards produce installation URLs. If you look at the function.js file it uses there’s some code there about producing the JSON and the installation URL.
  4. I did use an approach like this in the ThoughtAsylum Action Group to allow the TAD action to build the TAD-Library action from a copy of the tad.js file. Code below:
TadLibrary. TA_buildLibraryAction()
// Used to quickly replace the TAD-Library action contents from the tad.js library file.
    const strCall = "drafts5://action?data=";

    let fmCloud = FileManager.createCloud();
    let strScript = fmCloud.readString("/Library/Scripts/tad.js");

    let jsonBuildStep0 = {};
    jsonBuildStep0.platforms = 3;
    jsonBuildStep0.type = "script";
    jsonBuildStep0.isEnabled = true;
    jsonBuildStep0.uuid = "A0E1974C-F0B2-4DEF-860D-934BD3B9C041";
    jsonBuildStep0.data = {};
    jsonBuildStep0.data.allowAsync = "false";
    jsonBuildStep0.data.script = strScript;

    let jsonKeyCmd = {};
    jsonKeyCmd.optionKey = false;
    jsonKeyCmd.input = "";
    jsonKeyCmd.controlKey = false;
    jsonKeyCmd.commandKey = false;
    jsonKeyCmd.type = "action";
    jsonKeyCmd.discoverabilityTitle = "TAD-Library";
    jsonKeyCmd.shiftKey = false;

    let jsonBuild = {};
    jsonBuild.uuid = "31D93149-34A7-47B4-AD7F-4B2FB635E7DE";
    jsonBuild.steps = [];
    jsonBuild.backingPlatforms = 3;
    jsonBuild.shortName = "";
    jsonBuild.shouldConfirm = false;
    jsonBuild.disposition = 0;
    jsonBuild.keyCommand = jsonKeyCmd

    jsonBuild.logLevel = 1;
    jsonBuild.groupDisposition = 0;
    jsonBuild.notificationType = 1;
    jsonBuild.tintColor = "gray";
    jsonBuild.actionDescription = "An action copy of the tad.js library file.";
    jsonBuild.keyUseIcon = false;
    jsonBuild.icon = "667-gear3";
    jsonBuild.visibility = 480;
    jsonBuild.backingIsSeparator = false;
    jsonBuild.groupUUID = "54ADF94F-8F6B-4477-947C-175000317F7B";
    jsonBuild.assignTags = [];
    jsonBuild.name = "TAD-Library";

    let strJSONBuild = JSON.stringify(jsonBuild)

    app.openURL(strCall + encodeURIComponent(strJSONBuild));

You could build a web page on GitHub that utilises source JSON stored on GitHub, alongside all the files to build it, and offers a download of the latest version.

Failing that, if you note the ThoughtAsylum example above, the source code for the JavaScript step is read from a local file. You could read the entire JSON from GitHub within an action and have it build and open the installation URL on the fly.

My suggestion would be that if you are wanting to do development, manage it through GitHub. Then when you have a stable release, update the copy on the Action Directory.

Hope that helps.

1 Like

Yes. So we could offer an Action Factory - which has the added benefit of providing fill-in-the-blanks tailoring.