A little housekeeping
- Simplified user message generation (Info is default level) - Removed paket and FAKE files, as we're using the default .NET Core build system
This commit is contained in:
		
							parent
							
								
									739fe3ff9c
								
							
						
					
					
						commit
						47266817f6
					
				
										
											Binary file not shown.
										
									
								
							| @ -16,9 +16,9 @@ type PageModule (data : IMyWebLogData, clock : IClock) as this = | |||||||
| 
 | 
 | ||||||
|   do |   do | ||||||
|     this.Get    ("/pages",            fun _ -> this.PageList   ()) |     this.Get    ("/pages",            fun _ -> this.PageList   ()) | ||||||
|     this.Get    ("/page/{id}/edit",   fun parms -> this.EditPage   (downcast parms)) |     this.Get    ("/page/{id}/edit",   fun p -> this.EditPage   (downcast p)) | ||||||
|     this.Post   ("/page/{id}/edit",   fun parms -> this.SavePage   (downcast parms)) |     this.Post   ("/page/{id}/edit",   fun p -> this.SavePage   (downcast p)) | ||||||
|     this.Delete ("/page/{id}/delete", fun parms -> this.DeletePage (downcast parms)) |     this.Delete ("/page/{id}/delete", fun p -> this.DeletePage (downcast p)) | ||||||
| 
 | 
 | ||||||
|   /// List all pages |   /// List all pages | ||||||
|   member this.PageList () : obj = |   member this.PageList () : obj = | ||||||
| @ -74,12 +74,12 @@ type PageModule (data : IMyWebLogData, clock : IClock) as this = | |||||||
|             } |             } | ||||||
|           |> savePage data |           |> savePage data | ||||||
|         let model = MyWebLogModel (this.Context, this.WebLog) |         let model = MyWebLogModel (this.Context, this.WebLog) | ||||||
|  |         model.AddMessage | ||||||
|           { UserMessage.Empty with |           { UserMessage.Empty with | ||||||
|             Level   = Level.Info |  | ||||||
|               Message = System.String.Format |               Message = System.String.Format | ||||||
|                           (Strings.get "MsgPageEditSuccess", |                           (Strings.get "MsgPageEditSuccess", | ||||||
|                           Strings.get (match pageId with "new" -> "Added" | _ -> "Updated")) } |                             Strings.get (match pageId with "new" -> "Added" | _ -> "Updated")) | ||||||
|         |> model.AddMessage |             } | ||||||
|         this.Redirect (sprintf "/page/%s/edit" pId) model |         this.Redirect (sprintf "/page/%s/edit" pId) model | ||||||
|     | _ -> this.NotFound () |     | _ -> this.NotFound () | ||||||
| 
 | 
 | ||||||
| @ -92,9 +92,6 @@ type PageModule (data : IMyWebLogData, clock : IClock) as this = | |||||||
|     | Some page -> |     | Some page -> | ||||||
|         deletePage data page.WebLogId page.Id |         deletePage data page.WebLogId page.Id | ||||||
|         let model = MyWebLogModel (this.Context, this.WebLog) |         let model = MyWebLogModel (this.Context, this.WebLog) | ||||||
|         { UserMessage.Empty with |         model.AddMessage { UserMessage.Empty with Message = Strings.get "MsgPageDeleted" } | ||||||
|             Level   = Level.Info |  | ||||||
|             Message = Strings.get "MsgPageDeleted" } |  | ||||||
|         |> model.AddMessage |  | ||||||
|         this.Redirect "/pages" model |         this.Redirect "/pages" model | ||||||
|     | _ -> this.NotFound () |     | _ -> this.NotFound () | ||||||
|  | |||||||
| @ -28,7 +28,9 @@ type PostModule(data : IMyWebLogData, clock : IClock) as this = | |||||||
| 
 | 
 | ||||||
|   /// Get the page number from the dictionary |   /// Get the page number from the dictionary | ||||||
|   let getPage (parameters : DynamicDictionary) = |   let getPage (parameters : DynamicDictionary) = | ||||||
|     match parameters.ContainsKey "page" with true -> System.Int32.Parse (parameters.["page"].ToString ()) | _ -> 1 |     match parameters.ContainsKey "page" with | ||||||
|  |     | true -> match System.Int32.TryParse (parameters.["page"].ToString ()) with true, pg -> pg | _ -> 1 | ||||||
|  |     | _ -> 1 | ||||||
| 
 | 
 | ||||||
|   /// Convert a list of posts to a list of posts for display |   /// Convert a list of posts to a list of posts for display | ||||||
|   let forDisplay posts = posts |> List.map (fun post -> PostForDisplay (this.WebLog, post)) |   let forDisplay posts = posts |> List.map (fun post -> PostForDisplay (this.WebLog, post)) | ||||||
| @ -42,8 +44,8 @@ type PostModule(data : IMyWebLogData, clock : IClock) as this = | |||||||
|         items |         items | ||||||
|         |> List.sortBy (fun i -> i.ReleaseDate)  |         |> List.sortBy (fun i -> i.ReleaseDate)  | ||||||
|         |> List.map (fun i -> |         |> List.map (fun i -> | ||||||
|             XElement |             XElement ( | ||||||
|               (xn "item", |                xn "item", | ||||||
|                elem "title" (System.Net.WebUtility.HtmlEncode i.Title), |                elem "title" (System.Net.WebUtility.HtmlEncode i.Title), | ||||||
|                elem "link" i.Link, |                elem "link" i.Link, | ||||||
|                elem "guid" i.Link, |                elem "guid" i.Link, | ||||||
| @ -52,8 +54,8 @@ type PostModule(data : IMyWebLogData, clock : IClock) as this = | |||||||
|             )) |             )) | ||||||
|       XDocument ( |       XDocument ( | ||||||
|         XDeclaration ("1.0", "utf-8", "yes"), |         XDeclaration ("1.0", "utf-8", "yes"), | ||||||
|         XElement |         XElement ( | ||||||
|           (xn "rss", |            xn "rss", | ||||||
|            XAttribute (xn "version", "2.0"), |            XAttribute (xn "version", "2.0"), | ||||||
|            elem "title" channelTitle, |            elem "title" channelTitle, | ||||||
|            elem "link" channelLink, |            elem "link" channelLink, | ||||||
| @ -61,8 +63,8 @@ type PostModule(data : IMyWebLogData, clock : IClock) as this = | |||||||
|            elem "language" "en-us", |            elem "language" "en-us", | ||||||
|            XElement (xn "channel", elems)) |            XElement (xn "channel", elems)) | ||||||
|         |> box) |         |> box) | ||||||
|       |> box |  | ||||||
|     let schemeAndUrl = sprintf "%s://%s" this.Request.Url.Scheme this.WebLog.UrlBase |     let schemeAndUrl = sprintf "%s://%s" this.Request.Url.Scheme this.WebLog.UrlBase | ||||||
|  |     let feed = | ||||||
|       findFeedPosts data this.WebLog.Id 10 |       findFeedPosts data this.WebLog.Id 10 | ||||||
|       |> List.map (fun (post, _) -> |       |> List.map (fun (post, _) -> | ||||||
|           { Title       = post.Title |           { Title       = post.Title | ||||||
| @ -71,6 +73,11 @@ type PostModule(data : IMyWebLogData, clock : IClock) as this = | |||||||
|             Description = post.Text |             Description = post.Text | ||||||
|             }) |             }) | ||||||
|       |> myChannelFeed this.WebLog.Name schemeAndUrl this.WebLog.Subtitle |       |> myChannelFeed this.WebLog.Name schemeAndUrl this.WebLog.Subtitle | ||||||
|  |     let stream = new IO.MemoryStream () | ||||||
|  |     Xml.XmlWriter.Create stream |> feed.Save | ||||||
|  |     //|> match format with "atom" -> feed.SaveAsAtom10 | _ -> feed.SaveAsRss20 | ||||||
|  |     stream.Position <- 0L | ||||||
|  |     upcast this.Response.FromStream (stream, sprintf "application/%s+xml" format) | ||||||
|     // TODO: how to return this? |     // TODO: how to return this? | ||||||
| 
 | 
 | ||||||
|     (*  |     (*  | ||||||
| @ -246,7 +253,8 @@ type PostModule(data : IMyWebLogData, clock : IClock) as this = | |||||||
|     match postId with "new" -> Some Post.Empty | _ -> tryFindPost data this.WebLog.Id postId |     match postId with "new" -> Some Post.Empty | _ -> tryFindPost data this.WebLog.Id postId | ||||||
|     |> function |     |> function | ||||||
|     | Some post -> |     | Some post -> | ||||||
|         let rev = match post.Revisions |         let rev = | ||||||
|  |           match post.Revisions | ||||||
|                 |> List.sortByDescending (fun r -> r.AsOf) |                 |> List.sortByDescending (fun r -> r.AsOf) | ||||||
|                 |> List.tryHead with |                 |> List.tryHead with | ||||||
|           | Some r -> r |           | Some r -> r | ||||||
| @ -270,11 +278,13 @@ type PostModule(data : IMyWebLogData, clock : IClock) as this = | |||||||
|     |> function |     |> function | ||||||
|     | Some p -> |     | Some p -> | ||||||
|         let justPublished = p.PublishedOn = 0L && form.PublishNow |         let justPublished = p.PublishedOn = 0L && form.PublishNow | ||||||
|         let post = match postId with |         let post = | ||||||
|                    | "new" -> { p with |           match postId with | ||||||
|  |           | "new" -> | ||||||
|  |               { p with | ||||||
|                   WebLogId = this.WebLog.Id |                   WebLogId = this.WebLog.Id | ||||||
|                                   AuthorId = (this.Request.PersistableSession.GetOrDefault<User> |                   AuthorId = this.Request.PersistableSession.GetOrDefault<User>(Keys.User, User.Empty).Id | ||||||
|                                                 (Keys.User, User.Empty)).Id } |                 } | ||||||
|           | _ -> p |           | _ -> p | ||||||
|         let pId = |         let pId = | ||||||
|           { post with |           { post with | ||||||
| @ -296,12 +306,12 @@ type PostModule(data : IMyWebLogData, clock : IClock) as this = | |||||||
|                               Text       = form.Text } :: post.Revisions } |                               Text       = form.Text } :: post.Revisions } | ||||||
|           |> savePost data |           |> savePost data | ||||||
|         let model = MyWebLogModel(this.Context, this.WebLog) |         let model = MyWebLogModel(this.Context, this.WebLog) | ||||||
|  |         model.AddMessage | ||||||
|           { UserMessage.Empty with |           { UserMessage.Empty with | ||||||
|             Level   = Level.Info |  | ||||||
|               Message = System.String.Format |               Message = System.String.Format | ||||||
|                           (Strings.get "MsgPostEditSuccess", |                           (Strings.get "MsgPostEditSuccess", | ||||||
|                             Strings.get (match postId with "new" -> "Added" | _ -> "Updated"), |                             Strings.get (match postId with "new" -> "Added" | _ -> "Updated"), | ||||||
|                           (match justPublished with true -> Strings.get "AndPublished" | _ -> "")) } |                             (match justPublished with true -> Strings.get "AndPublished" | _ -> "")) | ||||||
|         |> model.AddMessage |             } | ||||||
|         this.Redirect (sprintf "/post/%s/edit" pId) model |         this.Redirect (sprintf "/post/%s/edit" pId) model | ||||||
|     | _ -> this.NotFound () |     | _ -> this.NotFound () | ||||||
|  | |||||||
| @ -1,14 +0,0 @@ | |||||||
| @echo off |  | ||||||
| cls |  | ||||||
| 
 |  | ||||||
| .paket\paket.bootstrapper.exe |  | ||||||
| if errorlevel 1 ( |  | ||||||
|   exit /b %errorlevel% |  | ||||||
| ) |  | ||||||
| 
 |  | ||||||
| .paket\paket.exe restore |  | ||||||
| if errorlevel 1 ( |  | ||||||
|   exit /b %errorlevel% |  | ||||||
| ) |  | ||||||
| 
 |  | ||||||
| packages\FAKE\tools\FAKE.exe build.fsx %* |  | ||||||
| @ -1,42 +0,0 @@ | |||||||
| // include Fake libs |  | ||||||
| #r "./packages/FAKE/tools/FakeLib.dll" |  | ||||||
| 
 |  | ||||||
| open Fake |  | ||||||
| 
 |  | ||||||
| // Directories |  | ||||||
| let buildDir  = "./build/" |  | ||||||
| let deployDir = "./deploy/" |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| // Filesets |  | ||||||
| let appReferences  = |  | ||||||
|     !! "/**/*.csproj" |  | ||||||
|       ++ "/**/*.fsproj" |  | ||||||
| 
 |  | ||||||
| // version info |  | ||||||
| let version = "0.1"  // or retrieve from CI server |  | ||||||
| 
 |  | ||||||
| // Targets |  | ||||||
| Target "Clean" (fun _ -> |  | ||||||
|     CleanDirs [buildDir; deployDir] |  | ||||||
| ) |  | ||||||
| 
 |  | ||||||
| Target "Build" (fun _ -> |  | ||||||
|     // compile all projects below src/app/ |  | ||||||
|     MSBuildDebug buildDir "Build" appReferences |  | ||||||
|         |> Log "AppBuild-Output: " |  | ||||||
| ) |  | ||||||
| 
 |  | ||||||
| Target "Deploy" (fun _ -> |  | ||||||
|     !! (buildDir + "/**/*.*") |  | ||||||
|         -- "*.zip" |  | ||||||
|         |> Zip buildDir (deployDir + "ApplicationName." + version + ".zip") |  | ||||||
| ) |  | ||||||
| 
 |  | ||||||
| // Build order |  | ||||||
| "Clean" |  | ||||||
|   ==> "Build" |  | ||||||
|   ==> "Deploy" |  | ||||||
| 
 |  | ||||||
| // start build |  | ||||||
| RunTargetOrDefault "Build" |  | ||||||
							
								
								
									
										33
									
								
								src/build.sh
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								src/build.sh
									
									
									
									
									
								
							| @ -1,33 +0,0 @@ | |||||||
| #!/bin/bash |  | ||||||
| if test "$OS" = "Windows_NT" |  | ||||||
| then |  | ||||||
|   # use .Net |  | ||||||
| 
 |  | ||||||
|   .paket/paket.bootstrapper.exe |  | ||||||
|   exit_code=$? |  | ||||||
|   if [ $exit_code -ne 0 ]; then |  | ||||||
|   	exit $exit_code |  | ||||||
|   fi |  | ||||||
| 
 |  | ||||||
|   .paket/paket.exe restore |  | ||||||
|   exit_code=$? |  | ||||||
|   if [ $exit_code -ne 0 ]; then |  | ||||||
|   	exit $exit_code |  | ||||||
|   fi |  | ||||||
| 
 |  | ||||||
|   packages/FAKE/tools/FAKE.exe $@ --fsiargs build.fsx |  | ||||||
| else |  | ||||||
|   # use mono |  | ||||||
|   mono .paket/paket.bootstrapper.exe |  | ||||||
|   exit_code=$? |  | ||||||
|   if [ $exit_code -ne 0 ]; then |  | ||||||
|   	exit $exit_code |  | ||||||
|   fi |  | ||||||
| 
 |  | ||||||
|   mono .paket/paket.exe restore |  | ||||||
|   exit_code=$? |  | ||||||
|   if [ $exit_code -ne 0 ]; then |  | ||||||
|   	exit $exit_code |  | ||||||
|   fi |  | ||||||
|   mono packages/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx |  | ||||||
| fi |  | ||||||
| @ -1,13 +0,0 @@ | |||||||
| framework: net40, net45, net452 |  | ||||||
| source https://www.nuget.org/api/v2 |  | ||||||
| nuget Common.Logging 3.3.0 |  | ||||||
| nuget FAKE |  | ||||||
| nuget FSharp.Interop.Dynamic |  | ||||||
| nuget FSharp.Formatting |  | ||||||
| nuget Nancy |  | ||||||
| nuget Nancy.Authentication.Forms |  | ||||||
| nuget Nancy.Session.RethinkDb |  | ||||||
| nuget Newtonsoft.Json |  | ||||||
| nuget NodaTime |  | ||||||
| nuget RethinkDb.Driver |  | ||||||
| nuget Suave |  | ||||||
| @ -1,34 +0,0 @@ | |||||||
| FRAMEWORK: NET40, NET45, NET452 |  | ||||||
| NUGET |  | ||||||
|   remote: https://www.nuget.org/api/v2 |  | ||||||
|     Common.Logging (3.3) |  | ||||||
|       Common.Logging.Core (>= 3.3) |  | ||||||
|     Common.Logging.Core (3.3.1) |  | ||||||
|     Dynamitey (1.0.2) |  | ||||||
|     FAKE (4.36) |  | ||||||
|     FSharp.Compiler.Service (2.0.0.6) |  | ||||||
|     FSharp.Core (4.0.0.1) |  | ||||||
|     FSharp.Formatting (2.14.4) |  | ||||||
|       FSharp.Compiler.Service (2.0.0.6) |  | ||||||
|       FSharpVSPowerTools.Core (>= 2.3 < 2.4) |  | ||||||
|     FSharp.Interop.Dynamic (3.0) |  | ||||||
|       Dynamitey (>= 1.0.2) |  | ||||||
|       FSharp.Core (>= 3.1.2.1) |  | ||||||
|     FSharpVSPowerTools.Core (2.3) |  | ||||||
|       FSharp.Compiler.Service (>= 2.0.0.3) |  | ||||||
|     Nancy (1.4.3) |  | ||||||
|     Nancy.Authentication.Forms (1.4.1) |  | ||||||
|       Nancy (>= 1.4.1) |  | ||||||
|     Nancy.Session.Persistable (0.9) |  | ||||||
|       Nancy (>= 1.4.3) |  | ||||||
|       Newtonsoft.Json (>= 9.0.1) |  | ||||||
|     Nancy.Session.RethinkDB (0.9) |  | ||||||
|       Nancy.Session.Persistable (>= 0.9) |  | ||||||
|       RethinkDb.Driver (>= 2.3.9) |  | ||||||
|     Newtonsoft.Json (9.0.1) |  | ||||||
|     NodaTime (1.3.2) |  | ||||||
|     RethinkDb.Driver (2.3.10) |  | ||||||
|       Common.Logging (>= 3.3) - framework: net45, net452 |  | ||||||
|       Newtonsoft.Json (>= 9.0.1) - framework: net45, net452 |  | ||||||
|     Suave (1.1.3) |  | ||||||
|       FSharp.Core (>= 3.1.2.5) |  | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user