message.naml

<macro name="message_with_signature" requires="node">
	<n.node_message_as_html />
	<n.if.both condition1="[n.owner.has_signature/]" condition2="[n.owner.is_active/]">
		<then>
			<div class="signature weak-color">
				<n.owner.signature_as_html/>
			</div>
		</then>
	</n.if.both>
</macro>

<macro name="node_message_block" dot_parameter="do" requires="node">
	<n.global_set_var name="message_block_node" value="[n.this_node/]" />
	<n.do/>
</macro>

<macro name="message_block_node" dot_parameter="do">
	<n.get_node node="[n.global_var name='message_block_node'/]" do="[n.do/]" />
</macro>

<macro name="node_message_as_html" requires="node">
	<n.node_message_block.message.message_as_html />
</macro>

<macro name="node_message_as_text" requires="node">
	<n.node_message_block.message.message_as_text />
</macro>

<macro name="message_quoted" requires="node" unindent="true">
	<quote author="[n.owner.name/]">
		<n.trim.message.as_quoted_text/>
	</quote>
	<n.nop/>
</macro>

<macro name="message_as_html" requires="message">
	<n.if.either condition1="[n.is_deleted/]" condition2="[n.is_deactivated/]">
		<then>
			<b><t>CONTENTS DELETED</t></b>
			<div class="weak-color"><t>The author has deleted this message.</t></div>
		</then>
		<else>
			<n.set_var. name="output">
				<n.as_html_list.process_message_html />
			</n.set_var.>
			<n.if.is_imported_mail>
				<then.set_var. name="output">
					<n.remove_unsubscription_link.var name="output" />
				</then.set_var.>
			</n.if.is_imported_mail>
			<n.var name="output" />
		</else>
	</n.if.either>
</macro>

<macro name="process_message_html" requires="html_list">
	<n.process_raw_tags/>
	<n.process_cdata_tags/>
	<n.process_embed regex="[n.embed_regex/]" />
	<n.process_file_tags/>
	<n.apply_message_security/>
	<n.process_quotes wrote="[t][n.author/] wrote[/t]"/>
	<n.process_email/>
	<n.set_target_to_top/>
	<n.add_nofollow/>
	<n.process_smilies/>
</macro>

<macro name="apply_message_security" requires="html_list">
	<n.if.is_in_command name="node_message_block">
		<then.if.not.message_block_node.has_unrestricted_posting>
			<then.message_security/>
		</then.if.not.message_block_node.has_unrestricted_posting>
		<else.message_security/>
	</n.if.is_in_command >
</macro>

<macro name="message_security" requires="html_list">
	<n.disable_banned_tags.>
		script,
		style,
		html,
		head,
		body,
		link
	</n.disable_banned_tags.>
	<n.disable_invalid_urls.>
		href,
		src,
		action
	</n.disable_invalid_urls.>
	<n.disable_javascript_urls.>
		href,
		src,
		action
	</n.disable_javascript_urls.>
	<n.disable_on_event/>
	<n.disable_scripts/>
	<n.disable_style_blocks/>
</macro>

<macro name="message_as_text" requires="message">
	<n.as_text_list.process_message_text />
</macro>

<macro name="process_message_text" requires="html_list">
	<n.process_quotes_as_text wrote="[t][n.author/] wrote[/t]"/>
	<n.process_smilies_as_text/>
	<n.process_file_tags/>
	<n.process_tag tag="b" do="*" />
	<n.process_tag tag="/b" do="*" />
	<n.process_tag tag="i" do="/" />
	<n.process_tag tag="/i" do="/" />
	<n.process_tag tag="u" do="_" />
	<n.process_tag tag="/u" do="_" />
	<n.process_text text="&lt;" replacement="[n.lt/]" />
	<n.process_text text="&gt;" replacement="[n.gt/]" />
</macro>


<macro name="embed_regex">
	<n.if.is_in_command name="node_message_block">
		<then.if.message_block_node.has_unrestricted_posting>
			<then>(?s).*</then>
			<else.embed_regex_list/>
		</then.if.message_block_node.has_unrestricted_posting>
		<else.embed_regex_list/>
	</n.if.is_in_command >
</macro>

<macro name="embed_regex_list">
	(<n.youtube_object_regex/>)|(<n.youtube_object_regex2/>)|(<n.youtube_iframe_regex/>)|(<n.liveleak_regex/>)|(<n.polldaddy_regex/>)|(<n.vimeo_regex/>)
</macro>

<macro name="youtube_object_regex">
	<![CDATA[\s*<object width="\d+" height="\d+"><param name="movie" value="http://www.youtube.com/v/[^"]+"></param><param name="allowFullScreen" value="\w+"></param><param name="allowscriptaccess" value="\w+"></param><embed src="http://www.youtube.com/v/[^"]+" type="application/x-shockwave-flash" allowscriptaccess="\w+" allowfullscreen="\w+" width="\d+" height="\d+"></embed></object>\s*]]>
</macro>

<macro name="youtube_object_regex2">
	<![CDATA[\s*<object width="\d+" height="\d+"><param name="movie" value="https?://www.youtube(-nocookie)?.com/v/[^"]+"></param><param name="allowFullScreen" value="\w+"></param><param name="allowscriptaccess" value="\w+"></param><embed src="https?://www.youtube(-nocookie)?.com/v/[^"]+" type="application/x-shockwave-flash" width="\d+" height="\d+"( allowscriptaccess="\w+")?( allowfullscreen="\w+")?></embed></object>\s*]]>
</macro>

<macro name="youtube_iframe_regex">
	<![CDATA[\s*<iframe[^>]* src="(https?:)?//www.youtube.com/embed/[^"]+"[^>]*></iframe>\s*]]>
</macro>

<macro name="liveleak_regex">
	<![CDATA[\s*<object width="\d+" height="\d+"><param name="movie" value="http://www.liveleak.com/e/\w+"></param><param name="wmode" value="\w+"></param><param name="allowscriptaccess" value="\w+"></param><embed src="http://www.liveleak.com/e/\w+" type="application/x-shockwave-flash" wmode="\w+" allowscriptaccess="\w+" width="\d+" height="\d+"></embed></object>\s*]]>
</macro>

<macro name="polldaddy_regex">
	<![CDATA[\s*<embed allowScriptAccess="\w+" saveEmbedTags="\w+" quality="\w+" wmode="\w+" bgcolor="#\w+" name="\w+" salign="\w+" scale="\w+" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="p=\d+" src="http://i.polldaddy.com/poll.swf" width="\d+" height="\d+"></embed>\s*]]>
</macro>

<macro name="vimeo_regex">
	<![CDATA[\s*<iframe src="http://player.vimeo.com/video/[^"]+" width="\d+" height="\d+" frameborder="0"( webkitAllowFullScreen)?( mozallowfullscreen)?( allowFullScreen)?></iframe>.*]]>
</macro>