Hey Folks,
My generic open-list-archive script works with Discourse. It will take the selected message in Mail.app and open the URL from the List-Archive mail-header (if extant) in Safari.
It also works with Yahoo Groups and any other forum that uses a List-Archive header.
All regex in this script is ‘sed’ from the shell, so no 3rd pty tools are required. All functionality can be replicated with KM except for grabbing the requisite data from Mail.
–
Best Regards,
Chris
Auth: Christopher Stone
dCre: 2013-04-02 : 14:00
dMod: 2013-12-15 : 10:04
Appl: Apple Mail & Default browser
Task: Visit List-Serve Page Related to List-Mail-Message if Available.
Libs: None
Osax: None
Tags: @Applescript, @Mail, @List, @Archive, @Header, @Browser
Note: Tested only on OSX 10.9.x
try
set listArchiveUrl to {}
set yahooGroupsBaseURL to “http://groups.yahoo.com/neo/groups/”
tell application "Mail"
set _msg to selection
if length of _msg = 1 then
set _msg to item 1 of _msg
else
error "No messages OR too many messages are seleced!"
end if
tell _msg
set listID to content of (headers whose name is "List-Id")
if listID ≠ {} then
set listID to item 1 of listID
end if
set listArchiveUrl to content of (headers whose name is "List-Archive")
if listArchiveUrl ≠ {} then
set listArchiveUrl to item 1 of listArchiveUrl
end if
if listArchiveUrl = {} then
if listID contains "applescript-users.lists.apple.com" then
set listArchiveUrl to "http://lists.apple.com/archives/applescript-users"
else if listID contains "yahoogroups.com" then
set _cmd to "<<< " & (quoted form of listID) & " sed -E '
s![<>]!!g
s!\\.yahoogroups\\.com$!!
'"
set listID to do shell script _cmd
set listArchiveUrl to yahooGroupsBaseURL & listID & "/"
end if
end if
end tell
end tell
if listArchiveUrl is in {{}, “”} then
beep
return
else
set _cmd to "<<< " & (quoted form of listArchiveUrl) & " sed -E ‘s!^<|>$!!g’"
set listArchiveUrl to do shell script _cmd
tell application "Safari"
make new document with properties {URL:listArchiveUrl}
set bounds of front window to {228, 22, 1542, 1196}
activate
end tell
end if
on error e number n
stdErr(e, n, true, true) of me
end try