Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added PortableAreaController, and added example to test site.

  • Loading branch information...
commit b1906d9e2a7cf137292b27335ee27a1cb37177cf 1 parent 95bab15
jamescurran authored
View
6 viewcomponents/trunk/Castle.MonoRail.ViewComponents-vs2008.sln
@@ -5,6 +5,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Castle.MonoRail.ViewCompone
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Castle.MonoRail.ViewComponents.TestSite-vs2008", "Castle.MonoRail.ViewComponents.TestSite\Castle.MonoRail.ViewComponents.TestSite-vs2008.csproj", "{6C229F56-62A2-47EE-973C-1F892960CA87}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Castle.MonoRail.PortableAreaExample-vs2008", "Castle.MonoRail.PortableAreaExample-vs2008\Castle.MonoRail.PortableAreaExample-vs2008.csproj", "{32137E1C-0252-4009-82E6-1A482612E44A}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -19,6 +21,10 @@ Global
{6C229F56-62A2-47EE-973C-1F892960CA87}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C229F56-62A2-47EE-973C-1F892960CA87}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6C229F56-62A2-47EE-973C-1F892960CA87}.Release|Any CPU.Build.0 = Release|Any CPU
+ {32137E1C-0252-4009-82E6-1A482612E44A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {32137E1C-0252-4009-82E6-1A482612E44A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {32137E1C-0252-4009-82E6-1A482612E44A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {32137E1C-0252-4009-82E6-1A482612E44A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
View
21 ...ents/trunk/Castle.MonoRail.ViewComponents.TestSite/Castle.MonoRail.ViewComponents.TestSite-vs2008.csproj
@@ -15,6 +15,7 @@
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -52,14 +53,29 @@
<HintPath>..\SharedLibs\NVelocity.dll</HintPath>
</Reference>
<Reference Include="System" />
+ <Reference Include="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
<Reference Include="System.Data" />
+ <Reference Include="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
+ <Reference Include="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Web.Mobile" />
+ <Reference Include="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
</ItemGroup>
<ItemGroup>
<Content Include="Default.aspx" />
@@ -98,6 +114,10 @@
<Compile Include="ViewComponents\MyCollapsiblePanelComponent.cs" />
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="..\Castle.MonoRail.PortableAreaExample-vs2008\Castle.MonoRail.PortableAreaExample-vs2008.csproj">
+ <Project>{32137E1C-0252-4009-82E6-1A482612E44A}</Project>
+ <Name>Castle.MonoRail.PortableAreaExample-vs2008</Name>
+ </ProjectReference>
<ProjectReference Include="..\Castle.MonoRail.ViewComponents\Castle.MonoRail.ViewComponents-vs2008.csproj">
<Project>{717C688D-81BC-4C81-9487-1D5151ADF573}</Project>
<Name>Castle.MonoRail.ViewComponents</Name>
@@ -130,6 +150,7 @@
<None Include="Views\Menu\default.vm" />
<Content Include="Views\Menu\minimenu.sitemap" />
<None Include="Views\MoreLessText\index.vm" />
+ <EmbeddedResource Include="Views\patest\page2.vm" />
<None Include="Views\SmartGrid\datatable.brail" />
<None Include="Views\SmartGrid\More.brail" />
<None Include="Views\SmartGrid\nullText.brail" />
View
15 viewcomponents/trunk/Castle.MonoRail.ViewComponents.TestSite/Views/layouts/default.brail
@@ -301,6 +301,21 @@ section body: %>
</ul>
<% end
end %>
+
+ <% component CollapsiblePanel, {@id:"PortableArea", @expandImagePath:"/Images/expand.jpg", @collapseImagePath:"/Images/collapse.jpg", @collapsed:true}:
+section caption: %>
+ <h3>Portable Area Example</h3>
+<% end
+section body: %>
+ <ul>
+ <li>
+ <a href="/PATest/Page1.rails">Example</a>
+ </li>
+
+ </ul>
+<% end
+ end %>
+
</div>
View
13 viewcomponents/trunk/Castle.MonoRail.ViewComponents.TestSite/Views/layouts/default.vm
@@ -310,6 +310,19 @@ $css
#end
#end
+#blockcomponent(CollapsiblePanel with "id=PortableArea" "expandImagePath=/Images/expand.jpg" "collapseImagePath=/Images/collapse.jpg" "collapsed=true")
+#caption
+ <h3>Portable Area Example</h3>
+#end
+#body
+ <ul>
+ <li>
+ <a href="/PATest/Page1.rails">Example</a>
+ </li>
+ </ul>
+
+#end
+#end
</div>
View
6 viewcomponents/trunk/Castle.MonoRail.ViewComponents.TestSite/Views/patest/page2.vm
@@ -0,0 +1,6 @@
+<h2>This is Page Two</h2>
+
+<p>This is the Override from the Website</p>
+<p> Remove (or rename) the file <code>Views/patest/page2.vm</code> to see the default page</p>
+
+
View
59 viewcomponents/trunk/Castle.MonoRail.ViewComponents.TestSite/Web.config
@@ -5,12 +5,20 @@
<section name="brail" type="Castle.MonoRail.Views.Brail.BrailConfigurationSection, Castle.MonoRail.Views.Brail"/>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
</sectionGroup>
- </configSections>
+ <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
+ <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
+ <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
+ <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
+ <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
+ <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
+ <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
+ <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/></sectionGroup></sectionGroup></sectionGroup></configSections>
<monorail>
<controllers>
<assembly>Castle.MonoRail.ViewComponents.TestSite</assembly>
<assembly>Castle.MonoRail.ViewComponents</assembly>
- </controllers>
+ <assembly>Castle.MonoRail.PortableAreaExample</assembly>
+ </controllers>
<viewEngines viewPathRoot="Views">
<add xhtml="false" type="Castle.MonoRail.Views.Brail.BooViewEngine, Castle.MonoRail.Views.Brail"/>
<add xhtml="false" type="Castle.MonoRail.Framework.Views.NVelocity.NVelocityViewEngine, Castle.MonoRail.Framework.Views.NVelocity"/>
@@ -29,10 +37,47 @@
<httpHandlers>
<add verb="*" path="*.rails" type="Castle.MonoRail.Framework.MonoRailHttpHandlerFactory, Castle.MonoRail.Framework"/>
<add verb="GET" path="captchaimage.ashx" type="Castle.MonoRail.ViewComponents.CaptchaImageHandler, Castle.MonoRail.ViewComponents"/>
- </httpHandlers>
+ <remove verb="*" path="*.asmx"/>
+ <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+ <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+ <add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></httpHandlers>
<httpModules>
<add name="routing" type="Castle.MonoRail.Framework.RoutingModule, Castle.MonoRail.Framework"/>
-<!-- <add name="monorail" type="Castle.MonoRail.Framework.EngineContextModule, Castle.MonoRail.Framework"/> -->
- </httpModules>
- <compilation debug="true"/></system.web>
-</configuration>
+ <!-- <add name="monorail" type="Castle.MonoRail.Framework.EngineContextModule, Castle.MonoRail.Framework"/> -->
+ <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></httpModules>
+ <compilation debug="true">
+ <assemblies>
+ <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
+ <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+ <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
+ <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation>
+ <pages>
+ <controls>
+ <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+ <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></controls></pages></system.web>
+ <system.codedom>
+ <compilers>
+ <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
+ <providerOption name="CompilerVersion" value="v3.5"/>
+ <providerOption name="WarnAsError" value="false"/></compiler></compilers></system.codedom>
+ <system.webServer>
+ <validation validateIntegratedModeConfiguration="false"/>
+ <modules>
+ <remove name="ScriptModule"/>
+ <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></modules>
+ <handlers>
+ <remove name="WebServiceHandlerFactory-Integrated"/>
+ <remove name="ScriptHandlerFactory"/>
+ <remove name="ScriptHandlerFactoryAppServices"/>
+ <remove name="ScriptResource"/>
+ <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+ <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+ <add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></handlers></system.webServer>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
+ <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
+ <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly></assemblyBinding></runtime></configuration>
View
4 viewcomponents/trunk/Castle.MonoRail.ViewComponents/Castle.MonoRail.ViewComponents-vs2008.csproj
@@ -92,6 +92,7 @@
<Compile Include="GridComponent .cs" />
<Compile Include="JavascriptComponent.cs" />
<Compile Include="LinkSubmitButtonComponent.cs" />
+ <Compile Include="MarkdownViewComponent.cs" />
<Compile Include="MaskedTextboxComponent.cs" />
<Compile Include="Menu.Designer.cs">
<AutoGen>True</AutoGen>
@@ -101,6 +102,9 @@
<Compile Include="MenuComponent.cs" />
<Compile Include="Filters\MobileFilter.cs" />
<Compile Include="MoreLessTextComponent.cs" />
+ <Compile Include="PortableAreaController.cs">
+ <SubType>Code</SubType>
+ </Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SearchFormComponent.cs" />
<Compile Include="SmartGridComponent.cs" />
View
2  viewcomponents/trunk/Castle.MonoRail.ViewComponents/Extensions/WebTraceExtension.cs
@@ -24,7 +24,7 @@ namespace Castle.MonoRail.Framework.Extensions
using Castle.MonoRail.Framework.Configuration;
using System.Collections;
-using System.CodeDom.Compiler;
+//using System.CodeDom.Compiler;
/// <summary>
/// This extension appends the ASP.NET Tracing diagnostic information and custom
View
43 viewcomponents/trunk/Castle.MonoRail.ViewComponents/MarkdownViewComponent.cs
@@ -0,0 +1,43 @@
+
+namespace Castle.MonoRail.ViewComponents
+{
+ using System;
+ using Castle.MonoRail.Framework;
+ using anrControls;
+
+ /// <summary>
+ ///
+ /// </summary>
+ [ViewComponentDetails("Markdown")]
+ public class MarkdownViewComponent : ViewComponentEx
+ {
+ [Flags]
+ public enum MarkDownStyle { Markdown = 0x01, SmartyPants=0x02, All = -1 }
+
+ [ViewComponentParam(Default=MarkDownStyle.All)]
+ public MarkDownStyle Style { get; set; }
+
+ public override void Render()
+ {
+ base.Render();
+ string text = GetBodyText();
+
+ if ( (Style & MarkDownStyle.Markdown) == MarkDownStyle.Markdown)
+ {
+ Markdown md = new Markdown ();
+ text = md.Transform(text);
+ }
+ if ( (Style & MarkDownStyle.SmartyPants) == MarkDownStyle.SmartyPants)
+ {
+ SmartyPants sm = new SmartyPants();
+ text = sm.Transform(text, ConversionMode.EducateDefault);
+ }
+
+ RenderText(text);
+ CancelView();
+
+ }
+
+
+ }
+}
View
84 viewcomponents/trunk/Castle.MonoRail.ViewComponents/PortableAreaController.cs
@@ -0,0 +1,84 @@
+using System;
+using System.IO;
+using System.Linq;
+using Castle.MonoRail.Framework;
+
+
+namespace Castle.MonoRail.ViewComponents
+{
+ /// <summary>
+ /// Base class for implementing a Portable Class
+ ///
+ /// </summary>
+ /// <remarks>
+ /// <list type="bullet">
+ /// <item><description> Add view templates in subfolder named same as controller, and mark as "EmbeddedREsource".</description></item>
+ /// <item><description> Add layout templates in "layouts" subfolder, and mark as "EmbeddedResource".</description></item>
+ /// <item><description> Add individual file in project root, and mark as "EmbeddedResource".</description></item>
+ /// </list>
+ /// </remarks>
+ public class PortableAreaController : SmartDispatcherController
+ {
+ private string[] resourceNames;
+ private string asmName;
+
+ [DefaultAction]
+ public void _DefaultAction()
+ {
+ string filename = asmName + "." + Action;
+ var resourceName = resourceNames.FirstOrDefault(rn=> rn.Equals(filename,StringComparison.InvariantCultureIgnoreCase));
+ if (resourceName != null)
+ {
+ string ext = Path.GetExtension(filename);
+ this.Response.ContentType = GetContentTypeFromExt(ext);
+
+ Stream contents = this.GetType().Assembly.GetManifestResourceStream(resourceName);
+ this.Response.BinaryWrite(contents);
+ CancelView();
+ }
+ else
+ DefaultAction();
+ }
+
+ /// <summary>
+ /// When overridden in derived class, called for each undeclared action.
+ /// </summary>
+ protected virtual void DefaultAction()
+ {
+ // do nothng here.
+ }
+
+
+ private string GetContentTypeFromExt(string ext)
+ {
+ string contentType = null;
+#if !MONO
+ var reg = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext);
+ if (reg != null)
+ contentType = reg.GetValue("Content Type") as string;
+#endif
+ if (contentType == null)
+ {
+ // put some slow, platform-independent, method here....
+
+ contentType = "text/plain";
+ }
+ return contentType;
+ }
+
+ /// <summary>
+ /// Initializes this instance. Implementors
+ /// can use this method to perform initialization
+ /// </summary>
+ public override void Initialize()
+ {
+ base.Initialize();
+ var asm = this.GetType().Assembly;
+ resourceNames = asm.GetManifestResourceNames();
+ asmName = asm.GetName().Name;
+ var asminfo = new AssemblySourceInfo(asm, asmName.ToLower());
+ if (!this.Context.Services.ViewSourceLoader.AssemblySources.Cast<AssemblySourceInfo>().Any(asi=>asi.AssemblyName==asminfo.AssemblyName))
+ this.Context.Services.ViewSourceLoader.AddAssemblySource(asminfo);
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.