Editorial Workflows

Add to Home Screen

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 lets you add a bookmark icon for an Editorial document to the iOS home screen.

The workflow automatically opens Safari with additional instructions for adding the icon (which must happen manually; there is no way to automate this step).

If you don't like the default icon, you can customize it by editing the workflow – simply change the value in the first ("Custom Icon URL") action.

The home screen icons created with this method are actually just special web bookmarks that redirect to the Editorial app. This is the only supported way of adding custom home screen icons. Unfortunately, this method has the side effect of leaving some clutter in the app switcher, and you'll briefly see a blank screen before Editorial is opened.

Shared by: @olemoritz

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Customize Icon ?
Variable Name
Icon URL
Value
http://omz-software.com/editorial/homescreen_bookmark.png
If… ?
Run the block if
File Name
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Stop ?
Stop
  • This Workflow
  • Repeat Block
Show HUD Alert
ON
Message
No Document Open
…End If
Get Bookmark URL ?
Include Selected Range
OFF
Run Python Script ?
Source Code
#! python2

import BaseHTTPServer
import webbrowser
import base64
import workflow
import editor
import os

page_template = '''<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
	<head>
		<meta charset="utf-8">
		<title>
			{{TITLE}}
		</title>
		<link rel="apple-touch-icon" sizes="76x76" href="{{ICON_URL}}">
		<link rel="apple-touch-icon" sizes="120x120" href="{{ICON_URL}}">
		<link rel="apple-touch-icon" sizes="152x152" href="{{ICON_URL}}">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="viewport" content="initial-scale=1 maximum-scale=1 user-scalable=no">
		<style type="text/css">
		body {
			background-color: #023a4e;
			-webkit-text-size-adjust: 100%;
			-webkit-user-select: none;
		}
		#help {
			display: none;
			color: white;
			font-family: "Avenir Next", helvetica, sans-serif;
			padding: 40px;
		}
		.help-step {
			border-radius: 8px;
			background-color: #047ea9;
			color: white;
			font-size: 20px;
			padding: 20px;
			margin-bottom: 20px;
		}
		.icon {
			background-image: url({{ICON_URL}});
			width: 76px;
			height: 76px;
			background-size: 76px 76px;
			border-radius: 15px;
			margin: 0 auto;
		}
		.share-icon {
			width: 32px;
			height: 27px;
			display: inline-block;
			background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAA2CAQAAADdG1eJAAAAyElEQVRYw+3YvQrCMBSG4a/SKxC8M6dOnQShk9BJKAi9OcFLKrwuaamDRRtMLHxnCBySch7yR6i07aCjy1seyEbgxhhd3vI5CKH8ddamJNAD0EoAEm1SQijfSCNAoklGoAcG6pAFgMQpCYELMFBN+QSQqBmA828BBx4cZ/kMIFFxZ5/2NLwA1sQu92VuQHZAubTB3vcVRfz4/5+BZfnnY5cPqjehAQYYYIABBhhQxn3+zYPFS2CAAQYYYIABBqx6kMT+htzADDwBk2GVUD9m13YAAAAASUVORK5CYII=');
			background-size: 32px 27px;
			vertical-align: -4px;
		}
		.icon-title {
			font-family: "Helvetica Neue", helvetica, sans-serif;
			text-align: center;
			font-size: 16px;
			margin-top: 10px;
			margin-bottom: 30px;
		}
		@media only screen and (max-width: 767px) {
			#help {
				padding: 30px 0px 10px 0px;
			}
			.help-step {
				padding: 10px;
			}
		}
		</style>
	</head>
	<body>
		<div id="help">
			<div class="icon"></div>
			<div class="icon-title">
				{{TITLE}}
			</div>
			<div class="help-step">
				<strong>1.</strong> Tap the
				<div class="share-icon"></div>button in the toolbar
			</div>
			<div class="help-step">
				<strong>2.</strong> Select "Add to Home Screen"
			</div>
			<div class="help-step">
				<strong>3.</strong> Tap "Add"
			</div>
		</div><script type="text/javascript">
if (navigator.standalone) {
		  window.location = "{{SHORTCUT_URL}}";
		} else {
		  var helpDiv = document.getElementById("help");
		  helpDiv.style.display = "block";
		}
		</script>
	</body>
</html>
'''

redirect_template = '''<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Loading...</title>
	</head>
	<body>
	<script>
	window.location = "data:text/html;base64,{{DATA}}";	  
	</script>
	</body>
</html>
'''

shortcut_url = workflow.get_input()
title = os.path.split(editor.get_path())[-1]
icon_url = workflow.get_variable('Icon URL')

page = page_template.replace('{{TITLE}}', title).replace('{{SHORTCUT_URL}}', shortcut_url).replace('{{ICON_URL}}', icon_url)
page_b64 = base64.b64encode(page)
redirect_page = redirect_template.replace('{{DATA}}', page_b64)

class MyHandler (BaseHTTPServer.BaseHTTPRequestHandler):
	def do_GET(s):
		s.send_response(200)
		s.send_header('Content-Type', 'text/html')
		s.end_headers()
		s.wfile.write(redirect_page)
	def log_message(self, format, *args):
		pass

httpd = BaseHTTPServer.HTTPServer(('', 0), MyHandler)
port = str(httpd.socket.getsockname()[1])
webbrowser.open('safari-http://localhost:' + port)
httpd.handle_request()