Skip to content

Commit

Permalink
GUI Updates..
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerlrhodes committed Nov 26, 2017
1 parent 99523b0 commit 8a46447
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 44 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,5 @@ ModelManifest.xml
/src/blog/Logs
/src/bagombo/Logs
/src/bagombo/Logs
/src/Bagombo/bower_components
/src/Bagombo/bower_components
/src/Bagombo/PostImages
1 change: 1 addition & 0 deletions src/Bagombo.Data/Models/ViewModels/Home/HomeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Bagombo.Models.ViewModels.Home
{
public class HomeViewModel
{
public IEnumerable<Category> Categories { get; set; }
public PaginatedList<BlogPost> RecentPosts { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/Bagombo/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ public async Task<IActionResult> Index(int? page)

var recentPosts = await _qpa.ProcessAsync(gbpfhp);

var categories = await _qpa.ProcessAsync(new GetCategoriesQuery());

var vhvm = new HomeViewModel()
{
Categories = categories,
RecentPosts = recentPosts
};

Expand Down
2 changes: 1 addition & 1 deletion src/Bagombo/Settings/BagomboSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class BagomboSettings
public string CopyRight { get; set; } = "Change me";
public string Description { get; set; } = "A technical blog on various topics";
public string ContactEmail { get; set; } = "[email protected]";
public int PostsOnHomePage { get; set; } = 8;
public int PostsOnHomePage { get; set; } = 6;
public int LinesPerPost { get; set; } = 5;
public string PostImagesRelativePath { get; set; } = "PostImages";
}
Expand Down
2 changes: 1 addition & 1 deletion src/Bagombo/Views/Home/BlogPost.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<div class="card-header">
Add Comment:
</div>
<div class="card-body p-3">
<div class="card-body p-3 mb-2">
<div asp-validation-summary="All" class="text-danger"></div>
<form asp-action="AddComment" method="post">
<input asp-for="Id" type="hidden" />
Expand Down
53 changes: 35 additions & 18 deletions src/Bagombo/Views/Home/CategoryPosts.cshtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@

@using Bagombo.Models.ViewModels.Home
@using Microsoft.Extensions.Options
@using CommonMark
@model CategoryPostsViewModel

@inject IOptions<BagomboSettings> _settings

@{
ViewData["Title"] = $"Posts for Category {Model.Category.Name}";
Layout = "_Layout";
Expand All @@ -10,30 +14,43 @@
<div class="container">
<div class="row">
<div class="col-md-12">
<h3>Posts for <span class="badge badge-primary">@Model.Category.Name</span></h3>
<h3>Posts for @Model.Category.Name</h3>
<hr />
</div>
</div>
@foreach (var post in Model.Posts)
@foreach (var bp in Model.Posts)
{
<div class="row">
<div class="col-md-12">
<div class="card mb-3">
<div class="card-body">
<h3>
<a asp-action="BlogPost" asp-route-id="@post.Id">@post.Title</a>
</h3>
<h5>
Author: @post.Author.FirstName @post.Author.LastName
</h5>
<hr />
<h5>
@post.Description
</h5>
<div class="row">
<div class="col-12">
<div class="card mb-3">
<div class="card-header">
<a asp-action="BlogPost" asp-route-id="@bp.Id">@bp.Title</a> by @bp.Author.FirstName @bp.Author.LastName on @bp.PublishOn
@if (bp.Comments != null)
{
<div class="float-right">@bp.Comments?.Count() Comments</div>
}
</div>
<div class="card-body pl-0">
<div class="container">
<div class="row">
<div class="col-12 pl-4">
@{
var content = bp.Content.Split('\n')
.Where(line => !line.Contains("<pre><code"))
.Where(line => !line.Contains("</code></pre>"))
.Take(_settings.Value.LinesPerPost);
var contentString = string.Join('\n', content);
}
@Html.Raw(CommonMarkConverter.Convert(contentString))
<div class="float-right">
<a asp-action="BlogPost" asp-route-id="@bp.Id">Read more</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

</div>
}
</div>
52 changes: 29 additions & 23 deletions src/Bagombo/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,29 @@
}

<div class="container">
@if (Model.RecentPosts.PageIndex == 1)
{
<div class="row mb-2">
<div class="col-md-12 mb-0 pb-0">
<div class="jumbotron mb-2 pt-5 pb-5">
<h4><strong>Bagombo Blog Engine (alpha release)</strong></h4>
<div class="container p-0">
<div class="row">
<div class="col-md-9">
<p>
The Bagombo Blog Engine is a free ASP.NET Core based blogging engine with support for multiple authors and editing in Markdown.
</p>
</div>
<div class="col-md-3">
<a class="btn btn-primary btn-lg" href="https://github.com/tylerlrhodes/bagombo/releases" role="button">Download 0.2.5a</a>
</div>
</div>

<div class="row mt-0">

<div class="col-md-10 col-12 mt-0">
@if (Model.RecentPosts.PageIndex == 1)
{
<div class="jumbotron mb-3 pt-5 pb-5">
<h4><strong>Bagombo Blog Engine (alpha release)</strong></h4>
<div class="container p-0">
<div class="row">
<div class="col-md-9">
<p>
The Bagombo Blog Engine is a free ASP.NET Core based blogging engine with support for multiple authors and editing in Markdown.

</p>
</div>
<div class="col-md-3">
<a class="btn btn-primary btn-lg" href="https://github.com/tylerlrhodes/bagombo/releases" role="button">Download 0.2.5a</a>
</div>
</div>
</div>
</div>
</div>
}
<div class="row mt-0">
<div class="col-md-12 mt-0">
}
@foreach (var bp in Model.RecentPosts)
{
<div class="card mb-3">
Expand Down Expand Up @@ -89,9 +87,17 @@
</div>
}
</div>
<div class="col-md-2 col-12">
<div class="mb-2" style="font-size: 1.3rem; white-space: pre-wrap">Categories</div>
@foreach (var category in Model.Categories)
{
<div class="mb-2" style="font-size: 1.3rem; white-space: pre-wrap"><a asp-action="CategoryPosts" asp-route-id="@category.Id">@category.Name</a></div>

}
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="col-md-10 col-12">
@{
var hasPrevious = Model.RecentPosts.HasPreviousPage ? "" : "disabled";
var hasNext = Model.RecentPosts.HasNextPage ? "" : "disabled";
Expand Down

0 comments on commit 8a46447

Please sign in to comment.