forked from blogifierdotnet/Blogifier
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
1,597 additions
and
4 deletions.
There are no files selected for viewing
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
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,40 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Razor"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<Version>1.0.1.0</Version> | ||
<RazorLangVersion>3.0</RazorLangVersion> | ||
<Authors>blogifierdotnet</Authors> | ||
<Company>Blogifier.Net</Company> | ||
<Description>Blogifier.Widgets provides shared Blazor widgets comonents to Blogifier blog</Description> | ||
<Copyright>Blogifier.net</Copyright> | ||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | ||
<PackageProjectUrl>http://blogifier.net</PackageProjectUrl> | ||
<PackageIcon>icon.png</PackageIcon> | ||
<RepositoryUrl>https://github.com/blogifierdotnet/Blogifier.Widgets</RepositoryUrl> | ||
<PackageTags>blogifier,blog,blazor,asp.net,asp.core,widgets</PackageTags> | ||
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Blogifier.Core" Version="2.5.5" /> | ||
<PackageReference Include="Demo.BlazorChartist" Version="0.1.0-20200124.1" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.1" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.1" /> | ||
<PackageReference Include="Markdig" Version="0.18.0" /> | ||
<PackageReference Include="Sotsera.Blazor.Toaster" Version="3.0.0" /> | ||
<PackageReference Include="Askmethat.Aspnet.JsonLocalizer" Version="2.2.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="..\..\LICENSE"> | ||
<Pack>True</Pack> | ||
<PackagePath></PackagePath> | ||
</None> | ||
<None Include="wwwroot\icon.png"> | ||
<Pack>True</Pack> | ||
<PackagePath></PackagePath> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
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,35 @@ | ||
@using Askmethat.Aspnet.JsonLocalizer.Localizer | ||
@inject IJsonStringLocalizer<Profile> Localizer | ||
|
||
<div class="card dash custom"> | ||
<div class="card-body"> | ||
@((MarkupString)@FieldValue.MdToHtml()) | ||
<button class="btn primary" style="float:right" @onclick="ShowEditor"><span class="oi oi-pencil"></span></button> | ||
</div> | ||
</div> | ||
|
||
@if (Visible) | ||
{ | ||
<div class="editor-modal-bg"> | ||
<div class="editor-modal-content"> | ||
<div class="modal-actions"> | ||
<ul class="nav nav-tabs" id="post-edit-tabs" role="tablist"> | ||
<li class="nav-item"> | ||
<a class="nav-link active" id="edit-tab" data-toggle="tab" href="#edit" role="tab" aria-controls="edit" aria-selected="true">@Localizer["custom-field"]</a> | ||
</li> | ||
</ul> | ||
<div class="btn-group post-options" role="group" aria-label="Post options"> | ||
<button class="btn btn-secondary" @onclick="Save" @onclick:preventDefault> | ||
<span class="oi oi-check"></span> @Localizer["save"] | ||
</button> | ||
<button class="btn btn-secondary btn-close" @onclick="HideEditor"> | ||
<span class="oi oi-x"></span> | ||
</button> | ||
</div> | ||
</div> | ||
<div class="profile-outer"> | ||
<MdEditor Content="@FieldValue" /> | ||
</div> | ||
</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using Blogifier.Core.Services; | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.JSInterop; | ||
using Sotsera.Blazor.Toaster; | ||
using System.Threading.Tasks; | ||
|
||
namespace Blogifier.Widgets | ||
{ | ||
public partial class Custom : ComponentBase | ||
{ | ||
[Inject] | ||
protected IJSRuntime JSRuntime { get; set; } | ||
[Inject] | ||
protected IDataService DataService { get; set; } | ||
[Inject] | ||
protected IToaster Toaster { get; set; } | ||
|
||
private string FieldKey = "admin-dashboard-sidebar"; | ||
protected bool Visible { get; set; } | ||
protected string FieldValue { get; set; } | ||
|
||
protected void ShowEditor() | ||
{ | ||
Visible = true; | ||
StateHasChanged(); | ||
} | ||
|
||
protected void HideEditor() | ||
{ | ||
Visible = false; | ||
StateHasChanged(); | ||
} | ||
|
||
protected override void OnInitialized() | ||
{ | ||
FieldValue = DataService.CustomFields.GetCustomValue(FieldKey); | ||
StateHasChanged(); | ||
} | ||
|
||
protected async Task Save() | ||
{ | ||
FieldValue = await JSRuntime.InvokeAsync<string>("commonJsFunctions.getEditorValue", ""); | ||
await DataService.CustomFields.SaveCustomValue(FieldKey, FieldValue); | ||
|
||
StateHasChanged(); | ||
Toaster.Success("Updated"); | ||
} | ||
} | ||
} |
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,9 @@ | ||
<div class="card"> | ||
<div class="card-body"> | ||
<h4>Disqus</h4> | ||
<textarea class="form-control txt-disqus" rows="3" @bind="DisqusValue" name="disqus" placeholder="Disqus script" /> | ||
<div class="btn-group" role="group" aria-label="Disqus"> | ||
<button class="btn btn-primary" @onclick="Save">Save</button> | ||
</div> | ||
</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Blogifier.Core.Services; | ||
using Microsoft.AspNetCore.Components; | ||
using Sotsera.Blazor.Toaster; | ||
using System.Threading.Tasks; | ||
|
||
namespace Blogifier.Widgets | ||
{ | ||
public partial class Disqus : ComponentBase | ||
{ | ||
[Inject] | ||
protected IDataService DataService { get; set; } | ||
[Inject] | ||
protected IToaster Toaster { get; set; } | ||
|
||
protected string DisqusValue { get; set; } | ||
private string DisqusKey = "disqus-key"; | ||
|
||
protected override void OnInitialized() | ||
{ | ||
DisqusValue = DataService.CustomFields.GetCustomValue(DisqusKey); | ||
StateHasChanged(); | ||
} | ||
|
||
protected async Task Save() | ||
{ | ||
await DataService.CustomFields.SaveCustomValue(DisqusKey, DisqusValue); | ||
StateHasChanged(); | ||
Toaster.Success("Updated"); | ||
} | ||
} | ||
} |
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,35 @@ | ||
@using Blogifier.Widgets | ||
|
||
<div class="card dash draft"> | ||
<div class="card-header"> | ||
@Localizer["draft"] | ||
</div> | ||
<div class="card-body"> | ||
@if(Posts == null || Posts.Count() == 0) | ||
{ | ||
<div class="notfound">@Localizer["empty"]</div> | ||
} | ||
<ul class="bf-list bf-posts-list d-block" aria-label="drafts"> | ||
@foreach (var post in Posts) | ||
{ | ||
<li class="bf-list-item d-flex align-items-center"> | ||
@{ | ||
string title = post.Title.Length < 60 ? post.Title : post.Title.Substring(0, 57) + "..."; | ||
} | ||
<a class="bf-list-item-link" href="" @onclick="@(() => EditPost(post.Id))" @onclick:preventDefault>@title</a> | ||
<span class="bf-list-item-status bf-list-item-status-draft ml-auto" @onclick="@(() => Publish(post.Id))" data-tooltip="" title="" data-original-title="draft"> | ||
<i class="fa fa-circle"></i> | ||
</span> | ||
<a href="posts/@post.Slug" target="_blank" class="bf-list-item-status bf-list-item-status-link ml-auto" data-tooltip="" title="" data-original-title="link"> | ||
<i class="fa fa-external-link"></i> | ||
</a> | ||
</li> | ||
} | ||
</ul> | ||
</div> | ||
</div> | ||
|
||
@if (Edit) | ||
{ | ||
<PostEditor PostId="@PostId" HideCallback="HideEditor" /> | ||
} |
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,76 @@ | ||
using Askmethat.Aspnet.JsonLocalizer.Localizer; | ||
using Blogifier.Core.Data; | ||
using Blogifier.Core.Services; | ||
using Microsoft.AspNetCore.Components; | ||
using Sotsera.Blazor.Toaster; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Blogifier.Widgets | ||
{ | ||
public partial class Drafts | ||
{ | ||
[Parameter] | ||
public EventCallback<string> OnUpdate { get; set; } | ||
|
||
[Inject] | ||
protected IDataService DataService { get; set; } | ||
[Inject] | ||
IJsonStringLocalizer<Drafts> Localizer { get; set; } | ||
[Inject] | ||
protected IToaster Toaster { get; set; } | ||
|
||
protected int PostId { get; set; } | ||
protected bool Edit { get; set; } | ||
|
||
IEnumerable<BlogPost> Posts { get; set; } | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
await Load(); | ||
} | ||
|
||
public async Task Load() | ||
{ | ||
Posts = await Task.FromResult(DataService.BlogPosts.Find( | ||
p => p.Published == DateTime.MinValue)); | ||
StateHasChanged(); | ||
} | ||
|
||
protected void Publish(int id) | ||
{ | ||
try | ||
{ | ||
var post = DataService.BlogPosts.Find(p => p.Id == id).FirstOrDefault(); | ||
post.Published = DateTime.UtcNow; | ||
DataService.Complete(); | ||
|
||
OnUpdate.InvokeAsync("publish"); | ||
|
||
StateHasChanged(); | ||
Toaster.Success("Saved"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Toaster.Error(ex.Message); | ||
} | ||
} | ||
|
||
protected void EditPost(int id) | ||
{ | ||
Edit = true; | ||
PostId = id; | ||
StateHasChanged(); | ||
} | ||
|
||
protected async Task HideEditor(string arg) | ||
{ | ||
Edit = false; | ||
PostId = 0; | ||
await OnUpdate.InvokeAsync(arg); | ||
StateHasChanged(); | ||
} | ||
} | ||
} |
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,31 @@ | ||
<div class="card"> | ||
<div class="card-header">@Localizer["featured"]</div> | ||
<div class="card-body"> | ||
@if (Posts == null || Posts.Count() == 0) | ||
{ | ||
<div class="notfound">@Localizer["empty"]</div> | ||
} | ||
<ul class="bf-list bf-posts-list d-block" aria-label="featured"> | ||
@foreach (var post in Posts) | ||
{ | ||
<li class="bf-list-item d-flex align-items-center"> | ||
@{ | ||
string title = post.Title.Length < 60 ? post.Title : post.Title.Substring(0, 57) + "..."; | ||
} | ||
<a class="bf-list-item-link" href="" @onclick="@(() => EditPost(post.Id))" @onclick:preventDefault>@title</a> | ||
<button class="btn-unstyled bf-list-item-favorite ml-3" @onclick="@(() => Feature(post.Id))" data-tooltip="" title="" data-original-title="featured"> | ||
<i class="fa fa-star"></i> | ||
</button> | ||
<a href="posts/@post.Slug" target="_blank" class="bf-list-item-status bf-list-item-status-link ml-auto" data-tooltip="" title="" data-original-title="link"> | ||
<i class="fa fa-external-link"></i> | ||
</a> | ||
</li> | ||
} | ||
</ul> | ||
</div> | ||
</div> | ||
|
||
@if (Edit) | ||
{ | ||
<PostEditor PostId="@PostId" HideCallback="HideEditor" /> | ||
} |
Oops, something went wrong.