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