Fix the build.
[castle.git] / MonoRail / Castle.MonoRail.Framework / Controllers / FilesController.cs
blob1657ab90a87366e2b2349a87a1d7c1b3eeb4582b
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
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
17 using System;
18 using System.Web;
19 using Castle.MonoRail.Framework.Attributes;
20 using Castle.MonoRail.Framework.Filters;
21 using Castle.MonoRail.Framework.Helpers;
23 /// <summary>
24 /// Buit in <see cref="Controller"/> containing the files requireds by helpers and other
25 /// parts of MonoRail.
26 /// </summary>
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")]
36 [PersistFlash]
37 public sealed class FilesController : Controller
39 /// <summary>
40 /// Script used by <see cref="AjaxHelper"/>.
41 /// </summary>
42 [Cache(HttpCacheability.Public, Duration=86400)] // 1 day
43 public void AjaxScripts()
45 RenderJavascriptFile("Ajax", "jsfunctions");
48 /// <summary>
49 /// Script used by <see cref="AjaxHelper"/>.
50 /// </summary>
51 [Cache(HttpCacheability.Public, Duration = 86400)] // 1 day
52 public void BehaviourScripts()
54 RenderJavascriptFile("Behaviour", "jsfunctions");
57 /// <summary>
58 /// Script used by <see cref="EffectsFatHelper"/>.
59 /// </summary>
60 [Cache(HttpCacheability.Public, Duration = 86400)] // 1 day
61 public void EffectsFatScripts()
63 RenderJavascriptFile("EffectsFat", "fatfunctions");
66 /// <summary>
67 /// Script used by <see cref="Effects2Helper"/>.
68 /// </summary>
69 [Cache(HttpCacheability.Public, Duration = 86400)] // 1 day
70 public void Effects2()
72 RenderJavascriptFile("Effects2", "functions");
75 /// <summary>
76 /// Script used by <see cref="ValidationHelper"/>.
77 /// </summary>
78 [Cache(HttpCacheability.Public, Duration = 86400)] // 1 day
79 public void ValidateConfig()
81 RenderJavascriptFile("Validation", "fValidateConfig");
84 /// <summary>
85 /// Script used by <see cref="ValidationHelper"/>.
86 /// </summary>
87 [Cache(HttpCacheability.Public, Duration = 86400)] // 1 day
88 public void ValidateCore()
90 RenderJavascriptFile("Validation", "fValidateCore");
93 /// <summary>
94 /// Script used by <see cref="ValidationHelper"/>.
95 /// </summary>
96 [Cache(HttpCacheability.Public, Duration = 86400)] // 1 day
97 public void ValidateValidators()
99 RenderJavascriptFile("Validation", "fValidateValidators");
102 /// <summary>
103 /// Script used by <see cref="ValidationHelper"/>.
104 /// </summary>
105 [Resource("ValidationLang", "Castle.MonoRail.Framework.Controllers.ValidationLang")]
106 [Cache(HttpCacheability.Public, Duration = 86400)] // 1 day
107 public void ValidateLang()
109 RenderJavascriptFile("ValidationLang", "fValidateLang");
112 /// <summary>
113 /// Install the zebda validation script
114 /// </summary>
115 [Cache(HttpCacheability.Public, Duration = 86400)] // 1 day
116 public void ZebdaScripts()
118 RenderJavascriptFile( "ZebdaValidation", "jsfunctions" );
121 /// <summary>
122 /// Script used by <see cref="AjaxHelper"/>.
123 /// </summary>
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];