Editorial Workflows

PostToPelican

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: Enters the current file to the Pelican processing queue. Relies on DropboxAuth workflow.

::version 1.0
::by dgold@ascraeus.org

Shared by: @dg01d

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Show Alert ?
Title
PostPelican
Message
Ready to post this to Pelican?
Button 1
OK
Output Value
Input
Button 2
(don't show)
Output Value
Button 3
(don't show)
Output Value
Show Cancel Button
ON
Get Current File Name ?
Include Folder
OFF
Include Extension
ON
Set Variable ?
Variable Name
fileName
Value
Input
Document Text ?
Folded Text
  • Include
  • Replace with:
Set Variable ?
Variable Name
fileText
Value
Input
Set Variable ?
Variable Name
postTitle
Value
null
Run Python Script ?
Source Code
#coding: utf-8
import workflow

textFile = workflow.get_variable('fileText')


firstLine = textFile.splitlines()[0]

postTitle = firstLine.replace('title: ', '')

workflow.set_variable('postTitle', postTitle)

action_in = workflow.get_input()

#TODO: Generate the output...
action_out = action_in

workflow.set_output(action_out)
Show HUD ?
HUD Text
postTitle
Duration
  • 1 Second
  • 2 Seconds
  • 3 Seconds
Icon
  • "Success"
  • "Error"
Set Variable ?
Variable Name
postLink
Value
null
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import editor
import datetime
import webbrowser
import urllib
import keychain
import pickle
from dropbox import session, client

# First, initialise thr droobox session, using dropboxAuth workflow

dropbox_params_str = keychain.get_password('dropbox', 'all_params')
dropbox_params = pickle.loads(dropbox_params_str)

sess = session.DropboxSession(**dropbox_params['session'])
sess.set_token(**dropbox_params['token'])
dropbox_client = client.DropboxClient(sess)

# Next, pull in the data from to workflow

file_name = workflow.get_variable('postTitle')
file_text = workflow.get_variable('fileText')

file_slug = ""
for c in file_name:
    if c in '!,.`?:"\';':
        c = ""
    file_slug += c
      
file_slug = file_slug.replace(" ", "-").lower()

file_id = file_slug + '.md'

# Sets the date strings for use in the script

current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')

current_date = datetime.datetime.now().strftime('%Y-%m-%d')

# Sets up some date-relevant data

tString = datetime.datetime.now().strftime('%H%M%S')
tMonth = datetime.datetime.now().strftime('%m')
tYear = datetime.datetime.now().strftime('%Y')

# http://ascraeus.org/2014/10/the-future-of-the-culture-wars-is-gamergate.html
tLink = ('http://ascraeus.org/' + tYear + '/' + tMonth + '/' + file_slug + '.html')

workflow.set_variable('postLink', tLink)


file_content = ('status: @post\n' +  'date: ' + current_time + '\n' + 'slug: ' + file_slug + '\n' + file_text)

file_path = 'Apps/Editorial/drafts/' + file_id

#editor.set_file_contents(file_slug, file_content)

#Creates the file in the dropbox folder

dropbox_client.put_file(file_path, file_content)



action_in = workflow.get_input()

#TODO: Generate the output...
action_out = action_in

workflow.set_output(action_out)
Play Sound Effect ?
Effect
Ding_3
Wait until Finished
OFF
Show HUD ?
HUD Text
File in Pelican Work Queue
Duration
  • 1 Second
  • 2 Seconds
  • 3 Seconds
Icon
  • "Success"
  • "Error"
Show Alert ?
Title
postTweet
Message
Tweet a link to the new post?
Button 1
OK
Output Value
Input
Button 2
(don't show)
Output Value
Button 3
(don't show)
Output Value
Show Cancel Button
ON
Select from List ?
Title
Choose Tweet Sentence
List (Lines)
I wrote a thing Time for a new post Blog post nua A View from Ascraeus
Multiple Selection
OFF
Show in Popover
OFF
Compose Tweet ?
Initial Text
Input, postTitle postLink
Stop if Canceled
ON