Skip to content

Commit

Permalink
Widgets library added to solution
Browse files Browse the repository at this point in the history
  • Loading branch information
rxtur committed Apr 9, 2020
1 parent 24bf35c commit 5dbf0c9
Show file tree
Hide file tree
Showing 35 changed files with 1,597 additions and 4 deletions.
7 changes: 7 additions & 0 deletions Blogifier.sln
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{BE5E262F
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blogifier", "src\Blogifier\Blogifier.csproj", "{0DC52C2B-3803-4BB3-A5A2-6371E94700D7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blogifier.Widgets", "src\Blogifier.Widgets\Blogifier.Widgets.csproj", "{19384C5F-D421-4A41-AD66-8812B48F48AC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -48,12 +50,17 @@ Global
{0DC52C2B-3803-4BB3-A5A2-6371E94700D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0DC52C2B-3803-4BB3-A5A2-6371E94700D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0DC52C2B-3803-4BB3-A5A2-6371E94700D7}.Release|Any CPU.Build.0 = Release|Any CPU
{19384C5F-D421-4A41-AD66-8812B48F48AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19384C5F-D421-4A41-AD66-8812B48F48AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19384C5F-D421-4A41-AD66-8812B48F48AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19384C5F-D421-4A41-AD66-8812B48F48AC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{0DC52C2B-3803-4BB3-A5A2-6371E94700D7} = {39614650-0D6E-4502-B87D-184366060F59}
{19384C5F-D421-4A41-AD66-8812B48F48AC} = {39614650-0D6E-4502-B87D-184366060F59}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D601BCCC-A1D9-415B-94B5-B3C0EF4AAF0B}
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ via theming engine and Blazor components.

## Other Projects

Blogifier uses `Blogifier.Widgets` and `Blogifier.Core` libraries hosted in this same
Blogifier uses `Blogifier.Core` library hosted in this same
repository and published to `Nuget.org` package gallery.

![blogifier-diagram](https://user-images.githubusercontent.com/1932785/78736463-d483c880-7912-11ea-93cd-ab75e6ee75a6.png)

![blogifier-diagram](https://user-images.githubusercontent.com/1932785/78852494-1465b100-79e2-11ea-81f4-2d7c51f89702.png)
## Demo site

The [demo site](http://blogifier.net) is a playground to check out Blogifier features. You can write and publish posts, upload files and test application before install.
Expand Down
40 changes: 40 additions & 0 deletions src/Blogifier.Widgets/Blogifier.Widgets.csproj
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>
35 changes: 35 additions & 0 deletions src/Blogifier.Widgets/Custom.razor
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>
}
49 changes: 49 additions & 0 deletions src/Blogifier.Widgets/Custom.razor.cs
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");
}
}
}
9 changes: 9 additions & 0 deletions src/Blogifier.Widgets/Disqus.razor
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>
31 changes: 31 additions & 0 deletions src/Blogifier.Widgets/Disqus.razor.cs
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");
}
}
}
35 changes: 35 additions & 0 deletions src/Blogifier.Widgets/Drafts.razor
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" />
}
76 changes: 76 additions & 0 deletions src/Blogifier.Widgets/Drafts.razor.cs
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();
}
}
}
31 changes: 31 additions & 0 deletions src/Blogifier.Widgets/Featured.razor
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" />
}
Loading

0 comments on commit 5dbf0c9

Please sign in to comment.