You must use Mac OS X and have a Blogger acount (logging and password) and at least one blog created (blog ID).
First of all, note the path of your Public Folder; it should be something like "HardDisksName:UserLogging:Public:".
Next, create a text file named GD.txt. I have no idea why I named it like that, didn't annoted the acronym [probabley general data], so feel free to change it, but remember to set it also in the script. It must be placed in your Public Folder.
It contains the CC license information, your ID, and contact details; it may be a flat file or marked to provide links, as the one I used :
by <a href="http://www.blogger.com/profile/1519384" target="_blank">Oldcola</a>
Contact: <a href="mailto:oldcola@gmail.com"><img src="http://oldcola.blogspot.com/goodies/ico/mail.png" alt="mail"></a> - <a href="aim:goim?screenname=avek@mac.com"><img src="http://oldcola.blogspot.com/goodies/ico/ichat.png" alt="iChat"></a> - <a href="callto://oldcola"><img src="http://oldcola.blogspot.com/goodies/ico/skype.png" alt="Skype"></a>
Producing:
by-nc-saby OldcolaContact:
-
- 
Prepare the droplet by including your data in the applescript (using ScriptEditor) and saving it as an application.
A file named tags.txt must be available. If you don't want to use tags, just let it empty. Otherwise, store in it the tags you use.
The description of the file you want to made available, should be in the comments of the file. You can get there by command-I :-)
Just drop the file on the droplet and let it do the job. It will produce a post like this:
- FileName: **test
- Size: 1407,0
- Created: lundi 24 janvier 2005 19:14:19
- Last modified: lundi 24 janvier 2005 21:12:37
This is a single paragraph, showing what an abstract would be like, once the keywords have been replaced by the corresponding tags for technorati use [example: blog, semanticinternet]. On use, it should be a description of the file's contents, a teaser for reader to promote downloading if they are interested, and an inhibitor for useless downloads from lurkers not realy concerned.
Now, the last thing to do is ping Technorati... I'll have to find something better then opening a page in my browser. Some work to do with XML-RPC. If you use Firefox you may use the "open URL" i placed as comment in the script.
A second option is to attach the script to the Public Folder as a "Folder Action". That means that every file will be presented, but the script will fail if you aren't connected. You need to have access to Blogger to post and publish. I may add a part allowing to batch the posts and wait for the next connexion to post them.
The script:
property bloggerAPIKey : "4FCE1E1F9E2DC89044F09D583390AB8A36F4903E"
property username : "loggin"
property myPassword : "password"
property weblogName : "blog name"
property weblogURL : "blog URL"
property blogid : "blog ID"
property content : ""
property autoURL : "True"
property APIURL : "http://plant.blogger.com/api/RPC2"
on open (filename)
set the filename to filename as alias
set ThePost to ""
set theuniquewords to {}
set thefolder to "the path to your public folder" as alias
set thefolders to thefolder as string
set GDFile to thefolders & "GD.txt" as alias
set thefileProp to (info for filename)
set thecomment to the comment of filename
end tell
set GDcontent to read GDFile as string
set thetext to thecomment
set thewords to every word of (thetext) as list
set tags to every word of (read ("the path to your Public Folder:tags.txt" as alias))
set this_item to item i of thewords
if theuniquewords contains this_item then
else
if tags contains this_item then
set theuniquewords to theuniquewords & this_item
end if
end if
end repeat
set this_item to item i of theuniquewords
set newform to "<a href=\"http://technorati.com/tag/" & this_item & "\" rel=\"tag\">" & this_item & "</a>"
set the thetext to replace_chars(thetext, this_item, newform)
end repeat
set ThePost to ThePost & "<p><ul><li>FileName: <b>" & name of thefileProp & "</b></li><li>Size: <b>" & size of thefileProp & "</b></li>" & "<li>Created: <b>" & creation date of thefileProp & "</b></li>" & "<li>Last modified: <b>" & modification date of thefileProp & "</b></li></ul></p>"
set ThePost to ThePost & "<p>" & thetext & "</p><p>" & GDcontent & "</p>"
set content to ThePost
set content to display dialog "Your post is empty!, try again." buttons {"Cancel"} default button {"Cancel"}
else
set postit to display dialog "Are you sure you want to publish this? " & return & return & content buttons {"Cancel", "Post", "Post & Publish"}
set publish to true
log publish
set postNumber to newPost(blogid, content, publish)
gotoURL(weblogURL)
end if
set publish to false
log publish
set postNumber to newPost(blogid, content, publish)
end if
try
(*
tell application "Firefox"
OpenURL "http://www.technorati.com/ping.html?url=http%3A%2F%2Foldcolapublic.blogspot.com%2F"
end tell
*)
end try
end open
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
on tellBloggerAPI(methodName, params)
using terms from application "http://www.apple.com"
tell application APIURL
return call xmlrpc {method name:methodName, parameters:{bloggerAPIKey} & params}
end tell
end using terms from
end tellBloggerAPI
on newPost(blogid, content, publish)
set params to {blogid, username, myPassword, content, publish}
return tellBloggerAPI("blogger.newPost", params)
end newPost
on gotoURL(weblogURL)
open location (weblogURL as text)
end gotoURL
No comments:
Post a Comment