Editorial Workflows

Jekyll Publish (Working Copy)

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: Requirements for this workflow:
* Working Copy

This workflow creates the front matter for a Jekyll post and saves the file to a Git repository using Working Copy. It asks the user for tags to include into the front matter. My full setup I am using this in is explained at https://blog.neverthesamecolor.net/ipad-only-blogging/

The markdown document is scanned for image references and commits the referenced files from the “assets/“ folder to the repository.

To use this workflow, change the key and repo variables to match the key and repo name in Working Copy.

Shared by: @saschaholesch

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Set Variable ?
Variable Name
key
Value
key
Set Variable ?
Variable Name
repo
Value
repo
Get Current File Name ?
Include Folder
OFF
Include Extension
OFF
Change Case ?
  • UPPER CASE
  • lower case
  • Title Case
Find / Replace ?
Find
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
-
Set Variable ?
Variable Name
filename
Value
Input
Set Variable ?
Variable Name
path
Value
_posts/Year: 2001-Month: 01-Day: 01-filename.markdown
Get Current File Name ?
Include Folder
OFF
Include Extension
OFF
Set Variable ?
Variable Name
post_title
Value
Input
Request Text Input ?
Title
Tags (comma separated)
Initial Text
  • Single Line
  • Multiple Lines
Keyboard Options:
Set Variable ?
Variable Name
post_tags
Value
Input
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import datetime

# Date logic adapted from http://stackoverflow.com/a/24740202/371228

# Get current local time and UTC time
localnow = datetime.datetime.now()
utcnow = datetime.datetime.utcnow()

# Compute the time difference in seconds
tzd = localnow - utcnow
secs = tzd.days*24*3600 + tzd.seconds

# Get a positive or negative prefix
prefix = '+'
if secs < 0:
	prefix = '-'
	secs = abs(secs)

# Return the local time and the difference
suffix = "%s%02d%02d" % (prefix, secs/3600, secs/60%60)

workflow.set_output(suffix)
Set Variable ?
Variable Name
post_timezone
Value
Input
Document Text ?
Folded Text
  • Include
  • Replace with:
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import re

action_in = workflow.get_input()

# Find all asset references
image_refs = re.findall(r'!\[.*\]\(assets\/.*\)', action_in)
find_result = '\n'.join(str(ref) for ref in image_refs)

# Remove markdown to only leave the actual path to the file
replace_result = re.sub(r'!\[.*\]\(', '', find_result)
replace_result = re.sub(r'\)', '', replace_result)

workflow.set_output(replace_result)
Repeat… ?
Repeat with
  • Every Line
  • Every Match of Regular Expression:
^assets
Match Group
0 (entire match)
Reverse
OFF
Set Variable ?
Variable Name
image_path
Value
Input
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import editor
import base64
import re

action_in = workflow.get_variable('image_path')
file_path = editor.get_path()
document_name = workflow.get_variable('post_title')
path = re.sub(document_name + '.md', '', file_path)
path = path + action_in
with open(path, 'r') as file:
	file_contents = file.read()
	action_out = base64.b64encode(file_contents)
	workflow.set_output(action_out)
Set Variable ?
Variable Name
image_file_contents
Value
Input
Open URL ?
Open in
  • In-App Browser
  • Default App / Safari
URL
working-copy://x-callback-url/write/?key=key&repo=repo&path=image_path&base64=image_file_contents&x-success=editorial://workflow-callback
Tab
  • Last-used Tab
  • New Tab
  • Tab with ID:
Unique identifier
Wait until Loaded
OFF
Reveal Browser Automatically
ON
Show HUD ?
HUD Text
Committed image to repository: Input
Duration
  • 1 Second
  • 2 Seconds
  • 3 Seconds
Icon
  • "Success"
  • "Error"
…End Repeat
Document Text ?
Folded Text
  • Include
  • Replace with:
Set Variable ?
Variable Name
header
Value
--- layout: post title: post_title date: Year: 2001-Month: 01-Day: 01 Hour: 01 (24h):Minute: 01:Second: 01 post_timezone tags: [post_tags] ---
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import base64
import editor

path = editor.get_path()
header = workflow.get_variable('header')
with open(path, 'r') as file:
	file_contents = file.read()
	file_contents = header + file_contents
	action_out = base64.b64encode(file_contents)
	workflow.set_output(action_out)
Set Variable ?
Variable Name
text64
Value
Input
Open URL ?
Open in
  • In-App Browser
  • Default App / Safari
URL
working-copy://x-callback-url/chain?key=key&repo=repo&command=write&path=path&base64=text64&command=commit&limit=999&message=File Name%20updated&command=push&x-success=editorial://workflow-callback
Tab
  • Last-used Tab
  • New Tab
  • Tab with ID:
Unique identifier
Wait until Loaded
OFF
Reveal Browser Automatically
ON
Show HUD ?
HUD Text
Article File Name published!
Duration
  • 1 Second
  • 2 Seconds
  • 3 Seconds
Icon
  • "Success"
  • "Error"