forked from rayrfan/Fanray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Add categories, tags, archives, header, footer and analytic…
…s view components rayrfan#224
- Loading branch information
Ray Fan
authored and
Ray Fan
committed
Sep 27, 2018
1 parent
98e8f09
commit 2b5947d
Showing
19 changed files
with
376 additions
and
123 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Fan.Blog.Services; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System.Threading.Tasks; | ||
|
||
namespace Fan.Blog.ViewComponents | ||
{ | ||
/// <summary> | ||
/// The BlogArchives view component. | ||
/// </summary> | ||
public class BlogArchivesViewComponent : ViewComponent | ||
{ | ||
private readonly IBlogService _blogSvc; | ||
public BlogArchivesViewComponent(IBlogService blogService) | ||
{ | ||
_blogSvc = blogService; | ||
} | ||
|
||
public async Task<IViewComponentResult> InvokeAsync() | ||
{ | ||
var years = await _blogSvc.GetArchivesAsync(); | ||
return View(years); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/Fan.Blog/ViewComponents/BlogCategoriesViewComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Fan.Blog.Services; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Fan.Blog.ViewComponents | ||
{ | ||
/// <summary> | ||
/// The BlogCategories view component. | ||
/// </summary> | ||
public class BlogCategoriesViewComponent : ViewComponent | ||
{ | ||
private readonly IBlogService _blogSvc; | ||
public BlogCategoriesViewComponent(IBlogService blogService) | ||
{ | ||
_blogSvc = blogService; | ||
} | ||
|
||
public async Task<IViewComponentResult> InvokeAsync() | ||
{ | ||
var cats = (await _blogSvc.GetCategoriesAsync()).Where(t => t.Count > 0); | ||
return View(cats); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Fan.Blog.Services; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Fan.Blog.ViewComponents | ||
{ | ||
/// <summary> | ||
/// The BlogTags view component. | ||
/// </summary> | ||
public class BlogTagsViewComponent : ViewComponent | ||
{ | ||
private readonly IBlogService _blogSvc; | ||
public BlogTagsViewComponent(IBlogService blogService) | ||
{ | ||
_blogSvc = blogService; | ||
} | ||
|
||
/// <summary> | ||
/// Returns the default view for BlogTags. TODO provide param for things like sorting. | ||
/// </summary> | ||
/// <returns></returns> | ||
public async Task<IViewComponentResult> InvokeAsync() | ||
{ | ||
var tags = (await _blogSvc.GetTagsAsync()).Where(t => t.Count > 0); | ||
return View(tags); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Fan.Web/Themes/Clarity/Views/Shared/Components/Analytics/Default.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@model AnalyticsViewModel | ||
|
||
@if (!Model.GoogleAnalyticsTrackingID.IsNullOrEmpty()) | ||
{ | ||
<!-- Global site tag (gtag.js) - Google Analytics --> | ||
<script async src="@string.Format("https://www.googletagmanager.com/gtag/js?id={0}", Model.GoogleAnalyticsTrackingID)"></script> | ||
<script> | ||
window.dataLayer = window.dataLayer || []; | ||
function gtag(){dataLayer.push(arguments);} | ||
gtag('js', new Date()); | ||
gtag('config', '@Model.GoogleAnalyticsTrackingID'); | ||
</script> | ||
} | ||
|
||
@Html.Raw(Model.AppInsightsFullScript) |
18 changes: 18 additions & 0 deletions
18
src/Fan.Web/Themes/Clarity/Views/Shared/Components/BlogArchives/Default.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@model Dictionary<int, List<MonthItem>> | ||
|
||
<ul class="month-list"> | ||
@foreach (var year in Model) | ||
{ | ||
<li class="year"> | ||
@year.Key | ||
<ul class="months"> | ||
@foreach (var item in year.Value) | ||
{ | ||
<li> | ||
<a href="@item.Url">@item.Title</a> (@item.Count) | ||
</li> | ||
} | ||
</ul> | ||
</li> | ||
} | ||
</ul> |
13 changes: 13 additions & 0 deletions
13
src/Fan.Web/Themes/Clarity/Views/Shared/Components/BlogCategories/Default.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@model IEnumerable<Category> | ||
|
||
<ul class="widget-categories"> | ||
@foreach (var t in Model) | ||
{ | ||
<li> | ||
<a href="@t.RssRelativeLink"> | ||
<i class="icon-rss" aria-hidden="true" style="color:orange"></i> | ||
</a> | ||
<a title="@t.Description" href="@t.RelativeLink">@t.Title (@t.Count)</a> | ||
</li> | ||
} | ||
</ul> |
11 changes: 11 additions & 0 deletions
11
src/Fan.Web/Themes/Clarity/Views/Shared/Components/BlogTags/Default.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@model IEnumerable<Tag> | ||
|
||
<ul class="widget-tags"> | ||
@foreach (var t in Model) | ||
{ | ||
<li> | ||
<a class="tag" rel="tag" title="@t.Description" href="@t.RelativeLink" style="background-color:@t.Color;">@t.Title</a> | ||
<span class="tag-multiplier">× @t.Count</span> | ||
</li> | ||
} | ||
</ul> |
8 changes: 8 additions & 0 deletions
8
src/Fan.Web/Themes/Clarity/Views/Shared/Components/Footer/Default.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@model CoreSettings | ||
|
||
<footer class="footer"> | ||
<div class="container"> | ||
<span class="text-muted pull-left">© @DateTime.Now.Year @Model.Title</span> | ||
<span class="text-muted pull-right">Powered by <a href="https://github.com/FanrayMedia/Fanray"><strong>Fanray</strong></a> <text>v</text>@SysVersion.CurrentVersion</span> | ||
</div> | ||
</footer> |
30 changes: 30 additions & 0 deletions
30
src/Fan.Web/Themes/Clarity/Views/Shared/Components/Header/Default.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
@model HeaderViewModel | ||
|
||
<div class="d-flex flex-column flex-md-row align-items-center px-md-4 pt-2 pb-0 pt-sm-2 pb-sm-0 py-md-2 py-lg-2 py-xl-2 mb-3 bg-white border-bottom box-shadow"> | ||
<h5 class="my-0 mr-md-auto font-weight-normal p-0 px-3 pl-md-0 pl-lg-0"> | ||
<a class="brand" href="/">@Model.Title</a> <small class="text-muted d-none d-sm-block" style="font-size:small;font-style:italic">@Model.Tagline</small> | ||
</h5> | ||
<nav class="navbar my-md-0 mr-md-3 mb-sm-0 p-0"> | ||
<a class="p-2 text-dark" href="/">Home</a> | ||
@if (Model.IsSignedIn) | ||
{ | ||
<a class="p-2 text-dark" href="/admin">Admin</a> | ||
<div class="dropdown"> | ||
<a class="nav-link" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | ||
<img gravatar-email="@Model.CurrentUser.Email" title="@Model.CurrentUser.DisplayName" class="avatar" /> | ||
</a> | ||
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown"> | ||
<a class="dropdown-item" href="/admin/compose"><i class="icon-pencil-square-o" aria-hidden="true"></i> Write</a> | ||
<div class="dropdown-divider"></div> | ||
<form asp-area="" asp-controller="Account" asp-action="Logout" method="post" id="logoutForm"> | ||
<button type="submit" class="dropdown-item btn btn-link navbar-btn navbar-link"><i class="icon-power-off" aria-hidden="true"></i> Logout</button> | ||
</form> | ||
</div> | ||
</div> | ||
} | ||
else | ||
{ | ||
<a class="p-2 text-dark" href="/login">Login</a> | ||
} | ||
</nav> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<div class="widgets"> | ||
<div class="widget"> | ||
<h4 class="widget-header">RSS</h4> | ||
<div class="widget-content"> | ||
<div class="social-icons"> | ||
<a href="/feed" style="font-size:28px"> | ||
<i class="icon-rss" aria-hidden="true" style="color:orange"></i> | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="widget"> | ||
<h4 class="widget-header">Tags</h4> | ||
<div class="widget-content"> | ||
@await Component.InvokeAsync("BlogTags") | ||
</div> | ||
</div> | ||
<div class="widget"> | ||
<h4 class="widget-header">Categories</h4> | ||
<div class="widget-content"> | ||
@await Component.InvokeAsync("BlogCategories") | ||
</div> | ||
</div> | ||
<div class="widget"> | ||
<h4 class="widget-header">Archives</h4> | ||
<div class="widget-content"> | ||
@await Component.InvokeAsync("BlogArchives") | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.