-
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
4 changed files
with
58 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,55 @@ | ||
@page "/feed" | ||
@using System.ServiceModel.Syndication | ||
@using System.Xml | ||
|
||
<PageTitle>Verse of the Day</PageTitle> | ||
|
||
<h1>Verse of the Day</h1> | ||
<h1>@pageTitle</h1> | ||
|
||
<hr /> | ||
|
||
<div id="dailyVersesWrapper"></div> | ||
<script async defer src="https://dailyverses.net/get/verse.js?language=niv"></script> | ||
@if (feedItems == null) | ||
{ | ||
@* <p><em>Loading...</em></p> *@ | ||
<div id="dailyVersesWrapper"></div> | ||
<script async defer src="https://dailyverses.net/get/verse.js?language=niv"></script> | ||
} | ||
else | ||
{ | ||
foreach (var feedItem in feedItems) | ||
{ | ||
<h4>@feedItem.Title</h4> | ||
<p>@feedItem.Content</p> | ||
<hr /> | ||
} | ||
} | ||
|
||
@code { | ||
static readonly string defaultFeed = "https://www.biblegateway.com/votd/get/?format=atom"; | ||
string pageTitle = "Verse of the Day"; | ||
List<FeedItem>? feedItems; | ||
HttpClient httpClient = new(); | ||
|
||
// protected override async Task OnInitializedAsync() | ||
// { | ||
// await GetFeedAsync(defaultFeed); | ||
// } | ||
private async Task GetFeedAsync(string feedUrl) | ||
{ | ||
using var xmlStream = await httpClient.GetStreamAsync(feedUrl); | ||
using var xmlReader = XmlReader.Create(xmlStream); | ||
var feed = SyndicationFeed.Load(xmlReader); | ||
pageTitle = feed.Title.Text; | ||
feedItems = new List<FeedItem>(); | ||
foreach (var item in feed.Items) | ||
{ | ||
if (item?.Content is TextSyndicationContent content && !string.IsNullOrWhiteSpace(content.Text)) | ||
feedItems.Add(new(item.Title.Text, (MarkupString)content.Text)); | ||
else if (!string.IsNullOrWhiteSpace(item?.Title.Text)) | ||
feedItems.Add(new(item.Title.Text, new())); | ||
} | ||
} | ||
|
||
record FeedItem(string? Title, MarkupString Content); | ||
} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
@page "/" | ||
|
||
<PageTitle>Home</PageTitle> | ||
<PageTitle>Bible</PageTitle> | ||
|
||
<h1>@reference</h1> | ||
|
||
|
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