Skip to content

Commit

Permalink
Merge pull request #29 from zhanknight/feature/author-name-on-content…
Browse files Browse the repository at this point in the history
…-card

Feature/author name on content card
  • Loading branch information
zhanknight committed Jan 12, 2024
2 parents d0a23a7 + 905ba50 commit 3f16447
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 96 deletions.
6 changes: 3 additions & 3 deletions TacoPoetry.API/TacoPoetry.API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
opt.AddSlidingWindowLimiter(policyName: "slidingWindow", options =>
{
options.PermitLimit = 4;
options.Window = TimeSpan.FromSeconds(10);
options.PermitLimit = 5;
options.Window = TimeSpan.FromSeconds(8);
options.SegmentsPerWindow = 2;
options.QueueProcessingOrder = QueueProcessingOrder.OldestFirst;
options.QueueLimit = 3;
options.QueueLimit = 4;
});
});

Expand Down
2 changes: 1 addition & 1 deletion TacoPoetry.UI/Components/AuthorCard.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class=" rounded overflow-hidden shadow-md m-2">
<div class=" rounded overflow-hidden shadow-md m-2 bg-slate-50">

<div class="px-6 pb-4 pt-2">
<div class="font-bold text-xl mb-2">
Expand Down
9 changes: 8 additions & 1 deletion TacoPoetry.UI/Components/ContentCard.razor
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<div class=" rounded overflow-hidden shadow-md m-1">
<div class="w-full rounded overflow-hidden shadow-md m-1 mx-auto bg-slate-50">

<div class="px-6 pb-4 pt-2">
<div class="font-bold text-xl mb-2">
@Content.ContentTitle

Check warning on line 5 in TacoPoetry.UI/Components/ContentCard.razor

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
<p class="text-gray-500 text-base">
by <NavLink href="@($"authors/{Content.ContentAuthorId}")" class="text-yellow-500 hover:text-amber-300">
@Content.ContentAuthor
</NavLink>
</p>
</div>
<p class="text-gray-700 text-base">
@Content.ContentBody
Expand All @@ -25,3 +30,5 @@
public Content? Content { get; set; }

}


10 changes: 8 additions & 2 deletions TacoPoetry.UI/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
@inherits LayoutComponentBase

<NavMenu />
<div class="h-lvh bg-gradient-to-b from-orange-100 to-white">
<NavMenu />
<div class="max-w-screen-md mx-auto">
<main> @Body </main>

</div>
</div>


<main> @Body </main>
17 changes: 10 additions & 7 deletions TacoPoetry.UI/Pages/AuthorContent.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
@page "/authors/{selectedAuthorId:int}"

@if (selectedContent == null)
{
<div class="text-center text-2xl text-gray-500">Gathering poems..</div>
}
else
{
<div class="md:flex">
<div class="pt-2 pb-1 px-6">
<div class="uppercase tracking-wide text-sm text-orange-500 font-semibold">
Expand All @@ -9,8 +15,7 @@
</div>

<div class="container flex flex-wrap p-3 mx-auto">

@if(!selectedContent.Any())
@if(!selectedContent.Any())
{
<div class="text-center text-2xl text-gray-500">No poems by this author yet!</div>
}
Expand All @@ -20,11 +25,9 @@
{
<ContentCard Content="c" />
}
}


}
</div>

}
@code {

[Parameter]
Expand All @@ -35,7 +38,7 @@
[Inject]
public ITacoDataService TacoDataService { get; set; }

public IEnumerable<Content> selectedContent { get; set; } = new List<Content>();
public IEnumerable<Content>? selectedContent { get; set; } = null;

protected async override Task OnInitializedAsync()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/";
@page "/musings";
@page "/poetry";

<div class="flex">
<div class="pt-2 pb-1 px-6">
Expand Down
21 changes: 14 additions & 7 deletions TacoPoetry.UI/Pages/TagContent.razor
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
@page "/tags/{selectedTag:int}"

@if (selectedContent == null)
{
<div class="text-center text-2xl text-gray-500">Gathering poems..</div>
}
else
{
<div class="md:flex">
<div class="pt-4 pb-1 px-6">
<div class="uppercase tracking-wide text-sm text-orange-500 font-semibold">
@(selectedContent.Any() ? $"Viewing poems tagged with {@selectedTagName}" : "Uh Oh")
</div>
</div>
</div>

<div class="container flex flex-wrap p-3 mx-auto">
@if (!selectedContent.Any())
{
<div class="text-center text-2xl text-gray-500">No poems with this tag yet!</div>
}
else
{
@foreach (Content c in selectedContent)
{
<ContentCard Content="c" />
}
@foreach (Content c in selectedContent)
{
<ContentCard Content="c" />
}
}


</div>
}

@code {

Expand All @@ -33,7 +39,7 @@
[Inject]
public ITacoDataService TacoDataService { get; set; }

public IEnumerable<Content> selectedContent { get; set; } = new List<Content>();
public IEnumerable<Content>? selectedContent { get; set; }

protected async override Task OnInitializedAsync()
{
Expand All @@ -47,6 +53,7 @@

protected override async Task OnParametersSetAsync()
{
selectedContent = null;
await OnInitializedAsync();
}

Expand Down
2 changes: 1 addition & 1 deletion TacoPoetry.UI/Pages/_Host.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />

</head>
<body>
<body class="">
<component type="typeof(App)" render-mode="ServerPrerendered" />

<div id="blazor-error-ui">
Expand Down
3 changes: 3 additions & 0 deletions TacoPoetry.UI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
using TacoPoetry.UI.Services.Interfaces;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddRazorPages();

builder.Services.AddServerSideBlazor();

builder.Services.AddHttpClient<ITacoDataService, TacoDataService>(client =>
Expand All @@ -25,6 +27,7 @@
app.UseRouting();

app.MapBlazorHub();

app.MapFallbackToPage("/_Host");

app.Run();
95 changes: 22 additions & 73 deletions TacoPoetry.UI/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
@@ -1,79 +1,28 @@
<nav class="flex flex-wrap bg-amber-500 p-6 justify-center">
<div class="flex flex-shrink-0 text-white mr-6">
<svg class="fill-current h-8 w-8 mr-2" width="54" height="54" viewBox="0 0 54 54" xmlns="http://www.w3.org/2000/svg">

<path d="M53.957,14.646c-0.107-0.107-0.219-0.207-0.328-0.313c0.534-0.476,0.878-1.162,0.878-1.933c0-1.654-1.346-3-3-3
c-0.004,0-0.007,0.002-0.01,0.002c0.001-0.152-0.023-0.304-0.095-0.449c-0.247-0.494-0.847-0.692-1.342-0.447l-1.529,0.765
c-0.515-0.44-1.038-0.858-1.569-1.256c0.16-0.098,0.315-0.209,0.453-0.347c0.53-0.531,0.822-1.236,0.822-1.987
s-0.292-1.456-0.823-1.986c-1.272-1.271-3.342-1.271-4.614,0c-0.375,0.375-0.655,0.808-0.841,1.271
c-0.801-0.384-1.612-0.724-2.43-1.023l0.616-2.4c0.137-0.535-0.185-1.08-0.72-1.218c-0.538-0.137-1.08,0.186-1.217,0.72
l-0.585,2.278c-0.304-0.085-0.608-0.165-0.913-0.238C36.293,1.319,34.715,0,32.827,0c-0.528,0-0.95,0.413-0.986,0.933
C31.306,0.601,30.681,0.4,30.007,0.4c-1.416,0-2.632,0.849-3.182,2.062c-0.349-0.117-0.747-0.047-1.025,0.231l-0.37,0.37
c-0.953,0.234-1.898,0.522-2.828,0.88l-1.166-2.914c-0.206-0.513-0.785-0.764-1.3-0.558c-0.513,0.205-0.762,0.787-0.557,1.3
l1.19,2.975c-0.783,0.379-1.554,0.803-2.312,1.276C17.903,5.634,17.233,5.4,16.507,5.4c-2.206,0-4,1.794-4,4
c0,0.377,0.217,0.692,0.524,0.863c-0.694,0.685-1.353,1.391-1.951,2.137H7.507c-0.552,0-1,0.447-1,1s0.448,1,1,1h2.149
c-0.468,0.726-0.906,1.48-1.304,2.271C7.938,16.498,7.484,16.4,7.007,16.4c-1.93,0-3.5,1.57-3.5,3.5
c0,1.576,1.054,2.896,2.489,3.333c-0.436,1.778-0.782,3.69-1.035,5.775l-1.006-0.503c-0.495-0.246-1.095-0.047-1.342,0.447
s-0.047,1.095,0.447,1.342l1.682,0.841c-0.039,0.438-0.075,0.886-0.108,1.338c-1.198-0.231-2.451,0.338-3.021,1.48
c-0.798,1.596-0.148,3.543,1.447,4.342C3.203,38.366,3.356,38.4,3.506,38.4c0.367,0,0.72-0.202,0.895-0.553
c0.248-0.493,0.047-1.095-0.446-1.342c-0.61-0.305-0.858-1.049-0.553-1.658c0.194-0.389,0.668-0.551,1.058-0.354
c0.037,0.018,0.054,0.044,0.08,0.067c0.021,0.123,0.061,0.235,0.122,0.34c0,0.049-0.004,0.098-0.004,0.147
c-0.004,0.009-0.001,0.016-0.006,0.025c-0.151,0.301-0.119,0.633,0.028,0.909c0.06,1.949,0.312,3.864,0.748,5.725l-2.238,0.746
c-0.524,0.174-0.807,0.74-0.632,1.265c0.14,0.419,0.53,0.684,0.949,0.684c0.104,0,0.211-0.017,0.316-0.052L5.95,43.64
c0.305,0.987,0.667,1.954,1.077,2.9c-0.305,0.171-0.52,0.485-0.52,0.86c0,0.553,0.448,1,1,1c0.174,0,0.33,0.057,0.473,0.136
c0.164,0.311,0.339,0.617,0.515,0.922C8.465,49.761,8.217,50,7.907,50c-0.154,0-0.28-0.126-0.28-0.28c0-0.553-0.448-1-1-1
s-1,0.447-1,1c0,1.258,1.023,2.28,2.28,2.28c0.676,0,1.287-0.266,1.75-0.69c0.206,0.301,0.414,0.601,0.631,0.895L9.8,52.693
c-0.391,0.391-0.391,1.023,0,1.414c0.195,0.195,0.451,0.293,0.707,0.293s0.512-0.098,0.707-0.293l0.333-0.333
c0.5,0.586,1.019,1.16,1.57,1.711c0.195,0.195,0.451,0.293,0.707,0.293s0.512-0.098,0.707-0.293L53.096,16.92l0.596-0.381
c0.233-0.149,0.394-0.389,0.444-0.66c0.005-0.029-0.005-0.058-0.002-0.087C54.321,15.418,54.269,14.957,53.957,14.646z
M50.529,10.508c0.056,0.5,0.464,0.893,0.978,0.893c0.551,0,1,0.448,1,1c0,0.226-0.13,0.416-0.315,0.518
c-0.672-0.775-1.365-1.51-2.079-2.203L50.529,10.508z M44.214,5.107c0.246-0.246,0.57-0.369,0.893-0.369S45.754,4.861,46,5.107
c0.153,0.153,0.237,0.356,0.237,0.572c0,0.217-0.084,0.42-0.237,0.573c-0.175,0.174-0.46,0.174-0.634,0
c-0.335-0.335-0.841-0.365-1.227-0.125c-0.128-0.076-0.256-0.15-0.385-0.224C43.836,5.613,43.985,5.337,44.214,5.107z
M41.743,7.055c0.02,0.114,0.054,0.224,0.084,0.336c-0.983-0.293-1.984-0.53-2.999-0.717l0.205-0.797
C39.938,6.208,40.843,6.598,41.743,7.055z M36.869,6.259c-0.011,0.042-0.001,0.082-0.006,0.124
c-0.312-0.036-0.625-0.066-0.94-0.091c0.304-0.331,0.539-0.72,0.693-1.151c0.169,0.042,0.338,0.08,0.508,0.126L36.869,6.259z
M26.354,4.967c0.105-0.023,0.21-0.046,0.316-0.068c0.223,0.741,0.676,1.379,1.288,1.825c-1.613,0.314-3.186,0.77-4.71,1.35
L26.354,4.967z M33.427,5.4c-0.087,0-0.165-0.027-0.244-0.049c0.112-0.244,0.202-0.499,0.255-0.768
c0.391,0.04,0.782,0.091,1.175,0.152C34.366,5.133,33.929,5.4,33.427,5.4z M30.627,5.262c-0.19,0.087-0.398,0.138-0.62,0.138
c-0.578,0-1.075-0.332-1.325-0.812c0.602-0.065,1.211-0.105,1.826-0.121c0,0.005-0.001,0.009-0.001,0.013
C30.507,4.753,30.557,5.012,30.627,5.262z M21.578,6.771c0.013,0.034,0.037,0.059,0.053,0.09L20.8,7.693
c-0.391,0.391-0.391,1.023,0,1.414c0.008,0.008,0.019,0.01,0.027,0.018c-0.36,0.177-0.717,0.358-1.069,0.55
c0.088-0.278,0.149-0.569,0.149-0.876c0-0.417-0.086-0.813-0.224-1.182c0.589-0.359,1.202-0.692,1.836-0.996L21.578,6.771z
M14.499,13.359c-0.02-0.472-0.367-0.843-0.82-0.924c0.474-0.509,0.981-0.999,1.511-1.478c0.371,0.376,0.853,0.639,1.397,0.726
C15.868,12.207,15.173,12.766,14.499,13.359z M17.906,8.792c0,0.003,0.001,0.005,0.001,0.008c0,0.507-0.413,0.92-0.92,0.92
c-0.087,0-0.166-0.026-0.238-0.062C17.124,9.365,17.505,9.075,17.906,8.792z M14.722,8.499c0.313-0.619,0.943-1.04,1.672-1.083
c-0.354,0.257-0.694,0.52-1.029,0.785C15.114,8.224,14.885,8.325,14.722,8.499z M13.374,14.4c-0.085,0.083-0.173,0.161-0.257,0.245
c-1.124,1.124-2.138,2.328-3.049,3.593c-0.052-0.094-0.094-0.195-0.154-0.284c0.616-1.28,1.339-2.452,2.151-3.555H13.374z
M5.507,19.9c0-0.827,0.673-1.5,1.5-1.5c0.179,0,0.349,0.037,0.509,0.095c-0.369,0.893-0.696,1.837-0.994,2.818
C5.934,21.11,5.507,20.557,5.507,19.9z M13.837,53.352c-1.299-1.396-2.426-2.912-3.387-4.515c-0.122-0.637-0.448-1.199-0.905-1.624
c-1.863-3.67-2.857-7.747-2.883-11.978c0.034-0.23,0.042-0.463,0.009-0.695c0.133-6.982,2.908-13.528,7.86-18.48
c5.077-5.077,11.827-7.873,19.006-7.873c5.979,0,11.66,1.94,16.324,5.521c0.274,0.565,0.771,0.994,1.378,1.182
c0.146,0.177,0.291,0.356,0.436,0.539l-0.158,0.148c-0.099,0.093-0.172,0.203-0.225,0.32L13.837,53.352z" />
</svg>

<NavLink href="/musings"><span class="font-semibold text-xl tracking-tight">Taco Poetry</span></NavLink>
</div>
<nav class="bg-amber-500 p-6">

<div class="w-full block flex-grow sm:flex items-center sm:items-center sm:w-auto sm:justify-center ml-4">
<div class="text-sm sm:flex-grow justify-center items-center">
<NavLink href="/musings" class="mt-0 inline-block text-white hover:text-yellow-200 mr-4">
Poems
</NavLink>
<NavLink href="/authors" class=" mt-0 inline-block text-white hover:text-yellow-200 mr-4">
Authors
</NavLink>
<NavLink href="/tags" class=" mt-0 inline-block text-white hover:text-yellow-200 mr-4">
Tags
</NavLink>
<NavLink href="/about" class=" mt-0 ml-6 inline-block text-white hover:text-yellow-200 hover:bg-amber-400">
About
</NavLink>
<div class="max-w-screen-md mx-auto">
<div class="max-w-screen-md mr-auto flex flex-col">
<div class="text-white mr-auto">
<NavLink href="/poetry"><span class="font-semibold text-xl tracking-tight">Taco Poetry</span></NavLink>
</div>

</div>
<div class="text-sm flex flex-row">
<NavLink href="/poetry" class="mt-0 inline-block text-white hover:text-yellow-200 mr-4">
Poems
</NavLink>
<NavLink href="/authors" class=" mt-0 inline-block text-white hover:text-yellow-200 mr-4">
Authors
</NavLink>
<NavLink href="/tags" class=" mt-0 inline-block text-white hover:text-yellow-200 mr-4">
Tags
</NavLink>
<NavLink href="/about" class=" mt-0 inline-block text-white hover:text-yellow-200 hover:bg-amber-400">
About
</NavLink>
</div>
</div>
</div>


</div>
</nav>

@code {
Expand Down

0 comments on commit 3f16447

Please sign in to comment.