diff src/nabble/view/naml/subscribe.naml @ 0:7ecd1a4ef557

add content
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 21 Mar 2019 19:15:52 -0600
parents
children 72765b66e2c3
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/nabble/view/naml/subscribe.naml	Thu Mar 21 19:15:52 2019 -0600
@@ -0,0 +1,442 @@
+<macro name="subscribe" requires="servlet">
+	<n.node_page.>
+		<n.html>
+			<head>
+				<meta name="robots" content="noindex,nofollow"/>
+				<n.title.><t>Subscribe via email</t></n.title.>
+				<n.main_title_css/>
+			</head>
+			<body>
+				<n.if.visitor.is_anonymous>
+					<then>
+						<n.edit_header first_text="[n.page_node.subject/]" second_text="[t]Email Subscription[/t]" />
+						<n.if.is_submitted_form>
+							<then>
+								<n.if.equal value1="send-anonymous" value2="[n.action_parameter/]">
+									<then>
+										<n.catch_exception. id="send-email-block">
+											<n.handle_anonymous_subscription/>
+										</n.catch_exception.>
+									</then>
+								</n.if.equal>
+								<n.if.has_exception for="send-email-block">
+									<then.show_subscription_error/>
+									<else.show_success_message/>
+								</n.if.has_exception>
+							</then>
+						</n.if.is_submitted_form>
+						<n.anonymous_subscription_form/>
+					</then>
+					<else>
+						<n.visitor.profile_header/>
+
+						<n.if.is_submitted_form>
+							<then.save_field_values/>
+							<else.load_field_values/>
+						</n.if.is_submitted_form>
+
+						<n.subscription_form/>
+					</else>
+				</n.if.visitor.is_anonymous>
+			</body>
+		</n.html>
+	</n.node_page.>
+</macro>
+
+<macro name="save_field_values">
+	<n.if.equal value1="save-subscription" value2="[n.action_parameter/]">
+		<then>
+			<n.page_node.visitor_subscription.save
+				to="[n.subscription_to_field.value/]"
+				type="[n.subscription_type_field.value/]"
+			/>
+			<n.redirect_to.subscription_saved_url/>
+		</then>
+	</n.if.equal>
+</macro>
+
+<macro name="load_field_values">
+	<n.subscription_to_field.set_value.>
+		<n.if.page_node.visitor_is_subscribed>
+			<then.page_node.visitor_subscription.to/>
+			<else>DESCENDANTS</else>
+		</n.if.page_node.visitor_is_subscribed>
+	</n.subscription_to_field.set_value.>
+
+	<n.subscription_type_field.set_value.>
+		<n.if.page_node.visitor_is_subscribed>
+			<then.page_node.visitor_subscription.type/>
+			<else>INSTANT</else>
+		</n.if.page_node.visitor_is_subscribed>
+	</n.subscription_type_field.set_value.>
+</macro>
+
+<macro name="subscription_form" requires="node_page">
+	<div class="shaded-bg-color rounded second-font main-title">
+		<n.if.page_node.visitor_is_subscribed>
+			<then><t>Edit Subscription</t></then>
+			<else><t>Confirm Subscription</t></else>
+		</n.if.page_node.visitor_is_subscribed>
+	</div>
+	<n.form.>
+		<input type="hidden" name="action" value="save-subscription"/>
+
+		<n.if.page_node.is_app>
+			<then.app_subscription_controls/>
+			<else.post_subscription_controls/>
+		</n.if.page_node.is_app>
+
+		<n.show_mailing_list_alert/>
+
+		<br/>
+		<input type="submit" class="toolbar action-button" value="[t]Save Subscription[/t]"/>
+
+		<n.if.page_node.visitor_is_subscribed>
+			<then>
+				<input type="button" class="toolbar action-button" value="[t]Unsubscribe[/t]" onclick="window.location='[n.page_node.unsubscribe_path/]'"/>
+			</then>
+		</n.if.page_node.visitor_is_subscribed>
+
+		<t>or</t> <a href="javascript:history.back()"><t>Cancel</t></a>
+	</n.form.>
+</macro>
+
+<macro name="app_subscription_controls">
+	<table style="margin:.2em 0 .5em">
+		<tr>
+			<td><img src="[n.page_node.image_icon/]" class="image16"/></td>
+			<td class="weak-color" style="font-weight:bold">
+				<n.page_node.subject/>
+			</td>
+		</tr>
+	</table>
+	<div style="margin:.5em 1em .2em">
+		<n.subscription_to_field.radio id="all" option_value="DESCENDANTS"/>
+		<label for="all">
+			<n.if.page_node.is_app>
+				<then><t>Receive every message posted in <t.location><n.italic.page_node.subject/></t.location>.</t></then>
+				<else><t>Receive every reply under this topic.</t></else>
+			</n.if.page_node.is_app>
+		</label>
+	</div>
+	<div style="margin:0 1em .2em">
+		<n.subscription_to_field.radio id="direct" option_value="CHILDREN"/>
+		<label for="direct">
+			<n.if.page_node.is_app>
+				<then><t>Receive new topics only.</t></then>
+				<else><t>Receive direct replies only.</t></else>
+			</n.if.page_node.is_app>
+		</label>
+	</div>
+	<div style="margin:1em 0;font-weight:bold">
+		<t>Subscription Format</t>
+	</div>
+	<div style="margin:.5em 1em .2em">
+		<n.subscription_type_field.radio id="individual" option_value="INSTANT"/>
+		<label for="individual"><t>Individual emails</t> <span class="weak-color"><t>(you can reply by email)</t></span></label>
+	</div>
+	<div style="margin:0 1em .2em">
+		<n.subscription_type_field.radio id="daily" option_value="DAILY_DIGEST"/>
+		<label for="daily"><t>Daily digest</t></label>
+	</div>
+</macro>
+
+<macro name="post_subscription_controls" requires="node_page">
+	<n.subscription_to_field.set_value value="DESCENDANTS"/>
+	<n.subscription_to_field.hidden/>
+
+	<n.subscription_type_field.set_value value="INSTANT"/>
+	<n.subscription_type_field.hidden/>
+
+	<div style="font-weight:bold;margin: 2em 0 .5em">
+		<t>Do you really want to subscribe to <t.location><a href="[n.page_node.url/]"><n.page_node.subject/></a></t.location>?</t>
+	</div>
+	<div class="weak-color">
+		<t>You will receive an email for each new message posted under this topic.</t>
+	</div>
+</macro>
+
+<macro name="unsubscribe_path" requires="node">
+	/template/NamlServlet.jtp?macro=unsubscribe&node=<n.id/>
+</macro>
+
+<macro name="show_mailing_list_alert" requires="node_page">
+	<n.if>
+		<condition>
+			<n.either>
+				<condition1.page_node.is_associated_with_mailing_list_archive/>
+				<condition2.page_node.has_sub_archive/>
+			</n.either>
+		</condition>
+		<then>
+			<div class="info-message rounded" style="padding:.5em;margin-top:1em">
+				<t><b>IMPORTANT:</b> This subscription is independent of the real mailing list subscription.
+				Basically, you will subscribe to the forum archive, not to the mailing list itself.
+				The archive subscription won't guarantee that your messages will be accepted by mailing list.</t>
+				<n.if.page_node.is_a_mailing_list_archive>
+					<then>
+						<n.page_node.get_associated_mailing_list_archive.>
+						<t>If you want to subscribe to the mailing list instead,
+						<n.mailing_list_options_link.>visit this page</n.mailing_list_options_link.>.</t>
+						</n.page_node.get_associated_mailing_list_archive.>
+					</then>
+				</n.if.page_node.is_a_mailing_list_archive>
+			</div>
+		</then>
+	</n.if>
+</macro>
+
+<macro name="subscription_to_field" dot_parameter="do">
+	<n.field. name="subscription_to"><n.do/></n.field.>
+</macro>
+
+<macro name="subscription_type_field" dot_parameter="do">
+	<n.field. name="subscription_type"><n.do/></n.field.>
+</macro>
+
+<macro name="image_icon" requires="node">
+	<n.if.is_app>
+		<then>/images/forum_sm.png</then>
+		<else>/images/thread_sm.png</else>
+	</n.if.is_app>
+</macro>
+
+<macro name="show_success_message">
+	<table class="info-message" style="width:100%;padding:.5em">
+		<tr>
+			<td><img src="/images/success.png"/></td>
+			<td style="width:100%;font-weight:bold">
+				<t>Success: a confirmation email has been sent to you.</t>
+			</td>
+		</tr>
+	</table>
+</macro>
+
+<macro name="action_parameter">
+	<n.get_parameter name='action'/>
+</macro>
+
+<macro name="email_parameter">
+	<n.get_parameter name='email'/>
+</macro>
+
+<macro name="code_parameter">
+	<n.get_parameter name='code'/>
+</macro>
+
+<macro name="handle_anonymous_subscription" requires="node_page">
+	<n.set_local_subscription.page_node.subscription_for email="[n.email_parameter/]" />
+	<n.if.visitor.can_view.page_node>
+		<then>
+			<n.if.local_subscription.is_subscribed>
+				<then.throw_template_exception name="already_subscribed"/>
+				<else.local_subscription.send_subscription_confirmation/>
+			</n.if.local_subscription.is_subscribed>
+		</then>
+		<else.throw_template_exception name="not_authorized"/>
+	</n.if.visitor.can_view.page_node>
+</macro>
+
+<macro name="show_subscription_error" requires="node_page">
+	<n.format_error.handle_exception. for="send-email-block">
+		<n.exception. name="invalid_email">
+			<t>Enter a valid email address.</t>
+		</n.exception.>
+		<n.exception. name="not_authorized">
+			<t>Sorry, but this email is not authorized to view messages under <t.location.page_node.subject/>.</t>
+		</n.exception.>
+		<n.exception. name="already_subscribed">
+			<t>This email is already subscribed.</t>
+		</n.exception.>
+	</n.format_error.handle_exception.>
+</macro>
+
+<macro name="anonymous_subscription_form">
+	<div style="margin:1em 0">
+		<t>Enter below your email address and we will send a confirmation email to you.</t>
+		<div class="second-font big-title" style="margin:1em 0 .2em">
+			<t>Enter your email address</t>
+		</div>
+		<n.form.>
+			<input type="hidden" name="node" value="[n.page_node.id/]"/>
+			<input type="hidden" name="action" value="send-anonymous"/>
+			<input type="text" size="40" maxlength="80" name="email"/><br/>
+			<n.if.page_node.is_post>
+				<then>
+					<input type="hidden" name="subscription_to" value="DESCENDANTS"/>
+					<div class="weak-color">
+						<t>You will receive an email for each new message posted under this topic.</t>
+					</div>
+				</then>
+				<else>
+					<input id="sChildren" type="radio" name="subscription_to" value="CHILDREN" checked="true"><label for="sChildren"><t>New topics only</t></label></input><br/>
+					<input id="sDescendants" type="radio" name="subscription_to" value="DESCENDANTS"><label for="sDescendants"><t>All posts</t></label></input><br/>
+				</else>
+			</n.if.page_node.is_post>
+			<input type="submit" class="toolbar action-button" value="[t]Subscribe[/t]" style="margin-top:.5em"/>
+		</n.form.>
+	</div>
+</macro>
+
+<macro name="send_subscription_confirmation" requires="subscription,node_page" unindent="true">
+	<n.set_local_subscription.this_subscription />
+	<n.new_email.>
+		<n.send>
+			<to><n.email_parameter/></to>
+			<subject><t>Subscribe to <t.location.page_node.subject/></t></subject>
+			<text_part>
+				<t>Dear user,</t>
+
+				<t>You have been invited to subscribe to <t.location.page_node.subject/>, which is available at:</t>
+				<n.page_node.url/>
+
+				<t>With your subscription, updates will be sent directly to your email address
+				and you can reply to them to participate in the discussion. Your subscription works the same
+				as a mailing list.</t>
+
+				<t>To confirm your subscription, click on the link below:</t>
+				<n.local_subscription.subscription_confirmation_subscribe_by_code_url/>
+
+				<t>Sincerely,</t>
+				<t>The Nabble team</t>
+				________________________________________
+				<t>Free Embeddable <t.app.page_node.view_name/></t> powered by Nabble
+				<n.nabble_homepage/>
+			</text_part>
+			<html_part>
+				<t>Dear user,</t><br/>
+				<br/>
+				<t>You have been invited to subscribe to <t.location.bold.page_node.subject/>, which is available at:</t><br/>
+				<a href="[n.page_node.url/]"><n.page_node.url/></a><br/>
+				<br/>
+				<t>With your subscription, updates will be sent directly to your email address
+				and you can reply to them to participate in the discussion. Your subscription works the same
+				as a mailing list.</t><br/>
+				<br/>
+				<t>To confirm your subscription, click on the link below:</t>
+				<div style="background-color:#FFFADB;border:#EDDD79 solid 1px;margin:1.2em 0;padding:.5em">
+					<a href="[n.local_subscription.subscription_confirmation_subscribe_by_code_url/]">
+						<n.local_subscription.subscription_confirmation_subscribe_by_code_url/>
+					</a>
+				</div>
+				<t>Sincerely,</t><br/>
+				<t>The Nabble team</t><br/>
+				________________________________________<br/>
+				<t>Free Embeddable <t.app.page_node.view_name/></t> powered by Nabble<br/>
+				<n.nabble_homepage/>
+			</html_part>
+		</n.send>
+	</n.new_email.>
+</macro>
+
+<macro name="subscription_confirmation_subscribe_by_code_url" requires="subscription">
+	<n.subscribe_by_code_url subscription_to="[n.subscription_to_field.value/]"/>
+</macro>
+
+<macro name="subscribe_by_code_url" parameters="subscription_to" requires="subscription">
+	<n.remove_spaces.>
+		<n.base_url/>
+		<n.encode_url.>
+			/template/NamlServlet.jtp?macro=subscribe_by_code&node=<n.node.id/>&code=<n.subscription_code/>
+			<n.add_to_path name="subscription_to" value="[n.subscription_to/]" />
+		</n.encode_url.>
+	</n.remove_spaces.>
+</macro>
+
+<macro name="subscribe_by_code" requires="servlet">
+	<n.node_page.>
+		<n.catch_exception. id="save-subscription">
+			<n.page_node.get_subscription_by_code. code="[n.code_parameter/]">
+				<n.if.not.is_subscribed>
+					<then.save to="[n.subscription_to_field.value/]" type="INSTANT" />
+					<else.throw_template_exception name="already_subscribed"/>
+				</n.if.not.is_subscribed>
+			</n.page_node.get_subscription_by_code.>
+		</n.catch_exception.>
+		<n.html>
+			<head>
+				<meta name="robots" content="noindex,nofollow"/>
+				<n.title.><t>Subscription Confirmation</t></n.title.>
+			</head>
+			<body>
+				<n.edit_header first_text="[n.page_node.subject/]" second_text="Subscription Confirmation" />
+				<br/>
+				<n.if.has_exception for="save-subscription">
+					<then>
+						<n.handle_exception. for="save-subscription">
+							<n.exception. name="invalid_link">
+								<h2><t>Invalid Code</t></h2>
+								<p><t>The code in the URL is not valid.</t>
+								<t>Please contact Nabble Support if you need help.</t></p>
+							</n.exception.>
+							<n.exception. name="already_subscribed">
+								<h2><t>Already Subscribed</t></h2>
+								<p><t>You are already subscribed to <n.page_node.subject/>.</t></p>
+							</n.exception.>
+						</n.handle_exception.>
+					</then>
+					<else>
+						<h2><t>Subscription Confirmed</t></h2>
+						<p><t>From now on, you will receive an email for each message posted under <t.location.page_node.subject/>.</t></p>
+					</else>
+				</n.if.has_exception>
+			</body>
+		</n.html>
+	</n.node_page.>
+</macro>
+
+<macro name="subscription_saved_url">
+	<n.remove_spaces.>
+		<n.page_node.base_url/>
+		/template/NamlServlet.jtp?macro=subscription_saved&node=<n.page_node.id/>
+	</n.remove_spaces.>
+</macro>
+
+<macro name="subscription_saved" requires="servlet">
+	<n.node_page.>
+		<n.subscription_msg
+			header="[t]Subscription Confirmed[/t]"
+			message="[t]Your subscription has been successfully saved.[/t]"
+		/>
+	</n.node_page.>
+</macro>
+
+<macro name="subscription_msg" parameters="header,message">
+	<n.html>
+		<head>
+			<n.title.><n.header/></n.title.>
+			<n.main_title_css/>
+		</head>
+		<body>
+			<n.visitor.profile_header/>
+			<div class="shaded-bg-color rounded second-font main-title">
+				<n.header/>
+			</div>
+
+			<table style="margin-bottom:1em">
+				<tr valign="top">
+					<td><img src="/images/success.png" class="image16"/></td>
+					<td>
+						<b><n.message/></b>
+						<p><a href="[n.page_node.url/]"><t>Return to <t.location.page_node.subject/></t></a></p>
+					</td>
+				</tr>
+			</table>
+		</body>
+	</n.html>
+</macro>
+
+<macro name="main_title_css">
+	<style type="text/css">
+		div.main-title {
+			font-size:120%;
+			font-weight:bold;
+			margin:1em 0;
+			padding: .2em;
+		}
+	</style>
+</macro>
+
+<macro name="edit_path" requires="subscription">
+	/template/NamlServlet.jtp?macro=subscribe&node=<n.node.id/>
+</macro>
\ No newline at end of file