read feeds implemented
This commit is contained in:
parent
c744b55de4
commit
fa6e8bf7cc
@ -1,14 +1,16 @@
|
|||||||
@inherits LayoutComponentBase
|
@inherits LayoutComponentBase
|
||||||
|
|
||||||
|
<NavMenu />
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<div class="sidebar">
|
|
||||||
<NavMenu />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
@* <div class="sidebar">
|
||||||
|
<NavMenu />
|
||||||
|
</div> *@
|
||||||
<main>
|
<main>
|
||||||
<div class="top-row px-4">
|
@* <div class="top-row px-4">
|
||||||
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
|
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
|
||||||
</div>
|
</div> *@
|
||||||
|
|
||||||
<article class="content px-4">
|
<article class="content px-4">
|
||||||
@Body
|
@Body
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
<div class="top-row ps-3 navbar navbar-dark">
|
<div class="top-row ps-3 navbar navbar-dark">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<a class="navbar-brand" href="">RBLNews.Maui</a>
|
<a class="navbar-brand" href="">RBL News auf einen Blick!</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@*
|
||||||
<input type="checkbox" title="Navigation menu" class="navbar-toggler" />
|
<input type="checkbox" title="Navigation menu" class="navbar-toggler" />
|
||||||
|
|
||||||
<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
|
<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
|
||||||
@ -14,7 +14,7 @@
|
|||||||
</NavLink>
|
</NavLink>
|
||||||
</div>
|
</div>
|
||||||
<div class="nav-item px-3">
|
<div class="nav-item px-3">
|
||||||
<NavLink class="nav-link" href="counter">
|
<NavLink class="nav-link" href="feeds">
|
||||||
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter
|
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</div>
|
</div>
|
||||||
@ -25,3 +25,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
*@
|
||||||
@ -1,24 +0,0 @@
|
|||||||
@page "/counter"
|
|
||||||
|
|
||||||
<h1>Counter</h1>
|
|
||||||
|
|
||||||
<p role="status">Current count: @currentCount</p>
|
|
||||||
|
|
||||||
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
|
|
||||||
|
|
||||||
@code {
|
|
||||||
private int currentCount = 0;
|
|
||||||
|
|
||||||
private void IncrementCount()
|
|
||||||
{
|
|
||||||
currentCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
<Card Style="width:18rem;">
|
|
||||||
<CardBody>
|
|
||||||
<CardTitle>Card title</CardTitle>
|
|
||||||
<CardText>Some quick example text to build on the card title and make up the bulk of the card's content.</CardText>
|
|
||||||
<Button Color="ButtonColor.Primary" To="#" Type="ButtonType.Link">Go somewhere</Button>
|
|
||||||
</CardBody>
|
|
||||||
</Card>
|
|
||||||
67
RBLNews.Shared/Components/Pages/Feeds.razor
Normal file
67
RBLNews.Shared/Components/Pages/Feeds.razor
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
@page "/"
|
||||||
|
@using RBLFeederCommon.Models.RssFeed
|
||||||
|
@using RBLNews.Shared.Enums
|
||||||
|
@if (rssVM == null)
|
||||||
|
{
|
||||||
|
<div class="d-flex justify-content-center">
|
||||||
|
Lade Feeds ...
|
||||||
|
<Spinner Type="SpinnerType.Grow" Color="SpinnerColor.Primary" Size="SpinnerSize.Large" />
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="row">
|
||||||
|
@foreach (FeedGroupVM feedGrp in rssVM.FeedGroups)
|
||||||
|
{
|
||||||
|
<h3>@feedGrp.PublishDate</h3>
|
||||||
|
@foreach (FeedVM feed in feedGrp.Feeds)
|
||||||
|
{
|
||||||
|
<div class="col-sm-12 col-md-9 col-lg-6">
|
||||||
|
<Card>
|
||||||
|
<CardBody>
|
||||||
|
<CardTitle>@feed.Title</CardTitle>
|
||||||
|
<CardText>@feed.Description</CardText>
|
||||||
|
</CardBody>
|
||||||
|
<CardFooter>
|
||||||
|
@GetRssSourceName((RssFeedSources)@feed.Source) | @feed.PubDate <Button Color="ButtonColor.Primary" To="@feed.Link" Type="ButtonType.Link">Öffnen</Button>
|
||||||
|
</CardFooter>
|
||||||
|
</Card>
|
||||||
|
<br />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
@code {
|
||||||
|
private RssVM rssVM;
|
||||||
|
HttpClient httpClient = new HttpClient();
|
||||||
|
|
||||||
|
protected async override Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
rssVM = await httpClient.GetFromJsonAsync<RssVM>("https://rblnews.de/api/feeds");
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetRssSourceName(RssFeedSources source)
|
||||||
|
{
|
||||||
|
switch (source)
|
||||||
|
{
|
||||||
|
case RssFeedSources.RbLive:
|
||||||
|
case RssFeedSources.NitterRbLive:
|
||||||
|
return "RBLive!";
|
||||||
|
case RssFeedSources.NitterFabrizioRomano:
|
||||||
|
return "Fabrizio Romano";
|
||||||
|
case RssFeedSources.Lvz:
|
||||||
|
return "LVZ";
|
||||||
|
case RssFeedSources.Kicker:
|
||||||
|
return "Kicker";
|
||||||
|
case RssFeedSources.Bild:
|
||||||
|
return "BILD";
|
||||||
|
case RssFeedSources.Transfermarkt:
|
||||||
|
return "Transfermarkt";
|
||||||
|
default:
|
||||||
|
return "?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
@page "/"
|
|
||||||
|
|
||||||
<h1>Hello, world!</h1>
|
|
||||||
|
|
||||||
Welcome to your new app.
|
|
||||||
@ -1,61 +0,0 @@
|
|||||||
@page "/weather"
|
|
||||||
|
|
||||||
<h1>Weather</h1>
|
|
||||||
|
|
||||||
<p>This component demonstrates showing data.</p>
|
|
||||||
|
|
||||||
@if (forecasts == null)
|
|
||||||
{
|
|
||||||
<p><em>Loading...</em></p>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Date</th>
|
|
||||||
<th>Temp. (C)</th>
|
|
||||||
<th>Temp. (F)</th>
|
|
||||||
<th>Summary</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach (var forecast in forecasts)
|
|
||||||
{
|
|
||||||
<tr>
|
|
||||||
<td>@forecast.Date.ToShortDateString()</td>
|
|
||||||
<td>@forecast.TemperatureC</td>
|
|
||||||
<td>@forecast.TemperatureF</td>
|
|
||||||
<td>@forecast.Summary</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
}
|
|
||||||
|
|
||||||
@code {
|
|
||||||
private WeatherForecast[]? forecasts;
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
{
|
|
||||||
// Simulate asynchronous loading to demonstrate a loading indicator
|
|
||||||
await Task.Delay(500);
|
|
||||||
|
|
||||||
var startDate = DateOnly.FromDateTime(DateTime.Now);
|
|
||||||
var summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" };
|
|
||||||
forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
|
||||||
{
|
|
||||||
Date = startDate.AddDays(index),
|
|
||||||
TemperatureC = Random.Shared.Next(-20, 55),
|
|
||||||
Summary = summaries[Random.Shared.Next(summaries.Length)]
|
|
||||||
}).ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class WeatherForecast
|
|
||||||
{
|
|
||||||
public DateOnly Date { get; set; }
|
|
||||||
public int TemperatureC { get; set; }
|
|
||||||
public string? Summary { get; set; }
|
|
||||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
13
RBLNews.Shared/Enums/RssFeedSourcesEnum.cs
Normal file
13
RBLNews.Shared/Enums/RssFeedSourcesEnum.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
namespace RBLNews.Shared.Enums
|
||||||
|
{
|
||||||
|
public enum RssFeedSources
|
||||||
|
{
|
||||||
|
Lvz,
|
||||||
|
Kicker,
|
||||||
|
Bild,
|
||||||
|
Transfermarkt,
|
||||||
|
NitterRbLive,
|
||||||
|
NitterFabrizioRomano,
|
||||||
|
RbLive
|
||||||
|
}
|
||||||
|
}
|
||||||
12
RBLNews.Shared/Models/FeedGroupVM.cs
Normal file
12
RBLNews.Shared/Models/FeedGroupVM.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace RBLFeederCommon.Models.RssFeed;
|
||||||
|
|
||||||
|
public class FeedGroupVM
|
||||||
|
{
|
||||||
|
[JsonProperty("pubDate")]
|
||||||
|
public DateTime PublishDate { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("news")]
|
||||||
|
public IList<FeedVM> Feeds { get; set; }
|
||||||
|
}
|
||||||
27
RBLNews.Shared/Models/FeedVM.cs
Normal file
27
RBLNews.Shared/Models/FeedVM.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace RBLFeederCommon.Models.RssFeed;
|
||||||
|
|
||||||
|
public class FeedVM
|
||||||
|
{
|
||||||
|
[JsonProperty("id")]
|
||||||
|
public string Id { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("title")]
|
||||||
|
public string Title { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("imgUrl")]
|
||||||
|
public string ImgUrl { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("description")]
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("pubDate")]
|
||||||
|
public DateTime? PubDate { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("link")]
|
||||||
|
public string Link { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("source")]
|
||||||
|
public int Source { get; set; }
|
||||||
|
}
|
||||||
17
RBLNews.Shared/Models/RssVM.cs
Normal file
17
RBLNews.Shared/Models/RssVM.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace RBLFeederCommon.Models.RssFeed;
|
||||||
|
|
||||||
|
public class RssVM
|
||||||
|
{
|
||||||
|
[JsonProperty("lastUpdate")]
|
||||||
|
public DateTime LastUpdate { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
[JsonProperty("description")]
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
[JsonProperty("feedGroups")]
|
||||||
|
public IList<FeedGroupVM> FeedGroups { get; set; } = new List<FeedGroupVM>();
|
||||||
|
}
|
||||||
@ -15,6 +15,7 @@
|
|||||||
<PackageReference Include="AntDesign" Version="0.20.3" />
|
<PackageReference Include="AntDesign" Version="0.20.3" />
|
||||||
<PackageReference Include="Blazor.Bootstrap" Version="3.0.0" />
|
<PackageReference Include="Blazor.Bootstrap" Version="3.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.8" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.8" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user