Editorial Workflows

Workflow Backup U...

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: Saves or restores a backup of all Editorial workflows in Dropbox (this requires the Dropbox account to be linked).

Shared by: @due3die

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Show Alert ?
Title
Create or Restore?
Message
The backup of your workflows will be created as a zip file in your Dropbox (Workflows_Year: 2001_Month: 01_Day: 01-Hour: 01 (12h)_Minute: 01_AM/PM.zip)
Button 1
Create Backup
Output Value
backup
Button 2
Restore...
Output Value
restore
Button 3
(don't show)
Output Value
Show Cancel Button
ON
Set Variable ?
Variable Name
Action
Value
Input
If "Backup" was selected... ?
Run the block if
Action
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
backup
Create the Backup (Python) ?
Source Code
#coding: utf-8
import workflow
import editor
import os
from zipfile import ZipFile
import datetime
from io import BytesIO

t = datetime.datetime.today()
backup_filename = 'Workflows_' + t.strftime('%Y_%m_%d-%I_%M_%p') + '.zip'
wf_path = editor.get_workflows_path()
files = os.listdir(wf_path)
zip_buffer = BytesIO()
with ZipFile(zip_buffer, 'w') as z:
	for filename in files:
		name, extension = os.path.splitext(filename)
		if extension in ('.wkflw', '.edcmd'):
			z.write(filename)
	
zip_data = zip_buffer.getvalue()
editor.set_file_contents(backup_filename, zip_data, 'dropbox')
Show HUD ?
HUD Text
Backup Created
Duration
  • 1 Second
  • 2 Seconds
  • 3 Seconds
Icon
  • "Success"
  • "Error"
…End If
If "Restore" was selected.... ?
Run the block if
Action
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
restore
List Backups (Python) ?
Source Code
#coding: utf-8
import workflow
import editor
import os
import re

wf_path = editor.get_workflows_path()
db_path = os.path.join(os.path.split(wf_path)[0], 'Dropbox')

backups = []
files = os.listdir(db_path)
for filename in files:
	if re.match('Workflows_.*\\.zip$', filename):
		backups.append(filename)
workflow.set_output('\n'.join(backups))
Stop if no backups are found... ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Show Alert ?
Title
No Backups Found
Message
No backup files were found. You might need to download them first, if you see grayed-out backup files in your Dropbox folder.
Button 1
OK
Output Value
Button 2
(don't show)
Output Value
Button 3
(don't show)
Output Value
Show Cancel Button
OFF
Stop ?
Stop
  • This Workflow
  • Repeat Block
Show HUD Alert
OFF
Message
Stopped
…End If
Select from List ?
Title
Select a Backup
List (Lines)
Input
Multiple Selection
OFF
Show in Popover
OFF
Show Warning Alert ?
Title
Warning
Message
This will replace all your workflows with the ones that are stored in the selected backup (Input).
Button 1
Continue
Output Value
Input
Button 2
(don't show)
Output Value
Button 3
(don't show)
Output Value
Show Cancel Button
ON
Restore the Backup (Python) ?
Source Code
#coding: utf-8
import workflow
import editor
from os import path
from zipfile import ZipFile

backup_filename = workflow.get_input()
db_path = path.join(path.split(editor.get_workflows_path())[0], 'Dropbox')
backup_path = path.join(db_path, backup_filename)

with ZipFile(backup_path, 'r') as z:
	z.extractall(editor.get_workflows_path())

editor.reload_workflows()
Show HUD ?
HUD Text
Backup Restored
Duration
  • 1 Second
  • 2 Seconds
  • 3 Seconds
Icon
  • "Success"
  • "Error"
…End If