Coder Social home page Coder Social logo

rsssyndication's Introduction

RssSyndication

.NET Core library for building RSS Feeds

Build status NuGet

Available as a Nuget Package for ASP.NET Core projects:

  • WilderMinds.RssSyndication

Example


// using WilderMinds.RssSyndication;

var feed = new Feed()
{
  Title = "Shawn Wildermuth's Blog",
  Description = "My Favorite Rants and Raves",
  Link = new Uri("http://wildermuth.com/feed"),
  Copyright = "(c) 2016"
};

var item1 = new Item()
{
  Title = "Foo Bar",
  Body = "<p>Foo bar</p>",
  Link = new Uri("http://foobar.com/item#1"),
  Permalink = "http://foobar.com/item#1",
  PublishDate = DateTime.UtcNow,
  Author = new Author() { Name = "Shawn Wildermuth", Email = "[email protected]" }
};

item1.Categories.Add("aspnet");
item1.Categories.Add("foobar");

item1.Comments = new Uri("http://foobar.com/item1#comments");

feed.Items.Add(item1);

var item2 = new Item()
{
  Title = "Quux",
  Body = "<p>Quux</p>",
  Link = new Uri("http://quux.com/item#1"),
  Permalink = "http://quux.com/item#1",
  PublishDate = DateTime.UtcNow,
  Author = new Author() { Name = "Shawn Wildermuth", Email = "[email protected]" }
};

item1.Categories.Add("aspnet");
item1.Categories.Add("quux");

feed.Items.Add(item2);
      
var rss = feed.Serialize();

Let me know if you have any questions or issues!

rsssyndication's People

Contributors

dbochicchio avatar dirq avatar fornever avatar h2df avatar joaoasrosa avatar joaomatossilva avatar jonms90 avatar justdmitry avatar shapeh avatar shawnwildermuth avatar tchelidze avatar zacpwhite avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

rsssyndication's Issues

<pubDate> is using localized dates which disagree with RFC 822

Preamble

The RSS specification states:

Element Description Example
pubDate The publication date for the content in the channel. For example, the New York Times publishes on a daily basis, the publication date flips once every 24 hours. That's when the pubDate of the channel changes. All date-times in RSS conform to the Date and Time Specification of RFC 822, with the exception that the year may be expressed with two characters or four characters (four preferred). Sat, 07 Sep 2002 00:00:01 GMT

So, let's take a look into RFC 822, Part 5: Date and Time Specification. Note that it strictly specifies the universal, non-localizable date format. E.g. the day of week and month names shouldn't be localized according to that format.

Fable

So, I'm using RssSyndication in my national environment, and it generates output such as <pubDate>Вс, 12 фев 2017 00:00:00 +0700</pubDate>; note some of the words are in Russian. I believe it should use the English words instead.

Add functionality to include Atom namespace to RSS for max. compatibility

For maximum compatibility with RSS readers, W3C recommends adding the atom namespace to the rss feed.

W3C validator (https://validator.w3.org/feed/check.cgi) will say:

This feed is valid, but interoperability with the widest range of feed readers could be improved by implementing the following recommendations.: Missing atom:link with rel="self"

For example this code:

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>Shawn Wildermuth's Blog</title>
    <link>http://wildermuth.com/feed</link>
    <description>My Favorite Rants and Raves</description>
    <copyright>(c) 2016</copyright>
    <item>
      <title>Foo Bar</title>
      <link>http://foobar.com/item#1</link>
      <description>&lt;p&gt;Foo bar&lt;/p&gt;</description>
      <author>[email protected] (Shawn Wildermuth)</author>
      <guid>http://foobar.com/item#1</guid>
      <pubDate>Wed, 23 Jan 2019 12:48:26 GMT</pubDate>
    </item>
  </channel>
</rss>

should turn into:

<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
  <atom:link rel="self" type="application/rss+xml" href="https://www.example.org/linktofeed"/>
    <title>Shawn Wildermuth's Blog</title>
    <link>http://wildermuth.com/feed</link>
    <description>My Favorite Rants and Raves</description>
    <copyright>(c) 2016</copyright>
    <item>
      <title>Foo Bar</title>
      <link>http://foobar.com/item#1</link>
      <description>&lt;p&gt;Foo bar&lt;/p&gt;</description>
      <author>[email protected] (Shawn Wildermuth)</author>
      <guid>http://foobar.com/item#1</guid>
      <pubDate>Wed, 23 Jan 2019 12:48:26 GMT</pubDate>
    </item>
  </channel>
</rss>

Basically "just" adding these two extra lines:

<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<atom:link rel="self" type="application/rss+xml" href="https://www.example.org/linktofeed"/>

I am not sure how to do this myself but any feedback would be great.

Lastest version as NuGet?

Hi,

Thanks for some awesome software!

By the looks of it, the current NuGet does not include the item enclosures, correct? Could you push a new NuGet version?

Will use the source for now.

Thanks!

Encoding would be better as UTF-8

XML is encoded as UTF-16. UTF-8 is more widely supported, I would consider changing it to UTF-8 or allowing the encoding to be specified.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.