Editorial Workflows

Journal

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: Create a new journal entry with time stamp and location. The time stamp is currently hard coded to a zone selection list until I need to auto detect it based on location or something. Time zones are hard.

Shared by: Aleksandr Pasechnik @alpiarian

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Select from List ?
Title
Time Zone
List (Lines)
America/New York America/Chicago
Multiple Selection
OFF
Show in Popover
OFF
Set Variable ?
Variable Name
timezone
Value
Input
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import location
import time


def decdeg2dmsz(dd):
	is_positive = dd >= 0
	dd = abs(dd)
	minutes,seconds = divmod(dd*3600,60)
	degrees,minutes = divmod(minutes,60)
	degrees = degrees if is_positive else -degrees
	degrees = int(degrees)
	minutes = int(minutes)
	z = int((seconds - int(seconds)) * 1e5)
	seconds = int(seconds)
	return [degrees,minutes,seconds,z]


location.start_updates()

gotloc = False
for _ in range(30):
	loc = location.get_location()
	if (time.time() - loc['timestamp']) < 5:
		gotloc = True
		break
	
	time.sleep(0.5)

location.stop_updates()

if not gotloc:
	workflow.set_output('Unknown')

else:
	lat_dms = decdeg2dmsz(loc['latitude'])
	lat_ns = 'N'
	if lat_dms[0] < 0:
		lat_ns = 'S'
		lat_dms[0] *= -1
		
	lon_dms = decdeg2dmsz(loc['longitude'])
	lon_ew = 'E'
	if lon_dms[0] < 0:
		lon_ew = 'W'
		lon_dms[0] *= -1
		
	latlon = "{0[0]}˚{0[1]}'{0[2]}.{0[3]:05}\" {1}, {2[0]}˚{2[1]}'{2[2]}.{2[3]:05}\" {3}".format(lat_dms, lat_ns, lon_dms, lon_ew)
	
	
	geo = location.reverse_geocode(loc)
	if len(geo) == 0:
		geo = {}
	else:
		geo = geo[0]
	
	addr_bits = [
		geo.get(bit, None)
		for bit in 'Street City State Country'.split()
	]
	addr_bits = filter(
		lambda b: b is not None,
		addr_bits,
	)
	addr = ', '.join(addr_bits)
	
	
	if addr != '':
		place = '{} ({})'.format(addr, latlon)
	else:
		place = latlon
	
	
	workflow.set_output(place)
Set Variable ?
Variable Name
location
Value
Input
Select from List ?
Title
Location Emoji
List (Lines)
🏠 🚍 ✈️ 🚇 🚕 (other) (none)
Multiple Selection
OFF
Show in Popover
OFF
Set Variable ?
Variable Name
location emoji
Value
Input
If… ?
Run the block if
location emoji
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
(other)
Request Text Input ?
Title
Other Location Emoji
Initial Text
  • Single Line
  • Multiple Lines
Keyboard Options:
Set Variable ?
Variable Name
location emoji
Value
Input
…End If
If… ?
Run the block if
location emoji
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
(none)
Set Variable ?
Variable Name
location emoji
Value
…End If
Create Document ?
Filename
Year: 2001-Month: 01-Day: 01 Hour: 01 (24h)-Minute: 01-Second: 01 Day: Mo.md
Content
# %cursor --- **Timestamp:** Day: Monday, Month: January Day: 1, Year: 2001 at Hour: 1 (24h):Minute: 01:Second: 01 timezone **Location:** location emoji location
Open in Editor
ON