Monday, November 08, 2010 at 12:01 AM.


on newPost (bodytext, username=nil, password=nil, link=nil, mediaFileData=nil, postTo="all") {
		<<3/1/08; 7:43:35 PM by DW
			<<if link != nil, then it's a link.
	local (apiurl, data);
	pownce.init ();
	bundle { //set apiurl
		apiurl = "";
		if mediaFileData != nil {
			apiurl = ""}
		else {
			if link != nil {
				apiurl = ""}}};
	bundle { //set username, password, if nil
		if username == nil {
			username = user.pownce.prefs.username};
		if password == nil {
			password = user.pownce.prefs.password}};
	bundle { //set data
		data = "note_to=" + postTo;
		if mediaFileData != nil {
			data = data + "&media_file=" + string.urlencode (mediaFileData)};
		if link != nil {
			data = data + "&url=" + link};
		data = data + "¬e_body=" + string.urlencode (bodytext)};
	local (s = pownce.httpClient ("POST", apiurl, data, username, password));
	wp.newtextobject (s, @scratchpad.s); edit (@scratchpad.s)};
bundle { //test code
	local (linkurl = "");
	local (mediafiledata = string (file.readwholefile ("ohio:theWireMarch10.mp3")));
	newPost ("Seventh in a series of test posts to see if the OPML Editor glue for Pownce is working, a retry of the previous test. It has an MP3 file attached, with an important announcement about the final episode of The Wire, airing on March 10. Put down the coffee cup and swallow before listening to this. Seriously. :-)", mediaFileData:mediafiledata, postTo:"all")}

This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.