File tree Expand file tree Collapse file tree 6 files changed +134
-7
lines changed
cloudscribe.Syndication.Web Expand file tree Collapse file tree 6 files changed +134
-7
lines changed Original file line number Diff line number Diff line change 1111using Microsoft . AspNetCore . Mvc ;
1212using Microsoft . Extensions . Logging ;
1313using System . Collections . Generic ;
14+ using System . IO ;
1415using System . Threading . Tasks ;
16+ using System . Xml . Linq ;
1517
1618namespace cloudscribe . Syndication . Web . Controllers
1719{
@@ -75,6 +77,9 @@ public virtual async Task<IActionResult> Index()
7577
7678 var xml = XmlFormatter . BuildXml ( currentChannel ) ;
7779
80+ var processingInstruction = new XProcessingInstruction ( "xml-stylesheet" , "type=\" text/xsl\" href=\" /rss-style.xsl\" " ) ;
81+ xml . AddFirst ( processingInstruction ) ;
82+
7883 return new XmlResult ( xml ) ;
7984
8085 }
Original file line number Diff line number Diff line change 1+ <Project >
2+ <Target Name =" CopyRssAssets" AfterTargets =" Build" >
3+ <Message Text =" Running CopyRssAssets" Importance =" High" />
4+ <ItemGroup >
5+ <RssAsset Include =" $(MSBuildThisFileDirectory)\rss-style.xsl" />
6+ <RssAsset Include =" $(MSBuildThisFileDirectory)\rss.css" />
7+ </ItemGroup >
8+
9+ <Message Text =" Checking file: %(RssAsset.Identity)" Importance =" High" />
10+
11+ <Copy
12+ SourceFiles =" @(RssAsset)"
13+ DestinationFiles =" @(RssAsset->'$(ProjectDir)wwwroot\%(Filename)%(Extension)')"
14+ SkipUnchangedFiles =" true"
15+ Condition =" !Exists('$(ProjectDir)wwwroot\rss-style.xsl') Or !Exists('$(ProjectDir)wwwroot\rss.css')" />
16+ </Target >
17+ </Project >
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <xsl : stylesheet version =" 3.0" xmlns : xsl =" http://www.w3.org/1999/XSL/Transform" >
3+ <xsl : output method =" html" version =" 1.0" encoding =" utf-8" indent =" yes" />
4+ <xsl : template match =" /" >
5+ <html xmlns =" http://www.w3.org/1999/xhtml" >
6+ <head >
7+ <title >
8+ <xsl : value-of select =" /rss/channel/title" />
9+ </title >
10+ <meta charset =" utf-8" />
11+ <meta name =" viewport" content =" width=device-width, initial-scale=1" />
12+ <link rel =" stylesheet" href =" /rss.css" />
13+ </head >
14+ <body >
15+ <header >
16+ <h1 >
17+ <xsl : value-of select =" /rss/channel/title" />
18+ </h1 >
19+ <p >
20+ <xsl : value-of select =" /rss/channel/description" />
21+ </p >
22+ </header >
23+ <main >
24+ <xsl : for-each select =" /rss/channel/item" >
25+ <article >
26+ <h3 >
27+ <a >
28+ <xsl : attribute name =" href" >
29+ <xsl : value-of select =" link" />
30+ </xsl : attribute >
31+ <xsl : value-of select =" title" />
32+ </a >
33+ </h3 >
34+ <p >
35+ <xsl : value-of select =" description" />
36+ </p >
37+ <p >
38+ <xsl : value-of select =" pubDate" />
39+ </p >
40+ </article >
41+ </xsl : for-each >
42+ </main >
43+ </body >
44+ </html >
45+ </xsl : template >
46+ </xsl : stylesheet >
Original file line number Diff line number Diff line change 1+ * {
2+ box-sizing : border-box;
3+ font-family : sans-serif;
4+ line-height : 1.4 ;
5+ margin : 0 ;
6+ padding : 0 ;
7+ }
8+
9+ html {
10+ background : # FFFFFF ;
11+ color : # 212529 ;
12+ }
13+
14+ body {
15+ padding : 1.5rem ;
16+ }
17+
18+ a {
19+ color : # 337ab7 ;
20+ }
21+
22+ a : hover {
23+ color : # 296292 ;
24+ }
25+
26+ main , header {
27+ margin-block-end : 3rem ;
28+ margin-inline : auto;
29+ max-inline-size : 80ch ;
30+ }
31+
32+ article {
33+ margin-block-end : 3rem ;
34+ }
35+
36+ h1 {
37+ font-size : 2.5rem ;
38+ line-height : 1.2 ;
39+ margin-block : 1rem ;
40+ }
41+
42+ h2 {
43+ font-size : 2rem ;
44+ margin-block : 2rem ;
45+ }
46+
47+ h3 {
48+ font-size : 1.75rem ;
49+ margin-block : 1rem ;
50+ }
51+
52+ p {
53+ font-size : 1.25rem ;
54+ margin-block-end : 1rem ;
55+ }
56+
57+ small {
58+ font-size : 1rem ;
59+ }
Original file line number Diff line number Diff line change 1- <Project Sdk =" Microsoft.NET.Sdk" >
1+ <Project Sdk =" Microsoft.NET.Sdk" >
22
33 <PropertyGroup >
44 <Description >asp.netcore mvc controller for rss feeds</Description >
2929 <ItemGroup >
3030 <FrameworkReference Include =" Microsoft.AspNetCore.App" />
3131 </ItemGroup >
32-
33-
32+
33+ <ItemGroup >
34+ <None Include =" buildTransitive\cloudscribe.Syndication.Web.targets" Pack =" true" PackagePath =" buildTransitive/cloudscribe.Syndication.Web.targets" />
35+ <None Include =" buildTransitive\rss-style.xsl" Pack =" true" PackagePath =" buildTransitive/" />
36+ <None Include =" buildTransitive\rss.css" Pack =" true" PackagePath =" buildTransitive/" />
37+ </ItemGroup >
3438</Project >
Original file line number Diff line number Diff line change 2323 <None Include =" icon.png" Pack =" true" PackagePath =" \" />
2424 </ItemGroup >
2525
26-
2726 <ItemGroup >
2827 <FrameworkReference Include =" Microsoft.AspNetCore.App" />
2928 </ItemGroup >
30-
31-
32-
3329</Project >
You can’t perform that action at this time.
0 commit comments