Editorial Workflows

Create Workflow Shortcut

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: Modified "Create File Shorcut" by:

http://twitter.com/that_pat

Creates a home screen shortcut to a user-specified workflow, using a user-selected icon. Based on the excellent script by @olemoritz.

Shared by: Tutorial Doctor

Comments: Comment Feed (RSS)

jpooley — 09 Jul 2014
Thanks for this! Though it is not working for me: despite using the exact workflow name, the homescreen button just hangs on a white screen. Looking at the profile created, in the "More Details" pane, is see there is no url listed, when (I think) there should be editorial://?command=[my workfow name]
Tutorial Doctor — 20 Jul 2014
I will look I to it. Thanks for the response.
Tutorial Doctor — 20 Jul 2014
This had happened to me once, I just had to change the name of the workflow to something simpler (no spaces and such). Everything should work though. Let me know if changing the name helps.
jpooley — 21 Jul 2014
That completely solved the problem--thanks again for building this (on Ole's already great work).

+ Add Comment

Workflow Preview
Get Workflow Name ?
Title
Enter the workflow Name
Initial Text
  • Single Line
  • Multiple Lines
Keyboard Options:
Store Workflow Name ?
Variable Name
wkflo_name
Value
Input
Store Label ?
Variable Name
label
Value
wkflo_name
Workflow URL ?
Text
editorial://?command=wkflo_name
Shortcut URL ?
Variable Name
shortcutURL
Value
Input
Add Shortcut ?
Source Code
# This script adds a "Webclip" shortcut to your homescreen.
# You'll be asked for an icon (from your camera roll).
# Path to file, file name, and root (dropbox vs local) are
#	detected automatically.

import plistlib
import BaseHTTPServer
import webbrowser
import uuid
from io import BytesIO
import Image
import photos
import notification
import console
import workflow
import editor

class ConfigProfileHandler (BaseHTTPServer.BaseHTTPRequestHandler):
	config = None
	def do_GET(s):
		s.send_response(200)
		s.send_header('Content-Type', 'application/x-apple-aspen-config')
		s.end_headers()
		plist_string = plistlib.writePlistToString(ConfigProfileHandler.config)
		s.wfile.write(plist_string)
	def log_message(self, format, *args):
		pass

def run_server(config):
	ConfigProfileHandler.config = config
	server_address = ('', 0)
	httpd = BaseHTTPServer.HTTPServer(server_address, ConfigProfileHandler)
	sa = httpd.socket.getsockname()
	webbrowser.open('safari-http://localhost:' + str(sa[1]))
	httpd.handle_request()
	notification.schedule('Tap "Install" to add the shortcut to your homescreen.', 1.0)

def main():
	url = workflow.get_variable('shortcutURL')
	label = workflow.get_variable('label')
	icon = photos.pick_image()
	if not icon:
		return
	console.show_activity('Preparing Configuration profile...')
	data_buffer = BytesIO()
	icon.save(data_buffer, 'PNG')
	icon_data = data_buffer.getvalue()
	unique_id = uuid.uuid4().urn[9:].upper()
	config = {'PayloadContent': [{'FullScreen': True,
            'Icon': plistlib.Data(icon_data), 'IsRemovable': True,
            'Label': label, 'PayloadDescription': 'Configures Web Clip', 
            'PayloadDisplayName': label,
            'PayloadIdentifier': 'com.omz-software.shortcut.' + unique_id, 
            'PayloadOrganization': 'omz:software', 
            'PayloadType': 'com.apple.webClip.managed',
            'PayloadUUID': unique_id, 'PayloadVersion': 1,
            'Precomposed': True, 'URL': url}], 
            'PayloadDescription': label,
            'PayloadDisplayName': label + ' (Shortcut)', 
            'PayloadIdentifier': 'com.omz-software.shortcut.' + unique_id,
            'PayloadOrganization': 'omz:software', 
            'PayloadRemovalDisallowed': False, 'PayloadType': 
            'Configuration', 'PayloadUUID': unique_id, 'PayloadVersion': 1}
	console.hide_activity()
	run_server(config)

if __name__ ==  '__main__':
	main()