Skip to content

Commit 0a5c433

Browse files
committed
Cleanup in app settings
1 parent 1e0747c commit 0a5c433

File tree

12 files changed

+14
-68
lines changed

12 files changed

+14
-68
lines changed

docs/AppSettings.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
11
Global application settings saved in the `appsettings.json` file.
2-
It is read/write so, when admin updates settings in UI, they also written in the file.
3-
When file is updated, admin screen will also pull updated value from the file.
42

53
```
64
"Blogifier": {
75
"DbProvider": "SQLite",
86
"ConnString": "DataSource=app.db",
9-
"Title": "Blog title",
10-
"Description": "Short description of the blog",
11-
"Cover": "data/admin/cover-desk.jpg",
12-
"Logo": "lib/img/logo-white.png",
137
"Avatar": "lib/img/avatar.jpg",
14-
"Theme": "Standard",
15-
"BlogThemes": null,
16-
"ItemsPerPage": 10,
17-
"UseDescInPostList": true,
188
"ImportTypes": "zip,7z,xml,pdf,doc,docx,xls,xlsx,mp3,avi",
199
"ImageExtensions": "png,jpg,gif,bmp,tiff",
2010
"DemoMode": true
@@ -27,9 +17,7 @@ Most settings are self-explanatory, here some that might require clarification:
2717

2818
`DbProvider` and `ConnectionString` are used when you need to switch to another database, like MS SQL Server or PostgreSQL
2919

30-
`ItemsPerPage` sets page size for all lists in application, so everything that requires paging will use it
31-
32-
`UseDescInPostList` when set to `true` returns post description instead of content in the post lists
20+
`ItemsPerPage` sets page size for all lists in the application, so everything that requires paging will use it
3321

3422
`ImportTypes` defines what type of files should be downloaded when importing posts from RSS feed
3523

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<link href="~/admin/markdown/simplemde.min.css" rel="stylesheet" />
88
@{
9-
var img = string.IsNullOrEmpty(Model.PostItem.Cover) ? Core.AppSettings.DefaultCover : Model.PostItem.Cover;
9+
var img = string.IsNullOrEmpty(Model.PostItem.Cover) ? Model.Blog.Cover : Model.PostItem.Cover;
1010
img = $"{Url.Content("~/")}{img}";
1111
var btnDisabled = Model.PostItem.Id == 0 ? "disabled" : "";
1212
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class EditModel : AdminPageModel
1212
{
1313
[BindProperty]
1414
public PostItem PostItem { get; set; }
15+
public BlogItem Blog { get; set; }
1516

1617
IDataService _db;
1718
INotificationService _ns;
@@ -29,8 +30,8 @@ public async Task OnGetAsync(int id)
2930

3031
Notifications = await _ns.GetNotifications(author.Id);
3132

32-
var blog = await _db.CustomFields.GetBlogSettings();
33-
PostItem = new PostItem { Author = author, Cover = blog.Cover };
33+
Blog = await _db.CustomFields.GetBlogSettings();
34+
PostItem = new PostItem { Author = author, Cover = Blog.Cover };
3435

3536
if (id > 0)
3637
PostItem = await _db.BlogPosts.GetItem(p => p.Id == id);

src/App/Pages/Admin/Posts/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
@foreach (var post in Model.Posts)
4747
{
4848
var dt = post.Published == DateTime.MinValue ? "DRAFT" : post.Published.ToFriendlyShortDateString();
49-
var img = string.IsNullOrEmpty(post.Cover) ? Core.AppSettings.DefaultCover : post.Cover;
49+
var img = string.IsNullOrEmpty(post.Cover) ? Model.Blog.Cover : post.Cover;
5050
img = $"{Url.Content("~/")}{img}";
5151
<div class="post-grid-col">
5252
<div class="post-grid-item">

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class IndexModel : AdminPageModel
1414
[BindProperty]
1515
public IEnumerable<PostItem> Posts { get; set; }
1616
public Pager Pager { get; set; }
17+
public BlogItem Blog { get; set; }
1718

1819
IDataService _db;
1920
INotificationService _ns;
@@ -51,8 +52,8 @@ public async Task<IActionResult> OnGetAsync(int pg = 1, string status = "A")
5152
}
5253

5354
Posts = await _db.BlogPosts.GetList(predicate, Pager);
54-
5555
Notifications = await _ns.GetNotifications(author.Id);
56+
Blog = await _db.CustomFields.GetBlogSettings();
5657

5758
return Page();
5859
}

src/App/Views/Themes/Standard/List.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
{
4545
foreach (var item in Model.Posts)
4646
{
47-
var img = string.IsNullOrEmpty(item.Cover) ? AppSettings.DefaultCover : item.Cover;
47+
var img = string.IsNullOrEmpty(item.Cover) ? Model.Blog.Cover : item.Cover;
4848
<article class="post">
4949
<div class="post-cover">
5050
<img src="~/@img" alt="@item.Title">

src/App/app.db

0 Bytes
Binary file not shown.

src/Core/AppSettings.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
11
using Microsoft.EntityFrameworkCore;
22
using System;
3-
using System.Collections.Generic;
43
using System.Reflection;
54

65
namespace Core
76
{
87
public class AppSettings
98
{
10-
public static string Title { get; set; }
11-
public static string Description { get; set; }
12-
public static string Theme { get; set; }
13-
14-
public static string Logo { get; set; }
159
public static string Avatar { get; set; }
16-
public static string Cover { get; set; }
17-
18-
public static int ItemsPerPage { get; set; }
19-
public static bool UseDescInPostList { get; set; }
20-
public static string DefaultCover { get; set; }
21-
2210
public static string ImportTypes { get; set; }
2311
public static string ImageExtensions { get; set; }
2412
public static bool DemoMode { get; set; }

src/Core/Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>netcoreapp2.1</TargetFramework>
5-
<Version>2.0.2.6</Version>
5+
<Version>2.0.2.7</Version>
66
</PropertyGroup>
77

88
<ItemGroup>

src/Core/Extensions/ServiceCollectionExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ public static class ServiceCollectionExtensions
2020
services.Configure<T>(section);
2121
services.AddTransient<IAppService<T>>(provider =>
2222
{
23-
var environment = provider.GetService<IHostingEnvironment>();
2423
var options = provider.GetService<IOptionsMonitor<T>>();
25-
return new AppService<T>(environment, options, section.Key);
24+
return new AppService<T>(options);
2625
});
2726
}
2827

0 commit comments

Comments
 (0)