1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.MonoRail
.Framework
.Controllers
19 using Castle
.MonoRail
.Framework
.Attributes
;
20 using Castle
.MonoRail
.Framework
.Filters
;
21 using Castle
.MonoRail
.Framework
.Helpers
;
24 /// Buit in <see cref="Controller"/> containing the files requireds by helpers and other
25 /// parts of MonoRail.
27 [ControllerDetails(Area
="MonoRail")]
28 [LocalizationFilter(Store
= RequestStore
.QueryString
, Key
= "locale")]
29 [Resource("Behaviour", "Castle.MonoRail.Framework.Controllers.Behaviour", CultureName
="neutral")]
30 [Resource("Ajax", "Castle.MonoRail.Framework.Controllers.Ajax", CultureName
="neutral")]
31 [Resource("Effects2", "Castle.MonoRail.Framework.Controllers.Effects2", CultureName
="neutral")]
32 [Resource("EffectsFat", "Castle.MonoRail.Framework.Controllers.EffectsFat", CultureName
="neutral")]
33 [Resource("Validation", "Castle.MonoRail.Framework.Controllers.Validation", CultureName
="neutral")]
34 [Resource("FormHelper", "Castle.MonoRail.Framework.Controllers.FormHelper", CultureName
="neutral")]
35 [Resource("ZebdaValidation", "Castle.MonoRail.Framework.Controllers.ZebdaValidation", CultureName
="neutral")]
37 public sealed class FilesController
: Controller
40 /// Script used by <see cref="AjaxHelper"/>.
42 [Cache(HttpCacheability
.Public
, Duration
=86400)] // 1 day
43 public void AjaxScripts()
45 RenderJavascriptFile("Ajax", "jsfunctions");
49 /// Script used by <see cref="AjaxHelper"/>.
51 [Cache(HttpCacheability
.Public
, Duration
= 86400)] // 1 day
52 public void BehaviourScripts()
54 RenderJavascriptFile("Behaviour", "jsfunctions");
58 /// Script used by <see cref="EffectsFatHelper"/>.
60 [Cache(HttpCacheability
.Public
, Duration
= 86400)] // 1 day
61 public void EffectsFatScripts()
63 RenderJavascriptFile("EffectsFat", "fatfunctions");
67 /// Script used by <see cref="Effects2Helper"/>.
69 [Cache(HttpCacheability
.Public
, Duration
= 86400)] // 1 day
70 public void Effects2()
72 RenderJavascriptFile("Effects2", "functions");
76 /// Script used by <see cref="ValidationHelper"/>.
78 [Cache(HttpCacheability
.Public
, Duration
= 86400)] // 1 day
79 public void ValidateConfig()
81 RenderJavascriptFile("Validation", "fValidateConfig");
85 /// Script used by <see cref="ValidationHelper"/>.
87 [Cache(HttpCacheability
.Public
, Duration
= 86400)] // 1 day
88 public void ValidateCore()
90 RenderJavascriptFile("Validation", "fValidateCore");
94 /// Script used by <see cref="ValidationHelper"/>.
96 [Cache(HttpCacheability
.Public
, Duration
= 86400)] // 1 day
97 public void ValidateValidators()
99 RenderJavascriptFile("Validation", "fValidateValidators");
103 /// Script used by <see cref="ValidationHelper"/>.
105 [Resource("ValidationLang", "Castle.MonoRail.Framework.Controllers.ValidationLang")]
106 [Cache(HttpCacheability
.Public
, Duration
= 86400)] // 1 day
107 public void ValidateLang()
109 RenderJavascriptFile("ValidationLang", "fValidateLang");
113 /// Install the zebda validation script
115 [Cache(HttpCacheability
.Public
, Duration
= 86400)] // 1 day
116 public void ZebdaScripts()
118 RenderJavascriptFile( "ZebdaValidation", "jsfunctions" );
122 /// Script used by <see cref="AjaxHelper"/>.
124 [Cache(HttpCacheability
.Public
, Duration
= 86400)] // 1 day
125 public void FormHelperScript()
127 RenderJavascriptFile("FormHelper", "jsfunctions");
130 private void RenderJavascriptFile(String resourceName
, String resourceKey
)
132 Response
.ContentType
= "text/javascript";
133 string fileContent
= GetResourceValue(resourceName
, resourceKey
);
134 RenderText(fileContent
);
137 private String
GetResourceValue(String resName
, String resKey
)
139 return (String
) (Resources
[resName
])[resKey
];