email.naml

<macro name="notify_subscribers" requires="node">
	<n.get_instant_emails.new_node.as_node_page.instant_emails />
</macro>

<macro name="instant_emails" requires="instant_mail,node_page">
	<n.subscription_list.loop.>
		<n.if.current_subscription.user.should_get_instant_mail>
			<then.current_subscription.send_instant_email />
		</n.if.current_subscription.user.should_get_instant_mail>
	</n.subscription_list.loop.>
</macro>

<macro name="should_get_instant_mail" requires="user,node_page" >
	<n.set_local_user.this_user/>
	<n.block.>
		<n.both>
			<condition1.local_user.can_view.page_node />
			<condition2.not.>
				<n.both>
					<condition1.page_node.owner.equals.local_user />
					<condition2.equal value1="[n.page_node.message.format/]" value2="mail" />
				</n.both>
			</condition2.not.>
		</n.both>
	</n.block.>
</macro>

<macro name="send_instant_email" requires="subscription,node_page">
	<n.set_local_subscription.this_subscription/>
	<n.send_subscription_email
		node_attr = "[n.page_node/]"
		text_part = "[n.local_subscription.instant_text/]"
		html_part = "[n.local_subscription.instant_html/]"
	/>
</macro>

<macro name="send_subscription_email" parameters="node_attr,text_part,html_part" requires="subscription">
	<n.set_local_subscription.this_subscription/>
	<n.set_local_node.node_attr/>
	<n.block.>
		<n.new_email.>
			<n.send>
				<to.local_subscription.user.user_email/>
				<to_name.local_subscription.user.name/>
				<from.local_subscription.user.reply_address_for.local_node/>
				<from_name><n.local_node.owner.name/> [via <n.root_node.subject/>]</from_name>
				<subject.local_node.subject/>
				<text_part.text_part/>
				<html_part.html_part/>
				<set_headers_for.local_node/>
				<bounce_to.local_subscription.user.bounces_address/>
			</n.send>
		</n.new_email.>
	</n.block.>
</macro>

<macro name="send_assign_email" requires="node_page">
	<n.if.topic_assignee.can_view.page_node>
		<then.new_email.>
			<n.send>
				<to.topic_assignee.user_email/>
				<to_name.topic_assignee.name/>
				<from.topic_assignee.reply_address_for.page_node/>
				<from_name><n.page_node.owner.name/> [via <n.root_node.subject/>]</from_name>
				<subject.page_node.subject/>
				<text_part.assign_text/>
				<html_part.assign_html/>
				<set_headers_for.page_node/>
				<bounce_to.topic_assignee.bounces_address/>
			</n.send>
		</then.new_email.>
	</n.if.topic_assignee.can_view.page_node>
</macro>

<macro name="digest email" requires="subscription,node_list">
	<n.set_local_subscription.this_subscription/>
	<n.filter_by.local_subscription.user.can_view.current_node/>
	<n.new_email.>
		<n.send>
			<to.local_subscription.user.user_email/>
			<to_name.local_subscription.user.name/>
			<from_name.root_node.subject/>
			<subject><n.local_subscription.node.subject/> - <t>Digest Email</t></subject>
			<text_part.local_subscription.digest_text/>
			<html_part.local_subscription.digest_html/>
			<bounce_to.local_subscription.user.bounces_address/>
		</n.send>
	</n.new_email.>
</macro>

<macro name="instant_text" requires="subscription,node_page" unindent="true">
	<n.if.page_node.is_app>
		<then>
			<t><t.username.page_node.owner.name/> created a new subcategory</t>:
			<n.page_node.subject/>
		</then>
	</n.if.page_node.is_app>

	<n.page_node.text_email_message_with_signature />
	_______________________________________________
	<t>If you reply to this email, your message will be added to the discussion below</t>:
	<n.page_node.url/>
	<n.start_new_topic_line/>
	<n.unsubscribe_line format="text"/>
</macro>

<macro name="instant_html" requires="subscription,node_page">
	<n.if.page_node.is_app>
		<then>
			<t><t.username.page_node.owner.name/> created a new subcategory</t>:
			<b><n.page_node.subject/></b><br/><br/>
		</then>
	</n.if.page_node.is_app>

	<n.page_node.html_email_message_with_signature/>
	<br/>
	<br/>
	<hr noshade="noshade" size="1" color="#cccccc" />
	<div style="color:#444; font: 12px tahoma,geneva,helvetica,arial,sans-serif;">
		<div style="font-weight:bold"><t>If you reply to this email, your message will be added to the discussion below</t>:</div>
		<a href="[n.page_node.url/]"><n.page_node.url/></a>
	</div>
	<div style="color:#666; font: 11px tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em;line-height:1.5em">
		<n.start_new_topic_line append="[br/]"/>
		<n.unsubscribe_line format="html"/><br/>
		<n.macro_viewer_email_link macro="instant_html"/>
	</div>
</macro>

<macro name="assign_text" requires="node_page" unindent="true">
	<n.page_node.text_email_message_with_signature/>
	______________________________________
	<t>This topic is assigned to you at priority <t.priority.topic_priority/></t>
	<t>View message</t> @ <n.page_node.url/>
</macro>

<macro name="assign_html" requires="node_page">
	<n.page_node.html_email_message_with_signature/>
	<br/>
	<br/>
	<hr noshade="noshade" size="1" color="#cccccc" />
	<div style="color:#666666;font: 11px tahoma,geneva,helvetica,arial,sans-serif;margin-bottom:1.5em;line-height:1.5em">
		<t>This topic is assigned to you at priority <t.priority><div style="[n.priority_style/]"><n.topic_priority/></div></t.priority></t><br/>
		<t>View message</t> @ <a href="[n.page_node.url/]"><n.page_node.url/></a><br/>
		<n.macro_viewer_email_link macro="assign_html"/>
	</div>
</macro>

<macro name="priority_style" requires="node_page">
	text-align:center;
	background-color: #<n.priority_bg_color/>;
	border:1px solid #<n.priority_border_color/>;
	color:#FFFFFF;
	display:inline;
	padding:0 .3em;
	font-weight:bold;
</macro>

<macro name="priority_bg_color" requires="node_page">
	<n.string_list. values="0,E94747,D8B23D,BCBCBC,81C7DE,4A7BD5" separator=",">
		<n.at_index.topic_priority/>
	</n.string_list.>
</macro>

<macro name="priority_border_color" requires="node_page">
	<n.string_list. values="0,F4A2A2,F5DAA9,DCDCDC,B9DDE9,A3BCEA" separator=",">
		<n.at_index.topic_priority/>
	</n.string_list.>
</macro>

<macro name="start_new_topic_line" parameters="append" requires="subscription, node_page">
    <n.set_local_user.this_subscription.user/>
    <n.set_local_node.page_node.get_app_node/>
    <n.if.both condition1="[n.local_user.has_subscription_to_descentants_of.local_node/]" condition2="[n.local_user.can_reply_to.local_node/]">
        <then>
            <t>To start a new topic under <t.location.local_node.subject/>, email <t.p2.local_node.user_address email="[n.local_user.user_email/]"/></t> <n.hide_null.append/>
        </then>
    </n.if.both>
</macro>

<macro name="unsubscribe_line" parameters="format" requires="subscription">
	<n.if.equal value1="[n.format/]" value2="html">
		<then><t>To unsubscribe from <t.location.node.subject/></t>, <a href="[n.unsubscribe_by_code_url/]"><t>click here</t></a>.</then>
		<else><t>To unsubscribe from <t.location.node.subject/></t>, <t>visit <t.url.unsubscribe_by_code_url/></t></else>
	</n.if.equal>
</macro>

<macro name="remove_unsubscription_link" dot_parameter="html">
	<n.regex_replace_all
		text = "[n.html/]"
		pattern = 'http://[^"\s]+\.jtp\?macro=unsubscribe_by_code[^"\s]*'
		replacement = ''
	/>
</macro>

<macro name="email_message" dot_parameter="do">
	<n.do/>
</macro>

<macro name="html_email_message_with_signature" requires="node">
	<n.email_message.>
		<n.fix_quotes.>
			<n.fix_signature.>
				<n.message_with_signature/>
			</n.fix_signature.>
		</n.fix_quotes.>
	</n.email_message.>
</macro>

<macro name="text_email_message_with_signature" requires="node" unindent="true">
	<n.email_message.>
		<n.node_message_as_text />
		<n.if.owner.has_signature>
			<then>
				<n.crlf/>-----
				<n.owner.signature.as_text/>
			</then>
		</n.if.owner.has_signature>
	</n.email_message.>
</macro>

<macro name="fix_quotes" dot_parameter="text">
	<n.regex_replace_all. pattern="[n.lt/]blockquote" replacement="[n.lt/]blockquote style='border-left:2px solid #CCCCCC;padding:0 1em'">
		<n.text/>
	</n.regex_replace_all.>
</macro>

<macro name="fix_signature" dot_parameter="text">
	<n.regex_replace_all. pattern='div class="signature weak-color"' replacement='div class="signature" style="margin-top:1em;color:#666666;font-size:11px;"'>
		<n.text/>
	</n.regex_replace_all.>
</macro>

<macro name="digest_text" requires="subscription,node_list" unindent="true">
	<n.set_local_subscription.this_subscription/>
	<t>Digest Email</t>
	"<n.local_subscription.node.subject/>"
	<n.digest_post_count/>

	<n.reset_list_index/>
	<n.loop.>
		[<n.current_node.digest_subject/>]
		<n.compress.>
			<n.truncate. size="200">
				<n.current_node.message.as_text/>
			</n.truncate.>
		</n.compress.>
		<n.compress.>
			<t>by <t.author.current_node.owner.name/></t>
			<t>on <t.date.current_node.when_created.custom_format format="yyyy-MM-dd"/></t>
			<t>in <t.location.current_node.get_app_node.subject/></t>
		</n.compress.>

		<t>Read more</t>
		<n.current_node.url/>

		<n.nop/>
	</n.loop.>
	<n.unsubscribe_line format="text"/>

	---
	<t>DO NOT REPLY TO THIS EMAIL</t>

	<t>Replies sent to this address are not read or processed.</t>
	<t>If you want to respond to a post for which you received this email,
	please go to the website: <t.url.local_subscription.node.url/></t>
</macro>

<macro name="digest_html" requires="subscription,node_list" unindent="true">
	<n.set_local_subscription.this_subscription/>
	<h2><t>Digest Email</t></h2>
	<h3><n.local_subscription.node.subject/></h3>
	<div style="color:#666666;font-weight:bold">
		<n.digest_post_count/>
	</div>

	<n.reset_list_index/>
	<n.loop.>
		<p>
			<div style="font-size:120%">
				<a href="[n.current_node.url/]"><n.current_node.digest_subject/></a>
			</div>
			<n.trim.truncate. size="200">
				<n.compress.current_node.message.as_text/>
			</n.trim.truncate.>
			<div style="color:#666666; font: 11px tahoma,geneva,helvetica,arial,sans-serif;">
				<t>by <t.author><b><n.current_node.owner.name/></b></t.author></t>
				<t>on <t.date.current_node.when_created.custom_format format="yyyy-MM-dd"/></t>
				<t>in <t.location><i><n.current_node.get_app_node.subject/></i></t.location></t>
			</div>
		</p>
	</n.loop.>

	<br/>
	<br/>
	<n.unsubscribe_line format="html"/>

	<hr noshade="noshade" size="1" color="#cccccc" />
	<div style="color:#666666; font: 11px tahoma,geneva,helvetica,arial,sans-serif;line-height:1.5em">
		<t>DO NOT REPLY TO THIS EMAIL</t><br/>
		<br/>
		<t>Replies sent to this address are not read or processed.</t>
		<t>If you want to respond to a post for which you received this email,
		please go to the website: <t.url.local_subscription.node.url/></t>
		<br/>
		<n.macro_viewer_email_link macro="digest_html"/>
	</div>
</macro>

<macro name="digest_subject" requires="node">
	<n.compress.>
		<n.if.is_post>
			<then>
				<n.topic_node.subject/>
				<n.if.not.ends_with text="[n.subject/]" suffix="[n.topic_node.subject/]" >
					<then>(<n.subject/>)</then>
				</n.if.not.ends_with>
			</then>
			<else>
				<n.subject/>
			</else>
		</n.if.is_post>
	</n.compress.>
</macro>

<macro name="digest_post_count" requires="node_list">
	<n.one_or_many.element_count>
		<one_text><t>new post</t></one_text>
		<many_text><t>new posts</t></many_text>
	</n.one_or_many.element_count>
</macro>

<macro name="topic_assignee" dot_parameter="do" requires="node_page">
	<n.page_node.topic_node.assignee.do/>
</macro>

<macro name="topic_priority" requires="node_page">
	<n.page_node.topic_node.priority/>
</macro>

<macro name="send bookmark email" unindent="true">
	<n.set_var. name='what'>
		<n.root_node.lower_case_view_name/>
	</n.set_var.>
	<n.new_email.>
		<n.send>
			<to><n.root_node.owner.user_email/></to>
			<subject><t>Link to <t.location.root_node.subject/></t></subject>
			<text_part>
				<t>Hi <t.name.root_node.owner.name/>,</t>
				<t>Congratulations on your new <t.app.var name='what'/>!</t>

				<n.root_node.subject/>
				<n.base_url/>

				<t>Please bookmark the link above or save this email so you
				can easily find your <t.app.var name='what'/> in the future.</t>

				<t>You can also promote your <t.app.var name='what'/> by sending the link
				to your friends, embedding it onto your website or talking about it on other forums.</t>

				<t>Sincerely,</t>
				<t>The Nabble Team</t>
				<n.nabble_homepage/>
				__________________________________________________________
				<t>This is an automatic email sent by Nabble to confirm the creation of your new <t.app.var name='what'/>.
				If you didn't create the <t.app.var name='what'/> mentioned above, please contact us through
				the Nabble Support forum.</t>
			</text_part>
			<html_part>
				<t>Hi <t.name.root_node.owner.name/>,</t><br/>
				<br/>
				<t>Congratulations on your new <t.app.var name='what'/>!</t><br/>
				<br/>
				<n.root_node.subject/><br/>
				<n.base_url/><br/>
				<br/>
				<t>Please bookmark the link above or save this email so you
				can easily find your <t.app.var name='what'/> in the future.</t><br/>
				<br/>
				<t>You can also promote your <t.app.var name='what'/> by sending the link
				to your friends, embedding it onto your website or talking about it on other forums.</t><br/>
				<br/>
				<t>Sincerely,</t><br/>
				<t>The Nabble Team</t><br/>
				<n.nabble_homepage/><br/>
				<hr noshade="noshade" size="1" color="#cccccc" />
				<div style="color:#666666; font: 11px tahoma,geneva,helvetica,arial,sans-serif;line-height:1.5em">
					<t>This is an automatic email sent by Nabble to confirm the creation of your new <t.app.var name='what'/>.
					If you didn't create the <t.app.var name='what'/> mentioned above, please contact us through
					the Nabble Support forum.</t>
					<br/>
					<n.macro_viewer_email_link macro="send bookmark email"/>
				</div>
			</html_part>
		</n.send>
	</n.new_email.>
</macro>

<macro name="macro_viewer_email_link" parameters="macro">
	<n.set_var. name="url"><n.macro_viewer_email_url macro="[n.macro/]"/></n.set_var.>
	<a href="[n.var name='url'/]" rel="nofollow" style="font:9px serif">NAML</a>
</macro>

<macro name="macro_viewer_email_url" parameters="macro">
	<n.remove_spaces.>
		<n.base_url/>
		<n.macro_search. query="[n.macro/]" search_by="name">
			<n.if.next_element>
				<then.current_command.command_path/>
			</n.if.next_element>
		</n.macro_search.>
	</n.remove_spaces.>
</macro>

<macro name="user email changed" parameters="old_email,new_email">
	<n.comment.>To be overridden</n.comment.>
</macro>