Mercurial Hosting > nabble
comparison src/nabble/view/naml/url_mapper.naml @ 0:7ecd1a4ef557
add content
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 21 Mar 2019 19:15:52 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:7ecd1a4ef557 |
---|---|
1 | |
2 <macro name="url mapper" requires="url_mapper"> | |
3 <n.map_root/> | |
4 <n.map_app/> | |
5 <n.map_topic/> | |
6 <n.map_atom_feeds/> | |
7 </macro> | |
8 | |
9 <macro name="set_parameter_if_found" parameters="name,group" requires="url_mapper,regex"> | |
10 <n.if.did_find group="[n.group/]"> | |
11 <then.set_parameter_to_found name="[n.name/]" group="[n.group/]" /> | |
12 </n.if.did_find> | |
13 </macro> | |
14 | |
15 <macro name="set_parameter_char_if_found" parameters="name,group,char,value" requires="url_mapper,regex"> | |
16 <n.if.did_find group="[n.group/]"> | |
17 <then> | |
18 <n.set_var. name='found'><n.found group="[n.group/]"/></n.set_var.> | |
19 <n.if.equal value1="[n.char/]" value2="[n.var name='found'/]"> | |
20 <then.set_parameter. name="[n.name/]"> | |
21 <n.value/> | |
22 </then.set_parameter.> | |
23 </n.if.equal> | |
24 </then> | |
25 </n.if.did_find> | |
26 </macro> | |
27 | |
28 <macro name="set_parameter_to_found" parameters="name,group" requires="url_mapper,regex"> | |
29 <n.set_parameter. name="[n.name/]"> | |
30 <n.found group="[n.group/]"/> | |
31 </n.set_parameter.> | |
32 </macro> | |
33 | |
34 | |
35 individual mappings | |
36 | |
37 <macro name="map_root" requires="url_mapper"> | |
38 <n.regex text="[n.path/]"> | |
39 <pattern> | |
40 ^/$ | |
41 </pattern> | |
42 <do> | |
43 <n.if.find> | |
44 <then> | |
45 <n.set_parameter. name="node"> | |
46 <n.root_node.id/> | |
47 </n.set_parameter.> | |
48 <n.set_parameter name="macro" value="view_app" /> | |
49 <n.exit/> | |
50 </then> | |
51 </n.if.find> | |
52 </do> | |
53 </n.regex> | |
54 </macro> | |
55 | |
56 <macro name="map_app" requires="url_mapper"> | |
57 <n.regex text="[n.path/]"> | |
58 <pattern> | |
59 -f(\d+)(?:p(\d+))?(?:a(\d+))?(?:i(\d+))?(?:d(\d+))?(?:ef\d+)?(?:\.([a-z]+))?\.html$ | |
60 </pattern> | |
61 <do> | |
62 <n.if.find> | |
63 <then> | |
64 <n.set_parameter_to_found name="node" group="1" /> | |
65 <n.set_parameter_if_found name="priority" group="2" /> | |
66 <n.set_parameter_if_found name="assignee" group="3" /> | |
67 <n.set_parameter_if_found name="index_record" group="4" /> | |
68 <n.set_parameter_if_found name="date" group="5" /> | |
69 <n.if.did_find group="6"> | |
70 <then> | |
71 <n.set_parameter. name="macro"> | |
72 view_<n.found group="6"/> | |
73 </n.set_parameter.> | |
74 </then> | |
75 <else> | |
76 <n.set_parameter name="macro" value="view_app" /> | |
77 </else> | |
78 </n.if.did_find> | |
79 <n.exit/> | |
80 </then> | |
81 </n.if.find> | |
82 </do> | |
83 </n.regex> | |
84 </macro> | |
85 | |
86 <macro name="map_topic" requires="url_mapper"> | |
87 <n.regex text="[n.path/]"> | |
88 <pattern> | |
89 -t(d|c|t)(\d+)(?:i(\d+))?(?:ef\d+)?\.html$ | |
90 </pattern> | |
91 <do> | |
92 <n.if.find> | |
93 <then> | |
94 <n.set_parameter_char_if_found name="view" group="1" char="d" value="classic" /> | |
95 <n.set_parameter_char_if_found name="view" group="1" char="c" value="list" /> | |
96 <n.set_parameter_char_if_found name="view" group="1" char="t" value="threaded" /> | |
97 <n.set_parameter_to_found name="node" group="2" /> | |
98 <n.set_parameter_if_found name="index_record" group="3" /> | |
99 <n.set_parameter name="macro" value="topic" /> | |
100 <n.exit/> | |
101 </then> | |
102 </n.if.find> | |
103 </do> | |
104 </n.regex> | |
105 </macro> | |
106 | |
107 <macro name="map_atom_feeds" requires="url_mapper"> | |
108 <n.regex text="[n.path/]"> | |
109 <pattern> | |
110 -f(t)?(\d+)(n(\d+))?.xml$ | |
111 </pattern> | |
112 <do> | |
113 <n.if.find> | |
114 <then> | |
115 <n.if.did_find group="1"> | |
116 <then.set_parameter name="macro" value="atom_topics_by_date" /> | |
117 <else.set_parameter name="macro" value="atom_posts_by_date" /> | |
118 </n.if.did_find> | |
119 <n.set_parameter_to_found name="node" group="2" /> | |
120 <n.set_parameter_if_found name="length" group="4" /> | |
121 <n.exit/> | |
122 </then> | |
123 </n.if.find> | |
124 </do> | |
125 </n.regex> | |
126 </macro> |