From 33dccf5822ffe1ba2fd929be2460508fe0440ac4 Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Sun, 4 Dec 2016 22:05:50 -0600 Subject: [PATCH] Combined all F# code into one project Less to migrate, less to maintain, and I'll never swap these out as components; might as well get the ease of managing them all in one project. --- .../Data}/Category.fs | 0 .../Data}/DataConfig.fs | 0 .../Data}/Extensions.fs | 0 .../Data}/Page.fs | 0 .../Data}/Post.fs | 0 .../Data}/RethinkMyWebLogData.fs | 0 .../Data}/SetUp.fs | 0 .../Data}/Table.fs | 0 .../Data}/User.fs | 0 .../Data}/WebLog.fs | 0 .../Entities}/Entities.fs | 0 .../Entities}/IMyWebLogData.fs | 0 .../Logic}/Category.fs | 0 .../Logic}/Page.fs | 0 .../Logic}/Post.fs | 0 .../Logic}/User.fs | 0 .../Logic}/WebLog.fs | 0 src/MyWebLog.App/{ => Modules}/AdminModule.fs | 0 .../{ => Modules}/CategoryModule.fs | 0 .../{ => Modules}/ModuleExtensions.fs | 0 src/MyWebLog.App/{ => Modules}/PageModule.fs | 0 src/MyWebLog.App/{ => Modules}/PostModule.fs | 2 +- src/MyWebLog.App/{ => Modules}/UserModule.fs | 0 .../Library.fs => MyWebLog.App/Strings.fs} | 6 +- .../en-US.json | 0 src/MyWebLog.App/project.json | 39 +++- src/MyWebLog.Data.RethinkDB/AssemblyInfo.fs | 21 --- .../MyWebLog.Data.RethinkDB.xproj | 21 --- src/MyWebLog.Data.RethinkDB/project.json | 37 ---- src/MyWebLog.Entities/AssemblyInfo.fs | 21 --- src/MyWebLog.Entities/MyWebLog.Entities.xproj | 21 --- src/MyWebLog.Entities/project.json | 28 --- src/MyWebLog.Logic/AssemblyInfo.fs | 21 --- src/MyWebLog.Logic/MyWebLog.Logic.xproj | 21 --- src/MyWebLog.Logic/project.json | 31 --- src/MyWebLog.Migrate/Program.fs | 178 ++++++++++++++++++ src/MyWebLog.Migrate/project.json | 33 ++++ src/MyWebLog.Resources/AssemblyInfo.fs | 25 --- .../MyWebLog.Resources.xproj | 21 --- src/MyWebLog.Resources/project.json | 30 --- src/MyWebLog/project.json | 7 +- src/global.json | 6 +- src/myWebLog.sln | 8 - 43 files changed, 249 insertions(+), 328 deletions(-) rename src/{MyWebLog.Data.RethinkDB => MyWebLog.App/Data}/Category.fs (100%) rename src/{MyWebLog.Data.RethinkDB => MyWebLog.App/Data}/DataConfig.fs (100%) rename src/{MyWebLog.Data.RethinkDB => MyWebLog.App/Data}/Extensions.fs (100%) rename src/{MyWebLog.Data.RethinkDB => MyWebLog.App/Data}/Page.fs (100%) rename src/{MyWebLog.Data.RethinkDB => MyWebLog.App/Data}/Post.fs (100%) rename src/{MyWebLog.Data.RethinkDB => MyWebLog.App/Data}/RethinkMyWebLogData.fs (100%) rename src/{MyWebLog.Data.RethinkDB => MyWebLog.App/Data}/SetUp.fs (100%) rename src/{MyWebLog.Data.RethinkDB => MyWebLog.App/Data}/Table.fs (100%) rename src/{MyWebLog.Data.RethinkDB => MyWebLog.App/Data}/User.fs (100%) rename src/{MyWebLog.Data.RethinkDB => MyWebLog.App/Data}/WebLog.fs (100%) rename src/{MyWebLog.Entities => MyWebLog.App/Entities}/Entities.fs (100%) rename src/{MyWebLog.Entities => MyWebLog.App/Entities}/IMyWebLogData.fs (100%) rename src/{MyWebLog.Logic => MyWebLog.App/Logic}/Category.fs (100%) rename src/{MyWebLog.Logic => MyWebLog.App/Logic}/Page.fs (100%) rename src/{MyWebLog.Logic => MyWebLog.App/Logic}/Post.fs (100%) rename src/{MyWebLog.Logic => MyWebLog.App/Logic}/User.fs (100%) rename src/{MyWebLog.Logic => MyWebLog.App/Logic}/WebLog.fs (100%) rename src/MyWebLog.App/{ => Modules}/AdminModule.fs (100%) rename src/MyWebLog.App/{ => Modules}/CategoryModule.fs (100%) rename src/MyWebLog.App/{ => Modules}/ModuleExtensions.fs (100%) rename src/MyWebLog.App/{ => Modules}/PageModule.fs (100%) rename src/MyWebLog.App/{ => Modules}/PostModule.fs (99%) rename src/MyWebLog.App/{ => Modules}/UserModule.fs (100%) rename src/{MyWebLog.Resources/Library.fs => MyWebLog.App/Strings.fs} (86%) rename src/{MyWebLog.Resources => MyWebLog.App}/en-US.json (100%) delete mode 100644 src/MyWebLog.Data.RethinkDB/AssemblyInfo.fs delete mode 100644 src/MyWebLog.Data.RethinkDB/MyWebLog.Data.RethinkDB.xproj delete mode 100644 src/MyWebLog.Data.RethinkDB/project.json delete mode 100644 src/MyWebLog.Entities/AssemblyInfo.fs delete mode 100644 src/MyWebLog.Entities/MyWebLog.Entities.xproj delete mode 100644 src/MyWebLog.Entities/project.json delete mode 100644 src/MyWebLog.Logic/AssemblyInfo.fs delete mode 100644 src/MyWebLog.Logic/MyWebLog.Logic.xproj delete mode 100644 src/MyWebLog.Logic/project.json create mode 100644 src/MyWebLog.Migrate/Program.fs create mode 100644 src/MyWebLog.Migrate/project.json delete mode 100644 src/MyWebLog.Resources/AssemblyInfo.fs delete mode 100644 src/MyWebLog.Resources/MyWebLog.Resources.xproj delete mode 100644 src/MyWebLog.Resources/project.json diff --git a/src/MyWebLog.Data.RethinkDB/Category.fs b/src/MyWebLog.App/Data/Category.fs similarity index 100% rename from src/MyWebLog.Data.RethinkDB/Category.fs rename to src/MyWebLog.App/Data/Category.fs diff --git a/src/MyWebLog.Data.RethinkDB/DataConfig.fs b/src/MyWebLog.App/Data/DataConfig.fs similarity index 100% rename from src/MyWebLog.Data.RethinkDB/DataConfig.fs rename to src/MyWebLog.App/Data/DataConfig.fs diff --git a/src/MyWebLog.Data.RethinkDB/Extensions.fs b/src/MyWebLog.App/Data/Extensions.fs similarity index 100% rename from src/MyWebLog.Data.RethinkDB/Extensions.fs rename to src/MyWebLog.App/Data/Extensions.fs diff --git a/src/MyWebLog.Data.RethinkDB/Page.fs b/src/MyWebLog.App/Data/Page.fs similarity index 100% rename from src/MyWebLog.Data.RethinkDB/Page.fs rename to src/MyWebLog.App/Data/Page.fs diff --git a/src/MyWebLog.Data.RethinkDB/Post.fs b/src/MyWebLog.App/Data/Post.fs similarity index 100% rename from src/MyWebLog.Data.RethinkDB/Post.fs rename to src/MyWebLog.App/Data/Post.fs diff --git a/src/MyWebLog.Data.RethinkDB/RethinkMyWebLogData.fs b/src/MyWebLog.App/Data/RethinkMyWebLogData.fs similarity index 100% rename from src/MyWebLog.Data.RethinkDB/RethinkMyWebLogData.fs rename to src/MyWebLog.App/Data/RethinkMyWebLogData.fs diff --git a/src/MyWebLog.Data.RethinkDB/SetUp.fs b/src/MyWebLog.App/Data/SetUp.fs similarity index 100% rename from src/MyWebLog.Data.RethinkDB/SetUp.fs rename to src/MyWebLog.App/Data/SetUp.fs diff --git a/src/MyWebLog.Data.RethinkDB/Table.fs b/src/MyWebLog.App/Data/Table.fs similarity index 100% rename from src/MyWebLog.Data.RethinkDB/Table.fs rename to src/MyWebLog.App/Data/Table.fs diff --git a/src/MyWebLog.Data.RethinkDB/User.fs b/src/MyWebLog.App/Data/User.fs similarity index 100% rename from src/MyWebLog.Data.RethinkDB/User.fs rename to src/MyWebLog.App/Data/User.fs diff --git a/src/MyWebLog.Data.RethinkDB/WebLog.fs b/src/MyWebLog.App/Data/WebLog.fs similarity index 100% rename from src/MyWebLog.Data.RethinkDB/WebLog.fs rename to src/MyWebLog.App/Data/WebLog.fs diff --git a/src/MyWebLog.Entities/Entities.fs b/src/MyWebLog.App/Entities/Entities.fs similarity index 100% rename from src/MyWebLog.Entities/Entities.fs rename to src/MyWebLog.App/Entities/Entities.fs diff --git a/src/MyWebLog.Entities/IMyWebLogData.fs b/src/MyWebLog.App/Entities/IMyWebLogData.fs similarity index 100% rename from src/MyWebLog.Entities/IMyWebLogData.fs rename to src/MyWebLog.App/Entities/IMyWebLogData.fs diff --git a/src/MyWebLog.Logic/Category.fs b/src/MyWebLog.App/Logic/Category.fs similarity index 100% rename from src/MyWebLog.Logic/Category.fs rename to src/MyWebLog.App/Logic/Category.fs diff --git a/src/MyWebLog.Logic/Page.fs b/src/MyWebLog.App/Logic/Page.fs similarity index 100% rename from src/MyWebLog.Logic/Page.fs rename to src/MyWebLog.App/Logic/Page.fs diff --git a/src/MyWebLog.Logic/Post.fs b/src/MyWebLog.App/Logic/Post.fs similarity index 100% rename from src/MyWebLog.Logic/Post.fs rename to src/MyWebLog.App/Logic/Post.fs diff --git a/src/MyWebLog.Logic/User.fs b/src/MyWebLog.App/Logic/User.fs similarity index 100% rename from src/MyWebLog.Logic/User.fs rename to src/MyWebLog.App/Logic/User.fs diff --git a/src/MyWebLog.Logic/WebLog.fs b/src/MyWebLog.App/Logic/WebLog.fs similarity index 100% rename from src/MyWebLog.Logic/WebLog.fs rename to src/MyWebLog.App/Logic/WebLog.fs diff --git a/src/MyWebLog.App/AdminModule.fs b/src/MyWebLog.App/Modules/AdminModule.fs similarity index 100% rename from src/MyWebLog.App/AdminModule.fs rename to src/MyWebLog.App/Modules/AdminModule.fs diff --git a/src/MyWebLog.App/CategoryModule.fs b/src/MyWebLog.App/Modules/CategoryModule.fs similarity index 100% rename from src/MyWebLog.App/CategoryModule.fs rename to src/MyWebLog.App/Modules/CategoryModule.fs diff --git a/src/MyWebLog.App/ModuleExtensions.fs b/src/MyWebLog.App/Modules/ModuleExtensions.fs similarity index 100% rename from src/MyWebLog.App/ModuleExtensions.fs rename to src/MyWebLog.App/Modules/ModuleExtensions.fs diff --git a/src/MyWebLog.App/PageModule.fs b/src/MyWebLog.App/Modules/PageModule.fs similarity index 100% rename from src/MyWebLog.App/PageModule.fs rename to src/MyWebLog.App/Modules/PageModule.fs diff --git a/src/MyWebLog.App/PostModule.fs b/src/MyWebLog.App/Modules/PostModule.fs similarity index 99% rename from src/MyWebLog.App/PostModule.fs rename to src/MyWebLog.App/Modules/PostModule.fs index 7e20d18..ec29d85 100644 --- a/src/MyWebLog.App/PostModule.fs +++ b/src/MyWebLog.App/Modules/PostModule.fs @@ -42,7 +42,7 @@ type PostModule (data : IMyWebLogData, clock : IClock) as this = let elem name (valu : string) = XElement (xn name, valu) let elems = items - |> List.sortBy (fun i -> i.ReleaseDate) + |> List.sortByDescending (fun i -> i.ReleaseDate) |> List.map (fun i -> XElement ( xn "item", diff --git a/src/MyWebLog.App/UserModule.fs b/src/MyWebLog.App/Modules/UserModule.fs similarity index 100% rename from src/MyWebLog.App/UserModule.fs rename to src/MyWebLog.App/Modules/UserModule.fs diff --git a/src/MyWebLog.Resources/Library.fs b/src/MyWebLog.App/Strings.fs similarity index 86% rename from src/MyWebLog.Resources/Library.fs rename to src/MyWebLog.App/Strings.fs index 6ec3f4b..f207444 100644 --- a/src/MyWebLog.Resources/Library.fs +++ b/src/MyWebLog.App/Strings.fs @@ -1,7 +1,9 @@ -module MyWebLog.Resources.Strings +module MyWebLog.Resources.Strings +open MyWebLog open Newtonsoft.Json open System.Collections.Generic +open System.Reflection /// The locales we'll try to load let private supportedLocales = [ "en-US" ] @@ -13,7 +15,7 @@ let private fallbackLocale = "en-US" let private getEmbedded locale = use rdr = new System.IO.StreamReader - (AssemblyInfo.HorribleHack().Assembly.GetManifestResourceStream(sprintf "MyWebLog.Resources.%s.json" locale)) + (typeof.GetTypeInfo().Assembly.GetManifestResourceStream(sprintf "MyWebLog.App.%s.json" locale)) rdr.ReadToEnd() /// The dictionary of localized strings diff --git a/src/MyWebLog.Resources/en-US.json b/src/MyWebLog.App/en-US.json similarity index 100% rename from src/MyWebLog.Resources/en-US.json rename to src/MyWebLog.App/en-US.json diff --git a/src/MyWebLog.App/project.json b/src/MyWebLog.App/project.json index 9d8feea..3ed4776 100644 --- a/src/MyWebLog.App/project.json +++ b/src/MyWebLog.App/project.json @@ -4,29 +4,48 @@ "compile": { "includeFiles": [ "AssemblyInfo.fs", + "Entities/Entities.fs", + "Entities/IMyWebLogData.fs", + "Data/Extensions.fs", + "Data/Table.fs", + "Data/DataConfig.fs", + "Data/Category.fs", + "Data/Page.fs", + "Data/Post.fs", + "Data/User.fs", + "Data/WebLog.fs", + "Data/SetUp.fs", + "Data/RethinkMyWebLogData.fs", + "Logic/Category.fs", + "Logic/Page.fs", + "Logic/Post.fs", + "Logic/User.fs", + "Logic/WebLog.fs", "Keys.fs", "AppConfig.fs", + "Strings.fs", "ViewModels.fs", - "ModuleExtensions.fs", - "AdminModule.fs", - "CategoryModule.fs", - "PageModule.fs", - "PostModule.fs", - "UserModule.fs", + "Modules/ModuleExtensions.fs", + "Modules/AdminModule.fs", + "Modules/CategoryModule.fs", + "Modules/PageModule.fs", + "Modules/PostModule.fs", + "Modules/UserModule.fs", "App.fs" ] + }, + "embed": { + "include": [ "en-US.json" ] } }, "dependencies": { - "MyWebLog.Data.RethinkDB": "0.9.2", - "MyWebLog.Entities": "0.9.2", - "MyWebLog.Logic": "0.9.2", - "MyWebLog.Resources": "0.9.2", "Nancy": "2.0.0-barneyrubble", "Nancy.Authentication.Forms": "2.0.0-barneyrubble", "Nancy.Session.Persistable": "0.9.1-pre", "Nancy.Session.RethinkDB": "0.9.1-pre", + "Newtonsoft.Json": "9.0.1", "NodaTime": "2.0.0-alpha20160729", + "RethinkDb.Driver": "2.3.15", "Suave": "2.0.0-rc2" }, "frameworks": { diff --git a/src/MyWebLog.Data.RethinkDB/AssemblyInfo.fs b/src/MyWebLog.Data.RethinkDB/AssemblyInfo.fs deleted file mode 100644 index 8325c20..0000000 --- a/src/MyWebLog.Data.RethinkDB/AssemblyInfo.fs +++ /dev/null @@ -1,21 +0,0 @@ -namespace myWebLog.Data.AssemblyInfo - -open System.Reflection -open System.Runtime.CompilerServices -open System.Runtime.InteropServices - -[] -[] -[] -[] -[] -[] -[] -[] -[] -[] -[] -[] - -do - () \ No newline at end of file diff --git a/src/MyWebLog.Data.RethinkDB/MyWebLog.Data.RethinkDB.xproj b/src/MyWebLog.Data.RethinkDB/MyWebLog.Data.RethinkDB.xproj deleted file mode 100644 index c31a3b8..0000000 --- a/src/MyWebLog.Data.RethinkDB/MyWebLog.Data.RethinkDB.xproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - d6c2be5e-883a-4f34-9905-b730543ca380 - MyWebLog.Data.RethinkDB - .\obj - .\bin\ - v4.5.2 - - - - 2.0 - - - diff --git a/src/MyWebLog.Data.RethinkDB/project.json b/src/MyWebLog.Data.RethinkDB/project.json deleted file mode 100644 index 5dd1369..0000000 --- a/src/MyWebLog.Data.RethinkDB/project.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "buildOptions": { - "compilerName": "fsc", - "compile": { - "includeFiles": [ - "AssemblyInfo.fs", - "Extensions.fs", - "Table.fs", - "DataConfig.fs", - "Category.fs", - "Page.fs", - "Post.fs", - "User.fs", - "WebLog.fs", - "SetUp.fs", - "RethinkMyWebLogData.fs" - ] - } - }, - "dependencies": { - "MyWebLog.Entities": "0.9.2", - "RethinkDb.Driver": "2.3.12" - }, - "frameworks": { - "netstandard1.6": { - "imports": "dnxcore50", - "dependencies": { - "Microsoft.FSharp.Core.netcore": "1.0.0-alpha-160629", - "NETStandard.Library": "1.6.0" - } - } - }, - "tools": { - "dotnet-compile-fsc": "1.0.0-preview2-*" - }, - "version": "0.9.2" -} diff --git a/src/MyWebLog.Entities/AssemblyInfo.fs b/src/MyWebLog.Entities/AssemblyInfo.fs deleted file mode 100644 index 1726ea3..0000000 --- a/src/MyWebLog.Entities/AssemblyInfo.fs +++ /dev/null @@ -1,21 +0,0 @@ -namespace MyWebLog.Entities.AssemblyInfo - -open System.Reflection -open System.Runtime.CompilerServices -open System.Runtime.InteropServices - -[] -[] -[] -[] -[] -[] -[] -[] -[] -[] -[] -[] - -do - () \ No newline at end of file diff --git a/src/MyWebLog.Entities/MyWebLog.Entities.xproj b/src/MyWebLog.Entities/MyWebLog.Entities.xproj deleted file mode 100644 index d252434..0000000 --- a/src/MyWebLog.Entities/MyWebLog.Entities.xproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - a87f3cf5-2189-442b-8acf-929f5153ac22 - MyWebLog.Entities - .\obj - .\bin\ - v4.5.2 - - - - 2.0 - - - diff --git a/src/MyWebLog.Entities/project.json b/src/MyWebLog.Entities/project.json deleted file mode 100644 index ce57f52..0000000 --- a/src/MyWebLog.Entities/project.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "buildOptions": { - "compilerName": "fsc", - "compile": { - "includeFiles": [ - "AssemblyInfo.fs", - "Entities.fs", - "IMyWebLogData.fs" - ] - } - }, - "dependencies": { - "Newtonsoft.Json": "9.0.1" - }, - "frameworks": { - "netstandard1.6": { - "dependencies": { - "Microsoft.FSharp.Core.netcore": "1.0.0-alpha-160629", - "NETStandard.Library": "1.6.0" - }, - "imports": "dnxcore50" - } - }, - "tools": { - "dotnet-compile-fsc": "1.0.0-preview2-*" - }, - "version": "0.9.2" -} diff --git a/src/MyWebLog.Logic/AssemblyInfo.fs b/src/MyWebLog.Logic/AssemblyInfo.fs deleted file mode 100644 index cc64863..0000000 --- a/src/MyWebLog.Logic/AssemblyInfo.fs +++ /dev/null @@ -1,21 +0,0 @@ -namespace myWebLog.Data.AssemblyInfo - -open System.Reflection -open System.Runtime.CompilerServices -open System.Runtime.InteropServices - -[] -[] -[] -[] -[] -[] -[] -[] -[] -[] -[] -[] - -do - () \ No newline at end of file diff --git a/src/MyWebLog.Logic/MyWebLog.Logic.xproj b/src/MyWebLog.Logic/MyWebLog.Logic.xproj deleted file mode 100644 index 27a50cf..0000000 --- a/src/MyWebLog.Logic/MyWebLog.Logic.xproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - 29f6eda3-4f43-4bb3-9c63-ae238a9b7f12 - MyWebLog.Logic - .\obj - .\bin\ - v4.5.2 - - - - 2.0 - - - diff --git a/src/MyWebLog.Logic/project.json b/src/MyWebLog.Logic/project.json deleted file mode 100644 index f43f23c..0000000 --- a/src/MyWebLog.Logic/project.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "buildOptions": { - "compilerName": "fsc", - "compile": { - "includeFiles": [ - "AssemblyInfo.fs", - "Category.fs", - "Page.fs", - "Post.fs", - "User.fs", - "WebLog.fs" - ] - } - }, - "dependencies": { - "MyWebLog.Entities": "0.9.2" - }, - "frameworks": { - "netstandard1.6": { - "dependencies": { - "Microsoft.FSharp.Core.netcore": "1.0.0-alpha-160629", - "NETStandard.Library": "1.6.0" - }, - "imports": "dnxcore50" - } - }, - "tools": { - "dotnet-compile-fsc": "1.0.0-preview2-*" - }, - "version": "0.9.2" -} diff --git a/src/MyWebLog.Migrate/Program.fs b/src/MyWebLog.Migrate/Program.fs new file mode 100644 index 0000000..7d6dafd --- /dev/null +++ b/src/MyWebLog.Migrate/Program.fs @@ -0,0 +1,178 @@ +module Program + +open MyWebLog +open MyWebLog.Data.RethinkDB +open MyWebLog.Entities +open Nancy.Cryptography +open Newtonsoft.Json +open Newtonsoft.Json.Linq +open NodaTime +open RethinkDb.Driver +open System +open System.Linq + +let r = RethinkDB.R + +let appCfg = try AppConfig.FromJson (System.IO.File.ReadAllText "config.json") + with ex -> raise <| Exception ("Bad config.json file", ex) +let cfg = appCfg.DataConfig +// DataConfig.Connect +// (JsonConvert.DeserializeObject("""{ "hostname" : "data01", "authKey" : "1d9a76f8-2d85-4033-be15-1f4313a96bb2", "database" : "myWebLog" }""")) +let conn = cfg.Conn +let toTicks (dt : DateTime) = Instant.FromDateTimeUtc(dt.ToUniversalTime()).ToUnixTimeTicks () +/// Hash the user's password +let pbkdf2 (pw : string) = + PassphraseKeyGenerator(pw, appCfg.PasswordSalt, 4096).GetBytes 512 + |> Seq.fold (fun acc byt -> sprintf "%s%s" acc (byt.ToString "x2")) "" + +let migr8 () = + SetUp.startUpCheck cfg + + Console.WriteLine "Migrating web logs..." + + r.Db("MyWebLog").Table(Table.WebLog) + .RunCursor(conn) + |> Seq.iter (fun x -> + r.Db("myWebLog").Table(Table.WebLog) + .Insert({ Id = string x.["id"] + Name = string x.["name"] + Subtitle = Some <| string x.["subtitle"] + DefaultPage = string x.["defaultPage"] + ThemePath = string x.["themePath"] + TimeZone = string x.["timeZone"] + UrlBase = string x.["urlBase"] + PageList = [] + }) + .RunResult(conn) + |> ignore) + + Console.WriteLine "Migrating users..." + + r.Db("MyWebLog").Table(Table.User) + .RunCursor(conn) + |> Seq.iter (fun x -> + r.Db("myWebLog").Table(Table.User) + .Insert({ Id = string x.["id"] + UserName = string x.["userName"] + FirstName = string x.["firstName"] + LastName = string x.["lastName"] + PreferredName = string x.["preferredName"] + PasswordHash = string x.["passwordHash"] + Url = Some <| string x.["url"] + Authorizations = x.["authorizations"] :?> JArray + |> Seq.map (fun y -> { WebLogId = string y.["webLogId"] + Level = string y.["level"] }) + |> Seq.toList + }) + .RunResult(conn) + |> ignore) + + Console.WriteLine "Migrating categories..." + + r.Db("MyWebLog").Table(Table.Category) + .RunCursor(conn) + |> Seq.iter (fun x -> + r.Db("myWebLog").Table(Table.Category) + .Insert({ Id = string x.["id"] + WebLogId = string x.["webLogId"] + Name = string x.["name"] + Slug = string x.["slug"] + Description = match String.IsNullOrEmpty(string x.["description"]) with + | true -> None + | _ -> Some <| string x.["description"] + ParentId = match String.IsNullOrEmpty(string x.["parentId"]) with + | true -> None + | _ -> Some <| string x.["parentId"] + Children = x.["children"] :?> JArray + |> Seq.map (fun y -> string y) + |> Seq.toList + }) + .RunResult(conn) + |> ignore) + + Console.WriteLine "Migrating comments..." + + r.Db("MyWebLog").Table(Table.Comment) + .RunCursor(conn) + |> Seq.iter (fun x -> + r.Db("myWebLog").Table(Table.Comment) + .Insert({ Id = string x.["id"] + PostId = string x.["postId"] + InReplyToId = match String.IsNullOrEmpty(string x.["inReplyToId"]) with + | true -> None + | _ -> Some <| string x.["inReplyToId"] + Name = string x.["name"] + Email = string x.["email"] + Url = match String.IsNullOrEmpty(string x.["url"]) with + | true -> None + | _ -> Some <| string x.["url"] + Status = string x.["status"] + PostedOn = x.["postedDate"].ToObject() |> toTicks + Text = string x.["text"] + }) + .RunResult(conn) + |> ignore) + + Console.WriteLine "Migrating pages..." + + r.Db("MyWebLog").Table(Table.Page) + .RunCursor(conn) + |> Seq.iter (fun x -> + r.Db("myWebLog").Table(Table.Page) + .Insert({ Id = string x.["id"] + WebLogId = string x.["webLogId"] + AuthorId = string x.["authorId"] + Title = string x.["title"] + Permalink = string x.["permalink"] + PublishedOn = x.["publishedDate"].ToObject () |> toTicks + UpdatedOn = x.["lastUpdatedDate"].ToObject () |> toTicks + ShowInPageList = x.["showInPageList"].ToObject() + Text = string x.["text"] + Revisions = [{ AsOf = x.["lastUpdatedDate"].ToObject () |> toTicks + SourceType = RevisionSource.HTML + Text = string x.["text"] + }] + }) + .RunResult(conn) + |> ignore) + + Console.WriteLine "Migrating posts..." + + r.Db("MyWebLog").Table(Table.Post) + .RunCursor(conn) + |> Seq.iter (fun x -> + r.Db("myWebLog").Table(Table.Post) + .Insert({ Id = string x.["id"] + WebLogId = string x.["webLogId"] + AuthorId = "9b491a0f-48df-4b7b-8c10-120b5cd02895" + Status = string x.["status"] + Title = string x.["title"] + Permalink = string x.["permalink"] + PublishedOn = match x.["publishedDate"] with + | null -> int64 0 + | dt -> dt.ToObject () |> toTicks + UpdatedOn = x.["lastUpdatedDate"].ToObject () |> toTicks + Revisions = [{ AsOf = x.["lastUpdatedDate"].ToObject () + |> toTicks + SourceType = RevisionSource.HTML + Text = string x.["text"] + }] + Text = string x.["text"] + Tags = x.["tag"] :?> JArray + |> Seq.map (fun y -> string y) + |> Seq.toList + CategoryIds = x.["category"] :?> JArray + |> Seq.map (fun y -> string y) + |> Seq.toList + PriorPermalinks = [] + Categories = [] + Comments = [] + }) + .RunResult(conn) + |> ignore) + + +[] +let main argv = + migr8 () + 0 // return an integer exit code diff --git a/src/MyWebLog.Migrate/project.json b/src/MyWebLog.Migrate/project.json new file mode 100644 index 0000000..9131f89 --- /dev/null +++ b/src/MyWebLog.Migrate/project.json @@ -0,0 +1,33 @@ +{ + "version": "1.0.0-*", + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true, + "compilerName": "fsc", + "compile": { + "includeFiles": [ + "Program.fs" + ] + } + }, + "dependencies": { + "MyWebLog.App": "0.9.2", + "MyWebLog.Data.RethinkDB": "0.9.2", + "MyWebLog.Entities": "0.9.2", + "NodaTime": "2.0.0-alpha20160729" + }, + "tools": { + "dotnet-compile-fsc":"1.0.0-preview2-*" + }, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + }, + "Microsoft.FSharp.Core.netcore": "1.0.0-alpha-160629" + } + } + } +} diff --git a/src/MyWebLog.Resources/AssemblyInfo.fs b/src/MyWebLog.Resources/AssemblyInfo.fs deleted file mode 100644 index 57a54c7..0000000 --- a/src/MyWebLog.Resources/AssemblyInfo.fs +++ /dev/null @@ -1,25 +0,0 @@ -namespace MyWebLog.Resources.AssemblyInfo - -open System.Resources -open System.Reflection -open System.Runtime.InteropServices - -[] -[] -[] -[] -[] -[] -[] -[] -[] -[] -[] -[] -[] - -do - () - -type HorribleHack() = - member this.Assembly = this.GetType().GetTypeInfo().Assembly diff --git a/src/MyWebLog.Resources/MyWebLog.Resources.xproj b/src/MyWebLog.Resources/MyWebLog.Resources.xproj deleted file mode 100644 index e7bb3b0..0000000 --- a/src/MyWebLog.Resources/MyWebLog.Resources.xproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - A12EA8DA-88BC-4447-90CB-A0E2DCC37523 - MyWebLog.Resources - .\obj - .\bin\ - v4.5.2 - - - - 2.0 - - - diff --git a/src/MyWebLog.Resources/project.json b/src/MyWebLog.Resources/project.json deleted file mode 100644 index c408007..0000000 --- a/src/MyWebLog.Resources/project.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "buildOptions": { - "compilerName": "fsc", - "compile": { - "includeFiles": [ - "AssemblyInfo.fs", - "Library.fs" - ] - }, - "embed": { - "include": [ "en-US.json" ] - } - }, - "dependencies": { - "Newtonsoft.Json": "9.0.1" - }, - "frameworks": { - "netstandard1.6": { - "imports": "dnxcore50", - "dependencies": { - "Microsoft.FSharp.Core.netcore": "1.0.0-alpha-160629", - "NETStandard.Library": "1.6.0" - } - } - }, - "tools": { - "dotnet-compile-fsc": "1.0.0-preview2-*" - }, - "version": "0.9.2" -} diff --git a/src/MyWebLog/project.json b/src/MyWebLog/project.json index d108274..86ea157 100644 --- a/src/MyWebLog/project.json +++ b/src/MyWebLog/project.json @@ -7,10 +7,6 @@ }, "dependencies": { "MyWebLog.App": "0.9.2", - "MyWebLog.Data.RethinkDB": "0.9.2", - "MyWebLog.Entities": "0.9.2", - "MyWebLog.Logic": "0.9.2", - "MyWebLog.Resources": "0.9.2" }, "frameworks": { "netcoreapp1.0": { @@ -23,5 +19,8 @@ "imports": "dnxcore50" } }, + "publishOptions": { + "include": [ "views", "content", "config.json" ] + }, "version": "0.9.2" } diff --git a/src/global.json b/src/global.json index 05d66c1..f0dd758 100644 --- a/src/global.json +++ b/src/global.json @@ -1,10 +1,6 @@ { "projects":[ "MyWebLog", - "MyWebLog.App", - "MyWebLog.Data.RethinkDB", - "MyWebLog.Entities", - "MyWebLog.Logic", - "MyWebLog.Resources" + "MyWebLog.App" ] } \ No newline at end of file diff --git a/src/myWebLog.sln b/src/myWebLog.sln index ff75052..b16adba 100644 --- a/src/myWebLog.sln +++ b/src/myWebLog.sln @@ -2,18 +2,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MyWebLog.Entities", "MyWebLog.Entities\MyWebLog.Entities.xproj", "{A87F3CF5-2189-442B-8ACF-929F5153AC22}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MyWebLog.Data.RethinkDB", "MyWebLog.Data.RethinkDB\MyWebLog.Data.RethinkDB.xproj", "{D6C2BE5E-883A-4F34-9905-B730543CA380}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MyWebLog.Logic", "MyWebLog.Logic\MyWebLog.Logic.xproj", "{29F6EDA3-4F43-4BB3-9C63-AE238A9B7F12}" -EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MyWebLog.App", "MyWebLog.App\MyWebLog.App.xproj", "{9CEA3A8B-E8AA-44E6-9F5F-2095CEED54EB}" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MyWebLog", "MyWebLog\MyWebLog.xproj", "{B9F6DB52-65A1-4C2A-8C97-739E08A1D4FB}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MyWebLog.Resources", "MyWebLog.Resources\MyWebLog.Resources.xproj", "{A12EA8DA-88BC-4447-90CB-A0E2DCC37523}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU