Last active
August 29, 2015 19:08
-
-
Save spiffytech/e41eeaaf37ea7ab2199c to your computer and use it in GitHub Desktop.
Patches an F# Scaffold project with basic WebSharper support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Web.config b/Web.config | |
new file mode 100644 | |
index 0000000..053354f | |
--- /dev/null | |
+++ b/Web.config | |
@@ -0,0 +1,358 @@ | |
+<configuration> | |
+ <configSections> | |
+ <sectionGroup name="elmah"> | |
+ <!-- NOTE! If you are using ASP.NET 1.x then remove the | |
+ requirePermission="false" attribute from the section | |
+ elements below as those are only needed for | |
+ partially trusted applications in ASP.NET 2.0 --> | |
+ <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" /> | |
+ <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" /> | |
+ <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" /> | |
+ <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" /> | |
+ <section name="errorTweet" requirePermission="false" type="Elmah.ErrorTweetSectionHandler, Elmah" /> | |
+ </sectionGroup> | |
+ </configSections> | |
+ | |
+ <runtime> | |
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | |
+ <probing privatePath="bin/awsgui" /> | |
+ </assemblyBinding> | |
+ </runtime> | |
+ | |
+ <elmah> | |
+ | |
+ <security allowRemoteAccess="0" /> | |
+ | |
+ <!-- | |
+ Use to log errors to Microsoft SQL Server 2000 or later | |
+ using ASP.NET 2.0. Set value of connectionStringName attribute | |
+ to the name of the connection string settings to use from | |
+ the <connectionStrings> section. | |
+ | |
+ <errorLog type="Elmah.SqlErrorLog, Elmah" | |
+ connectionStringName="..." /> | |
+ --> | |
+ | |
+ <!-- | |
+ Use to log errors to Microsoft SQL Server 2000 or later | |
+ using ASP.NET 1.x and adjust the value of connectionString | |
+ attribute to your settings. | |
+ | |
+ <errorLog type="Elmah.SqlErrorLog, Elmah" | |
+ connectionString="Data Source=.;Initial Catalog=ELMAH;Trusted_Connection=True" /> | |
+ --> | |
+ | |
+ <!-- | |
+ Use to log errors to MySQL 5.0+. Set value of | |
+ connectionStringName attribute to the name of the connection | |
+ string settings to use from the <connectionStrings> section. | |
+ | |
+ <errorLog type="Elmah.MySqlErrorLog, Elmah" | |
+ connectionString="..." /> | |
+ --> | |
+ | |
+ <!-- | |
+ Use to log errors to a SQL Server Compact 4 database file | |
+ (requires .NET 3.5 SP1). Set value of connectionStringName | |
+ attribute to the name of the connection string settings to use | |
+ from the <connectionStrings> section. | |
+ | |
+ <errorLog type="Elmah.SqlServerCompactErrorLog, Elmah" connectionStringName="..." /> | |
+ | |
+ The format of the connection string should be as follows: | |
+ | |
+ <connectionStrings> | |
+ <add name="..." connectionString="data source=[path to the database file]" /> | |
+ </connectionStrings> | |
+ | |
+ Replace the content of the brackets with a file path, for | |
+ example: | |
+ | |
+ data source=C:\Elmah.sdf | |
+ | |
+ If the database file doesn't exist it is created automatically. | |
+ You can also place the file in the App_Data folder, by using | |
+ the |DataDirectory| macro: | |
+ | |
+ <connectionStrings> | |
+ <add name="..." connectionString="data source=|DataDirectory|\Elmah.sdf" /> | |
+ </connectionStrings> | |
+ | |
+ --> | |
+ | |
+ <!-- | |
+ Use to log errors to SQLite using ASP.NET 2.0. Set value of | |
+ connectionStringName attribute to the name of the connection | |
+ string settings to use from the <connectionStrings> section. | |
+ | |
+ <errorLog type="Elmah.SQLiteErrorLog, Elmah" connectionStringName="..." /> | |
+ | |
+ The format of the connection string should be as follows: | |
+ | |
+ <connectionStrings> | |
+ <add name="..." connectionString="data source=[path to the database file]" /> | |
+ </connectionStrings> | |
+ | |
+ Replace the content of the brackets with a file path, | |
+ for example: | |
+ | |
+ data source=C:\Elmah.db | |
+ | |
+ If the database file doesn't exist it is created automatically. | |
+ To specify a path relative to and below the application root, | |
+ start with the root operator (~) followed by a forward slash | |
+ (/), as it is common in ASP.NET applications. For example: | |
+ | |
+ data source=~/App_Data/Error.db | |
+ --> | |
+ | |
+ <!-- | |
+ Use to log errors into separate XML files that are stored on | |
+ disk at the path specified in the logPath attribute. | |
+ | |
+ <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="..." /> | |
+ --> | |
+ | |
+ <!-- | |
+ Use to log errors to Oracle using ASP.NET 2.0. Set value of | |
+ connectionStringName attribute to the name of the connection | |
+ string settings to use from the <connectionStrings> section. | |
+ | |
+ The schemaOwner parameter is *optional*. Use this if the owner | |
+ of the ELMAH package (pkg_elmah$error) is not the same user that | |
+ you are using to connect to the database. | |
+ | |
+ <errorLog type="Elmah.OracleErrorLog, Elmah" | |
+ schemaOwner="xxx" /> | |
+ connectionStringName="..." /> | |
+ --> | |
+ | |
+ <!-- | |
+ Use to log errors to Oracle using ASP.NET 1.1 and adjust the | |
+ value of connectionString attribute to your settings. | |
+ | |
+ The schemaOwner parameter is *optional*. Use this if the owner | |
+ of the ELMAH package (pkg_elmah$error) is not the same user that | |
+ you are using to connect to the database. | |
+ | |
+ <errorLog type="Elmah.OracleErrorLog, Elmah" | |
+ schemaOwner="xxx" /> | |
+ connectionString="Data Source=xxxx;User ID=username;Password=password" /> | |
+ --> | |
+ | |
+ <!-- | |
+ Use to log errors to Microsoft Access using ASP.NET 1.x and | |
+ adjust the value of connectionString attribute to your settings. | |
+ Use Elmah.mdb as your database. | |
+ | |
+ <errorLog type="Elmah.AccessErrorLog, Elmah" | |
+ connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|Elmah.mdb" /> | |
+ --> | |
+ | |
+ <!-- | |
+ Use to log errors to Microsoft Access using ASP.NET 2.0. Set | |
+ value of connectionStringName attribute to the name of the | |
+ connection string settings to use from the <connectionStrings> | |
+ section. Use Elmah.mdb as your database. | |
+ | |
+ <errorLog type="Elmah.AccessErrorLog, Elmah" | |
+ connectionStringName="..." /> | |
+ --> | |
+ | |
+ <!-- | |
+ Use to log errors to PostgresSQL using ASP.NET 2.0. Set value of | |
+ connectionString to a valid Npgsql connection string. | |
+ | |
+ <errorLog type="Elmah.PgsqlErrorLog, Elmah" | |
+ connectionString="Server=...;Port=...;Database=...;User Id=...;Password=...;" /> | |
+ --> | |
+ | |
+ <!-- | |
+ Use to send error reports by e-mail and adjust the attributes | |
+ according to settings desired. Note that only the from and | |
+ to attributes are required. The rest are optional and may | |
+ be removed. If the SMTP server does not require authentication, | |
+ you MUST remove the userName and password attributes or | |
+ set them to empty values (resulting in zero-length strings). | |
+ If you are using ELMAH compiled for .NET Framework 1.x, then | |
+ the to attribute may contain multiple recipient addresses, | |
+ each of which must be delimited by a semi-colon (;). If you are | |
+ using ELMAH compiled for .NET Framework 2.0 or later, then the | |
+ to attribute may contain multiple recipient addresses, | |
+ each of which must be delimited by a comma (,). | |
+ | |
+ <errorMail | |
+ from="[email protected]" | |
+ to="[email protected]" | |
+ subject="..." | |
+ priority="Low|Normal|High" | |
+ async="true|false" | |
+ smtpPort="25" | |
+ smtpServer="smtp.example.com" | |
+ useSsl="true|false" | |
+ userName="johndoe" | |
+ password="secret" | |
+ noYsod="true|false" /> | |
+ --> | |
+ | |
+ <!-- | |
+ Use to send short error messages to a Twitter account. | |
+ <errorTweet | |
+ userName="johndoe" | |
+ password="secret" /> | |
+ --> | |
+ | |
+ <!-- | |
+ Use to prevent errors from being mailed or logged based on | |
+ assertions. An assertion evaluates the current context, | |
+ resulting in a Boolean outcome. An error is filtered if the | |
+ assertion results in true. For a more detailed explanation, see: | |
+ | |
+ http://code.google.com/p/elmah/wiki/ErrorFiltering | |
+ | |
+ The example below will filter errors when any of the | |
+ following conditions occur: | |
+ | |
+ - The status code is set to 404 | |
+ - The root/base cause is System.IO.FileNotFoundException | |
+ - The root/base cause is System.Web.HttpRequestValidationException | |
+ - The user agent making the request identifies itself as "crawler" | |
+ - The request is from the local machine | |
+ | |
+ The assertion below is expressed as a JScript expression and is | |
+ the most generic and simplest of the assertions to use if you | |
+ are familiar with the JavaScript language. It can work in Medium | |
+ and Full trust environments. | |
+ | |
+ NOTE: For versions of ELMAH 1.2 SP1 and earlier, use the | |
+ undocumented `$context` instead of `$` in the expression below | |
+ to workaround a bug when the expression is evaluated under full | |
+ trust environments. See issue #278[1] for more details. | |
+ | |
+ [1] http://code.google.com/p/elmah/issues/detail?id=278 | |
+ | |
+ <errorFilter> | |
+ <test> | |
+ <jscript> | |
+ <expression> | |
+ <![CDATA[ | |
+ // @assembly mscorlib | |
+ // @assembly System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a | |
+ // @import System.IO | |
+ // @import System.Web | |
+ | |
+ $.HttpStatusCode == 404 | |
+ || $.BaseException instanceof FileNotFoundException | |
+ || $.BaseException instanceof HttpRequestValidationException | |
+ /* Using RegExp below (see http://msdn.microsoft.com/en-us/library/h6e2eb7w.aspx) */ | |
+ || $.Context.Request.UserAgent.match(/crawler/i) | |
+ || $.Context.Request.ServerVariables['REMOTE_ADDR'] == '127.0.0.1' // IPv4 only | |
+ ]]> | |
+ </expression> | |
+ </jscript> | |
+ </test> | |
+ </errorFilter> | |
+ --> | |
+ | |
+ </elmah> | |
+ <!-- NOTE: uncomment the following to run on F# 3.1 --> | |
+ <!--<runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | |
+ <dependentAssembly> | |
+ <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | |
+ <bindingRedirect oldVersion="0.0.0.0-4.3.1.0" newVersion="4.3.1.0" /> | |
+ </dependentAssembly> | |
+ </assemblyBinding></runtime>--> | |
+ <system.web> | |
+ <!-- NOTE: remove debug="true" to serve compressed JavaScript --> | |
+ <compilation debug="true" targetFramework="4.0" /> | |
+ <!-- This is only needed for VS Development WebServer. IIS/IIS Express do not use this:--> | |
+ <httpModules> | |
+ <add name="WebSharper.RemotingModule" type="WebSharper.Web.RpcModule, WebSharper.Web" /> | |
+ <add name="WebSharper.Sitelets" type="WebSharper.Sitelets.HttpModule, WebSharper.Sitelets" /> | |
+ | |
+ <!-- | |
+ Uncomment the entry below if all of the following are true: | |
+ 1) you are using wildcard mapping in IIS 5.x | |
+ 2) you are not using .NET 1.0 | |
+ 3) you are experiencing HTTP 404 errors when trying to view | |
+ elmah.axd or elmah.axd/detail?id=* etc | |
+ --> | |
+ <!--<add name="FixIIS5xWildcardMapping" type="Elmah.FixIIS5xWildcardMappingModule, Elmah" />--> | |
+ | |
+ <!-- | |
+ Uncomment the entry below if you are using MS AJAX v1.0.x.x | |
+ and want to capture errors during Partial Postbacks | |
+ NB This is not required for the version of AJAX shipped with | |
+ .NET Framework v3.5! | |
+ --> | |
+ <!--<add name="MsAjaxDeltaErrorLog" type="Elmah.MsAjaxDeltaErrorLogModule, Elmah" />--> | |
+ | |
+ <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" /> | |
+ | |
+ <!-- | |
+ Uncomment the entries below if error mail reporting and | |
+ filtering is desired. | |
+ --> | |
+ | |
+ <!--<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />--> | |
+ <!--<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />--> | |
+ <!--<add name="ErrorTweet" type="Elmah.ErrorTweetModule, Elmah" />--> | |
+ </httpModules> | |
+ </system.web> | |
+ <system.webServer> | |
+ <modules> | |
+ <add name="WebSharper.RemotingModule" type="IntelliFactory.WebSharper.Web.RpcModule, IntelliFactory.WebSharper.Web" /> | |
+ <add name="WebSharper.Sitelets" type="IntelliFactory.WebSharper.Sitelets.HttpModule, IntelliFactory.WebSharper.Sitelets" /> | |
+ </modules> | |
+ <!-- This is only needed for VS Development WebServer (see above). IIS/IIS Express do not use this: --> | |
+ <validation validateIntegratedModeConfiguration="false"/> | |
+ </system.webServer> | |
+ <!-- | |
+ This entry provides the UI for the error log at elmah.axd below the | |
+ application path. For example, if your domain is www.example.com and | |
+ your application is at the root, then you can view the error log by | |
+ visiting the following URL: | |
+ | |
+ http://www.example.com/elmah.axd | |
+ | |
+ IMPORTANT! To secure this location, consult the following notes: | |
+ | |
+ http://code.google.com/p/elmah/wiki/SecuringErrorLogPages | |
+ --> | |
+ | |
+ <location path="elmah.axd"> | |
+ <system.web> | |
+ <httpHandlers> | |
+ <add verb="POST,GET,HEAD" | |
+ path="elmah.axd" | |
+ type="Elmah.ErrorLogPageFactory, Elmah" /> | |
+ </httpHandlers> | |
+ <!-- | |
+ The following entry denies unauthenticated users access to | |
+ the path from where ELMAH's handlers are accessible. If you | |
+ have role-based security implemented, you SHOULD consider | |
+ instead allowing access by a particular role (for example, | |
+ operators and administrators). | |
+ | |
+ IMPORTANT: If you change the path of the handler then you | |
+ MUST also change the path in the containing location tag | |
+ to be the same. | |
+ | |
+ For more information, see: | |
+ http://code.google.com/p/elmah/wiki/SecuringErrorLogPages | |
+ --> | |
+ <authorization> | |
+ <allow users="?" /> | |
+ </authorization> | |
+ </system.web> | |
+ <system.webServer> | |
+ <handlers> | |
+ <add name="ELMAH" | |
+ verb="POST,GET,HEAD" | |
+ path="elmah.axd" | |
+ type="Elmah.ErrorLogPageFactory, Elmah" | |
+ preCondition="integratedMode" /> | |
+ </handlers> | |
+ </system.webServer> | |
+ </location> | |
+</configuration> | |
diff --git a/paket.dependencies b/paket.dependencies | |
index 712fd08..1317d3f 100644 | |
--- a/paket.dependencies | |
+++ b/paket.dependencies | |
@@ -7,3 +7,8 @@ nuget FAKE | |
nuget SourceLink.Fake | |
github fsharp/FAKE modules/Octokit/Octokit.fsx | |
+ | |
+nuget websharper | |
+nuget websharper.ui.next | |
+ | |
+nuget elmah | |
diff --git a/paket.lock b/paket.lock | |
index 1031037..e038c2b 100644 | |
--- a/paket.lock | |
+++ b/paket.lock | |
@@ -1,6 +1,9 @@ | |
NUGET | |
remote: https://nuget.org/api/v2 | |
specs: | |
+ elmah (1.2.2) | |
+ elmah.corelibrary (>= 1.2.2) | |
+ elmah.corelibrary (1.2.2) | |
FAKE (4.1.4) | |
FSharp.Compiler.Service (1.4.0.1) | |
FSharp.Formatting (2.10.0) | |
@@ -19,6 +22,9 @@ NUGET | |
Octokit (0.14.0) | |
Microsoft.Net.Http | |
SourceLink.Fake (1.0.0) | |
+ WebSharper (3.4.9.188) | |
+ WebSharper.UI.Next (3.4.9.157) | |
+ WebSharper | |
GITHUB | |
remote: fsharp/FAKE | |
specs: | |
diff --git a/src/awsgui/Library.fs b/src/awsgui/Library.fs | |
index 3912945..7765341 100644 | |
--- a/src/awsgui/Library.fs | |
+++ b/src/awsgui/Library.fs | |
@@ -1,16 +1,24 @@ | |
namespace awsgui | |
-/// Documentation for my library | |
-/// | |
-/// ## Example | |
-/// | |
-/// let h = Library.hello 1 | |
-/// printfn "%d" h | |
-/// | |
-module Library = | |
- | |
- /// Returns 42 | |
- /// | |
- /// ## Parameters | |
- /// - `num` - whatever | |
- let hello num = 42 | |
+open WebSharper | |
+ | |
+module Server = | |
+ open WebSharper | |
+ open WebSharper.Sitelets | |
+ open WebSharper.UI.Next | |
+ open WebSharper.UI.Next.Html | |
+ open WebSharper.UI.Next.Server | |
+ | |
+ type Action = | |
+ | Index | |
+ | |
+ let IndexContent (_ (*ctx*) : Context<Action>) = | |
+ Content.Doc( | |
+ div [text "blah"] | |
+ ) | |
+ | |
+ [<Website>] | |
+ let MyWebsite = | |
+ Sitelet.Sum [ | |
+ Sitelet.Content "/" Index IndexContent | |
+ ] | |
diff --git a/src/awsgui/awsgui.fsproj b/src/awsgui/awsgui.fsproj | |
index 9c709c1..c8c48f6 100644 | |
--- a/src/awsgui/awsgui.fsproj | |
+++ b/src/awsgui/awsgui.fsproj | |
@@ -43,6 +43,11 @@ | |
<Reference Include="System" /> | |
<Reference Include="System.Core" /> | |
<Reference Include="System.Numerics" /> | |
+ <Reference Include="System.Web" /> | |
+ <Reference Include="System.Web.Extensions" /> | |
+ <Reference Include="../../packages/WebSharper/lib/net40/*.dll" /> | |
+ <Reference Include="../../packages/WebSharper/tools/net40/*.dll" /> | |
+ <Reference Include="../../packages/WebSharper.UI.Next/lib/net40/*.dll" /> | |
</ItemGroup> | |
<ItemGroup> | |
<Compile Include="Library.fs" /> | |
@@ -74,4 +79,5 @@ | |
</Target> | |
--> | |
<Import Project="..\..\.paket\paket.targets" /> | |
+ <Import Project="../../packages/WebSharper/build/WebSharper.targets" /> | |
</Project> | |
@@ -77,6 +77,8 @@ | |
</Otherwise> | |
</Choose> | |
<PropertyGroup> | |
+ <OtherFlags>--quotations-debug</OtherFlags> | |
+ <WebSharperSourceMap>True</WebSharperSourceMap> | |
<WebProjectOutputDir>../../</WebProjectOutputDir> | |
</PropertyGroup> | |
<Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')" /> | |
diff --git a/tests/awsgui.Tests/Tests.fs b/tests/awsgui.Tests/Tests.fs | |
index 3379dac..06f8c97 100644 | |
--- a/tests/awsgui.Tests/Tests.fs | |
+++ b/tests/awsgui.Tests/Tests.fs | |
@@ -3,8 +3,10 @@ module awsgui.Tests | |
open awsgui | |
open NUnit.Framework | |
+(* | |
[<Test>] | |
let ``hello returns 42`` () = | |
let result = Library.hello 42 | |
printfn "%i" result | |
Assert.AreEqual(42,result) | |
+ *) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment