Skip to content

Commit 5b45b7d

Browse files
committed
Linux datetime fix and upgrade feature early preview
1 parent b09ee3a commit 5b45b7d

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

src/App/Pages/Admin/Posts/Edit.cshtml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ public async Task<IActionResult> OnPostAsync()
7070
if (PostItem.Status == SaveStatus.Unpublishing)
7171
PostItem.Published = DateTime.MinValue;
7272

73+
// fix for linux default datetime
74+
if (PostItem.Published == DateTime.Parse("1/1/2001"))
75+
PostItem.Published = DateTime.MinValue;
76+
7377
PostItem.Slug = await GetSlug(PostItem.Id, PostItem.Title);
7478

7579
var item = await _db.BlogPosts.SaveItem(PostItem);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
@page
2+
@model App.Pages.Admin.Upgrade.UpgradeModel
3+
@{
4+
Layout = null;
5+
}
6+
<!DOCTYPE html>
7+
<html>
8+
<head>
9+
<title>Blogifier upgrade</title>
10+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css">
11+
</head>
12+
<body>
13+
<div class="container">
14+
<br />
15+
<form method="post" asp-antiforgery="true">
16+
<div class="jumbotron">
17+
<h1>Upgrade to version 2.1</h1>
18+
<p>
19+
You running Blogifier version 2.0. There new version 2.1 is <a href="#">available in the repository</a>. You can upgrade to new version manually or just click button below and run in-place upgrade process.
20+
</p>
21+
<p>
22+
Please do <b>back up your data</b> before running upgrade, manual or automatic - if something goes wrong it's always good to have a fallback plan!
23+
</p>
24+
@if (Model.IsUpgrading)
25+
{
26+
<div class="alert alert-success" role="alert">
27+
Upgrade process has started and might take few minutes to run, depending on your server power and blog size. Once completed, aplication will start again.
28+
</div>
29+
}
30+
else
31+
{
32+
<p id="action-buttons">
33+
<button type="submit" onclick="runUpgrade()" class="btn btn-lg btn-primary">Upgrade now</button>
34+
<a class="btn btn-lg btn-default" href="~/admin" role="button">Cancel</a>
35+
</p>
36+
}
37+
</div>
38+
</form>
39+
</div>
40+
</body>
41+
</html>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Microsoft.AspNetCore.Hosting;
2+
using System.Diagnostics;
3+
4+
namespace App.Pages.Admin.Upgrade
5+
{
6+
public class UpgradeModel : AdminPageModel
7+
{
8+
private IApplicationLifetime ApplicationLifetime { get; set; }
9+
10+
public bool IsUpgrading = false;
11+
12+
public UpgradeModel(IApplicationLifetime appLifetime)
13+
{
14+
ApplicationLifetime = appLifetime;
15+
}
16+
17+
public void OnGet()
18+
{
19+
// check for newer version
20+
}
21+
22+
public void OnPost()
23+
{
24+
IsUpgrading = true;
25+
26+
// Download new version
27+
//string zipPath = @"c:\demo\foo.zip";
28+
//string extractPath = @"c:\demo\extract";
29+
//ZipFile.ExtractToDirectory(zipPath, extractPath);
30+
31+
// start upgrade process
32+
//Process p = new Process();
33+
//p.StartInfo.FileName = "dotnet";
34+
//p.StartInfo.Arguments = "upgrade.dll";
35+
//p.StartInfo.UseShellExecute = false;
36+
//p.StartInfo.CreateNoWindow = false;
37+
38+
//p.Start();
39+
ApplicationLifetime.StopApplication();
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)