Editorial Workflows

Gaddgict Publish Workflow Template

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: Redacted version of the script I wrote to Publish a new post to my site.

Shared by: Gaddgict.com / @SyrinxStarman

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Set fn variable ?
Variable Name
fn
Value
Get Current File Name ?
Include Folder
OFF
Include Extension
ON
Stores Current File Name in variable ?
Variable Name
edFileName
Value
Input
Document Text ?
Folded Text
  • Include
  • Replace with:
Find Post Type ?
Search for
<!--pt (.*) pt-->
Match Group (RegEx)
1
Search Type
  • Regular Expression
  • Case-insensitive Search (A = a)
  • Case-sensitive Search (A ≠ a)
Output
  • Found Text
  • Range of Text (from:to)
Store postType ?
Variable Name
postType
Value
Input
Document Text ?
Folded Text
  • Include
  • Replace with:
Find Post Category ?
Search for
<!--pc (.*) pc-->
Match Group (RegEx)
1
Search Type
  • Regular Expression
  • Case-insensitive Search (A = a)
  • Case-sensitive Search (A ≠ a)
Output
  • Found Text
  • Range of Text (from:to)
Store postCategory ?
Variable Name
postCategory
Value
Input
Document Text ?
Folded Text
  • Include
  • Replace with:
Store postContent ?
Variable Name
postContent
Value
Input
Find Post Title ?
Search for
<!--t (.*) t-->
Match Group (RegEx)
1
Search Type
  • Regular Expression
  • Case-insensitive Search (A = a)
  • Case-sensitive Search (A ≠ a)
Output
  • Found Text
  • Range of Text (from:to)
Remove all special characters ?
Find
[.,\/#!$%\^&\*;:{}=\-_’'”“"‘?~+()]
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
Replace spaces with dashes ?
Find
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
-
Change Case ?
  • UPPER CASE
  • lower case
  • Title Case
Store postTitle ?
Variable Name
postTitle
Value
Input
Generate Text ?
Text
postContent
Find Tags ?
Search for
<!--tag (.*) tag-->
Match Group (RegEx)
1
Search Type
  • Regular Expression
  • Case-insensitive Search (A = a)
  • Case-sensitive Search (A ≠ a)
Output
  • Found Text
  • Range of Text (from:to)
Replace spaces with dashes ?
Find
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
-
Change Case ?
  • UPPER CASE
  • lower case
  • Title Case
Store postTags ?
Variable Name
postTags
Value
Input
SSH Publish (Python) ?
Source Code
#coding: utf-8
import workflow
import editor
import datetime
import paramiko
import console

#Grab some of the workflow variables used so far.
postTitle = workflow.get_variable('postTitle')
postTags = workflow.get_variable('postTags')
postType = workflow.get_variable('postType')
postCategory = workflow.get_variable('postCategory')
postContents = workflow.get_variable('postContent')
edFileName = workflow.get_variable('edFileName')

#Formulate the filename for the post once its uploaded to the server (HTMLy's format).
fileName = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')+'_'+postTags+'_'+postTitle+'.md'
workflow.set_variable('fn',fileName)

#Get the local Editorial path to the folder of your private SSH key.
editor_path = editor.get_path()
delim = "/"
ed_path_trunced = delim.join(editor_path.split('/', 7)[:7]) + "/Documents/Private/"

#Set the remote path for the file to be stored on the server, in addition to the username, host, and port.
remotePath = "/blog/path/" + postCategory + "/" + postType + "/" + fileName
user = "user"
host = "example.com"
port = 1234

#Set the log file for paramiko (Python SSH module)
paramiko.util.log_to_file(ed_path_trunced + 'paramiko.log')

#Identify the private key file location
k = paramiko.RSAKey.from_private_key_file(ed_path_trunced + 'keyfile_name')

#Use paramiko Transport to connect to the server
transport = paramiko.Transport((host, port))
transport.connect(username = user, pkey = k)
sftp = paramiko.SFTPClient.from_transport(transport)

#Get full path to the local file within Editorial and upload to the server
edFile = editor.get_path()
sftp.put(edFile, remotePath)
console.hud_alert('Posted '+fileName, 'success')

#close connections
sftp.close()
transport.close()

action_in = workflow.get_input()

# Extension point to do something after the file is uploaded
action_out = action_in

workflow.set_output(action_out)
Clear Cache (Python) ?
Workflow
Can Stop Main Workflow
OFF
Move Caret ?
Direction
  • Backward
  • Forward
  • Start/End of Document
  • Start/End of Line
  • Number of Characters:
1
Insert HTMLy filename into bottom ?
Replacement Text
<!--fn fn fn-->
Generate permalink ?
Variable Name
permalink
Value
https://gaddgict.com/Year: 2001/Month: 01/postTitle
Get post name ?
Text
File Name
Copy post name to clipboard ?
Share Sheet for Tweetbot ?
Text
permalink
Share as
  • Text
  • URL
Open FB Share Page ?
Open in
  • In-App Browser
  • Default App / Safari
URL
https://www.facebook.com/sharer/sharer.php?u=permalink
Tab
  • Last-used Tab
  • New Tab
  • Tab with ID:
Unique identifier
Wait until Loaded
OFF
Reveal Browser Automatically
ON
Open article page ?
Open in
  • In-App Browser
  • Default App / Safari
URL
permalink
Tab
  • Last-used Tab
  • New Tab
  • Tab with ID:
Unique identifier
Wait until Loaded
OFF
Reveal Browser Automatically
ON
Open Google Search Console ?
Open in
  • In-App Browser
  • Default App / Safari
URL
https://www.google.com/webmasters/tools/googlebot-fetch?hl=en&siteUrl=https://gaddgict.com/
Tab
  • Last-used Tab
  • New Tab
  • Tab with ID:
Unique identifier
Wait until Loaded
OFF
Reveal Browser Automatically
ON