view src/nabble/modules/ad/ad.naml @ 0:7ecd1a4ef557

add content
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 21 Mar 2019 19:15:52 -0600
parents
children
line wrap: on
line source


<override_macro name="nabble_shared_scripts">
	<n.overridden/>
	<n.array_of_user_ids var_name="site_admins" group="[n.administrators_group/]"/>
	<script type="text/javascript">
		var isSafe = <n.is_ad_safe/>;
		var Ads = Ads || {};
		Ads.text = {
			daysLeft: '<t>Trial period ends in <t.number>$1</t.number> day(s)</t>',
			removeAds: '<t>Remove Ads</t>',
			buyCredits: '<t>Upgrade</t>'
		};
		$(document).ready(function() {
			if (Nabble.wasCreatedRecently && Nabble.currentCredits == 0 && isSafe) {
				var s = '<div class="weak-color" style="text-align:center;margin:1em;font-size:80%">';
				s += Ads.text.daysLeft.replace(/\$1/,daysLeft)+' &ndash; ';
				s += '<a href="[n.site_payment_path/]">'+(Nabble.isSafe?Ads.text.removeAds:Ads.text.buyCredits)+'</a>';
				s += '</div>';
				var isAdmin = Nabble.userId && site_admins.indexOf(Number(Nabble.userId)) >= 0;
				isAdmin && $('div.nabble').append(s);
			}
		});
	</script>
	<n.visible_for_admins selector="div.no-ads-message"/>
</override_macro>

<macro name="show_ad" parameters="location" requires="servlet">
	<n.comment.>
		WARNING: users are NOT allowed to change this macro in order to remove ads from their apps.
		If you want to remove ads, please buy the premium subscription. Also, if you want to place your
		own ads code, please put them in the 'show_custom_ads' macro (your ads will be displayed while
		your premium subscription is active). Please DO NOT try dirty tricks to hide the ads. We may delete
		your site at any time if you do that.
	</n.comment.>
	<n.if.has_ads>
		<then>
			<n.put_in_head.adbayes_script params="[n.adbayes_params_for.location/]"/>
			<script type="text/javascript">
				Nabble.ads('<n.location/>');
			</script>
		</then>
		<else>
			<script type="text/javascript">
				Nabble.noAds('<n.location/>');
			</script>
			<n.show_custom_ads location="[n.location/]" />
		</else>
	</n.if.has_ads>
</macro>

<macro name="show_custom_ads" parameters="location" requires="servlet" >
	<n.comment.>
		Here you can place your own ads and make money with your Nabble application.
		But please remember that you must pay for ad-free credits if you want to remove Nabble's ads.
	</n.comment.>
</macro>

<macro name="menu_premium_upgrade" requires="node">
	<n.if.is_in_command name="dropdown">
		<then>
			dropdown.add('premiumUpgrade', '<n.javascript_string_encode.site_payment_link/>', 'display:none');
		</then>
		<else>
			<n.set_local_node.this_node/>
			<n.if>
				<condition>
					<n.both>
						<condition1.local_node.is_root/>
						<condition2.both condition1="[n.visitor.can_edit.local_node/]" condition2="[n.not.is_paid_site/]"/>
					</n.both>
				</condition>
				<then>
					NabbleDropdown.show('premiumUpgrade');
				</then>
			</n.if>
		</else>
	</n.if.is_in_command>
</macro>

<macro name="ads_widget">
	<n.widget.>
		<n.show_ad location="widget" />
	</n.widget.>
</macro>

<override_macro name="sidebar_widget" requires="node_page,servlet">
	<n.overridden />
	<n.ads_widget />
</override_macro>

<override_macro name="topic_controls" requires="blog_topic_namespace">
	<n.overridden />
	<n.show_ad location="blog_topic"/>
</override_macro>

<override_macro name="classic_message_cell" requires="node">
	<n.overridden />
	<n.if.not.is_blog_topic>
		<then>
			<n.if.is_first_element>
				<then>
					<n.show_ad location="first_classic_message"/>
				</then>
			</n.if.is_first_element>
			<n.if.is_last_element>
			 <then>
				 <n.if.not.regex_matches pattern='1' text="[n.page_node.descendant_count/]">
					<then.show_ad location="last_classic_message"/>
				 </n.if.not.regex_matches>
			 </then>
		 </n.if.is_last_element>
		</then>
	</n.if.not.is_blog_topic>
</override_macro>

<override_macro name="topic_rows" requires="node,forum_topic_namespace,list_view_namespace">
	<n.overridden />
	<n.show_ad location="list_bottom"/>
</override_macro>

<override_macro name="topic_rows" requires="node,forum_topic_namespace,threaded_view_namespace">
	<n.overridden />
	<n.show_ad location="threaded_bottom"/>
</override_macro>

<override_macro name="search_pagination" requires="search">
	<n.overridden />
	<n.show_ad location="search_bottom"/>
</override_macro>

<override_macro name="search_results_header" requires="search">
	<n.overridden />
	<script type="text/javascript">
		var nabble_search_query = '<n.hide_null.get_parameter name="query"/>';
	</script>
	<n.show_ad location="search_top"/>
</override_macro>

<override_macro name="app_body_footer">
	<n.overridden/>
	<n.show_ad location="app_bottom"/>
</override_macro>

<override_macro name="topic_bottom">
	<n.overridden/>
	<n.show_ad location="topic_bottom"/>
</override_macro>

<macro name="ad_notice">
	<n.new_email.>
		<n.send>
			<to><n.root_node.owner.user_email/></to>
			<subject><t><t.location.root_node.subject/> - Your credits are running out</t></subject>
			<text_part>
				<t>Dear user,</t>

				<t><t.location.root_node.subject/> is running out of credits.</t>
				<t>Current Credits</t>: <t><t.number.current_credits/> Credits</t>

				<t>For a premium upgrade, please visit:</t>
				<n.base_url/><n.site_payment_path/>

				<t>Regards,</t>
				<t>The Nabble team</t>
			</text_part>
			<html_part>
				<t>Dear user,</t><br/>
				<br/>
				<t><t.location.root_node.subject/> is running out of credits.</t><br/>
				<t>Current Credits</t>: <t><t.number.current_credits/> Credits</t><br/>
				<br/>
				<t>For a premium upgrade, please visit:</t><br/>
				<a href="[n.base_url/][n.site_payment_path/]"><n.base_url/><n.site_payment_path/></a><br/>
				<br/>
				<t>Regards,</t><br/>
				<t>Nabble Team</t>
			</html_part>
			</n.send>
	</n.new_email.>
</macro>

<override_macro name="bottom_scripts">
	<n.as_html_comments.>Ad.<n.is_ad_safe/> | <n.current_credits/> credits</n.as_html_comments.>
	<script type="text/javascript">
		Nabble.trk = Nabble.trk || {};
		Nabble.trk.safe = <n.is_ad_safe/>;
	</script>
	<n.overridden/>
</override_macro>

<macro name="adbayes_script" parameters="params" requires="ad, servlet">
	<n.if.not.is_null.adbayes_link>
		<then>
			<script type="text/javascript" src="[n.adbayes_link/][n.hide_null.params/]"></script>
			<script type="text/javascript">
				Nabble.adbayes();
			</script>
		</then>
	</n.if.not.is_null.adbayes_link>
</macro>

<macro name="adbayes_params_for" dot_parameter="location" requires="ad, servlet">
	<n.switch. value="[n.location/]">
		<n.case. value="list_bottom">
			&canonical=<n.encode.use_url_encoder.regex_replace_all text="[n.current_url/]" pattern="-tc(\d+)" replacement="-td$1"/>
		</n.case.>
		<n.case. value="threaded_bottom">
			&canonical=<n.encode.use_url_encoder.regex_replace_all text="[n.current_url/]" pattern="-tt(\d+)" replacement="-td$1"/>
		</n.case.>
		<n.case. value="search_bottom">
			&text=<n.encode.use_url_encoder.get_parameter name="query"/>
		</n.case.>
		<n.case. value="search_top">
			&text=<n.encode.use_url_encoder.get_parameter name="query"/>
		</n.case.>
	</n.switch.>
</macro>

<override_macro name="javascript_library" requires="servlet">
	<n.overridden/>
	<n.compress.ad_javascript/>
</override_macro>

<override_macro name="report_inappropriate_content_submit" requires="servlet">
	<n.if.is_ad_safe>
		<then.overridden/>
	</n.if.is_ad_safe>
</override_macro>

<macro name="site_payment_link">
	<a href="[n.site_payment_path/]"><t>Premium upgrade</t></a>
</macro>

<macro name="site_payment_path">
	/template/NamlServlet.jtp?macro=site_payment
</macro>

<macro name="site_payment">
	<n.if.visitor.is_authenticated>
		<then>
			<n.redirect_to.site_payment_url/>
		</then>
		<else>
			<n.login.>You must login to upgrade this site.</n.login.>
		</else>
	</n.if.visitor.is_authenticated>
</macro>

<macro name="payment_confirmed">
	<n.html>
		<head>
			<meta name="robots" content="noindex,nofollow"/>
			<n.title.><t>Payment Confirmation</t></n.title.>
		</head>
		<body>
			<n.if.confirm_payment customer_id="[n.get_parameter name='c'/]" user="[n.get_parameter name='user'/]" key1="[n.get_parameter name='key1'/]" key2="[n.get_parameter name='key2'/]">
				<then>
					<h1><t>Payment Confirmed</t></h1>
					<p>Your payment has been confirmed. You can find payment options on your account settings page.</p>
				</then>
				<else>
					<h1><t>Payment Failed</t></h1>
					<p>
						Sorry, but something went wrong with your payment.
						You may send an email to <a href="mailto:payments@nabble.com">payments@nabble.com</a> if you need help.
					</p>
				</else>
			</n.if.confirm_payment>
		</body>
	</n.html>
</macro>

<override_macro name="authenticated_self_profile_header" requires="user">
	<n.overridden/>
	<n.if.both condition1="[n.not.is_null.site_payment_cancellation_url/]" condition2="[n.is_paid_site/]">
		<then>
			<div style="margin-top:.5em">
				<img src="/images/icon_info.png" class="image16" style="margin:0 1px"/>
				<a href="[n.site_payment_cancellation_url/]" target="_top"><t>Cancel Payment Subscription</t></a>
			</div>
		</then>
	</n.if.both>
</override_macro>

<macro name="cancelled">
	<n.html>
		<head>
			<meta name="robots" content="noindex,nofollow"/>
			<n.title.><t>Payment Subscription Cancelled</t></n.title.>
		</head>
		<body>
			<n.update_status customer_id="[n.get_parameter name='c'/]"/>
			<h1><t>Payment Subscription Cancelled</t></h1>
			<p>Your payment subscription has been cancelled and your card has been removed from the billing cycle.</p>
		</body>
	</n.html>
</macro>