Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Automatic WordPress Journal
-----------------------------------------------------
-- WordPress Journal
-----------------------------------------------------
-- Created by Graham English
-- http://integral.grahamenglish.net
-- http://consulting.grahamenglish.net
-- http://www.grahamenglish.net/blog
-----------------------------------------------------
-- Released under the Creative Commons Attribution, ShareAlike license.
-----------------------------------------------------
-- This journal script uses one timed repeat variable from 9 to 5 PM, and
-- another the rest of the time, using your system clock. Set the options
-- below to your desired repeat times.
-----------------------------------------------------
global startTime, endTime
-- set your options
set startTime to "8"
set endTime to "20" -- e.g. 13 for 1 PM
set timeOption1 to (30 * 15) -- repeats every 15 minutes
set timeOption2 to (60 * 30) -- repeats every half hour
set timeNow to hours of (current date)
set theBlogID to "default"
set theAccountName to "admin" -- Your Blog Username
set theAccountPassword to "Fo$Z!R%F%xxb" -- Your Blog Password
set theDate to (current date) as string
set journalQuestion to "What are you doing?" as text
if timeNow ≥ startTime and timeNow < endTime then
repeat
tell application "Finder"
activate
set journalEntry to (display dialog journalQuestion default answer "" buttons {"Cancel", "Add"} default button "Add")
set journalData to text returned of journalEntry
if length of journalData < 40 then
set theTitle to journalData as string
end if
if length of journalData > 40 then
set theTitle to characters 1 thru 40 of journalData as string
set theTitle to theTitle & "..."
end if
tell application "http://journal.private/xmlrpc.php" -- The URL to your blog
set returnValue to call xmlrpc {method name:"metaWeblog.newPost", parameters:{theBlogID, theAccountName, theAccountPassword, {title:theTitle, description:journalData}, 1}}
end tell
set results to returnValue
tell application "GrowlHelperApp"
register as application "WordPress Journal" all notifications {"Alert"} default notifications {"Alert"} icon of application "TextEdit.app"
notify with name "Alert" title "Successful Post ID:" description results application name "WordPress Journal"
end tell
end tell
delay timeOption1
end repeat
else
-- Option 2
repeat
tell application "Finder"
activate
set journalEntry to (display dialog journalQuestion default answer "" buttons {"Cancel", "Add"} default button "Add")
set journalData to text returned of journalEntry
set theTitle to characters 1 thru 40 of journalData as string
if length of journalData > 40 then
set theTitle to theTitle & "..."
end if
tell application "http://journal.private/xmlrpc.php" -- The URL to your blog
set returnValue to call xmlrpc {method name:"metaWeblog.newPost", parameters:{theBlogID, theAccountName, theAccountPassword, {title:theTitle, description:journalData}, 1}}
end tell
set results to returnValue
tell application "GrowlHelperApp"
register as application "WordPress Journal" all notifications {"Alert"} default notifications {"Alert"} icon of application "TextEdit.app"
notify with name "Alert" title "Successful Post ID:" description results application name "WordPress Journal"
end tell
end tell
delay timeOption2
end repeat
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.