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.
This commit is contained in:
parent
f5b65d320e
commit
33dccf5822
@ -42,7 +42,7 @@ type PostModule (data : IMyWebLogData, clock : IClock) as this =
|
|||||||
let elem name (valu : string) = XElement (xn name, valu)
|
let elem name (valu : string) = XElement (xn name, valu)
|
||||||
let elems =
|
let elems =
|
||||||
items
|
items
|
||||||
|> List.sortBy (fun i -> i.ReleaseDate)
|
|> List.sortByDescending (fun i -> i.ReleaseDate)
|
||||||
|> List.map (fun i ->
|
|> List.map (fun i ->
|
||||||
XElement (
|
XElement (
|
||||||
xn "item",
|
xn "item",
|
@ -1,7 +1,9 @@
|
|||||||
module MyWebLog.Resources.Strings
|
module MyWebLog.Resources.Strings
|
||||||
|
|
||||||
|
open MyWebLog
|
||||||
open Newtonsoft.Json
|
open Newtonsoft.Json
|
||||||
open System.Collections.Generic
|
open System.Collections.Generic
|
||||||
|
open System.Reflection
|
||||||
|
|
||||||
/// The locales we'll try to load
|
/// The locales we'll try to load
|
||||||
let private supportedLocales = [ "en-US" ]
|
let private supportedLocales = [ "en-US" ]
|
||||||
@ -13,7 +15,7 @@ let private fallbackLocale = "en-US"
|
|||||||
let private getEmbedded locale =
|
let private getEmbedded locale =
|
||||||
use rdr =
|
use rdr =
|
||||||
new System.IO.StreamReader
|
new System.IO.StreamReader
|
||||||
(AssemblyInfo.HorribleHack().Assembly.GetManifestResourceStream(sprintf "MyWebLog.Resources.%s.json" locale))
|
(typeof<AppConfig>.GetTypeInfo().Assembly.GetManifestResourceStream(sprintf "MyWebLog.App.%s.json" locale))
|
||||||
rdr.ReadToEnd()
|
rdr.ReadToEnd()
|
||||||
|
|
||||||
/// The dictionary of localized strings
|
/// The dictionary of localized strings
|
@ -4,29 +4,48 @@
|
|||||||
"compile": {
|
"compile": {
|
||||||
"includeFiles": [
|
"includeFiles": [
|
||||||
"AssemblyInfo.fs",
|
"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",
|
"Keys.fs",
|
||||||
"AppConfig.fs",
|
"AppConfig.fs",
|
||||||
|
"Strings.fs",
|
||||||
"ViewModels.fs",
|
"ViewModels.fs",
|
||||||
"ModuleExtensions.fs",
|
"Modules/ModuleExtensions.fs",
|
||||||
"AdminModule.fs",
|
"Modules/AdminModule.fs",
|
||||||
"CategoryModule.fs",
|
"Modules/CategoryModule.fs",
|
||||||
"PageModule.fs",
|
"Modules/PageModule.fs",
|
||||||
"PostModule.fs",
|
"Modules/PostModule.fs",
|
||||||
"UserModule.fs",
|
"Modules/UserModule.fs",
|
||||||
"App.fs"
|
"App.fs"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"embed": {
|
||||||
|
"include": [ "en-US.json" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"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": "2.0.0-barneyrubble",
|
||||||
"Nancy.Authentication.Forms": "2.0.0-barneyrubble",
|
"Nancy.Authentication.Forms": "2.0.0-barneyrubble",
|
||||||
"Nancy.Session.Persistable": "0.9.1-pre",
|
"Nancy.Session.Persistable": "0.9.1-pre",
|
||||||
"Nancy.Session.RethinkDB": "0.9.1-pre",
|
"Nancy.Session.RethinkDB": "0.9.1-pre",
|
||||||
|
"Newtonsoft.Json": "9.0.1",
|
||||||
"NodaTime": "2.0.0-alpha20160729",
|
"NodaTime": "2.0.0-alpha20160729",
|
||||||
|
"RethinkDb.Driver": "2.3.15",
|
||||||
"Suave": "2.0.0-rc2"
|
"Suave": "2.0.0-rc2"
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
namespace myWebLog.Data.AssemblyInfo
|
|
||||||
|
|
||||||
open System.Reflection
|
|
||||||
open System.Runtime.CompilerServices
|
|
||||||
open System.Runtime.InteropServices
|
|
||||||
|
|
||||||
[<assembly: AssemblyTitle("MyWebLog.Data.RethinkDB")>]
|
|
||||||
[<assembly: AssemblyDescription("RethinkDB data access for myWebLog")>]
|
|
||||||
[<assembly: AssemblyConfiguration("")>]
|
|
||||||
[<assembly: AssemblyCompany("DJS Consulting")>]
|
|
||||||
[<assembly: AssemblyProduct("MyWebLog.Data.RethinkDB")>]
|
|
||||||
[<assembly: AssemblyCopyright("Copyright © 2016")>]
|
|
||||||
[<assembly: AssemblyTrademark("")>]
|
|
||||||
[<assembly: AssemblyCulture("")>]
|
|
||||||
[<assembly: ComVisible(false)>]
|
|
||||||
[<assembly: Guid("1fba0b84-b09e-4b16-b9b6-5730dea27192")>]
|
|
||||||
[<assembly: AssemblyVersion("0.9.2.0")>]
|
|
||||||
[<assembly: AssemblyFileVersion("1.0.0.0")>]
|
|
||||||
|
|
||||||
do
|
|
||||||
()
|
|
@ -1,21 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
|
||||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>d6c2be5e-883a-4f34-9905-b730543ca380</ProjectGuid>
|
|
||||||
<RootNamespace>MyWebLog.Data.RethinkDB</RootNamespace>
|
|
||||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
|
||||||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
|
||||||
</Project>
|
|
@ -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"
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
namespace MyWebLog.Entities.AssemblyInfo
|
|
||||||
|
|
||||||
open System.Reflection
|
|
||||||
open System.Runtime.CompilerServices
|
|
||||||
open System.Runtime.InteropServices
|
|
||||||
|
|
||||||
[<assembly: AssemblyTitle("MyWebLog.Entities")>]
|
|
||||||
[<assembly: AssemblyDescription("Entity definitions for myWebLog")>]
|
|
||||||
[<assembly: AssemblyConfiguration("")>]
|
|
||||||
[<assembly: AssemblyCompany("DJS Consulting")>]
|
|
||||||
[<assembly: AssemblyProduct("MyWebLog.Entities")>]
|
|
||||||
[<assembly: AssemblyCopyright("Copyright © 2016")>]
|
|
||||||
[<assembly: AssemblyTrademark("")>]
|
|
||||||
[<assembly: AssemblyCulture("")>]
|
|
||||||
[<assembly: ComVisible(false)>]
|
|
||||||
[<assembly: Guid("c4507e99-478d-4cf6-b20d-767763a62afb")>]
|
|
||||||
[<assembly: AssemblyVersion("0.9.2.0")>]
|
|
||||||
[<assembly: AssemblyFileVersion("1.0.0.0")>]
|
|
||||||
|
|
||||||
do
|
|
||||||
()
|
|
@ -1,21 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
|
||||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>a87f3cf5-2189-442b-8acf-929f5153ac22</ProjectGuid>
|
|
||||||
<RootNamespace>MyWebLog.Entities</RootNamespace>
|
|
||||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
|
||||||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
|
||||||
</Project>
|
|
@ -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"
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
namespace myWebLog.Data.AssemblyInfo
|
|
||||||
|
|
||||||
open System.Reflection
|
|
||||||
open System.Runtime.CompilerServices
|
|
||||||
open System.Runtime.InteropServices
|
|
||||||
|
|
||||||
[<assembly: AssemblyTitle("MyWebLog.Logic")>]
|
|
||||||
[<assembly: AssemblyDescription("Application Logic for myWebLog")>]
|
|
||||||
[<assembly: AssemblyConfiguration("")>]
|
|
||||||
[<assembly: AssemblyCompany("DJS Consulting")>]
|
|
||||||
[<assembly: AssemblyProduct("MyWebLog.Logic")>]
|
|
||||||
[<assembly: AssemblyCopyright("Copyright © 2016")>]
|
|
||||||
[<assembly: AssemblyTrademark("")>]
|
|
||||||
[<assembly: AssemblyCulture("")>]
|
|
||||||
[<assembly: ComVisible(false)>]
|
|
||||||
[<assembly: Guid("a829a243-e095-416e-be12-23490725ef1d")>]
|
|
||||||
[<assembly: AssemblyVersion("0.9.2.0")>]
|
|
||||||
[<assembly: AssemblyFileVersion("1.0.0.0")>]
|
|
||||||
|
|
||||||
do
|
|
||||||
()
|
|
@ -1,21 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
|
||||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>29f6eda3-4f43-4bb3-9c63-ae238a9b7f12</ProjectGuid>
|
|
||||||
<RootNamespace>MyWebLog.Logic</RootNamespace>
|
|
||||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
|
||||||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
|
||||||
</Project>
|
|
@ -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"
|
|
||||||
}
|
|
178
src/MyWebLog.Migrate/Program.fs
Normal file
178
src/MyWebLog.Migrate/Program.fs
Normal file
@ -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<DataConfig>("""{ "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<JObject>(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<JObject>(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<JObject>(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<JObject>(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<DateTime>() |> toTicks
|
||||||
|
Text = string x.["text"]
|
||||||
|
})
|
||||||
|
.RunResult(conn)
|
||||||
|
|> ignore)
|
||||||
|
|
||||||
|
Console.WriteLine "Migrating pages..."
|
||||||
|
|
||||||
|
r.Db("MyWebLog").Table(Table.Page)
|
||||||
|
.RunCursor<JObject>(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<DateTime> () |> toTicks
|
||||||
|
UpdatedOn = x.["lastUpdatedDate"].ToObject<DateTime> () |> toTicks
|
||||||
|
ShowInPageList = x.["showInPageList"].ToObject<bool>()
|
||||||
|
Text = string x.["text"]
|
||||||
|
Revisions = [{ AsOf = x.["lastUpdatedDate"].ToObject<DateTime> () |> toTicks
|
||||||
|
SourceType = RevisionSource.HTML
|
||||||
|
Text = string x.["text"]
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
.RunResult(conn)
|
||||||
|
|> ignore)
|
||||||
|
|
||||||
|
Console.WriteLine "Migrating posts..."
|
||||||
|
|
||||||
|
r.Db("MyWebLog").Table(Table.Post)
|
||||||
|
.RunCursor<JObject>(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<DateTime> () |> toTicks
|
||||||
|
UpdatedOn = x.["lastUpdatedDate"].ToObject<DateTime> () |> toTicks
|
||||||
|
Revisions = [{ AsOf = x.["lastUpdatedDate"].ToObject<DateTime> ()
|
||||||
|
|> 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)
|
||||||
|
|
||||||
|
|
||||||
|
[<EntryPoint>]
|
||||||
|
let main argv =
|
||||||
|
migr8 ()
|
||||||
|
0 // return an integer exit code
|
33
src/MyWebLog.Migrate/project.json
Normal file
33
src/MyWebLog.Migrate/project.json
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,25 +0,0 @@
|
|||||||
namespace MyWebLog.Resources.AssemblyInfo
|
|
||||||
|
|
||||||
open System.Resources
|
|
||||||
open System.Reflection
|
|
||||||
open System.Runtime.InteropServices
|
|
||||||
|
|
||||||
[<assembly: AssemblyTitle("MyWebLog.Resources")>]
|
|
||||||
[<assembly: AssemblyDescription("Resources for the myWebLog package")>]
|
|
||||||
[<assembly: AssemblyConfiguration("")>]
|
|
||||||
[<assembly: AssemblyCompany("")>]
|
|
||||||
[<assembly: AssemblyProduct("MyWebLog.Resources")>]
|
|
||||||
[<assembly: AssemblyCopyright("Copyright © 2016")>]
|
|
||||||
[<assembly: AssemblyTrademark("")>]
|
|
||||||
[<assembly: AssemblyCulture("")>]
|
|
||||||
[<assembly: ComVisible(false)>]
|
|
||||||
[<assembly: Guid("a12ea8da-88bc-4447-90cb-a0e2dcc37523")>]
|
|
||||||
[<assembly: AssemblyVersion("0.9.2.0")>]
|
|
||||||
[<assembly: AssemblyFileVersion("1.0.0.0")>]
|
|
||||||
[<assembly: NeutralResourcesLanguage("en-US")>]
|
|
||||||
|
|
||||||
do
|
|
||||||
()
|
|
||||||
|
|
||||||
type HorribleHack() =
|
|
||||||
member this.Assembly = this.GetType().GetTypeInfo().Assembly
|
|
@ -1,21 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
|
||||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>A12EA8DA-88BC-4447-90CB-A0E2DCC37523</ProjectGuid>
|
|
||||||
<RootNamespace>MyWebLog.Resources</RootNamespace>
|
|
||||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
|
||||||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
|
||||||
</Project>
|
|
@ -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"
|
|
||||||
}
|
|
@ -7,10 +7,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"MyWebLog.App": "0.9.2",
|
"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": {
|
"frameworks": {
|
||||||
"netcoreapp1.0": {
|
"netcoreapp1.0": {
|
||||||
@ -23,5 +19,8 @@
|
|||||||
"imports": "dnxcore50"
|
"imports": "dnxcore50"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"publishOptions": {
|
||||||
|
"include": [ "views", "content", "config.json" ]
|
||||||
|
},
|
||||||
"version": "0.9.2"
|
"version": "0.9.2"
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
{
|
{
|
||||||
"projects":[
|
"projects":[
|
||||||
"MyWebLog",
|
"MyWebLog",
|
||||||
"MyWebLog.App",
|
"MyWebLog.App"
|
||||||
"MyWebLog.Data.RethinkDB",
|
|
||||||
"MyWebLog.Entities",
|
|
||||||
"MyWebLog.Logic",
|
|
||||||
"MyWebLog.Resources"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -2,18 +2,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio 14
|
# Visual Studio 14
|
||||||
VisualStudioVersion = 14.0.25420.1
|
VisualStudioVersion = 14.0.25420.1
|
||||||
MinimumVisualStudioVersion = 10.0.40219.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}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MyWebLog.App", "MyWebLog.App\MyWebLog.App.xproj", "{9CEA3A8B-E8AA-44E6-9F5F-2095CEED54EB}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MyWebLog", "MyWebLog\MyWebLog.xproj", "{B9F6DB52-65A1-4C2A-8C97-739E08A1D4FB}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MyWebLog", "MyWebLog\MyWebLog.xproj", "{B9F6DB52-65A1-4C2A-8C97-739E08A1D4FB}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MyWebLog.Resources", "MyWebLog.Resources\MyWebLog.Resources.xproj", "{A12EA8DA-88BC-4447-90CB-A0E2DCC37523}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Loading…
Reference in New Issue
Block a user