diff src/nabble/view/naml/change_title_and_meta_tags.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 diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/nabble/view/naml/change_title_and_meta_tags.naml	Thu Mar 21 19:15:52 2019 -0600
@@ -0,0 +1,143 @@
+<macro name="change_title_and_meta_tags" requires="servlet">
+	<n.node_page.>
+		<n.if.not.visitor.is_site_admin>
+			<then>
+				<n.login.><t>Only authorized users can proceed in this area.</t></n.login.>
+			</then>
+		</n.if.not.visitor.is_site_admin>
+
+		<n.if.is_submitted_form>
+			<then>
+				<n.if.has_custom_values_field.is_checked>
+					<then>
+						<n.page_node.set_property name="page_title" value="[n.page_title_field.value/]"/>
+						<n.page_node.set_property name="page_meta_description" value="[n.page_meta_description_field.value/]"/>
+					</then>
+					<else>
+						<n.page_node.delete_property name="page_title"/>
+						<n.page_node.delete_property name="page_meta_description"/>
+					</else>
+				</n.if.has_custom_values_field.is_checked>
+				<n.redirect_to.page_node.path/>
+			</then>
+			<else>
+				<n.has_custom_values_field.set_value value="[n.page_node.has_custom_meta_tags/]"/>
+				<n.page_title_field.set_value.property_default property="page_title" default="[n.page_node.default_title_contents/]"/>
+				<n.page_meta_description_field.set_value.property_default property="page_meta_description" default="[n.page_node.default_meta_description/]"/>
+			</else>
+		</n.if.is_submitted_form>
+		<n.html>
+			<head>
+				<meta name="robots" content="noindex,nofollow"/>
+				<n.title.><t>Change title and meta tags</t></n.title.>
+				<style type="text/css">
+					textarea {
+						margin:.4em 0 2em;
+						width:40em;
+						height:3em;
+					}
+				</style>
+				<script type="text/javascript">
+					var txt_counter = '<t>Current length: <t.number>#1</t.number> characters</t>';
+					function updateCounters(){
+						$('textarea').each(function() {
+							var $textarea = $(this);
+							$textarea.prev().html(txt_counter.replace(/#1/, $textarea.val().length));
+						});
+					};
+
+					function enableFields() {
+						var checked = $('#has_custom_values').is(':checked');
+						var $fields = $('#page_title,#page_meta_description');
+						if (checked) {
+							$('textarea').keyup(updateCounters);
+							$fields.removeAttr('disabled');
+							$fields.eq(0).focus();
+						} else
+							$fields.attr('disabled', true);
+					};
+					$(document).ready(function() {
+						enableFields();
+						updateCounters();
+						$('#has_custom_values').click(enableFields);
+					});
+				</script>
+			</head>
+			<body>
+				<n.edit_header first_text="[n.page_node.subject/]" second_text="[t]Change title and meta tags[/t]" />
+				<div class="weak-color" style="margin:1em 0">
+					<t>Here you can customize the title and meta tags of the <t.location><i><n.page_node.subject/></i></t.location> page.</t>
+					<t>The meta information below can help you optimize this page for search engines (e.g., google, yahoo!, etc.).</t>
+				</div>
+				<n.form.>
+					<div style="margin:1em 0 0;">
+						<n.has_custom_values_field.checkbox />
+						<label for="[n.has_custom_values_field.name/]" class="big-title second-font"><t>Use custom values</t></label><br/>
+					</div>
+
+					<div style="margin:1em 0 0 3em">
+						<div class="big-title second-font"><t>Page Title</t></div>
+						<div class="weak-color"><t>Enter a context-rich title that clearly identifies this page.</t></div>
+						<div class="weak-color"><t>The title should ideally be less than 70 characters in length.</t></div>
+						<div class="weak-color"></div>
+						<n.page_title_field.textarea maxlength="100"/>
+
+						<div class="big-title second-font"><t>Meta Description</t></div>
+						<div class="weak-color"><t>Enter a brief and concise summary of your page's content.</t></div>
+						<div class="weak-color"><t>Limit your description to 155 characters or 170 characters at most.</t></div>
+						<div class="weak-color"></div>
+						<n.page_meta_description_field.textarea maxlength="250"/>
+					</div>
+
+					<div>
+						<input type="submit" class="toolbar action-button" value="[t]Save Changes[/t]" />
+						<t>or</t> <a href="[n.page_node.path/]"><t>Cancel</t></a>
+					</div>
+				</n.form.>
+			</body>
+		</n.html>
+	</n.node_page.>
+</macro>
+
+<macro name="has_custom_meta_tags" requires="node">
+	<n.both>
+		<condition1.has_property name="page_title"/>
+		<condition2.has_property name="page_meta_description"/>
+	</n.both>
+</macro>
+
+<macro name="property_default" parameters="property, default">
+	<n.if.page_node.has_property name="[n.property/]">
+		<then.page_node.get_property name="[n.property/]"/>
+		<else.compress.default/>
+	</n.if.page_node.has_property>
+</macro>
+
+<macro name="default_title_contents" requires="node">
+	<n.if.is_app>
+		<then.default_app_title_contents/>
+		<else.default_topic_title_contents/>
+	</n.if.is_app>
+</macro>
+
+<macro name="change_title_and_meta_tags_link" requires="node" dot_parameter="text" parameters="title, class">
+	<a href="[n.change_title_and_meta_tags_path/]" class="[n.class/]" rel="nofollow" title="[n.title/]"><n.default. to="[t]Change title and meta tags[/t]"><n.text/></n.default.></a>
+</macro>
+
+<macro name="change_title_and_meta_tags_path">
+	<n.encode_url.>
+		/template/NamlServlet.jtp?macro=change_title_and_meta_tags&node=<n.id/>
+	</n.encode_url.>
+</macro>
+
+<macro name="page_title_field" dot_parameter="do">
+	<n.field. name="page_title"><n.do/></n.field.>
+</macro>
+
+<macro name="page_meta_description_field" dot_parameter="do">
+	<n.field. name="page_meta_description"><n.do/></n.field.>
+</macro>
+
+<macro name="has_custom_values_field" dot_parameter="do">
+	<n.field. name="has_custom_values"><n.do/></n.field.>
+</macro>
\ No newline at end of file