Editorial Workflows

Insert @start tag

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: This workflow prompts the user to select a date, then inserts a taskpaper @start(YYYY-MM-DD) tag at the cursor where YYYY-MM-DD is the selected date.

Copyright (c) 2017 Duncan MacIntyre

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Shared by: Duncan MacIntyre

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Run Python Script ?
Source Code
# Insert @start tag
# A workflow for the iOS text editor Editorial
# Copyright (c) 2017 Duncan MacIntyre

# This workflow, when run, prompts the user to select a date. @start(YYYY-MM-DD) is then inserted
# at the cursor, where YYYY-MM-DD is the selected date.

import datetime
import dialogs
import workflow
import editor

# generate a list of DateObjects for the next seven days after today
dates = [datetime.date.today() + datetime.timedelta(days=(i + 1)) for i in range(7)]

# generate a list of readable dates in the form '   Weekday, Month Day', each corresponding to
# one date in dates
readable_dates = [i.strftime('   %A, %B %d') for i in dates]

# prompt the user to choose one of readable_dates or '   Other', store choice in chosen
chosen = dialogs.list_dialog(title = 'Choose a start date:', items = readable_dates + ['   Other'])

# if one of readable_dates was chosen...
if chosen in readable_dates:
	# change chosen to the DateObject in dates at the same index as chosen is in readable_dates
	chosen = dates[readable_dates.index(chosen)]
# otherwise, if '   Other' was chosen...
elif chosen == '   Other':
	# prompt the user to choose a date, store their choice as a DateObject in chosen
	chosen = dialogs.date_dialog()

# if chosen is not None...
# (this would happen if the user closed one of the above dialogs without choosing anything)
if chosen is not None:
	# insert @start(YYYY-MM-DD) at the cursor, where YYYY-MM-DD is the chosen date in this format
	editor.insert_text('@start(' + chosen.isoformat() + ')')