Editorial Workflows

Archive @done

unlisted 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: This workflow has no description.

Shared by: rol

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
Move Caret ?
Direction
  • Backward
  • Forward
  • Start/End of Document
  • Start/End of Line
  • Number of Characters:
1
Extend Selection ?
Direction
  • Backward
  • Forward
  • Both
Unit
  • Start/End of Document
  • Start/End of Line
  • Number of Characters...
1
Set Clipboard ?
Get Current File Name ?
Include Folder
OFF
Include Extension
ON
Set Variable ?
Variable Name
DocName
Value
Input
Open Document ?
File Name
CompletedTasks.taskpaper
In Dropbox
ON
Move Caret ?
Direction
  • Backward
  • Forward
  • Start/End of Document
  • Start/End of Line
  • Number of Characters:
1
Get Clipboard ?
Replace Selected Text ?
Replacement Text
Input
Move Caret ?
Direction
  • Backward
  • Forward
  • Start/End of Document
  • Start/End of Line
  • Number of Characters:
1
Move Caret ?
Direction
  • Backward
  • Forward
  • Start/End of Document
  • Start/End of Line
  • Number of Characters:
7
Replace Selected Text ?
Replacement Text
Year: 2001-Month: 01-Day: 01
Open Document ?
File Name
%var:DocName
In Dropbox
ON