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

scripting2Suite.server.urlToStory

on urlToStory (username, url, adrtype, adradrstory) {
	<<Changes
		<<6/11/10; 10:18:32 PM by DW
			<<Created. 
	local (adrdata = scripting2suite.inituser (username), adrsystemdata = scripting2suite.init (), baseurl);
	bundle { //get baseurl
		if adrdata^.prefs.ftp.enabled {
			baseurl = adrdata^.prefs.ftp.url}
		else {
			baseurl = adrsystemdata^.prefs.baseurl + username + "/"}};
	local (s = string.delete (url, 1, sizeof (baseurl))); //now it's stories/2010/06/10/myScripting2Todo.html
	adrtype^ = string.lower (string.nthfield (s, "/", 1));
	s = string.delete (s, 1, sizeof (adrtype^) + 1);
	case adrtype^ {
		"stories" {
			local (year, month, day, adrday, adrstory);
			year = string.nthfield (s, "/", 1);
			month = string.nthfield (s, "/", 2);
			day = string.nthfield (s, "/", 3);
			adrday = @adrdata^.calendar.[year].[month].[day];
			for adrstory in adrday {
				if string.lower (adrstory^.url) == string.lower (url) {
					adradrstory^ = adrstory;
					return (true)}}};
		"blogroll";
		"hometemplate";
		"storytemplate" {
			return (true)};
		"stylesheet" {
			return (true)}};
	scripterror ("Can't locate the outline identified by the url \"" + url + "\" because it doesn't exist.")};
bundle { //test code
	local (tc = clock.ticks (), type, adrstory);
	for i = 1 to 1 {
		urlToStory ("davewiner", "http://scripting.com/stories/2010/06/10/myScripting2Todo.html", @type, @adrstory)};
	dialog.alert (clock.ticks () - tc);
	edit (adrstory)}



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.