Skip to content

Instantly share code, notes, and snippets.

@pdxmph
Created January 12, 2015 02:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdxmph/1e89bc5060a62acf7f28 to your computer and use it in GitHub Desktop.
Save pdxmph/1e89bc5060a62acf7f28 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'trello'
include Trello
subject = ARGV[0]
id = ARGV[1]
message = ARGV[2]
# There's a little setup involved here.
# Step 1. Write an Applescript that looks like this:
=begin
on log_err(message)
display notification message
log message
end log_err
on run
try
tell application "Mail"
set theSelection to selection
set theMessage to item 1 of theSelection
set messageText to (content of theMessage)
set theSubject to the subject of theMessage
set theMessageID to the message id of theMessage
do shell script "~/bin/amail2trello.rb " & quoted form of theSubject & " " & quoted form of theMessageID & " " & quoted form of messageText
end tell
on error errmsg
my log_err("Could not send message: " & errmsg)
end try
end run
=end
# Step 2. Get Your Application Key from here:
# https://trello.com/1/appKey/generate
public_key = ""
# Step 3. Get Your Token to Approve Your "App" from here:
# https://trello.com/1/authorize?key=YOUR_APPLICATION_KEY_FROM_STEP_1&name=SOME_ARBITRARY_NAME&expiration=never&response_type=token&scope=read,write
member_token = ""
# Step 4. Set up misc. variables
board_name = ""
list_name = ""
username = ""
Trello.configure do |config|
config.developer_public_key = public_key
config.member_token = member_token
end
user = Member.find(username)
board = user.boards.select { |b| b.name == board_name }.first
list = board.lists.select { |l| l.name == list_name }.first
message_id = CGI.escape(id)
card = Card.create(:name => subject, :desc => "message://%3c#{id}%3e\n\n#{message}", :list_id => list.id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment