Action

Process Weekly Review Brain Dump

Posted by Mike Burke, Last update 11 months ago

This action is designed to seamlessly transfer to-do items from Drafts to Things while intelligently tagging them based on their corresponding level 1 and 2 headers in the draft.

Learn more about the script here.

Steps

  • script

    // Split the draft into an array of lines
    const lines = draft.content.split("\n");
    
    // Variables to keep track of the current level 1 and level 2 headers
    let currentHeaderL1 = '';
    let currentHeaderL2 = '';
    
    // Create an array to hold the Things todos
    let todos = [];
    
    // Loop over the lines of the draft
    for (let line of lines) {
    	// Check if the line is a level 1 header
    	if (line.startsWith('# ') && !line.startsWith('##')) {
    		// Update the current level 1 header and reset the level 2 header
    		currentHeaderL1 = line.substring(2).trim();
    		currentHeaderL2 = '';
    	}
    	// Check if the line is a level 2 header
    	else if (line.startsWith('## ')) {
    		// Update the current level 2 header
    		currentHeaderL2 = line.substring(3).trim();
    	}
    	// Process lines that are not headers and not empty
    	else if (line && !line.startsWith('#')) {
    		let todo = TJSTodo.create();
    		todo.title = line;
    
    		// Add the current level 1 header as a tag if it's not empty
    		if (currentHeaderL1) {
    			todo.addTag(currentHeaderL1);
    		}
    
    		// Add the current level 2 header as a tag if it's not empty
    		if (currentHeaderL2) {
    			todo.addTag(currentHeaderL2);
    		}
    
    		todos.push(todo);
    	}
    }
    
    // Create a container for the todos
    const container = TJSContainer.create(todos);
    
    // Create a callback URL
    let cb = CallbackURL.create();
    cb.baseURL = container.url;
    
    // Attempt to open the callback URL
    if (cb.open()) {
    	console.log("Todos created in Things with appropriate tags");
    } else
    
    // Log an error message if the callback URL fails to open
    console.error("Failed to create Todos in Things");

Options

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