Editorial Workflows

Post to Dreamwidth/LiveJournal

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 posts to Dreamwidth or LiveJournal depending on user input, and could be set to post to other sites which are based on LiveJournal’s codebase and use the same XMLRPC API.

The workflow fetches a tag list, automatically sets the location, and allows for the user's mood and music to be passed to LiveJournal before opening the entry in Safari.

This must be combined with my Set Password workflow to work properly (the title of the service you set in the Set Password workflow must be the same as the one you select from the list in this workflow). In order to use this workflow, edit the 'username' variable to your username.

This workflow was based in part on the 'Post to WordPress' workflow by Federico Viticci. It was also greatly informed by posts on both EllisLab and the lj-clients community on LiveJournal.

Shared by: @johncoxon

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Set Username ?
Variable Name
username
Value
johncoxon
Post Coordinates? (true/false) ?
Variable Name
post_coordinates
Value
false
Select from List ?
Title
LiveJournal or Dreamwidth?
List (Lines)
Dreamwidth LiveJournal
Multiple Selection
OFF
Show in Popover
OFF
Set Variable ?
Variable Name
service
Value
Input
Check Subject ?
Title
Check Subject
Initial Text
File Name%cursor
  • Single Line
  • Multiple Lines
Keyboard Options:
Store Subject ?
Variable Name
subject
Value
Input
Get Markdown ?
Folded Text
  • Include
  • Replace with:
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
Fix LJ Cut ?
Find
^<p><lj-cut text="(.+)"></p>$
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
<lj-cut text="$1">
Fix LJ Cut ?
Find
<p></lj-cut></p>
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
</lj-cut>
Store Content ?
Variable Name
content
Value
Input
Get Tags ?
Source Code
#coding: utf-8
import xmlrpclib
import workflow
import keychain
import console

console.show_activity('Fetching tags...')

service = workflow.get_variable('service')
username = workflow.get_variable('username')

event = {
	'username': username,
	'password': keychain.get_password(service, username)
}

# Log in and get the tags from the server.
url_dict = {
	'Dreamwidth': 'https://www.dreamwidth.org/interface/xmlrpc',
	'LiveJournal': 'https://www.livejournal.com/interface/xmlrpc'
}
server = xmlrpclib.ServerProxy(url_dict[service])
response = server.LJ.XMLRPC.getusertags(event)

# Go through the tags one by one and make them into a list for making the selection.
tags = ''
for x in response['tags']:
	tags += '\n' + str(x['name'])
workflow.set_variable('tags', tags)
console.hide_activity()
workflow.set_output(tags)
Remove Blank Tags ?
  • Trim leading/trailing whitespace
  • Remove empty lines
Alphabetise Tags ?
Sort Order
  • Ascending (A → Z)
  • Descending (Z → A)
Choose Tags ?
Title
Select Tags
List (Lines)
Input
Multiple Selection
ON
Show in Popover
ON
Store Tags ?
Variable Name
selected_tags
Value
Input
Current Mood ?
Title
Current Mood
List (Lines)
accomplished (90) aggravated (1) amused (44) angry (2) annoyed (3) anxious (4) apathetic (114) artistic (108) awake (87) bitchy (110) blah (92) blank (113) bored (5) bouncy (59) busy (91) calm (68) cheerful (125) chipper (99) cold (84) complacent (63) confused (6) contemplative (101) content (64) cranky (8) crappy (7) crazy (106) creative (107) crushed (129) curious (56) cynical (104) depressed (9) determined (45) devious (130) dirty (119) disappointed (55) discontent (10) distressed (127) ditzy (35) dorky (115) drained (40) drunk (34) ecstatic (98) embarrassed (79) energetic (11) enraged (12) enthralled (13) envious (80) exanimate (78) excited (41) exhausted (14) flirty (67) frustrated (47) full (93) geeky (103) giddy (120) giggly (72) gloomy (38) good (126) grateful (132) groggy (51) grumpy (95) guilty (111) happy (15) high (16) hopeful (43) horny (17) hot (83) hungry (18) hyper (52) impressed (116) indescribable (48) indifferent (65) infuriated (19) intimidated (128) irate (20) irritated (112) jealous (133) jubilant (21) lazy (33) lethargic (75) listless (76) lonely (22) loved (86) melancholy (39) mellow (57) mischievous (36) moody (23) morose (37) naughty (117) nauseated (97) nerdy (102) nervous (134) nostalgic (60) numb (124) okay (61) optimistic (70) peaceful (58) pensive (73) pessimistic (71) pissedoff (24) pleased (109) predatory (118) productive (89) quixotic (105) recumbent (77) refreshed (69) rejected (123) rejuvenated (62) relaxed (53) relieved (42) restless (54) rushed (100) sad (25) satisfied (26) scared (46) shocked (122) sick (82) silly (66) sleepy (49) sore (27) stressed (28) surprised (121) sympathetic (81) thankful (131) thirsty (29) thoughtful (30) tired (31) touched (32) uncomfortable (74) weird (96) working (88) worried (85)
Multiple Selection
OFF
Show in Popover
ON
Store Mood ?
Variable Name
current_mood
Value
Input
Publish Entry ?
Source Code
#coding: utf-8
import xmlrpclib
import workflow
import console
import keychain
import time
import location

console.show_activity('Publishing...')

service = workflow.get_variable('service')
username = workflow.get_variable('username')

# Populate event with all the stuff necessary to make the post.
event = {
	'username': username,
	'password': keychain.get_password(service, username),
	'event': workflow.get_variable('content'),
	'subject': workflow.get_variable('subject'),
	'year': time.localtime()[0],
	'mon': time.localtime()[1],
	'day': time.localtime()[2],
	'hour': time.localtime()[3],
	'min': time.localtime()[4],
	'security': 'usemask',
	'allowmask': 1,
	'props': {'opt_preformatted': 1}
}

# security can take strings: public/private/usemask.
# Usemask restricts to the value in allowmask: 0 for private, 1 for flocked, others for friend groups.
# This could be relatively easily edited to take an input from the user instead of being set here.

# Get the user's current location from iOS.
location.start_updates()
location_data = location.get_location()
location.stop_updates()

# Get address and coordinate strings from the location to pass to LiveJournal.
try:
	current_coordinates = str(location_data['latitude']) + ', ' + str(location_data['longitude'])
	address_data = location.reverse_geocode(location_data)
	city_country = address_data[0]['City'] + ', ' + address_data[0]['Country']
	current_location = city_country.replace('United Kingdom', 'UK')
	if workflow.get_variable('post_coordinates') == 'true':
		event['props']['current_coords'] = current_coordinates
	event['props']['current_location'] = current_location
except:
	pass

# Get the tags as a comma separated list.
selected_tags = workflow.get_variable('selected_tags')
event['props']['taglist'] = selected_tags.replace('\n',',')

# Get the current mood from the inputs earlier.
selected_mood = workflow.get_variable('current_mood')
if selected_mood == '':
	mood_name = ''
	mood_ID = ''
else:
	mood_components = selected_mood.split(' (')
	event['props']['current_mood'] = mood_components[0]
	event['props']['current_moodid'] = mood_components[1].replace(')','')

# Actually post the entry.
url_dict = {
	'Dreamwidth': 'https://www.dreamwidth.org/interface/xmlrpc',
	'LiveJournal': 'https://www.livejournal.com/interface/xmlrpc'
}
server = xmlrpclib.ServerProxy(url_dict[service])
response = server.LJ.XMLRPC.postevent(event)

# Notify the user that the workflow has completed.
console.hud_alert('Published ' + str(response['itemid']), 'success', 1.0)
workflow.set_output(response['url'])
Open LiveJournal Entry ?
Open in
  • In-App Browser
  • Default App / Safari
URL
Input
Tab
  • Last-used Tab
  • New Tab
  • Tab with ID:
Unique identifier
Wait until Loaded
OFF
Reveal Browser Automatically
ON