-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RSS reader web application example
- Loading branch information
Showing
73 changed files
with
74,708 additions
and
0 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
16 changes: 16 additions & 0 deletions
16
projects/rss-reader/rss-reader/RssReaderWebApplication.sln
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RssReaderWebApplication", "RssReaderWebApplication\RssReaderWebApplication.csproj", "{18C926DB-958A-4FDA-962B-23F336D68900}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{18C926DB-958A-4FDA-962B-23F336D68900}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{18C926DB-958A-4FDA-962B-23F336D68900}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{18C926DB-958A-4FDA-962B-23F336D68900}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{18C926DB-958A-4FDA-962B-23F336D68900}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
13 changes: 13 additions & 0 deletions
13
projects/rss-reader/rss-reader/RssReaderWebApplication/Controllers/HomeController.cs
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace RssReaderWebApplication.Controllers; | ||
|
||
public class HomeController : Controller | ||
{ | ||
public IActionResult Index() | ||
{ | ||
const string rssUrl = "https://www.newyorker.com/feed/everything"; | ||
var rssItems = RssFeedService.GetRssFeedItems(rssUrl); | ||
return View(rssItems); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
projects/rss-reader/rss-reader/RssReaderWebApplication/Models/RssItem.cs
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace RssReaderWebApplication.Models; | ||
|
||
public class RssItem | ||
{ | ||
public string? Title { get; set; } | ||
public string? Link { get; set; } | ||
public string? Description { get; set; } | ||
} |
24 changes: 24 additions & 0 deletions
24
projects/rss-reader/rss-reader/RssReaderWebApplication/Program.cs
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
builder.Services.AddControllersWithViews(); | ||
|
||
var app = builder.Build(); | ||
|
||
if (!app.Environment.IsDevelopment()) | ||
{ | ||
app.UseExceptionHandler("/Home/Error"); | ||
app.UseHsts(); | ||
} | ||
|
||
app.UseHttpsRedirection(); | ||
app.UseStaticFiles(); | ||
|
||
app.UseRouting(); | ||
|
||
app.UseAuthorization(); | ||
|
||
app.MapControllerRoute( | ||
name: "default", | ||
pattern: "{controller=Home}/{action=Index}/{id?}"); | ||
|
||
app.Run(); |
30 changes: 30 additions & 0 deletions
30
projects/rss-reader/rss-reader/RssReaderWebApplication/RssFeedService.cs
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Xml; | ||
using RssReaderWebApplication.Models; | ||
|
||
namespace RssReaderWebApplication; | ||
|
||
public static class RssFeedService | ||
{ | ||
public static List<RssItem> GetRssFeedItems(string rssUrl) | ||
{ | ||
var rssItems = new List<RssItem>(); | ||
var rssXmlDoc = new XmlDocument(); | ||
|
||
rssXmlDoc.Load(rssUrl); | ||
var rssNodes = rssXmlDoc.SelectNodes("rss/channel/item"); | ||
|
||
if (rssNodes == null) | ||
return rssItems; | ||
|
||
rssItems.AddRange( | ||
from XmlNode rssNode in rssNodes | ||
select new RssItem | ||
{ | ||
Title = rssNode.SelectSingleNode("title").InnerText, | ||
Link = rssNode.SelectSingleNode("link").InnerText, | ||
Description = rssNode.SelectSingleNode("description").InnerText | ||
}); | ||
|
||
return rssItems; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
projects/rss-reader/rss-reader/RssReaderWebApplication/RssReaderWebApplication.csproj
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<_ContentIncludedByDefault Remove="Views\RssFeed\Index.cshtml" /> | ||
</ItemGroup> | ||
|
||
</Project> |
16 changes: 16 additions & 0 deletions
16
projects/rss-reader/rss-reader/RssReaderWebApplication/Views/Home/Index.cshtml
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@{ | ||
ViewData["Title"] = "Home Page"; | ||
} | ||
|
||
@model List<RssReaderWebApplication.Models.RssItem> | ||
|
||
<h2>RSS Feed</h2> | ||
<ul> | ||
@foreach (var item in Model) | ||
{ | ||
<li> | ||
<a href="@item.Link">@item.Title</a> | ||
<p>@item.Description</p> | ||
</li> | ||
} | ||
</ul> |
40 changes: 40 additions & 0 deletions
40
projects/rss-reader/rss-reader/RssReaderWebApplication/Views/Shared/_Layout.cshtml
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> | ||
<title>@ViewData["Title"] - RssReaderWebApplication</title> | ||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css"/> | ||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true"/> | ||
<link rel="stylesheet" href="~/RssReaderWebApplication.styles.css" asp-append-version="true"/> | ||
</head> | ||
<body> | ||
<header> | ||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3"> | ||
<div class="container-fluid"> | ||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">RssReaderWebApplication</a> | ||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent" | ||
aria-expanded="false" aria-label="Toggle navigation"> | ||
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between"> | ||
<ul class="navbar-nav flex-grow-1"> | ||
<li class="nav-item"> | ||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</nav> | ||
</header> | ||
<div class="container"> | ||
<main role="main" class="pb-3"> | ||
@RenderBody() | ||
</main> | ||
</div> | ||
<script src="~/lib/jquery/dist/jquery.min.js"></script> | ||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script> | ||
<script src="~/js/site.js" asp-append-version="true"></script> | ||
@await RenderSectionAsync("Scripts", required: false) | ||
</body> | ||
</html> |
48 changes: 48 additions & 0 deletions
48
projects/rss-reader/rss-reader/RssReaderWebApplication/Views/Shared/_Layout.cshtml.css
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification | ||
for details on configuring this project to bundle and minify static web assets. */ | ||
|
||
a.navbar-brand { | ||
white-space: normal; | ||
text-align: center; | ||
word-break: break-all; | ||
} | ||
|
||
a { | ||
color: #0077cc; | ||
} | ||
|
||
.btn-primary { | ||
color: #fff; | ||
background-color: #1b6ec2; | ||
border-color: #1861ac; | ||
} | ||
|
||
.nav-pills .nav-link.active, .nav-pills .show > .nav-link { | ||
color: #fff; | ||
background-color: #1b6ec2; | ||
border-color: #1861ac; | ||
} | ||
|
||
.border-top { | ||
border-top: 1px solid #e5e5e5; | ||
} | ||
.border-bottom { | ||
border-bottom: 1px solid #e5e5e5; | ||
} | ||
|
||
.box-shadow { | ||
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); | ||
} | ||
|
||
button.accept-policy { | ||
font-size: 1rem; | ||
line-height: inherit; | ||
} | ||
|
||
.footer { | ||
position: absolute; | ||
bottom: 0; | ||
width: 100%; | ||
white-space: nowrap; | ||
line-height: 60px; | ||
} |
2 changes: 2 additions & 0 deletions
2
...s-reader/rss-reader/RssReaderWebApplication/Views/Shared/_ValidationScriptsPartial.cshtml
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script> | ||
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script> |
3 changes: 3 additions & 0 deletions
3
projects/rss-reader/rss-reader/RssReaderWebApplication/Views/_ViewImports.cshtml
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@using RssReaderWebApplication | ||
@using RssReaderWebApplication.Models | ||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
3 changes: 3 additions & 0 deletions
3
projects/rss-reader/rss-reader/RssReaderWebApplication/Views/_ViewStart.cshtml
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@{ | ||
Layout = "_Layout"; | ||
} |
22 changes: 22 additions & 0 deletions
22
projects/rss-reader/rss-reader/RssReaderWebApplication/wwwroot/css/site.css
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
html { | ||
font-size: 14px; | ||
} | ||
|
||
@media (min-width: 768px) { | ||
html { | ||
font-size: 16px; | ||
} | ||
} | ||
|
||
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { | ||
box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; | ||
} | ||
|
||
html { | ||
position: relative; | ||
min-height: 100%; | ||
} | ||
|
||
body { | ||
margin-bottom: 60px; | ||
} |
Binary file added
BIN
+5.3 KB
projects/rss-reader/rss-reader/RssReaderWebApplication/wwwroot/favicon.ico
Binary file not shown.
4 changes: 4 additions & 0 deletions
4
projects/rss-reader/rss-reader/RssReaderWebApplication/wwwroot/js/site.js
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification | ||
// for details on configuring this project to bundle and minify static web assets. | ||
|
||
// Write your JavaScript code. |
22 changes: 22 additions & 0 deletions
22
projects/rss-reader/rss-reader/RssReaderWebApplication/wwwroot/lib/bootstrap/LICENSE
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2011-2021 Twitter, Inc. | ||
Copyright (c) 2011-2021 The Bootstrap Authors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
Oops, something went wrong.