documentation: regenerate documents from current code base
[project/luci.git] / documentation / api / modules / luci.dispatcher.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html>
4 <head>
5     <title>Reference</title>
6     <link rel="stylesheet" href="../luadoc.css" type="text/css" />
7         <!--meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/-->
8 </head>
9
10 <body>
11 <div id="container">
12
13 <div id="product">
14         <div id="product_logo"></div>
15         <div id="product_name"><big><b></b></big></div>
16         <div id="product_description"></div>
17 </div> <!-- id="product" -->
18
19 <div id="main">
20
21 <div id="navigation">
22
23
24 <h1>LuaDoc</h1>
25 <ul>
26         
27         <li><a href="../index.html">Index</a></li>
28         
29 </ul>
30
31
32 <!-- Module list -->
33
34 <h1>Modules</h1>
35 <ul>
36
37         <li><strong>luci.dispatcher</strong></li>
38         
39         <li>
40                 <a href="../modules/luci.http.html">luci.http</a>
41         </li>
42
43         <li>
44                 <a href="../modules/luci.http.conditionals.html">luci.http.conditionals</a>
45         </li>
46
47         <li>
48                 <a href="../modules/luci.http.date.html">luci.http.date</a>
49         </li>
50
51         <li>
52                 <a href="../modules/luci.http.mime.html">luci.http.mime</a>
53         </li>
54
55         <li>
56                 <a href="../modules/luci.i18n.html">luci.i18n</a>
57         </li>
58
59         <li>
60                 <a href="../modules/luci.ip.html">luci.ip</a>
61         </li>
62
63         <li>
64                 <a href="../modules/luci.ip.cidr.html">luci.ip.cidr</a>
65         </li>
66
67         <li>
68                 <a href="../modules/luci.json.html">luci.json</a>
69         </li>
70
71         <li>
72                 <a href="../modules/luci.jsonc.html">luci.jsonc</a>
73         </li>
74
75         <li>
76                 <a href="../modules/luci.jsonc.parser.html">luci.jsonc.parser</a>
77         </li>
78
79         <li>
80                 <a href="../modules/luci.model.ipkg.html">luci.model.ipkg</a>
81         </li>
82
83         <li>
84                 <a href="../modules/luci.model.uci.html">luci.model.uci</a>
85         </li>
86
87         <li>
88                 <a href="../modules/luci.rpcc.html">luci.rpcc</a>
89         </li>
90
91         <li>
92                 <a href="../modules/luci.rpcc.ruci.html">luci.rpcc.ruci</a>
93         </li>
94
95         <li>
96                 <a href="../modules/luci.sys.html">luci.sys</a>
97         </li>
98
99         <li>
100                 <a href="../modules/luci.sys.init.html">luci.sys.init</a>
101         </li>
102
103         <li>
104                 <a href="../modules/luci.sys.iptparser.html">luci.sys.iptparser</a>
105         </li>
106
107         <li>
108                 <a href="../modules/luci.sys.net.html">luci.sys.net</a>
109         </li>
110
111         <li>
112                 <a href="../modules/luci.sys.process.html">luci.sys.process</a>
113         </li>
114
115         <li>
116                 <a href="../modules/luci.sys.user.html">luci.sys.user</a>
117         </li>
118
119         <li>
120                 <a href="../modules/luci.sys.wifi.html">luci.sys.wifi</a>
121         </li>
122
123         <li>
124                 <a href="../modules/luci.util.html">luci.util</a>
125         </li>
126
127         <li>
128                 <a href="../modules/nixio.html">nixio</a>
129         </li>
130
131         <li>
132                 <a href="../modules/nixio.CHANGELOG.html">nixio.CHANGELOG</a>
133         </li>
134
135         <li>
136                 <a href="../modules/nixio.CryptoHash.html">nixio.CryptoHash</a>
137         </li>
138
139         <li>
140                 <a href="../modules/nixio.File.html">nixio.File</a>
141         </li>
142
143         <li>
144                 <a href="../modules/nixio.README.html">nixio.README</a>
145         </li>
146
147         <li>
148                 <a href="../modules/nixio.Socket.html">nixio.Socket</a>
149         </li>
150
151         <li>
152                 <a href="../modules/nixio.TLSContext.html">nixio.TLSContext</a>
153         </li>
154
155         <li>
156                 <a href="../modules/nixio.TLSSocket.html">nixio.TLSSocket</a>
157         </li>
158
159         <li>
160                 <a href="../modules/nixio.UnifiedIO.html">nixio.UnifiedIO</a>
161         </li>
162
163         <li>
164                 <a href="../modules/nixio.bin.html">nixio.bin</a>
165         </li>
166
167         <li>
168                 <a href="../modules/nixio.bit.html">nixio.bit</a>
169         </li>
170
171         <li>
172                 <a href="../modules/nixio.crypto.html">nixio.crypto</a>
173         </li>
174
175         <li>
176                 <a href="../modules/nixio.fs.html">nixio.fs</a>
177         </li>
178
179 </ul>
180
181
182
183 <!-- File list -->
184
185
186
187
188
189
190
191 </div><!-- id="navigation" -->
192
193 <div id="content">
194
195 <h1>Class <code>luci.dispatcher</code></h1>
196
197 <p></p>
198
199
200
201
202
203
204
205 <h2>Functions</h2>
206 <table class="function_list">
207
208         <tr>
209         <td class="name" nowrap><a href="#_">_</a>&nbsp;()</td>
210         <td class="summary">
211  
212 No-op function used to mark translation entries for menu labels.</td>
213         </tr>
214
215         <tr>
216         <td class="name" nowrap><a href="#alias">alias</a>&nbsp;(...)</td>
217         <td class="summary">
218  
219 Create a redirect to another dispatching node.</td>
220         </tr>
221
222         <tr>
223         <td class="name" nowrap><a href="#arcombine">arcombine</a>&nbsp;(trg1, trg2)</td>
224         <td class="summary">
225  
226 Create a combined dispatching target for non argv and argv requests.</td>
227         </tr>
228
229         <tr>
230         <td class="name" nowrap><a href="#assign">assign</a>&nbsp;(path, clone, title, order)</td>
231         <td class="summary">
232  
233 Clone a node of the dispatching tree to another position.</td>
234         </tr>
235
236         <tr>
237         <td class="name" nowrap><a href="#build_url">build_url</a>&nbsp;(...)</td>
238         <td class="summary">
239  
240 Build the URL relative to the server webroot from given virtual path.</td>
241         </tr>
242
243         <tr>
244         <td class="name" nowrap><a href="#call">call</a>&nbsp;(name, ...)</td>
245         <td class="summary">
246  
247 Create a function-call dispatching target.</td>
248         </tr>
249
250         <tr>
251         <td class="name" nowrap><a href="#cbi">cbi</a>&nbsp;(model)</td>
252         <td class="summary">
253  
254 Create a CBI model dispatching target.</td>
255         </tr>
256
257         <tr>
258         <td class="name" nowrap><a href="#createindex">createindex</a>&nbsp;()</td>
259         <td class="summary">
260  
261 Generate the dispatching index using the native file-cache based strategy.</td>
262         </tr>
263
264         <tr>
265         <td class="name" nowrap><a href="#createtree">createtree</a>&nbsp;()</td>
266         <td class="summary">
267  
268 Create the dispatching tree from the index.</td>
269         </tr>
270
271         <tr>
272         <td class="name" nowrap><a href="#dispatch">dispatch</a>&nbsp;(request)</td>
273         <td class="summary">
274  
275 Dispatches a LuCI virtual path.</td>
276         </tr>
277
278         <tr>
279         <td class="name" nowrap><a href="#entry">entry</a>&nbsp;(path, target, title, order)</td>
280         <td class="summary">
281  
282 Create a new dispatching node and define common parameters.</td>
283         </tr>
284
285         <tr>
286         <td class="name" nowrap><a href="#error404">error404</a>&nbsp;(message)</td>
287         <td class="summary">
288  
289 Send a 404 error code and render the "error404" template if available.</td>
290         </tr>
291
292         <tr>
293         <td class="name" nowrap><a href="#error500">error500</a>&nbsp;(message)</td>
294         <td class="summary">
295  
296 Send a 500 error code and render the "error500" template if available.</td>
297         </tr>
298
299         <tr>
300         <td class="name" nowrap><a href="#firstchild">firstchild</a>&nbsp;()</td>
301         <td class="summary">
302  
303 Alias the first (lowest order) page automatically 
304  
305  </td>
306         </tr>
307
308         <tr>
309         <td class="name" nowrap><a href="#form">form</a>&nbsp;(model)</td>
310         <td class="summary">
311  
312 Create a CBI form model dispatching target.</td>
313         </tr>
314
315         <tr>
316         <td class="name" nowrap><a href="#get">get</a>&nbsp;(...)</td>
317         <td class="summary">
318  
319 Fetch or create a dispatching node without setting the target module or 
320 enabling the node.</td>
321         </tr>
322
323         <tr>
324         <td class="name" nowrap><a href="#httpdispatch">httpdispatch</a>&nbsp;(request)</td>
325         <td class="summary">
326  
327 Dispatch an HTTP request.</td>
328         </tr>
329
330         <tr>
331         <td class="name" nowrap><a href="#lookup">lookup</a>&nbsp;(...)</td>
332         <td class="summary">
333  
334 Lookup node in dispatching tree.</td>
335         </tr>
336
337         <tr>
338         <td class="name" nowrap><a href="#modifier">modifier</a>&nbsp;(func, order)</td>
339         <td class="summary">
340  
341 Register a tree modifier.</td>
342         </tr>
343
344         <tr>
345         <td class="name" nowrap><a href="#node">node</a>&nbsp;(...)</td>
346         <td class="summary">
347  
348 Fetch or create a new dispatching node.</td>
349         </tr>
350
351         <tr>
352         <td class="name" nowrap><a href="#node_childs">node_childs</a>&nbsp;(node)</td>
353         <td class="summary">
354  
355 Return a sorted table of visible childs within a given node 
356  </td>
357         </tr>
358
359         <tr>
360         <td class="name" nowrap><a href="#node_visible">node_visible</a>&nbsp;(node)</td>
361         <td class="summary">
362  
363 Check whether a dispatch node shall be visible 
364  </td>
365         </tr>
366
367         <tr>
368         <td class="name" nowrap><a href="#rewrite">rewrite</a>&nbsp;(n, ...)</td>
369         <td class="summary">
370  
371 Rewrite the first x path values of the request.</td>
372         </tr>
373
374         <tr>
375         <td class="name" nowrap><a href="#template">template</a>&nbsp;(name)</td>
376         <td class="summary">
377  
378 Create a template render dispatching target.</td>
379         </tr>
380
381         <tr>
382         <td class="name" nowrap><a href="#translate">translate</a>&nbsp;(text)</td>
383         <td class="summary">
384  
385 Access the luci.i18n translate() api.</td>
386         </tr>
387
388 </table>
389
390
391
392
393
394
395 <br/>
396 <br/>
397
398
399 <h2><a name="functions"></a>Functions</h2>
400 <dl class="function">
401
402
403
404 <dt><a name="_"></a><strong>_</strong>&nbsp;()</dt>
405 <dd>
406
407  
408 No-op function used to mark translation entries for menu labels. 
409  
410 This function does not actually translate the given argument but 
411 is used by build/i18n-scan.pl to find translatable entries. 
412
413
414
415
416
417
418
419
420
421
422 </dd>
423
424
425
426
427 <dt><a name="alias"></a><strong>alias</strong>&nbsp;(...)</dt>
428 <dd>
429
430  
431 Create a redirect to another dispatching node. 
432
433
434
435 <h3>Parameters</h3>
436 <ul>
437         
438         <li>
439           ...: Virtual path destination
440         </li>
441         
442 </ul>
443
444
445
446
447
448
449
450
451 </dd>
452
453
454
455
456 <dt><a name="arcombine"></a><strong>arcombine</strong>&nbsp;(trg1, trg2)</dt>
457 <dd>
458
459  
460 Create a combined dispatching target for non argv and argv requests. 
461
462
463
464 <h3>Parameters</h3>
465 <ul>
466         
467         <li>
468           trg1: Overview Target
469         </li>
470         
471         <li>
472           trg2: Detail Target
473         </li>
474         
475 </ul>
476
477
478
479
480
481
482
483
484 </dd>
485
486
487
488
489 <dt><a name="assign"></a><strong>assign</strong>&nbsp;(path, clone, title, order)</dt>
490 <dd>
491
492  
493 Clone a node of the dispatching tree to another position. 
494
495
496
497 <h3>Parameters</h3>
498 <ul>
499         
500         <li>
501           path: Virtual path destination
502         </li>
503         
504         <li>
505           clone: Virtual path source
506         </li>
507         
508         <li>
509           title: Destination node title (optional)
510         </li>
511         
512         <li>
513           order: Destination node order value (optional)
514         </li>
515         
516 </ul>
517
518
519
520
521
522
523 <h3>Return value:</h3>
524 Dispatching tree node
525
526
527
528 </dd>
529
530
531
532
533 <dt><a name="build_url"></a><strong>build_url</strong>&nbsp;(...)</dt>
534 <dd>
535
536  
537 Build the URL relative to the server webroot from given virtual path. 
538
539
540
541 <h3>Parameters</h3>
542 <ul>
543         
544         <li>
545           ...: Virtual path
546         </li>
547         
548 </ul>
549
550
551
552
553
554
555 <h3>Return value:</h3>
556 Relative URL
557
558
559
560 </dd>
561
562
563
564
565 <dt><a name="call"></a><strong>call</strong>&nbsp;(name, ...)</dt>
566 <dd>
567
568  
569 Create a function-call dispatching target. 
570
571
572
573 <h3>Parameters</h3>
574 <ul>
575         
576         <li>
577           name: Target function of local controller
578         </li>
579         
580         <li>
581           ...: Additional parameters passed to the function
582         </li>
583         
584 </ul>
585
586
587
588
589
590
591
592
593 </dd>
594
595
596
597
598 <dt><a name="cbi"></a><strong>cbi</strong>&nbsp;(model)</dt>
599 <dd>
600
601  
602 Create a CBI model dispatching target. 
603
604
605
606 <h3>Parameters</h3>
607 <ul>
608         
609         <li>
610           model: CBI model to be rendered
611         </li>
612         
613 </ul>
614
615
616
617
618
619
620
621
622 </dd>
623
624
625
626
627 <dt><a name="createindex"></a><strong>createindex</strong>&nbsp;()</dt>
628 <dd>
629
630  
631 Generate the dispatching index using the native file-cache based strategy. 
632  
633
634
635
636
637
638
639
640
641
642
643 </dd>
644
645
646
647
648 <dt><a name="createtree"></a><strong>createtree</strong>&nbsp;()</dt>
649 <dd>
650
651  
652 Create the dispatching tree from the index. 
653  
654 Build the index before if it does not exist yet. 
655
656
657
658
659
660
661
662
663
664
665 </dd>
666
667
668
669
670 <dt><a name="dispatch"></a><strong>dispatch</strong>&nbsp;(request)</dt>
671 <dd>
672
673  
674 Dispatches a LuCI virtual path. 
675
676
677
678 <h3>Parameters</h3>
679 <ul>
680         
681         <li>
682           request: Virtual path
683         </li>
684         
685 </ul>
686
687
688
689
690
691
692
693
694 </dd>
695
696
697
698
699 <dt><a name="entry"></a><strong>entry</strong>&nbsp;(path, target, title, order)</dt>
700 <dd>
701
702  
703 Create a new dispatching node and define common parameters. 
704
705
706
707 <h3>Parameters</h3>
708 <ul>
709         
710         <li>
711           path: Virtual path
712         </li>
713         
714         <li>
715           target: Target function to call when dispatched.
716         </li>
717         
718         <li>
719           title: Destination node title
720         </li>
721         
722         <li>
723           order: Destination node order value (optional)
724         </li>
725         
726 </ul>
727
728
729
730
731
732
733 <h3>Return value:</h3>
734 Dispatching tree node
735
736
737
738 </dd>
739
740
741
742
743 <dt><a name="error404"></a><strong>error404</strong>&nbsp;(message)</dt>
744 <dd>
745
746  
747 Send a 404 error code and render the "error404" template if available. 
748
749
750
751 <h3>Parameters</h3>
752 <ul>
753         
754         <li>
755           message: Custom error message (optional)
756         </li>
757         
758 </ul>
759
760
761
762
763
764
765 <h3>Return value:</h3>
766 false
767
768
769
770 </dd>
771
772
773
774
775 <dt><a name="error500"></a><strong>error500</strong>&nbsp;(message)</dt>
776 <dd>
777
778  
779 Send a 500 error code and render the "error500" template if available. 
780
781
782
783 <h3>Parameters</h3>
784 <ul>
785         
786         <li>
787           message: Custom error message (optional)#
788         </li>
789         
790 </ul>
791
792
793
794
795
796
797 <h3>Return value:</h3>
798 false
799
800
801
802 </dd>
803
804
805
806
807 <dt><a name="firstchild"></a><strong>firstchild</strong>&nbsp;()</dt>
808 <dd>
809
810  
811 Alias the first (lowest order) page automatically 
812  
813
814
815
816
817
818
819
820
821
822
823 </dd>
824
825
826
827
828 <dt><a name="form"></a><strong>form</strong>&nbsp;(model)</dt>
829 <dd>
830
831  
832 Create a CBI form model dispatching target. 
833
834
835
836 <h3>Parameters</h3>
837 <ul>
838         
839         <li>
840           model: CBI form model tpo be rendered
841         </li>
842         
843 </ul>
844
845
846
847
848
849
850
851
852 </dd>
853
854
855
856
857 <dt><a name="get"></a><strong>get</strong>&nbsp;(...)</dt>
858 <dd>
859
860  
861 Fetch or create a dispatching node without setting the target module or 
862 enabling the node. 
863
864
865
866 <h3>Parameters</h3>
867 <ul>
868         
869         <li>
870           ...: Virtual path
871         </li>
872         
873 </ul>
874
875
876
877
878
879
880 <h3>Return value:</h3>
881 Dispatching tree node
882
883
884
885 </dd>
886
887
888
889
890 <dt><a name="httpdispatch"></a><strong>httpdispatch</strong>&nbsp;(request)</dt>
891 <dd>
892
893  
894 Dispatch an HTTP request. 
895
896
897
898 <h3>Parameters</h3>
899 <ul>
900         
901         <li>
902           request: LuCI HTTP Request object
903         </li>
904         
905 </ul>
906
907
908
909
910
911
912
913
914 </dd>
915
916
917
918
919 <dt><a name="lookup"></a><strong>lookup</strong>&nbsp;(...)</dt>
920 <dd>
921
922  
923 Lookup node in dispatching tree. 
924
925
926
927 <h3>Parameters</h3>
928 <ul>
929         
930         <li>
931           ...: Virtual path
932         </li>
933         
934 </ul>
935
936
937
938
939
940
941 <h3>Return value:</h3>
942 Node object, canonical url or nil if the path was not found.
943
944
945
946 </dd>
947
948
949
950
951 <dt><a name="modifier"></a><strong>modifier</strong>&nbsp;(func, order)</dt>
952 <dd>
953
954  
955 Register a tree modifier. 
956
957
958
959 <h3>Parameters</h3>
960 <ul>
961         
962         <li>
963           func: Modifier function
964         </li>
965         
966         <li>
967           order: Modifier order value (optional)
968         </li>
969         
970 </ul>
971
972
973
974
975
976
977
978
979 </dd>
980
981
982
983
984 <dt><a name="node"></a><strong>node</strong>&nbsp;(...)</dt>
985 <dd>
986
987  
988 Fetch or create a new dispatching node. 
989
990
991
992 <h3>Parameters</h3>
993 <ul>
994         
995         <li>
996           ...: Virtual path
997         </li>
998         
999 </ul>
1000
1001
1002
1003
1004
1005
1006 <h3>Return value:</h3>
1007 Dispatching tree node
1008
1009
1010
1011 </dd>
1012
1013
1014
1015
1016 <dt><a name="node_childs"></a><strong>node_childs</strong>&nbsp;(node)</dt>
1017 <dd>
1018
1019  
1020 Return a sorted table of visible childs within a given node 
1021
1022
1023
1024 <h3>Parameters</h3>
1025 <ul>
1026         
1027         <li>
1028           node: Dispatch node
1029         </li>
1030         
1031 </ul>
1032
1033
1034
1035
1036
1037
1038 <h3>Return value:</h3>
1039 Ordered table of child node names
1040
1041
1042
1043 </dd>
1044
1045
1046
1047
1048 <dt><a name="node_visible"></a><strong>node_visible</strong>&nbsp;(node)</dt>
1049 <dd>
1050
1051  
1052 Check whether a dispatch node shall be visible 
1053
1054
1055
1056 <h3>Parameters</h3>
1057 <ul>
1058         
1059         <li>
1060           node: Dispatch node
1061         </li>
1062         
1063 </ul>
1064
1065
1066
1067
1068
1069
1070 <h3>Return value:</h3>
1071 Boolean indicating whether the node should be visible
1072
1073
1074
1075 </dd>
1076
1077
1078
1079
1080 <dt><a name="rewrite"></a><strong>rewrite</strong>&nbsp;(n, ...)</dt>
1081 <dd>
1082
1083  
1084 Rewrite the first x path values of the request. 
1085
1086
1087
1088 <h3>Parameters</h3>
1089 <ul>
1090         
1091         <li>
1092           n: Number of path values to replace
1093         </li>
1094         
1095         <li>
1096           ...: Virtual path to replace removed path values with
1097         </li>
1098         
1099 </ul>
1100
1101
1102
1103
1104
1105
1106
1107
1108 </dd>
1109
1110
1111
1112
1113 <dt><a name="template"></a><strong>template</strong>&nbsp;(name)</dt>
1114 <dd>
1115
1116  
1117 Create a template render dispatching target. 
1118
1119
1120
1121 <h3>Parameters</h3>
1122 <ul>
1123         
1124         <li>
1125           name: Template to be rendered
1126         </li>
1127         
1128 </ul>
1129
1130
1131
1132
1133
1134
1135
1136
1137 </dd>
1138
1139
1140
1141
1142 <dt><a name="translate"></a><strong>translate</strong>&nbsp;(text)</dt>
1143 <dd>
1144
1145  
1146 Access the luci.i18n translate() api. 
1147
1148
1149
1150 <h3>Parameters</h3>
1151 <ul>
1152         
1153         <li>
1154           text: Text to translate
1155         </li>
1156         
1157 </ul>
1158
1159
1160
1161
1162
1163
1164
1165
1166 </dd>
1167
1168
1169 </dl>
1170
1171
1172
1173
1174
1175 </div> <!-- id="content" -->
1176
1177 </div> <!-- id="main" -->
1178
1179 <div id="about">
1180         <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
1181 </div> <!-- id="about" -->
1182
1183 </div> <!-- id="container" -->
1184 </body>
1185 </html>