Editorial Workflows

Archive @done

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Moves @done tasks in a TaskPaper document to the "Archive" project (created if necessary).

If a task is in a project, a @project(name) tag is appended automatically. Note that this ignores indentation and doesn't handle sub-projects though.

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Check if TaskPaper File... ?
Run the block if
File Extension
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
taskpaper
Show Alert ?
Title
Not TaskPaper?
Message
TaskPaper documents typically use a ".taskpaper" file extension, this document uses ".File Extension". Do you want to continue?
Button 1
Continue
Output Value
Input
Button 2
(don't show)
Output Value
Button 3
(don't show)
Output Value
Show Cancel Button
ON
…End If
Unfold All Text ?
Set Variable ?
Variable Name
Message
Value
(the Python script will set this to show the number of tasks being archived)
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import editor
import re
import sys

text = editor.get_text()
lines = text.splitlines()

new_lines = []
archive_found = False
done_tasks = []
current_project = None
for i, line in enumerate(lines):
	if line.strip().endswith(':'):
		current_project = line.strip(': ')
	if line.strip().startswith('Archive:'):
		archive_found = True
		new_lines.append(line)
		new_lines += done_tasks
	elif not archive_found and line.find('@done') >= 0:
		if current_project:
			line = '%s @project(%s)' % (line, current_project)
		done_tasks.append(line)
	else:
		new_lines.append(line)

if not done_tasks:
	workflow.set_output('')
	workflow.set_variable('Message', 'No @done Tasks')
else:
	workflow.set_variable('Message', '%i Task%s Archived' % (len(done_tasks), '' if len(done_tasks) == 1 else 's'))
	if not archive_found:
		new_lines.append('Archive:')
		new_lines += done_tasks
	output = '\n'.join(new_lines)
	workflow.set_output(output)
Set Variable ?
Variable Name
Replacement
Value
Input
If… ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Extend Selection ?
Direction
  • Backward
  • Forward
  • Both
Unit
  • Start/End of Document
  • Start/End of Line
  • Number of Characters...
1
Replace Selected Text ?
Replacement Text
Replacement
Find "Archive:" (to move cursor) ?
Search for
^ *Archive:()
Match Group (RegEx)
1
Search Type
  • Regular Expression
  • Case-insensitive Search (A = a)
  • Case-sensitive Search (A ≠ a)
Output
  • Found Text
  • Range of Text (from:to)
Select Range ?
Range (from:to)
Input
Relative to
  • Entire Document
  • Current Selection
…End If
Show HUD ?
HUD Text
Message
Duration
  • 1 Second
  • 2 Seconds
  • 3 Seconds
Icon
  • "Success"
  • "Error"