Schedule in beorg

Last update 7 months ago

Ask the user for a date and then use the beorg URL scheme to add a new item to the inbox. The item will use the first line as the title and any subsequent lines as notes. The title will be a link to open this draft in Drafts.

beorg is a plain text task manager which use the Org mode syntax (https://beorg.app)

Steps

  • script

    function pad2(num) {
    	return num < 10 ? `0${num}` : `${num}`
    }
    
    function toOrgDate(date) {
    	return `${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())}`
    }
    
    let p = Prompt.create();
    
    p.title = "Schedule for";
    p.addDatePicker("date", "", new Date(), {"mode": "date"});
    p.addButton("Schedule");
    
    if (p.show()) {
        if (p.buttonPressed === "Schedule") {
            let d = p.fieldValues["date"];
            let dStr = toOrgDate(d);
            let title = `[[${draft.permalink}][${draft.title}]]`;
            let notes = draft.content;
            if (notes.length > title.length) {
            		notes = notes.substring(title.length);
            	} else {
            	   notes = ""
            	}
            let baseURL = "beorg://x-callback-url/capture";
            let params = {
                "title": title,
                "notes": notes,
                "scheduled": dStr
            };
            let cb = CallbackURL.create();
            cb.baseURL = baseURL;
            cb.addParameter("title", title);
            cb.addParameter("notes", notes);
            cb.addParameter("scheduled", dStr);
            if (!cb.open()) {
                context.fail();
            }
        } else {
            context.cancel();
        }
    } else {
    	context.cancel();
    }

Options

  • After Success Ask
    Notification Info
    Log Level Info
Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.