This commit is contained in:
Max Holleman 2023-05-12 15:48:14 +02:00
parent 574546d74b
commit fcda58d30f
8 changed files with 70 additions and 36 deletions

View File

@ -1,10 +0,0 @@
namespace SharpRss.Models
{
public class CategoryItem
{
public string CategoryId { get; set; }
public string CategoryName { get; set; }
public string CategoryIcon { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SharpRss.Models
{
/// <summary>
/// To store and load data from file/database
/// </summary>
public class CategoryModel
{
public string Name { get; set; }
public HashSet<FeedModel> Feeds { get; set; }
}
}

View File

@ -1,10 +0,0 @@
using CodeHollow.FeedReader;
namespace SharpRss.Models
{
public class FeedInfo
{
public string FeedName { get; set; }
public string Url { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SharpRss.Models
{
public class FeedModel
{
public string Type { get; set; }
public string Text { get; set; }
public string Title { get; set; }
public string XmlUrl { get; set; }
public string HtmlUrl { get; set; }
}
}

View File

@ -6,37 +6,48 @@ using SharpRss.Models;
namespace SharpRss namespace SharpRss
{ {
/// <summary>
/// Managing RSS feeds and categories.
/// </summary>
public class RssService public class RssService
{ {
public RssService() public RssService()
{ {
//TODO: Check if db exists else create. /// Storage options:
/// - Database
/// - File
/// - Memory
} }
public async Task<HashSet<CategoryItem>> GetCategories() public async Task<HashSet<CategoryModel>> GetCategories()
{ {
return new HashSet<CategoryItem>(); return new HashSet<CategoryModel>();
} }
public async void GetFeeds() public async Task<HashSet<FeedModel>> GetAllFeeds()
{ {
//TODO: Load from db or something. return new HashSet<FeedModel>();
}
var urls = await FeedReader.GetFeedUrlsFromUrlAsync(_feeds[0]);
/// Old
public async Task<Feed> GetFeed(string feedUrl)
{
var urls = await FeedReader.GetFeedUrlsFromUrlAsync(feedUrl);
string url; string url;
if (urls.Count() < 1) if (urls.Count() < 1)
url = _feeds[0]; url = _feeds[0];
else else
url = urls.First().Url; url = urls.First().Url;
Feed f = await FeedReader.ReadAsync(url); return await FeedReader.ReadAsync(url);
}
public async Task<HashSet<Feed>> GetFeedsFromCatAsync(CategoryModel category)
{
return new HashSet<Feed>();
} }
private readonly string[] _feeds = { "https://www.reddit.com/r/freshrss/.rss", "http://fedoramagazine.org/" }; private readonly string[] _feeds = { "https://www.reddit.com/r/freshrss/.rss", "http://fedoramagazine.org/" };
private void CheckDbExist()
{
}
} }
} }

View File

@ -0,0 +1,15 @@
using SharpRss.Models;
namespace WebSharpRSS.Models
{
public class CategoryItem : CategoryModel, ISelectableGuideItem
{
public CategoryItem(CategoryModel model)
{
Name = model.Name;
Feeds = model.Feeds;
}
public bool IsSelected { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public bool IsExpanded { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
}
}

View File

@ -1,4 +0,0 @@
{
"FaviconResolveUrl": "https://icons.duckduckgo.com/ip3/{0}.ico",
"LogPath": "/home/max/GitHub/SharpRSS/WebSharpRSS/logs/log_.json"
}

View File

@ -1,3 +1,4 @@
@using SharpRss.Models;
@using WebSharpRSS.Models @using WebSharpRSS.Models
@using MudBlazor.Utilities @using MudBlazor.Utilities
@using CodeHollow.FeedReader @using CodeHollow.FeedReader
@ -14,6 +15,7 @@
@code { @code {
public HashSet<CategoryGuideItem> Categories = new HashSet<CategoryGuideItem>(); public HashSet<CategoryGuideItem> Categories = new HashSet<CategoryGuideItem>();
public HashSet<CategoryItem> Cats = new HashSet<CategoryItem>();
protected override void OnInitialized() protected override void OnInitialized()
{ {
Log.Verbose("Setting up test data"); Log.Verbose("Setting up test data");