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

system.verbs.builtins.radio.macros.newStory

<<Changes
	<<9/17/04; 1:53:28 PM by SK
		<<Bug fix to name the form and allow better compatibility with the WYSIWYG text editor
	<<3/18/02; 6:06:19 PM by JES
		<<If no title is supplied, add an error message at the top of the page.
	<<1/28/02; 12:16:38 PM by JS
		<<If this is MacOS, convert the title and text of the new story to Mac text.
	<<1/26/02; 2:42:10 AM by JES
		<<Respect the editing tool pref at weblogData.prefs.editingToolName.
	<<12/23/01; 11:36:31 PM by JES
		<<Don't pass in a ctrows value to radio.userinterface.editorbox. The default value at user.radio.prefs.browserBasedEditorSize will be used.
	<<12/23/01; 4:26:00 PM by JES
		<<Commented out code which adds the Open in outliner checkbox, and the code which references user.radio.stats.flNewStoryOpensInOutliner. New stories are always .txt files in Radio 7.1.
	<<12/21/01; 5:38:03 PM by JES
		<<Create new stories in the /stories/ folder, instead of in the same folder as the new story page. Redirect to the synamic version of the new story, without the file extension.
	<<12/21/01; 1:11:24 PM by JES
		<<Fixed help link on open in outliner checkbox.
	<<12/5/01; 7:59:41 PM by JES
		<<Localized.
	<<10/31/01; 3:12:52 PM by JES
		<<Removed the workgroup notification checkbox.
		<<Fixed a bug where the Edit This Page button would result in loading a page with a macro error about itemtext not being defined.
		<<Fixed the redirection after creating a new story, so that it goes to the correct url.
		<<Open the file in Radio's outliner, if the user checked the open in outliner box.
	<<10/14/01; 1:39:34 AM by JES
		<<Added some <br> tags to make the checkboxes render in a prettier location.
local (pta = html.getpagetableaddress ());
local (adrblog = radio.weblog.init ());
pta^.editingToolName = adrblog^.prefs.editingToolName;
local (pc = file.getPathChar ());
pta^.title = radio.string.getlocalizedstring ("newStory.title");
<<scratchpad.params = pta^; edit (@scratchpad.params)
local (htmltext = "\r", indentlevel = 0);
on add (s) {
	htmltext = htmltext + string.filledstring ("\t", indentlevel) + s + "\r\n"};
local (initialtext = "", errormessage = "");
if pta^.method == "POST" { //possibly handle the post
	with pta^.radioResponder {
		if defined (postArgs.postNewStory) {
			<<user.radio.stats.flNewStoryOpensInOutliner = defined (postArgs.editInOpml)
			<<user.radio.stats.flNotifyWorkgroupOfNewStory = defined (postArgs.notifyWorkgroup)
			local (folder = user.radio.prefs.wwwFolder + radio.data.folderNames.wwwStoriesSubFolderName + pc);
			<<local (folder = file.folderfrompath (fileBeingRendered))
			<<postArgs.itemtext = string.replaceall (postArgs.itemtext, "{", "{")
			<<postArgs.title = string.replaceall (postArgs.title, "{", "{")
			<<workspace.postArgs = postargs; edit (@workspace.postArgs)
			local (title = string.trimWhiteSpace (postArgs.title), text = postArgs.itemtext);
			if title == "" { //error
				errormessage = "Can't post this story because no title was supplied.";
				initialtext = text}
			else { //create the story
				if system.environment.isMac {
					title = string.latinToMac (title);
					text = string.latinToMac (text)};
				local (relativepath = radio.file.newStoryFile (folder, title, text, false)); //user.radio.stats.flNewStoryOpensInOutliner)) //JES: commented out opening in outliner
				<<if user.radio.stats.flNewStoryOpensInOutliner //open the file, bring Radio to the front
					<<Frontier.tools.windowTypes.commands.open (radio.file.getAbsolutePath (relativePath))
					<<Frontier.bringToFront ()
				pta^.radioResponder.redirectUrl = "/" + string.popSuffix (relativepath);
				return ("")}}}};

bundle { //render the new story form
	if errormessage != "" { //add the error message
		add ("<p><font color=\"red\"><b>" + errormessage + "</b></font></p>")};
	add (html.editor.formStart ("itemtext", pta:pta, name:"editPostForm")); indentlevel++;
	add ("<b>" + radio.string.getlocalizedstring ("newStory.titlePrompt") + "</b><br>");
	add ("<input type=\"text\" name=\"title\" size=\"55\" maxlength=\"255\" value=\"" + "" + "\"><br><br>");
	add ("<b>" + radio.string.getlocalizedstring ("newStory.textPrompt") + "</b><br>");
	add (radio.userinterface.editorbox (initialtext));
	<<bundle //add notification checkbox
		<<local (checkboxval = "xxx ")
		<<if user.radio.stats.flNotifyWorkgroupOfNewStory
			<<checkboxval = checkboxval + "checked"
		<<add ("<br><br><input type=\"checkbox\" name=\"notifyWorkgroup\" value=" + checkboxval + "> Send email notification to workgroup members. " + radio.userinterface.helplink ("newStoryNotification") + "<br>")
	<<bundle //add OPML checkbox
		<<local (checkboxval = "xxx ")
		<<if user.radio.stats.flNewStoryOpensInOutliner
			<<checkboxval = checkboxval + "checked"
		<<add ("<br><input type=\"checkbox\" name=\"editInOpml\" value=" + checkboxval + "> " + radio.string.getlocalizedstring ("newStory.openInOutliner") + " " + radio.userinterface.helplink ("Editing Stories in Radio UserLand's outliner") + "<br>")
	add ("<p><input type=\"submit\" name=\"postNewStory\" value=\"" + radio.string.getlocalizedstring ("newStory.createNewStoryButton") + "\">");
	add ("</form>"); indentlevel--;
	return (htmltext)}



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.