Skip to content

Commit 3c469db

Browse files
committed
PostList widget updates
1 parent 7aadb20 commit 3c469db

File tree

5 files changed

+34
-13
lines changed

5 files changed

+34
-13
lines changed
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
<div>
2-
This post is from PostList widget loaded from external class library.
1+
@model IEnumerable<BlogPost>
2+
<div class="list-group">
3+
@foreach (var post in Model)
4+
{
5+
<a href="~/posts/@post.Slug" class="list-group-item list-group-item-action" title="">@post.Title</a>
6+
}
37
</div>

plugins/Common/Widgets/PostList.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
using Microsoft.AspNetCore.Mvc;
1+
using Core.Services;
2+
using Microsoft.AspNetCore.Mvc;
23

34
namespace Common.Widgets
45
{
56
[ViewComponent(Name = "PostList")]
67
public class PostList : ViewComponent
78
{
8-
public PostList()
9+
IDataService _db;
10+
11+
public PostList(IDataService db)
912
{
13+
_db = db;
1014
}
1115

1216
public IViewComponentResult Invoke()
1317
{
14-
return View("~/Views/Widgets/PostList/Index.cshtml");
18+
var model = _db.BlogPosts.All();
19+
20+
return View("~/Views/Widgets/PostList/Index.cshtml", model);
1521
}
1622
}
1723
}

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,36 @@
33
@{
44
ViewData["Title"] = "Users";
55
}
6-
76
<style>
87
.modal-body .row {
98
line-height: 2.5em;
109
border-bottom: 1px solid #efefef;
1110
}
11+
.post-grid-col { max-width: 200px !important }
1212
</style>
1313
<div class="bf-main">
1414
<partial name="~/Pages/Admin/Settings/_Taskbar.cshtml" />
1515
<div class="bf-body">
16-
<div class="bf-content bf-content-boxed bf-settings">
16+
<!-- Grid -->
17+
<div class="bf-posts-grid d-flex" aria-label="posts">
1718
@foreach (var user in Model.Authors)
1819
{
1920
var avatar = user.Avatar ?? AppSettings.Avatar;
20-
<div class="card" style="width: 130px; margin: 10px 5px 0 0; float: left">
21-
<img class="card-img-top" style="height: 130px; overflow: hidden" src="~/@avatar" alt="@avatar" />
22-
<div class="card-body">
23-
<p style="text-align: center">
24-
<a href="~/admin/settings/profile?name=@user.AppUserName">@user.AppUserName</a>
25-
</p>
21+
var img = $"{Url.Content("~/")}{avatar}";
22+
<div class="post-grid-col">
23+
<div class="post-grid-item">
24+
<a class="item-link" style="background-image:url(@img);"><div class="item-title mt-auto">&nbsp;</div></a>
25+
<div class="item-info d-flex align-items-center">
26+
<span class="item-date mr-auto">@user.DisplayName</span>
27+
<a href="~/admin/settings/profile?name=@user.AppUserName" class="btn-unstyled item-favorite ml-3" data-tooltip="" title="" data-original-title="Profile">
28+
<i class="fas fa-external-link-square-alt"></i>
29+
</a>
30+
</div>
2631
</div>
2732
</div>
2833
}
2934
</div>
35+
<!--/Grid -->
3036
</div>
3137
</div>
3238

src/App/Views/Themes/Simple/Shared/_Sidebar.cshtml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,9 @@
2525
<div class="card-body">
2626
@await Component.InvokeAsync("HtmlBlock", new { theme = "Simple", widget = "Sidebar" })
2727
</div>
28+
</div>
29+
30+
<div class="card my-4">
31+
<h5 class="card-header">Post List</h5>
32+
@await Component.InvokeAsync("PostList", new { theme = "Simple", widget = "Post List" })
2833
</div>

src/App/app.db

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)