Editorial Workflows

Restore Shared Workflow...

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: Downloads a workflow that you've previously shared (from the same device), but deleted since. Unlike installing the workflow directly, this preserves the "ownership", so you can update the workflow without creating a new entry in the directory.

Shared by: @olemoritz

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import sqlite3
import editor
import os
from datetime import datetime

def main():
	db_path = os.path.abspath(os.path.join(editor.get_workflows_path(), '../SharedWorkflows.sqlite'))
	if not os.path.exists(db_path):
		print 'No shared workflows found'
		return

	connection = sqlite3.connect(db_path)
	c = connection.cursor()

	action_out = '\n'.join(['%s (%s)\t%s' % (row[1], datetime.strftime(datetime.fromtimestamp(row[2]), '%D'), row[0]) for row in c.execute('SELECT id, title, date FROM workflows')])
	connection.close()
	
	workflow.set_output(action_out)

main()
Select from List ?
Title
Restore Shared Workflow...
List (Lines)
Input
Multiple Selection
OFF
Show in Popover
OFF
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import sqlite3
import editor
import os
import json

def main():
	wf_id = long(workflow.get_input())
	db_path = os.path.abspath(os.path.join(editor.get_workflows_path(), '../SharedWorkflows.sqlite'))
	connection = sqlite3.connect(db_path)
	c = connection.cursor()
	c.execute('SELECT url, uuid, title FROM workflows WHERE id == ?', (wf_id,))
	url, uuid, title = c.fetchone()
	connection.close()
	with open('Commands.edcmd', 'r') as f:
		workflows = json.load(f)
	for wf in workflows:
		if wf['uuid'] == uuid:
			print 'This workflow is still installed ("%s")' % (wf['title'],)
			return
	print 'Downloading shared workflow...'
	import requests
	r = requests.get(url + '?format=json')
	wf_dict = r.json()['workflow_data']
	os.chdir(editor.get_workflows_path())
	with open(uuid + '.wkflw', 'w') as f:
		json.dump(wf_dict, f)
	new_entry = {'filename': uuid + '.wkflw', 'uuid': uuid, 'title': title}
	if wf_dict.get('icon', None):
		new_entry['iconName'] = wf_dict['icon']
	workflows.insert(0, new_entry)
	with open('Commands.edcmd', 'w') as f:
		json.dump(workflows, f)
	editor.reload_workflows()
	print 'Workflow restored.'

main()