PageRenderTime 22ms CodeModel.GetById 14ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/modules/mod_base/dispatch/dispatch

https://code.google.com/p/zotonic/
#! | 93 lines | 74 code | 19 blank | 0 comment | 0 complexity | c9eabe73eb8aeedc32dc1af15f1533cf MD5 | raw file
 1%% Base dispatch rules for zotonic
 2[
 3    %% The home page, just shows the "home.tpl" template.
 4    {home,     [],            resource_template, [ {template, "home.tpl"} ]},
 5
 6    %% Comet connection, used with long polls from the browser.
 7    {comet,    ["comet"],     resource_comet, [{ssl, any}]},
 8
 9    %% Comet sub-domain connection, used with long polls from the browser.
10    {comet,    ["comet", "subdomain"], resource_template, [{template, "comet_subdomain.tpl"}]},
11    
12    %% WebSocket connection.
13    {websocket,    ["websocket"],     resource_websocket, [{ssl, any}]},
14    
15    %% Postback of events from the browser to the server, dispatched from the postback resource.
16    {postback, ["postback"],  resource_postback, [{ssl, any}]},
17    
18    %% Used in Ajax file upload, fixes a problem in Safari.  Just closes the connection.
19    {close_connection, ["close-connection"],  resource_close_connection, [{ssl, any}]},
20
21    %% Normal page to show a resource.
22    {page,    ["page", id],       resource_page, [ {template, {cat, "page.tpl"}} ]},
23    {page,    ["page", id, slug], resource_page, [ {template, {cat, "page.tpl"}} ]},
24
25    %% The id controller redirects depending on the accept header sent by the user agent.
26    {id,       ["id", id],    resource_id, []},
27
28    % CSS and Javascript files from the "lib" module folder. Possibly more than one file combined in one request.
29    {lib,      ["lib",'*'],   resource_lib, [ {use_cache, false}, {ssl, any} ]},
30
31    % Redirect controller for resource of type 'website'
32    {website,  ["redirect", id, slug],   resource_website_redirect, []},
33
34    %% Resized images, expects resize parameters and a checksum. Places resized images in the root folder.
35    %% The original images must be present in the media_path.
36    {image,    ["image",'*'], resource_file_readonly, [ 
37                                            {use_cache, false},
38                                            {is_media_preview, true},
39                                            {ssl, any}
40                                        ]},
41
42    %% Download of an image, attached to a media rsc
43    {media_attachment, ["media","attachment","id",id], resource_file_readonly, [ 
44                                            {path, id},
45                                            {use_cache, false},
46                                            {content_disposition, attachment}
47                                        ]},
48
49    %% Download of an image, attached to a media rsc
50    {media_inline, ["media","inline","id",id], resource_file_readonly, [ 
51                                            {path, id},
52                                            {use_cache, false},
53                                            {content_disposition, inline}
54                                        ]},
55
56    %% Inline display of original uploaded files. Assumes the files are in the root folder.
57    {media_inline, ["media","inline",'*'], resource_file_readonly, [
58                                            {use_cache, false},
59                                            {content_disposition, inline}
60                                        ]},
61
62    %% Download of original uploaded files. Assumes the files are in the root folder.
63    {media_attachment, ["media","attachment",'*'], resource_file_readonly, [
64                                            {use_cache, false},
65                                            {content_disposition, attachment}
66                                        ]},
67
68    %% API access
69    {api,    ["api",module,method], resource_api, []},
70    {api,    ["api",module], 		resource_api, [{method_is_module, true}]},
71    
72    %% Serves the favicon.ico from "lib/images/favicon.ico" in the modules.
73    {favicon, ["favicon.ico"], resource_file_readonly, [ 
74                                            {path, "images/favicon.ico"},
75                                            {root,[lib]}, 
76                                            {use_cache, false},
77                                            {content_disposition, inline},
78                                            {ssl, any}
79                                        ]},
80    
81    %% robots.txt - simple allow all file
82    {robots_txt, ["robots.txt"], resource_file_readonly, [
83                                            {path, "misc/robots.txt"},
84                                            {root,[lib]}, 
85                                            {use_cache, false},
86                                            {content_disposition, inline}
87                                        ]}
88    
89    %% "Last resort" we check the request path against the page_path of resources and redirect to
90    %% the page configured for the page path.
91    %% {page_path, ['*'], resource_page_path, []}
92
93].