public string Generate(string title, List<string> filePaths, string imagePath = null) { // todo: add validation library - CuttingEdge.Conditions ? var feed = new RssFeed(); feed.Channel.Link = new Uri(GetUrl(Port, "feed.xml")); feed.Channel.Title = title; if (imagePath != null) { var file = new FileInfo(imagePath); if (file.Exists) { var extension = new YahooMediaSyndicationExtension(); extension.Context.Thumbnails.Add(new YahooMediaThumbnail(new Uri(GetUrl(Port, file.Name)))); feed.Channel.AddExtension(extension); } } foreach (string filePath in filePaths) { var item = GetItem(filePath); if (item != null) feed.Channel.AddItem(item); } return feed.CreateNavigator().OuterXml; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); RssFeed feed = new RssFeed(); feed.Channel.Link = new Uri("http://blag.Jiyuu.org/"); feed.Channel.Title = "אנימה בלאג"; feed.Channel.Description = "סיכום הפוסטים האחרונים שאונדקסו בבלאג"; List<BlogPost> posts = AggregationManager.GetPosts(null, null).Take(15).ToList(); RssItem item; foreach (BlogPost post in posts) { item = new RssItem(); item.Title = post.Title; item.Link = new Uri(post.Link); item.Description = post.Summary; Argotic.Extensions.Core.SiteSummaryContentSyndicationExtension contentExt = new Argotic.Extensions.Core.SiteSummaryContentSyndicationExtension(); contentExt.Context.Encoded = "";// HttpUtility.HtmlDecode(string.Format(@"<dir=""rtl"" style=""text-align: right;"" trbidi=""on"">{0}</div>", post.Summary)); //Argotic.Extensions.Core.SiteSummaryContentItem content = new Argotic.Extensions.Core.SiteSummaryContentItem(); //content.Content = new XCData(string.Format(@"<dir=""rtl"" style=""text-align: right;"" trbidi=""on"">{0}</div>", post.Summary)).ToString(); //contentExt.Context.Items.Add(content); item.AddExtension(contentExt); item.PublicationDate = post.PublicationTS; feed.Channel.AddItem(item); } //using (FileStream stream = new FileStream("SimpleRssFeed.xml", FileMode.Create, FileAccess.Write)) //{ Response.ContentType = "application/rss+xml"; Response.Write(feed.CreateNavigator().OuterXml); //} }