url_mapper.naml
<macro name="url mapper" requires="url_mapper">
<n.map_root/>
<n.map_app/>
<n.map_topic/>
<n.map_atom_feeds/>
</macro>
<macro name="set_parameter_if_found" parameters="name,group" requires="url_mapper,regex">
<n.if.did_find group="[n.group/]">
<then.set_parameter_to_found name="[n.name/]" group="[n.group/]" />
</n.if.did_find>
</macro>
<macro name="set_parameter_char_if_found" parameters="name,group,char,value" requires="url_mapper,regex">
<n.if.did_find group="[n.group/]">
<then>
<n.set_var. name='found'><n.found group="[n.group/]"/></n.set_var.>
<n.if.equal value1="[n.char/]" value2="[n.var name='found'/]">
<then.set_parameter. name="[n.name/]">
<n.value/>
</then.set_parameter.>
</n.if.equal>
</then>
</n.if.did_find>
</macro>
<macro name="set_parameter_to_found" parameters="name,group" requires="url_mapper,regex">
<n.set_parameter. name="[n.name/]">
<n.found group="[n.group/]"/>
</n.set_parameter.>
</macro>
individual mappings
<macro name="map_root" requires="url_mapper">
<n.regex text="[n.path/]">
<pattern>
^/$
</pattern>
<do>
<n.if.find>
<then>
<n.set_parameter. name="node">
<n.root_node.id/>
</n.set_parameter.>
<n.set_parameter name="macro" value="view_app" />
<n.exit/>
</then>
</n.if.find>
</do>
</n.regex>
</macro>
<macro name="map_app" requires="url_mapper">
<n.regex text="[n.path/]">
<pattern>
-f(\d+)(?:p(\d+))?(?:a(\d+))?(?:i(\d+))?(?:d(\d+))?(?:ef\d+)?(?:\.([a-z]+))?\.html$
</pattern>
<do>
<n.if.find>
<then>
<n.set_parameter_to_found name="node" group="1" />
<n.set_parameter_if_found name="priority" group="2" />
<n.set_parameter_if_found name="assignee" group="3" />
<n.set_parameter_if_found name="index_record" group="4" />
<n.set_parameter_if_found name="date" group="5" />
<n.if.did_find group="6">
<then>
<n.set_parameter. name="macro">
view_<n.found group="6"/>
</n.set_parameter.>
</then>
<else>
<n.set_parameter name="macro" value="view_app" />
</else>
</n.if.did_find>
<n.exit/>
</then>
</n.if.find>
</do>
</n.regex>
</macro>
<macro name="map_topic" requires="url_mapper">
<n.regex text="[n.path/]">
<pattern>
-t(d|c|t)(\d+)(?:i(\d+))?(?:ef\d+)?\.html$
</pattern>
<do>
<n.if.find>
<then>
<n.set_parameter_char_if_found name="view" group="1" char="d" value="classic" />
<n.set_parameter_char_if_found name="view" group="1" char="c" value="list" />
<n.set_parameter_char_if_found name="view" group="1" char="t" value="threaded" />
<n.set_parameter_to_found name="node" group="2" />
<n.set_parameter_if_found name="index_record" group="3" />
<n.set_parameter name="macro" value="topic" />
<n.exit/>
</then>
</n.if.find>
</do>
</n.regex>
</macro>
<macro name="map_atom_feeds" requires="url_mapper">
<n.regex text="[n.path/]">
<pattern>
-f(t)?(\d+)(n(\d+))?.xml$
</pattern>
<do>
<n.if.find>
<then>
<n.if.did_find group="1">
<then.set_parameter name="macro" value="atom_topics_by_date" />
<else.set_parameter name="macro" value="atom_posts_by_date" />
</n.if.did_find>
<n.set_parameter_to_found name="node" group="2" />
<n.set_parameter_if_found name="length" group="4" />
<n.exit/>
</then>
</n.if.find>
</do>
</n.regex>
</macro>