# MarsEdit Applescripts
Shared by Miraz Jordan, https://miraz.me
to accompany the 2023 Micro Camp Presentation:
Take the Captain’s Chair of your Micro.Blog with the MarsEdit App for Mac: Time Travel, Replicators, Warp Speed and More
Use these with caution. I'm no Applescript expert and although they work for me they may bring unexpected results for you.
Copy a script and paste it into the Script Editor.app on your Mac. You'll probably find it in Applications - Utilities.
## Table of Contents
- Get the title of a selected post
- Title and URL as Markdown link
- Title and URL as an HTML link
- Title and URL as a plain text link
- Grab some stuff from a post and put it on the clipboard
- Link and title and body for ME post
- Get bounds of MarsEdit windows
- Resize windows
================
## Get the title of a selected post
-- This script gets the Title of a selected blog post if there is one
-- Otherwise it gets the first ~100 characters
-- and puts it on the clipboard
-- by Miraz Jordan, https://miraz.me, 14 May 2023
-- use at your own risk
tell application "MarsEdit"
set newTitle to ""
set newTitle to (title of selected post) as text
set the clipboard to newTitle
end tell
================
## Title and URL as Markdown link
-- get Title and published URL of a selected post
-- format it as a Markdown link
-- and put it on the clipboard
-- by Miraz Jordan, https://miraz.me
-- use at your own risk
tell application "MarsEdit"
set newLink to ""
set newLink to (permalink of selected post) as text
set newTitle to (title of selected post) as text
set the clipboard to "[" & newTitle & "]" & "(" & newLink & ")"
end tell
================
## Title and URL as an HTML link
-- get Title and published URL of a selected post
-- format it as an HTML link
-- and put it on the clipboard
-- by Miraz Jordan, https://miraz.me
-- use at your own risk
tell application "MarsEdit"
set newLink to ""
set newLink to (permalink of selected post) as text
set newTitle to (title of selected post) as text
set the clipboard to "" & newTitle & ""
end tell
================
## Title and URL as a plain text link
-- get Title and published URL of a selected post
-- format it as a plain text link
-- and put it on the clipboard
-- by Miraz Jordan, https://miraz.me
-- use at your own risk
tell application "MarsEdit"
set newLink to ""
set newLink to (permalink of selected post) as text
set newTitle to (title of selected post) as text
set the clipboard to newTitle & ":" & newLink
end tell
================
## Grab some stuff from a post and put it on the clipboard
-- This script grabs title, URL, published date and previously copied text
-- and puts it on the clipboard
-- by Miraz Jordan, https://miraz.me, 28 July 2020
-- use at your own risk
tell application "MarsEdit"
-- first *copy* the text from the post that you want to include
tell selected post
-- clear variables
set myTitle to ""
set myLink to ""
set myPub to ""
set myText to ""
-- grab info and load into variables
-- put each bit on a new line
set myTitle to return & "Title: " & title
set myLink to return & "Link: " & permalink
set myPub to return & "Published: " & published date
set myText to return & "Quote: " & (the clipboard) -- this is the selection you copied
-- assemble into a chunk ready to paste elsewhere
set the clipboard to myTitle & myLink & myPub & myText
end tell
end tell
================
## Link and title and body for ME post
-- Get Link and title and body for ME post
-- in HTML
-- and put it all on the clipboard
-- by Miraz Jordan, https://miraz.me
-- use at your own risk
tell application "MarsEdit"
set newLink to ""
set newTitle to ""
set myPost to ""
set newLink to (permalink of selected post) as text
set newTitle to (title of selected post) as text
set myPost to (body of selected post) as text
set the clipboard to "" & newTitle & "" & return & myPost
end tell
================
## Get bounds of MarsEdit windows
-- I use this to establish the sizes of the Composition and Preview windows
-- get bounds of ME composition and Preview windows
-- first bring the composition window to the front so that one's listed first
-- by Miraz Jordan, https://miraz.me
-- use at your own risk
tell application "MarsEdit"
get bounds of window index 1
get bounds of window index 2
end tell
================
## Resize windows
-- arrange the windows how I like them
-- see the above script
-- I use this to set the sizes and positions
-- of the Composition and Preview windows
-- first bring the composition window to the front so that one's resized on the left
tell application "MarsEdit"
set bounds of window index 1 to {0, 22, 762, 900}
set bounds of window index 2 to {763, 22, 1440, 900}
end tell
================
If you create any Applescripts for MarsEdit (or can improve on these), please let me know.
Miraz Jordan, miraz@firstbite.nz
14 May 2023