Editorial Workflows

Post to Scriptogram

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: Post content to scriptogr.am.

The workflow will try to automatically get the post date and title of huge post from the metadata.

Be sure to enter in your own app key and user ID into the variables at the top of the workflow.

Shared by: Www.Ryanmo.co

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Your App Key ?
Variable Name
APP_KEY
Value
Your User ID ?
Variable Name
USER_ID
Value
Document Text ?
Folded Text
  • Include
  • Replace with:
Set Variable ?
Variable Name
doctext
Value
Input
Generate Text ?
Text
doctext
Find ?
Search for
^Title: (.*)$
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)
Post title ?
Title
Post Title
Initial Text
Input
  • Single Line
  • Multiple Lines
Keyboard Options:
Set Variable ?
Variable Name
post_title
Value
Input
Generate Text ?
Text
doctext
Find ?
Search for
^Date:\s*(\d{4}-\d{1,2}-\d{1,2})$
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)
Request Text Input ?
Title
Date
Initial Text
Input%cursor
  • Single Line
  • Multiple Lines
Keyboard Options:
Set Variable ?
Variable Name
post_date
Value
Input
Show HUD ?
HUD Text
Posting to Scriptogr.am
Duration
  • 1 Second
  • 2 Seconds
  • 3 Seconds
Icon
  • "Success"
  • "Error"
Run Python Script ?
Source Code
import requests
import workflow


APP_KEY = workflow.get_variable('APP_KEY')
USER_ID = workflow.get_variable('USER_ID')

post_date = workflow.get_variable('post_date')
content = workflow.get_variable('doctext')
post_title = workflow.get_variable('post_title')

class NetworkError(Exception):
    pass

datas = {
    'app_key': APP_KEY,
    'user_id': USER_ID,
    'name': '%s_%s' % (post_title.replace(' ', '-'), post_date.replace('-', '.')),
    'text': content
}

url = 'http://scriptogr.am/api/article/post/'

res = requests.post(url, data=datas)

if res.status_code != requests.codes.ok:
    workflow.set_output('HTTP Error : %d' % res.status_code)
else:
    if 'status' not in res.json():
        workflow.set_output('Invalid answer from scriptogr.am API'
                           % res.json()['reason'])
    if res.json()['status'] != 'success':
        workflow.set_output('%s' % res.json()['reason']) 
workflow.set_output('Sucess! Posted to Scriptogram')
Show HUD ?
HUD Text
Input
Duration
  • 1 Second
  • 2 Seconds
  • 3 Seconds
Icon
  • "Success"
  • "Error"