Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinmoris committed Dec 21, 2017
2 parents 38cabad + 15a2c7c commit 709fd27
Show file tree
Hide file tree
Showing 22 changed files with 472 additions and 41 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,7 @@ __pycache__/
*.btm.cs
*.odx.cs
*.xsd.cs

#macOS

.DS_Store
46 changes: 42 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ Giraffe web application template for the `dotnet new` command.
- [Documentation](#documentation)
- [Installation](#installation)
- [Usage](#usage)
- [ViewEngine options](#viewengine-options)
- [Restoring and building](#restoring-and-building)
- [Updating the template](#updating-the-template)
- [Nightly builds and NuGet feed](#nightly-builds-and-nuget-feed)
- [More information](#more-information)
- [License](#license)

Expand All @@ -35,9 +38,33 @@ After the template has been installed you can create a new Giraffe web applicati
dotnet new giraffe
```

After successfully running this command you should be able to restore, build and run your Giraffe web application without any further doing:
#### ViewEngine options

##### Windows example:
The Giraffe template supports three different view engine types at the moment:

- `giraffe` (default)
- `razor`
- `dotliquid`

You can optionally specify the `--ViewEngine` parameter (short `-V`) and pass in one of the supported values:

```
dotnet new giraffe --ViewEngine razor
```

...or using `-V`:

```
dotnet new giraffe -V dotliquid
```

If you do not specify the `--ViewEngine` parameter then the `dotnet new giraffe` command will automatically create a Giraffe web application with the default `Giraffe.GiraffeViewEngine` engine.

For further help you can also run `dotnet new giraffe --help` which will print all available parameters and their supported values.

#### Restoring and building

After successfully creating a new application you should be able to restore, build and run your Giraffe web application without any further doing:

```
mkdir GiraffeSampleApp
Expand All @@ -50,17 +77,28 @@ dotnet build
dotnet run
```


### Updating the template

Whenever there is a new version of the Giraffe template you can update it by re-running the [instructions from the installation](#installation).

You can also explicitly set the version when installing the template:

```
dotnet new -i "giraffe-template::0.9.0"
dotnet new -i "giraffe-template::0.10.0"
```

## Nightly builds and NuGet feed

All official Giraffe packages are published to the official and public NuGet feed.

Unofficial builds (such as pre-release builds from the `develop` branch and pull requests) produce unofficial pre-release NuGet packages which can be pulled from the project's public NuGet feed on AppVeyor:

```
https://ci.appveyor.com/nuget/giraffe-template
```

If you add this source to your NuGet CLI or project settings then you can pull unofficial NuGet packages for quick feature testing or urgent hot fixes.

## More information

For more information about Giraffe, how to set up a development environment, contribution guidelines and more please visit the [main documentation](https://github.com/giraffe-fsharp/Giraffe#table-of-contents) page.
Expand Down
18 changes: 18 additions & 0 deletions RELEASE_NOTES.md
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).
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ artifacts:
- path: '**\giraffe-template.*.nupkg'
name: Giraffe Template package
nuget:
account_feed: true
project_feed: false
account_feed: false
project_feed: true
deploy:
provider: NuGet
api_key:
Expand Down
46 changes: 42 additions & 4 deletions src/content/.template.config/template.json
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\")"
}
]
}
46 changes: 46 additions & 0 deletions src/content/DotLiquid.Template/AppNamePlaceholder.fsproj
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>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace _AppName.Models
namespace AppNamePlaceholder.Models

[<CLIMutable>]
type Message =
Expand Down
77 changes: 77 additions & 0 deletions src/content/DotLiquid.Template/Program.fs
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
13 changes: 13 additions & 0 deletions src/content/DotLiquid.Template/Views/Index.html
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>
10 changes: 10 additions & 0 deletions src/content/DotLiquid.Template/WebRoot/main.css
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;
}
36 changes: 36 additions & 0 deletions src/content/Giraffe.Template/AppNamePlaceholder.fsproj
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>
Loading

0 comments on commit 709fd27

Please sign in to comment.