Editorial Workflows

Hugo Post, Working Copy (v1.1)

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: Creates a Hugo formatted document, saves to a local Git repository in Working Copy then commits & pushes it to the remote Git repository.

How to use:
This Workflow requires the document in Editorial to have been given a file name, and for the WorkingCopyApp.com to be installed and it to have 'Allow URL Actions' enabled in settings.

The workflow requires some configuration before using - to do this the first three steps (highlighted in purple) should be set as follows:

- 'key' matches the secret URL Callback key from App integration settings in the Working Copy App,

- 'repo' matches the repository name of your Hugo site &

- 'categories' matches your list of desired categories.

Features:
You can type a title of Hugo post & description, which default to match the filename, select categories, tags & set a featured image (which will be displayed on the website if your Hugo theme supports it).

Shared by: @iannoble

Comments: Comment Feed (RSS)

@iannoble — 10 Sep 2017
To handle filenames in Editorial with spaces, add a Find/Replace action after the 'Get Current Filename' step, find set to 1 space character, and replace set to a - character.
@iannoble — 10 Sep 2017
The shared workflow has been updated to v1.1:

Improved handling of source filenames (change spaces to -, ensure all lower case)

+ Add Comment

Workflow Preview
Set Working Copy URL key ?
Variable Name
key
Value
Replace with URL key from Working Copy app
Set GIT Repository name ?
Variable Name
repo
Value
Replace with name of GIT repository which stores the Hugo site
Set Category options ?
Variable Name
Categories
Value
Edit Workflow To replace Categories Variable with Your Categories
If… ?
Run the block if
key
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Replace with URL key from Working Copy app
Show Alert ?
Title
Workflow stopped
Message
Working Copy URL key not defined. Please see the workflow description for further details.
Button 1
OK
Output Value
Input
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
Workflow stopped
…End If
If… ?
Run the block if
repo
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Replace with name of GIT repository which stores the Hugo site
Show Alert ?
Title
Workflow stopped
Message
GIT Repository name not defined. Please see the workflow description for further details.
Button 1
OK
Output Value
Input
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
Get Current File Name ?
Include Folder
OFF
Include Extension
OFF
Replace spaces with - ?
Find
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
-
Set filename to lower case ?
  • UPPER CASE
  • lower case
  • Title Case
URL Escape ?
Set Variable ?
Variable Name
filename
Value
Input
Find / Replace ?
Find
-
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
Change Case ?
  • UPPER CASE
  • lower case
  • Title Case
Set Variable ?
Variable Name
pretty_name
Value
Input
Build location of file in repo ?
Variable Name
path
Value
/content/post/Year: 2001-Month: 01-Day: 01-filename.md
Select from List ?
Title
Set featured image?
List (Lines)
Yes No
Multiple Selection
OFF
Show in Popover
OFF
If… ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Yes
Request Text Input ?
Title
Featured image path & filename
Initial Text
/assets/images/YYYY/MM/filename
  • Single Line
  • Multiple Lines
Keyboard Options:
Set Variable ?
Variable Name
post_image_feature
Value
Input
…End If
Request Text Input ?
Title
Title
Initial Text
pretty_name
  • Single Line
  • Multiple Lines
Keyboard Options:
Set Variable ?
Variable Name
post_title
Value
Input
Request Text Input ?
Title
Description
Initial Text
pretty_name
  • Single Line
  • Multiple Lines
Keyboard Options:
Set Variable ?
Variable Name
post_description
Value
Input
Select from List ?
Title
Category
List (Lines)
Categories
Multiple Selection
ON
Show in Popover
OFF
Prefix / Suffix Lines ?
  • Prefix
  • Suffix
Text
-
Set Variable ?
Variable Name
post_categories
Value
Input
Request Text Input ?
Title
Tags (comma seperated)
Initial Text
  • Single Line
  • Multiple Lines
Keyboard Options:
Set Variable ?
Variable Name
post_tags
Value
Input
Get Date, Time & Timezone ?
Source Code
#coding: utf-8
import workflow
import datetime
import time

def isoformat_offset(dt, offset, dt_sep='T', hm_sep=True):

    offset_hours = offset // 3600
    offset_mins = (offset - offset_hours * 3600) // 60
    frmt = '%s%+03d'
    args = [dt.strftime("%Y-%m-%dT%H:%M:%S"), offset_hours]
    if hm_sep is True:
        frmt += ':'
    frmt += '%02d'
    args.append(offset_mins)
    
    return frmt % tuple(args)
    
now = datetime.datetime.now()

offset = -time.altzone
suffix = isoformat_offset(now, offset)

workflow.set_output(suffix)
Set Variable ?
Variable Name
post_datetime
Value
Input
Document Text ?
Folded Text
  • Include
  • Replace with:
Construct Hugo Document ?
Variable Name
text
Value
--- title: post_title description: post_description date: post_datetime categories: post_categories tags: [post_tags] featured_image: post_image_feature --- Input
Send to Working Copy ?
Open in
  • In-App Browser
  • Default App / Safari
URL
working-copy://x-callback-url/chain?key=key&repo=repo&command=pull&command=write&path=path&text=text&command=commit&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