YandexTurboRss 1.0.1

dotnet add package YandexTurboRss --version 1.0.1                
NuGet\Install-Package YandexTurboRss -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="YandexTurboRss" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add YandexTurboRss --version 1.0.1                
#r "nuget: YandexTurboRss, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install YandexTurboRss as a Cake Addin
#addin nuget:?package=YandexTurboRss&version=1.0.1

// Install YandexTurboRss as a Cake Tool
#tool nuget:?package=YandexTurboRss&version=1.0.1                

YandexTurboRss library

The YandexTurboRss library is the RSS feed markup tool written in C# programming language for the Yandex Turbo pages. Turbo pages feed data is exported in the XML-based RSS 2.0 format.

Please see more about the technology and the data format at the official website: https://tech.yandex.com/turbo/doc/rss/markup-docpage/ and https://tech.yandex.ru/turbo/doc/rss/markup-docpage/

Usage

The library provides you with a bunch of classes that represent a Yandex Turbo Pages feed structure. One of the main classes is TurboChannel that contains information about the source site and maps to the channel tag in the feed. And the crucial class is the TurboFeed that contains channel with items and allows you to add feed items represented by TurboFeedItem, save the feed data to disk or to get the feed collection.

Let's code some examples...

First of all, we need to create a channel:

TurboChannel channel = new TurboChannel()
{
    Description = "Short description of the feed",
    Title = "Feed title",
    Link = new Uri("http://www.example.com/")
};

All right! We've just set up the source information! Now let's create a feed and initialize it with the channel created previously:

TurboFeed feed = new TurboFeed(channel);

So, now we have an empty feed. It's time to add some items there:

TurboFeedItem item = new TurboFeedItem()
 {
    Author = "John Doe",
    Link = "http://www.example.com/category/sub-category/page1.html",
    PubDate = DateTime.Now,
    Topic = "Page title goes here...",
    Content = "Page content goes here..."
 };
feed.AddItem(item);

...or you can add a collection of items:

IEnumerable<TurboFeedItem> items = GetTurboFeedItems();
feed.AddItems(items);

Also, you can pass the feed items when you initialize the channel:

TurboChannel channel = new TurboChannel()
{
    Description = "Short description of the feed",
    Title = "Feed title",
    Link = new Uri("http://www.example.com/"),
    Items = GetTurboFeedItems()
};
TurboFeed feed = new TurboFeed(channel);

Please pay attention to the Yandex requirements about the page's header: https://tech.yandex.com/turbo/doc/rss/markup-docpage/#turbo-content. You'll need to create the header according to the requirements and concatenate it with the page's content. After this, initialize the TurboChannel.Description property with your content. Our library wraps it in [CDATA[...]] so you do not need to care about this. Perhaps the page header functionality will be included in the future versions.

Also, the date passed to the PubDate property will be formatted automatically to the RFC-822 format.

At the end, you can save your feed to disk:

feed.SaveToFile("C:\\rss\\turbo.xml");

Or get the feed collection:

XDocument feedDocument = feed.GetFeed();

Adding analytics to the yandex turbo feed

It is easy to add your counters to the feed ussing the https://webmaster.yandex.ru interface. You can also add analytics using our library:

TurboChannel channel = new TurboChannel()
{
    Analytics = new List<TurboAnalytics>()
    {
        new YandexMetrika("12345"),
        new GoogleAnalytics("ga-12345"),
        new LiveInternet(),
        new RamblerTop100("345678")
    }
};
TurboFeed feed = new TurboFeed(channel);

Adding advertisements to the yandex turbo feed

Here is an example of how you can add some ads to the feed:

TurboChannel channel = new TurboChannel()
{
    AdNetworks = new List<TurboAdNetwork>()
    {
        new AdFox("turbo-ad-id", "<script>ad script</script>"),
        new YandexAd("yandex-block-id", "yandex_ad_place")
    }
};

Please note that Yandex turbo pages only allows you to display Yandex Direct or AdFox ads.

You can post links to other resources or customize the display of the infinite scroll. These links will be placed at the bottom of the Turbo page. To add links anywhere on the page, use YandexRelated class:

TurboFeed feed = new TurboFeed(new TurboChannel()
{
    Description = "Short description",
    Title = "Feed title",
    Link = new Uri("https://sourcewebsite.com"),
});
            
TurboFeedItem item = new TurboFeedItem()
 {
    Related = new YandexRelated
     {
         RelatedLinks = new List<YandexRelatedLink>()
         {
             new YandexRelatedLink()
             {
                 Url = "https://link.com/link1",
                 Text = "Link 1 text"
             },
             new YandexRelatedLink()
             {
                 Url = "https://link.com/link2",
                 Text = "Link 2 text"
             }
         }
     }
};

feed.AddItem(item);
Product Compatible and additional computed target framework versions.
.NET Framework net452 is compatible.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 655 3/9/2020

This package contains a first version of the RSS generator for the Yandex turbo pages.