-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
472 additions
and
41 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -286,3 +286,7 @@ __pycache__/ | |
*.btm.cs | ||
*.odx.cs | ||
*.xsd.cs | ||
|
||
#macOS | ||
|
||
.DS_Store |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,24 @@ | ||
Release Notes | ||
============= | ||
|
||
## 0.10.0 | ||
|
||
#### New features | ||
|
||
The Giraffe template supports three different view engines now: | ||
|
||
- `giraffe` (default) | ||
- `razor` | ||
- `dotliquid` | ||
|
||
You can optionally specify the `--ViewEngine` (or short `-V`) parameter and select one of the supported options when creating a new Giraffe project: | ||
|
||
``` | ||
dotnet new giraffe --ViewEngine razor | ||
``` | ||
|
||
When you run `dotnet new giraffe` it will automatically create a new Giraffe project with the default `GiraffeViewEngine` engine. | ||
|
||
## 0.9.0 and before | ||
|
||
Previous releases of this library were documented in [Giraffe's release notes](https://github.com/giraffe-fsharp/Giraffe/blob/master/RELEASE_NOTES.md). |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,49 @@ | ||
{ | ||
"identity": "Giraffe.Template", | ||
"author": "David Sinclair and contributors", | ||
"classifications": [ "Web", "Giraffe", "ASP.NET", "ASP.NET Core" ], | ||
"shortName": "giraffe", | ||
"name": "Giraffe Web App", | ||
"author": "Dustin Moris Gorski, David Sinclair and contributors", | ||
"classifications": [ "Web", "Giraffe", "ASP.NET" ], | ||
"tags": { | ||
"language": "F#" | ||
}, | ||
"shortName": "giraffe", | ||
"sourceName": "_AppName" | ||
"sourceName": "AppNamePlaceholder", | ||
"symbols": { | ||
"ViewEngine": { | ||
"type": "parameter", | ||
"dataType": "choice", | ||
"defaultValue": "giraffe", | ||
"choices": [ | ||
{ | ||
"choice": "giraffe", | ||
"description": "Default GiraffeViewEngine" | ||
}, | ||
{ | ||
"choice": "razor", | ||
"description": "MVC Razor views" | ||
}, | ||
{ | ||
"choice": "dotliquid", | ||
"description": "DotLiquid template engine" | ||
} | ||
] | ||
} | ||
}, | ||
"sources": [ | ||
{ | ||
"source": "./Giraffe.Template/", | ||
"target": "./", | ||
"condition": "(ViewEngine == \"giraffe\")" | ||
}, | ||
{ | ||
"source": "./Razor.Template/", | ||
"target": "./", | ||
"condition": "(ViewEngine == \"razor\")" | ||
}, | ||
{ | ||
"source": "./DotLiquid.Template/", | ||
"target": "./", | ||
"condition": "(ViewEngine == \"dotliquid\")" | ||
} | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
<DebugType>portable</DebugType> | ||
<AssemblyName>AppNamePlaceholder</AssemblyName> | ||
<OutputType>Exe</OutputType> | ||
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion> | ||
<EnableDefaultContentItems>false</EnableDefaultContentItems> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.0.*" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.0.*" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.0.*" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.0.*" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.0.*"/> | ||
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.*" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.*" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.*" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.0.*" /> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.*" /> | ||
<PackageReference Include="Giraffe" Version="0.1.0-beta-600" /> | ||
<PackageReference Include="Giraffe.DotLiquid" Version="0.1.0-beta-310" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Watch Include="**\*.html" Exclude="bin\**\*" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="Models.fs" /> | ||
<Compile Include="Program.fs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="Views\*.html;WebRoot\**\*"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
|
||
</Project> |
2 changes: 1 addition & 1 deletion
2
src/content/Models/Message.fs → src/content/DotLiquid.Template/Models.fs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace _AppName.Models | ||
namespace AppNamePlaceholder.Models | ||
|
||
[<CLIMutable>] | ||
type Message = | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
module AppNamePlaceholder.App | ||
|
||
open System | ||
open System.IO | ||
open Microsoft.AspNetCore.Builder | ||
open Microsoft.AspNetCore.Cors.Infrastructure | ||
open Microsoft.AspNetCore.Hosting | ||
open Microsoft.Extensions.Logging | ||
open Microsoft.Extensions.DependencyInjection | ||
open Giraffe | ||
open DotLiquid | ||
open AppNamePlaceholder.Models | ||
|
||
// --------------------------------- | ||
// Web app | ||
// --------------------------------- | ||
|
||
let indexHandler (name : string) = | ||
let greetings = sprintf "Hello %s, from Giraffe!" name | ||
let model = { Text = greetings } | ||
dotLiquidHtmlView "Views/Index.html" model | ||
|
||
let webApp = | ||
choose [ | ||
GET >=> | ||
choose [ | ||
route "/" >=> indexHandler "world" | ||
routef "/hello/%s" indexHandler | ||
] | ||
setStatusCode 404 >=> text "Not Found" ] | ||
|
||
// --------------------------------- | ||
// Error handler | ||
// --------------------------------- | ||
|
||
let errorHandler (ex : Exception) (logger : ILogger) = | ||
logger.LogError(EventId(), ex, "An unhandled exception has occurred while executing the request.") | ||
clearResponse >=> setStatusCode 500 >=> text ex.Message | ||
|
||
// --------------------------------- | ||
// Config and Main | ||
// --------------------------------- | ||
|
||
let configureCors (builder : CorsPolicyBuilder) = | ||
builder.WithOrigins("http://localhost:8080") | ||
.AllowAnyMethod() | ||
.AllowAnyHeader() | ||
|> ignore | ||
|
||
let configureApp (app : IApplicationBuilder) = | ||
app.UseCors(configureCors) | ||
.UseGiraffeErrorHandler(errorHandler) | ||
.UseStaticFiles() | ||
.UseGiraffe(webApp) | ||
|
||
let configureServices (services : IServiceCollection) = | ||
services.AddCors() |> ignore | ||
|
||
let configureLogging (builder : ILoggingBuilder) = | ||
let filter (l : LogLevel) = l.Equals LogLevel.Error | ||
builder.AddFilter(filter).AddConsole().AddDebug() |> ignore | ||
|
||
[<EntryPoint>] | ||
let main _ = | ||
let contentRoot = Directory.GetCurrentDirectory() | ||
let webRoot = Path.Combine(contentRoot, "WebRoot") | ||
WebHostBuilder() | ||
.UseKestrel() | ||
.UseContentRoot(contentRoot) | ||
.UseIISIntegration() | ||
.UseWebRoot(webRoot) | ||
.Configure(Action<IApplicationBuilder> configureApp) | ||
.ConfigureServices(configureServices) | ||
.ConfigureLogging(configureLogging) | ||
.Build() | ||
.Run() | ||
0 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>AppNamePlaceholder</title> | ||
<link rel="stylesheet" type="text/css" href="/main.css"> | ||
</head> | ||
<body> | ||
<h1>AppNamePlaceholder</h1> | ||
<p> | ||
{{ text }} | ||
</p> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
body { | ||
font-family: Arial, Helvetica, sans-serif; | ||
color: #333; | ||
font-size: .9em; | ||
} | ||
|
||
h1 { | ||
font-size: 1.5em; | ||
color: #334499; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
<DebugType>portable</DebugType> | ||
<AssemblyName>AppNamePlaceholder</AssemblyName> | ||
<OutputType>Exe</OutputType> | ||
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion> | ||
<EnableDefaultContentItems>false</EnableDefaultContentItems> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.0.*" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.0.*" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.0.*" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.0.*" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.0.*"/> | ||
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.*" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.*" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.*" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.0.*" /> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.*" /> | ||
<PackageReference Include="Giraffe" Version="0.1.0-beta-600" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="Program.fs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="WebRoot\**\*"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.