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

system.verbs.builtins.radio.macros.commentOnThisPage

on commentOnThisPage (linktext="", title="", adrblog=radio.weblog.init ()) {
	<<Changes
		<<9/3/02; 11:39:16 PM by LL
			<<Added a check to not display the link for weekly archive pages.
		<<8/27/02; 3:44:26 PM by LL
			<<Added a check to not display the link for monthly archive pages.
		<<8/15/02; 8:07:48 PM by JES
			<<Call through radio.file.getRelativePath to get the story ID instead of bashing the text here.
		<<8/9/02; 1:16:50 PM by LL
			<<Created.
	local (pta = html.getpagetableaddress ());
	bundle { //find reasons not to display the link
		if defined (radio.data.appProfile.flCommentsEnabled) { //community must support comments
			if not radio.data.appProfile.flCommentsEnabled {
				return ("")}};
		if not adrblog^.prefs.flCommentLinksEnabled { //comments must be enabled in prefs
			return ("")};
		if defined (pta^.flHomePage) { //must not be the home page -- use item level comments instead
			if pta^.flHomePage {
				return ("")}};
		if defined (pta^.flArchivePage) { //must not be an archive page -- use item level comments instead
			if pta^.flArchivePage {
				return ("")}};
		if defined (pta^.flMonthlyArchive) { //must not be a monthly archive page -- use item level comments instead
			if pta^.flMonthlyArchive {
				return ("")}};
		if defined (pta^.flWeeklyArchive) { //must not be a weekly archive page -- use item level comments instead
			if pta^.flWeeklyArchive {
				return ("")}};
		if defined (pta^.flSystemPage) { //must not be a system page
			if pta^.flSystemPage {
				return ("")}}};
	if linktext == "" {
		linktext = adrblog^.prefs.commentLinkText};
	if title == "" {
		title = radio.string.getLocalizedString ("misc.clickToCommentOnThisPage")};
	local (s);
	if string.lower (linktext) contains "<%commentcount%>" {
		s = "<script src=\"" + weblogData.prefs.commentsPageUrl + "?u=" + user.radio.prefs.usernum + "&c=counts\" type=\"text/javascript\"></script>\r"};
	local (linkarg = "");
	local (f = pta^.radioResponder.fileBeingRendered);
	local (id = string.popSuffix (radio.file.getRelativePath (f)));
	linkarg = "&link=" + string.urlEncode (radio.upstream.getFileUrl (f));
	local (commentPageUrl = adrblog^.prefs.commentsPageUrl + "?u=" + user.radio.prefs.usernum + "&p=" + string.urlEncode (id) + linkarg);
	bundle { //insert JavaScript for comment counter
		linktext = string.replaceAll (linktext, "<%commentCount%>", "<script type=\"text/javascript\" language=\"JavaScript\">commentCounter (\"" + id + "\")</script>", false)};
	local (onclick = "window.open (this.href, \'comments\', \'width=515, height=480, location=0, resizable=1, scrollbars=1, status=0, toolbar=0, directories=0\'); return(false);");
	s = s +"<a href=\"" + commentPageUrl + "\" onclick=\"" + onclick + "\" title=\"" + title + "\" class=\"commentLink\">" + linktext + "</a>";
	return (s)}



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.