Skip to content

Commit 7a426ed

Browse files
committed
Simple theme to app folder
1 parent fe654ae commit 7a426ed

File tree

9 files changed

+37
-7
lines changed

9 files changed

+37
-7
lines changed

src/App/Pages/Admin/Settings/Themes.cshtml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
}
3030
else
3131
{
32-
<a class="btn-unstyled item-favorite ml-3" href="@lnkSet" data-tooltip="" title="" data-original-title="set as default">
32+
<button class="btn-unstyled item-favorite ml-3" onclick="submitForm('@theme.Title', 'set')" data-tooltip="" title="" data-original-title="set as default">
3333
<i class="far fa-star"></i>
34-
</a>
35-
<a class="item-show ml-4" href="@lnkDel" data-tooltip="" title="" data-original-title="Delete">
34+
</button>
35+
<a class="item-show ml-4" href="" onclick="submitForm('@theme.Title', 'del'); return false" data-tooltip="" title="" data-original-title="Delete">
3636
<i class="fas fa-trash" style="color: #ff6666"></i>
3737
</a>
3838
}
@@ -42,6 +42,10 @@
4242
}
4343
</div>
4444
<!--/Grid -->
45+
<form id="frmThemes" method="post" asp-antiforgery="true">
46+
<input type="hidden" id="hdnTheme" name="hdnTheme" />
47+
<input type="hidden" id="hdnAct" name="hdnAct" />
48+
</form>
4549
</div>
4650
</div>
4751
@section Scripts{
@@ -53,4 +57,11 @@
5357
{
5458
<script>toastr.error('@Model.Error')</script>
5559
}
60+
<script>
61+
var submitForm = function (id, act) {
62+
$("#hdnTheme").val(id);
63+
$("#hdnAct").val(act);
64+
$('#frmThemes').submit();
65+
}
66+
</script>
5667
}

src/App/Pages/Admin/Settings/Themes.cshtml.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,40 @@ public ThemesModel(IDataService db, IStorageService storage, INotificationServic
2626
_ns = ns;
2727
}
2828

29-
public async Task<IActionResult> OnGetAsync(string id, string act)
29+
public async Task<IActionResult> OnGetAsync()
3030
{
3131
var author = await _db.Authors.GetItem(a => a.AppUserName == User.Identity.Name);
3232
IsAdmin = author.IsAdmin;
3333

3434
Notifications = await _ns.GetNotifications(author.Id);
3535

36+
if (!IsAdmin)
37+
return RedirectToPage("../Shared/_Error", new { code = 403 });
38+
39+
BlogItem = await _db.CustomFields.GetBlogSettings();
40+
Themes = GetThemes();
41+
42+
return Page();
43+
}
44+
45+
public async Task<IActionResult> OnPostAsync()
46+
{
47+
string act = Request.Form["hdnAct"];
48+
string id = Request.Form["hdnTheme"];
49+
50+
var author = await _db.Authors.GetItem(a => a.AppUserName == User.Identity.Name);
51+
IsAdmin = author.IsAdmin;
52+
53+
Notifications = await _ns.GetNotifications(author.Id);
54+
3655
if (!IsAdmin)
3756
return RedirectToPage("../Shared/_Error", new { code = 403 });
3857

3958
if (act == "set" && !string.IsNullOrEmpty(id))
4059
{
4160
var theme = _db.CustomFields.Single(f => f.AuthorId == 0 && f.Name == Constants.BlogTheme);
4261

43-
if(theme == null)
62+
if (theme == null)
4463
{
4564
theme = new CustomField { AuthorId = 0, Name = Constants.BlogTheme, Content = id };
4665
_db.CustomFields.Add(theme);
@@ -53,7 +72,7 @@ public async Task<IActionResult> OnGetAsync(string id, string act)
5372
_db.Complete();
5473
}
5574

56-
if(act == "del" && !string.IsNullOrEmpty(id))
75+
if (act == "del" && !string.IsNullOrEmpty(id))
5776
{
5877
var slash = Path.DirectorySeparatorChar.ToString();
5978
var themeContent = $"{AppSettings.WebRootPath}{slash}themes{slash}{id.ToLower()}";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

plugins/Common/Views/Themes/Simple/Shared/_Sidebar.cshtml renamed to src/App/Views/Themes/Simple/Shared/_Sidebar.cshtml

File renamed without changes.

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.1.0.3</Version>
5+
<Version>2.1.0.4</Version>
66
</PropertyGroup>
77

88
<ItemGroup>

0 commit comments

Comments
 (0)