Action

Ulysses sheet w/ tags

Posted by RoyRogers, Last update over 5 years ago

Opens Ulysses with current draft as new sheet, and adds tags as keywords to this sheet.
Draft is archived with new tag=“sent2ulysses”

Make sure the group “FromDrafts” exists in Ulysses before running this action!

Steps

  • script

    // Opens Ulysses with current draft as new sheet, and adds tags as keywords to this sheet.
    // Make sure the group “FromDrafts” exists in Ulysses before running this script!
    
    const baseURL = "ulysses://x-callback-url/new-sheet?group=FromDrafts";
    
    let cb = CallbackURL.create();
    cb.baseURL = baseURL;
    cb.addParameter("text", draft.content);
    cb.waitForResponse = true;
    var success = cb.open();
    if (success) {
    	// console.log("Event created");
    	var sheet = JSON.parse(cb.callbackResponse.sheet);
    	var id = sheet.identifier;
    	
    	let tags = draft.tags;
    	tags.push("FromDrafts");
    	const ctags = encodeURI(tags.join(','));
    	console.log(ctags)
    		
    	var url = `ulysses://x-callback-url/attach-keywords?id=${id}&keywords=${ctags}`;
    	var result = app.openURL(url);
    		
    	// The following is replaced with the openURL
    	// statement above, to avoid returning to Drafts:
    	/*
    	draft.setTemplateTag("sheet_id", id);
    	draft.setTemplateTag("my_tags", tags);
    	const baseURL2 = "ulysses://x-callback-url/attach-keywords?"
    	cb.baseURL = baseURL2;
    	cb.addParameter("id", id);
    	cb.addParameter("keywords", tags);
    	console.log(id);
    	cb.waitForResponse = false;
    	var success = cb.open();
    	*/
    }
    

Options

  • After Success Archive , Tags: sent2ulysses
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.