BlogsAPI published-FOAF-parser

После некоторых раздумий выложил исходники BlogsAPI в опен сорс. Мне не жалко, если кто будет их использовать для своих проектов, ведь главное, что они будут написаны на .Net.
Большую часть Юнит-тестов я исключил из проекта, чтобы не палить пароли от реальных аккаунтов.

Отдельно обращаю внимание на то, как с помощью библиотеки парсить FOAF файлы:

Copy Source | Copy HTML
  1. namespace BlogsAPI.Rdf
  2. {
  3.     using System;
  4.     using RssToolkit.Xml;
  5.     using NUnit.Framework;
  6.  
  7.     [TestFixture]
  8.     public class RdfUnitTest
  9.     {
  10.         /// <summary>
  11.         /// Parsing FOAF data from Internet
  12.         /// </summary>
  13.         [Test]
  14.         public void LoadFoaf()
  15.         {
  16.             Uri[] FOAFs = new[] {
  17.                 new Uri("http://www.liveinternet.ru/users/flashr/foaf/"),
  18.                 new Uri("http://community.livejournal.com/ktosomnoi/data/foaf"),
  19.                 new Uri("http://dolboeb.livejournal.com/data/foaf"),
  20.                 new Uri("http://flashr.ya.ru/foaf.xml"),
  21.                 new Uri("http://clubs.ya.ru/ya/foaf.xml"),
  22.                 new Uri("http://eikeon.com/foaf.rdf"),
  23.                 new Uri("http://madskristensen.net/foaf.axd")
  24.             };
  25.             foreach (Uri linkto in FOAFs)
  26.             {
  27.                 RdfDocument rDoc = RdfDocument.Load(linkto);
  28.                 Assert.AreNotEqual(null, rDoc.Who);
  29.             //    String foafFile = rDoc.ToXml(DocumentType.Rdf);
  30.             //    Assert.AreEqual(false, String.IsNullOrEmpty(foafFile));
  31.             }
  32.         }
  33.  
  34.         /// <summary>
  35.         /// Making FOAF file
  36.         /// </summary>
  37.         [Test]
  38.         public void PublishFoaf()
  39.         {
  40.             RdfDocument rdf = new RdfDocument
  41.                   {
  42.                       Version = "0.9",
  43.                       Lang = "ru",
  44.                       Who = new FoafPerson
  45.                         {
  46.                             Pages = new[]
  47.                             {
  48.                                      new RdfElement
  49.                                      {
  50.                                          Resource = "http://ya.topbot.ru/feedback.aspx",
  51.                                          Description = "Flashr's contact information",
  52.                                          Date = DateTime.Now.ToString("yyyy-MM-dd"),
  53.                                      },
  54.                             },
  55.                             Language = "ru-RU",
  56.                             Name = "Flashr",
  57.                             Nick = "Topbot",
  58.                             About = "Робот блогосферы",
  59.                             BirthDay = "1985-10-11",
  60.                             Bio = ".Net Developer",
  61.                             City = new RdfElement
  62.                                        {
  63.                                            Title = "Москва",
  64.                                            Resource = "http://maps.google.com/maps?f=q&source=s_q&hl=ru&geocode=&q=%D0%9C%D0%BE%D1%81%D0%BA%D0%B2%D0%B0&sll=37.0625,-95.677068&sspn=27.976484,63.544922&ie=UTF8&hq=&hnear=%D0%A0%D0%BE%D1%81%D1%81%D0%B8%D1%8F,+%D0%9C%D0%BE%D1%81%D0%BA%D0%B2%D0%B0&t=h&z=9"
  65.                                        },
  66.                             //Gender = FoafGender.male,
  67.                             Weblog = new WeblogExt
  68.                                          {
  69.                                              Title = "My Blog",
  70.                                              Resource = "http://ya.topbot.ru"
  71.                                          },
  72.                             Activities = new []
  73.                              {
  74.                                  new BlogActivityClass{
  75.                                      data = new PostsActivity
  76.                                      {
  77.                                          RSS =
  78.                                              "http://feeds.feedburner.com/Topbot",
  79.                                          Posted = 666
  80.                                      }},
  81.                                  new BlogActivityClass{
  82.                                      data = new CommentsActivity
  83.                                      {
  84.                                          Received = 11
  85.                                      }
  86.                                  }
  87.                              },
  88.                              Knows = new []{
  89.                                  new FoafKnow
  90.                                  {
  91.                                      Person = new FoafPerson
  92.                                       {
  93.  
  94.                                           Nick = "idiot1",
  95.                                           Name = "Someone",
  96.                                           Weblog = new WeblogExt
  97.                                           {
  98.                                                Resource = "http://idiot1.livejournal.com"
  99.                                           }
  100.                                       }
  101.                                  },
  102.                                  new FoafKnow
  103.                                  {
  104.                                      Person = new FoafGroup
  105.                                       {
  106.                                           Name = "Клуб алкоголиков",
  107.                                           Nick = "alco_club",
  108.                                           Weblog = new WeblogExt
  109.                                            {
  110.                                             Resource = "http://community.livejournal.com/alco_club"
  111.                                            }
  112.  
  113.                                       }
  114.                                  }
  115.                         }
  116.                     }
  117.               };
  118.             //
  119.             String foafFile = rdf.ToXml(DocumentType.Rdf);
  120.             Assert.AreEqual(false,String.IsNullOrEmpty(foafFile));
  121.         }
  122.     }
  123. }
  124.  

Метки: , , ,   


blog comments powered by Disqus

Добавить комментарий

Кто я?

Программист. Я слежу за блогосферой и знаю, как будет развиваться интернет. Когда у меня есть время я даже прилагаю для этого усилия. Подробнее

Последние комментарии

Не отображать

Topbot at FeedsBurner
 

копирайт

Все мысли, высказанные в блоге, являются моим мнением и за это мнение меня никто не забанит! Кроме того, никто не имеет право копировать материалы блога без использования ctrl+C/V!

© Copyright 2008