Editorial Workflows

Upload to Evernote

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: This workflow converts markdown to html and uploads it to default Evernote notebook. In addition, filters lines with dates in format YYYY-MM-DD and sets it as Evernote Note Title and fetches Evernote Tags so those could be assigned to the note.

Based on @viticci "Fetch Tags" workflow and HTML to EN workflow.

More info: http://www.cookiemash.cz/od-editorial-k-omnifocus/

Shared by: @ToBazi

Comments: Comment Feed (RSS)

Fonnesbeck — 04 Nov 2015
This workflow DELETES THE CONTENTS OF THE NOTE being sent to Evernote in the current version of Editorial. Not good.

+ Add Comment

Workflow Preview
Document Text ?
Folded Text
  • Include
  • Replace with:
Extract lines with dates ?
Output Lines That
  • Contain
  • Don't Contain
  • Match Regular Expression:
Year: 2001-Month: 01-Day: 01
Output Format
  • Only Lines
  • Lines and Ranges
Select from List ?
Title
Select the name of Evernote Note
List (Lines)
Input
Multiple Selection
OFF
Show in Popover
OFF
Select Range ?
Range (from:to)
Input
Relative to
  • Entire Document
  • Current Selection
Set Variable ?
Variable Name
filename
Value
Input
Select Range ?
Range (from:to)
Sel. Range: Start:Sel. Range: End+1
Relative to
  • Entire Document
  • Current Selection
Replace Selected Text ?
Replacement Text
Task Clone Tag ?
Variable Name
taskclone
Value
Send_To_OmniFocus
Show Alert ?
Title
Evernote Tags
Message
Fetch Evernote tags?
Button 1
No
Output Value
no
Button 2
Yes
Output Value
yes
Button 3
(don't show)
Output Value
Show Cancel Button
OFF
If… ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
yes
Fetch Evernote Tags ?
Source Code
#coding: utf-8
import workflow
import console
import webbrowser
import keychain
import pickle
import evernote.edam.userstore.constants as UserStoreConstants
import evernote.edam.type.ttypes as Types
from evernote.api.client import EvernoteClient

#keychain.delete_password('evernote', 'editorial')
login = keychain.get_password('evernote', 'editorial')
if login is not None:
	auth_token = pickle.loads(login)
else:
	token_choice = console.alert('Token Needed', 'A Developer Token is needed. Go get one?', 'Yes', 'I have One', 'Cancel')
	if token_choice == 1:
		webbrowser.open('safari-https://www.evernote.com/Login.action?targetUrl=%2Fapi%2FDeveloperToken.action')
		raise KeyboardInterrupt
	elif token_choice == 2:
		auth_token = console.password_alert('Evernote Developer Token', 'Paste Your Evernote Developer Token')
		pickle_token = pickle.dumps(auth_token)
		keychain.set_password('evernote', 'editorial', pickle_token)
	else:
		raise KeyboardInterrupt

console.show_activity('Getting Tags...')
client = EvernoteClient(token=auth_token, sandbox=False)
note_store = client.get_note_store()
console.show_activity('Getting Tags...')

note = Types.Note()
s = []

# List all of the tags in the user's account
tags = note_store.listTags()
console.show_activity('Getting Tags...')
for tag in tags:
	console.show_activity()
	s.append(tag.name) 
	console.show_activity('Getting Tags...')
	output = '\n'.join(s)
workflow.set_output(output)
Sort Lines ?
Sort Order
  • Ascending (A → Z)
  • Descending (Z → A)
Select from List ?
Title
Select Evernote Tags
List (Lines)
Input
Multiple Selection
ON
Show in Popover
OFF
Set Variable ?
Variable Name
fetched_tags
Value
Input
Set Variable ?
Variable Name
selected_tags
Value
fetched_tags taskclone
…End If
Set Variable ?
Variable Name
title
Value
filename
Set Clipboard ?
Document Text ?
Folded Text
  • Include
  • Replace with:
Set Variable ?
Variable Name
text
Value
Input
Generate Text ?
Text
text
Convert Markdown ?
Markdown Extras: Footnotes
ON
…Auto-Links
ON
…Strikethrough (~~x~~)
ON
…Superscript (^x)
ON
…Tables
ON
…Smart Quotes etc.
ON
…Strip Metadata Headers
OFF
Set Variable ?
Variable Name
htmltext
Value
Input
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import webbrowser
import console
import keychain
import pickle
import evernote.edam.userstore.constants as UserStoreConstants
import evernote.edam.type.ttypes as Types
from evernote.api.client import EvernoteClient
import markdown2
import editor


#keychain.delete_password('evernote', 'editorial')
login = keychain.get_password('evernote', 'editorial')
if login is not None:
	auth_token = pickle.loads(login)
else:
	token_choice = console.alert('Token Needed', 'A Developer Token is needed. Go get one?', 'Yes', 'I have One', 'Cancel')
	if token_choice == 1:
		webbrowser.open('safari-https://www.evernote.com/Login.action?targetUrl=%2Fapi%2FDeveloperToken.action')
		raise KeyboardInterrupt
	elif token_choice == 2:
		auth_token = console.password_alert('Evernote Developer Token', 'Paste Your Evernote Developer Token')
		pickle_token = pickle.dumps(auth_token)
		keychain.set_password('evernote', 'editorial', pickle_token)
	else:
		raise KeyboardInterrupt

current_text = editor.get_text()
evernote_tags = workflow.get_variable('selected_tags')
doc_title = workflow.get_variable('title').encode('utf-8')
html_text = workflow.get_variable('htmltext').encode('utf-8')

client = EvernoteClient(token=auth_token, sandbox=False)
note_store = client.get_note_store()
notebooks = note_store.listNotebooks()


if evernote_tags is None:
 tags = workflow.get_variable('taskclone').split('\n')
elif evernote_tags is not None:
 tags = []
 tagnew = evernote_tags.split('\n')
 for x in tagnew:
  tags.append(x)




# To create a new note, simply create a new Note object and fill in
# attributes such as the note's title.
note = Types.Note()
note.title = doc_title
note.tagNames = tags

note.content = '<?xml version="1.0" encoding="UTF-8"?>'
note.content += '<!DOCTYPE en-note SYSTEM ' \
   '"http://xml.evernote.com/pub/enml2.dtd">'
note.content += '<en-note>' + html_text + '<br/>'
note.content += '</en-note>'

# Finally, send the new note to Evernote using the createNote method
# The new Note object that is returned will contain server-generated
# attributes such as the new note's unique GUID.
created_note = note_store.createNote(note)

#print "Successfully created a new note with GUID: ", created_note.guid

console.hud_alert(doc_title+' saved to the default folder in Evernote','success')