コード例 #1
0
        public SyndicationFeedFormatter GetJobs(string format)
        {
            var groups = _Scheduler.GetJobGroupNames();
            SyndicationFeed feed = new SyndicationFeed();
            List<SyndicationItem> items = new List<SyndicationItem>();
            foreach (var group in groups)
            {
                var jobKeys = _Scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(group));

                foreach (var jobKey in jobKeys)
                {
                    var job = _Scheduler.GetJobDetail(jobKey);
                    SyndicationItem item = new SyndicationItem();
                    item.Id = job.Key.ToString();
                    item.LastUpdatedTime = DateTime.UtcNow;
                    item.Title = new TextSyndicationContent(string.Format("{0} - {1}", job.Key.Group, job.Key.Name), TextSyndicationContentKind.Plaintext);
                    item.Summary = new TextSyndicationContent(string.Format("Job {0} for group {1}.", job.Key.Name, job.Key.Group), TextSyndicationContentKind.Plaintext);
                    items.Add(item);
                }

            }
            feed.Items = items;
            SyndicationFeedFormatter formatter = new Rss20FeedFormatter(feed);

            return formatter;
        }
コード例 #2
0
ファイル: RSS.aspx.cs プロジェクト: rndthoughts/ipimpplus
        protected void Page_Load(object sender, System.EventArgs e)
        {
            List<SyndicationItem> syndicationItems = new List<SyndicationItem>();

            IList<Card> cards = uWiMP.TVServer.Cards.GetCards();
            foreach (Card card in cards)
            {
                if (card.Enabled & card.Name.ToLower().Contains("builtin"))
                {
                    uWiMP.TVServer.Cards.Status status = uWiMP.TVServer.Cards.GetCardStatus(card);
                    SyndicationItem si = new SyndicationItem();
                    si.Title = new TextSyndicationContent("Recording");
                }
            }

            SyndicationFeed feed = new SyndicationFeed(syndicationItems);

            StringWriter output = new StringWriter();
            XmlTextWriter writer = new XmlTextWriter(output);

            Rss20FeedFormatter f = new Rss20FeedFormatter(feed);
            f.WriteTo(writer);

            Context.Response.ContentType = "application/rss+xml";
            Context.Response.Write(output.ToString());
        }
コード例 #3
0
 protected override void because()
 {
     base.because();
     entry = new BlogEntry
                 {Author = "Me", Content = "Content", PublicationDate = DateTime.Now, Title = "Title"};
     item = new BlogEntryToRssConverter(entry).ToRssItem();
 }
コード例 #4
0
        /// <summary>
        /// Converts This IComposableMessage Into A Geo-RSS SyndicationItem
        /// </summary>
        /// <param name="myitem">Pointer to a Syndication Item to Populate</param>
        internal override void ToGeoRSS(System.ServiceModel.Syndication.SyndicationItem myitem)
        {
            myitem.Title = new TextSyndicationContent("Field Observation - " + this.observationType.ToString() + " (EDXL-SitRep)");
            TextSyndicationContent content = new TextSyndicationContent("Observation: " + this.observationText + "\nImmediate Needs: " + this.immediateNeeds);

            myitem.Content = content;
        }
コード例 #5
0
ファイル: HomeController.cs プロジェクト: gmstr/GMSBlog
        public virtual ActionResult Feed()
        {
            using (var repository = ObjectFactory.GetInstance<IBlogService>())
            {
                var items = new List<SyndicationItem>();

                foreach (var post in repository.GetPublishedPosts())
                {
                    var item = new SyndicationItem(post.Title,
                                                            post.Summary,
                                                            new Uri(String.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority,
                                                                Url.Action(Actions.PostByName(post.Title,
                                                                                                post.DateCreated.Year,
                                                                                                post.DateCreated.Month,
                                                                                                post.DateCreated.Day)))));

                    items.Add(item);
                }

                var feed = new SyndicationFeed(MvcApplication.BlogTitle,
                                                   MvcApplication.BlogSubtitle,
                                                   new Uri(String.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority)), items);

                return new RssActionResult(feed);
            }
        }
コード例 #6
0
ファイル: feeds.cs プロジェクト: tmzu/keymapper
        public static SyndicationFeed GetPostFeed()
        {
            SyndicationFeed postfeed = Feeds.GetFeed();
            postfeed.Title = new TextSyndicationContent("Key Mapper Developer Blog");
            postfeed.Description = new TextSyndicationContent("Post feed for the Key Mapper Developer Blog");

            Collection<Post> posts = Post.GetAllPosts(CommentType.Approved);
            List<SyndicationItem> items = new List<SyndicationItem>();

            foreach (Post p in posts)
            {
                SyndicationItem item = new SyndicationItem();
                item.Id = p.Id.ToString();
                item.Title = new TextSyndicationContent(p.Title);
                item.Content = new TextSyndicationContent(p.Body);

                SyndicationLink itemlink = new SyndicationLink();
                itemlink.Title = "Key Mapper Blog";
                itemlink.Uri = new Uri("http://justkeepswimming.net/keymapper/default.aspx?p="
                    + p.Id.ToString() + ".aspx");
                item.Links.Add(itemlink);

                SyndicationPerson person = new SyndicationPerson();
                person.Name = "Stuart Dunkeld";
                person.Email = "*****@*****.**";
                item.Authors.Add(person);

                items.Add(item);
            }

            postfeed.Items = items;
            return postfeed;
        }
コード例 #7
0
ファイル: FeedService.cs プロジェクト: rriwaj/rss-feed-wcf
 public SyndicationFeed GenerateFeeds(int noOfFeeds)
 {
     var feed = new SyndicationFeed
     {
         Title = new TextSyndicationContent("A simple rss feeder."),
         Language = "en-us",
         LastUpdatedTime = DateTime.Now,
         Copyright = new TextSyndicationContent("RRiwaj"),
         Description = new TextSyndicationContent("This is a simple rss feeder created using WCF Syndication class."),
         ImageUrl = new Uri("/Contents/Images/rss.png", UriKind.Relative),
     };
     var itemsRepo = _feedRepository.GetFeedItems(noOfFeeds); // Get Item Feeds from feed repository.
     var feedItems = new List<SyndicationItem>(); // Create new Syndication Item List which will be added to Syndication Feed
     foreach (var proxyItem in itemsRepo)
     {
         var item = new SyndicationItem
         {
             Title = SyndicationContent.CreatePlaintextContent(proxyItem.Title),
             PublishDate = proxyItem.FeedDate,
             Summary = SyndicationContent.CreateHtmlContent(proxyItem.Summary)
         };
         var authInfo = new SyndicationPerson
         {
             Name = proxyItem.AuthorName,
             Email = proxyItem.AuthorEmail
         };
         item.Authors.Add(authInfo);
         item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(proxyItem.FeedUrl)));
         feedItems.Add(item);
     }
     feed.Items = feedItems;
     return feed;
 }
コード例 #8
0
ファイル: RSSResult.cs プロジェクト: ruisebastiao/nerddinner
        protected override void WriteFile(System.Web.HttpResponseBase response)
        {
            var items = new List<SyndicationItem>();

            foreach (Dinner d in this.Dinners)
            {
                string contentString = String.Format("{0} with {1} on {2:MMM dd, yyyy} at {3}. Where: {4}, {5}",
                            d.Description, d.HostedBy, d.EventDate, d.EventDate.ToShortTimeString(), d.Address, d.Country);

                var item = new SyndicationItem(
                    title: d.Title,
                    content: contentString,
                    itemAlternateLink: new Uri("http://nrddnr.com/" + d.DinnerID),
                    id: "http://nrddnr.com/" + d.DinnerID,
                    lastUpdatedTime: d.EventDate.ToUniversalTime()
                    );
                item.PublishDate = d.EventDate.ToUniversalTime();
                item.Summary = new TextSyndicationContent(contentString, TextSyndicationContentKind.Plaintext);
                items.Add(item);
            }

            SyndicationFeed feed = new SyndicationFeed(
                this.Title,
                this.Title, /* Using Title also as Description */
                currentUrl,
                items);

            Rss20FeedFormatter formatter = new Rss20FeedFormatter(feed);

            using (XmlWriter writer = XmlWriter.Create(response.Output))
            {
                formatter.WriteTo(writer);
            }
        }
コード例 #9
0
        public ActionResult Rss(string domain="")
        {
            var news = NewsProvider.GetSeason(2014, domain).OrderByDescending(n=>n.Date).Take(10);

            var feedItems = new List<SyndicationItem>();
            foreach (var news_item in news)
            {
                var item = new SyndicationItem()
                {
                    Title = TextSyndicationContent.CreatePlaintextContent(news_item.Title),
                    PublishDate = new DateTimeOffset(news_item.Date),
                    Summary = TextSyndicationContent.CreateHtmlContent(CombineBriefWithImage(news_item)),
                };
                string url = "http://afspb.org.ru/news/" + news_item.Slug;

                var link = new SyndicationLink(new Uri(url));
                link.Title = "Перейти к новости";
                item.Links.Add(link);
                feedItems.Add(item);
            }

            var feed = new SyndicationFeed(
                    "Новости сайта Автомобильной Федерации Санкт-Петербурга и Ленинградской области",
                    "",
                    new Uri("http://afspb.org.ru/news/Rss"),
                    feedItems);

            return new RssResult()
            {
                Feed = feed
            };
        }
コード例 #10
0
ファイル: Feed.cs プロジェクト: ThomasCOLLIN/dotNET
        public SyndicationFeedFormatter CreateFeedForBlog(string user, string blog)
        {
            SyndicationFeed feed = new SyndicationFeed("Blog feed", "A feed linked to a blog", null);
            List<SyndicationItem> items = new List<SyndicationItem>();
            List<Dbo.RssArticle> articles = BusinessManagement.Feed.GetBlogContent(user, blog);

            foreach (Dbo.RssArticle article in articles)
            {
                SyndicationItem item = new SyndicationItem(article.Title, article.Content, null);
                item.PublishDate = article.CreationDate;
                items.Add(item);
            }
            feed.Items = items;

            // Renvoie ATOM ou RSS en fonction de la chaîne de requête
            // rss -> http://localhost:8733/Design_Time_Addresses/FluxRss/Feed1/
            // atom -> http://localhost:8733/Design_Time_Addresses/FluxRss/Feed1/?format=atom
            string query = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["format"];
            SyndicationFeedFormatter formatter = null;
            if (query == "atom")
            {
                formatter = new Atom10FeedFormatter(feed);
            }
            else
            {
                formatter = new Rss20FeedFormatter(feed);
            }

            return formatter;
        }
コード例 #11
0
		/// <summary>
		/// Executes the syndication result on the given context.
		/// </summary>
		/// <param name="context">The current context.</param>
		public override void ExecuteResult(ControllerContext context) {
			var response = context.HttpContext.Response;
			var writer = new XmlTextWriter(response.OutputStream, Encoding.UTF8);

			// Write headers
			response.ContentType = ContentType;
			response.ContentEncoding = Encoding.UTF8;

			var feed = new SyndicationFeed() { 
				Title = new TextSyndicationContent(Config.Blog.Title),
				LastUpdatedTime = Posts.First().Published.Value,
				Description = new TextSyndicationContent(Config.Blog.Description),
			};
			feed.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(Utils.AbsoluteUrl("~/"))));

			var items = new List<SyndicationItem>();
			foreach (var post in Posts) {
				var item = new SyndicationItem() { 
					Title = SyndicationContent.CreatePlaintextContent(post.Title),
					PublishDate = post.Published.Value,
					Summary = SyndicationContent.CreateHtmlContent(post.Html.ToHtmlString())
				};
				item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(Utils.AbsoluteUrl("~/" + post.Slug))));
				items.Add(item);
			}
			feed.Items = items;

			var formatter = GetFormatter(feed);
			formatter.WriteTo(writer);

			writer.Flush();
			writer.Close();
		}
コード例 #12
0
        public Rss20FeedFormatter GetFeed()
        {
            List<News> news = NewsRepository.GetNews();

            var feed = new SyndicationFeed("Nieuwsoverzicht van het festival", "Description", new Uri("http://localhost:8080"));
            feed.Authors.Add(new SyndicationPerson("Festival naam"));
            feed.Categories.Add(new SyndicationCategory("Festival"));
            feed.Description = new TextSyndicationContent("This is a how to sample that demonstrates how to expose a feed using RSS with WCF");

            List<SyndicationItem> items = new List<SyndicationItem>();
            foreach (News n in news)
            {
                SyndicationItem item = new SyndicationItem(
                n.Title,
                n.Content,
                new Uri("http://localhost:51172/"),
                n.Id,
                n.Date);
                item.Authors.Add(new SyndicationPerson(n.Author));

                items.Add(item);
            }
            feed.Items = items;

            return new Rss20FeedFormatter(feed);
        }
コード例 #13
0
ファイル: Feed1.cs プロジェクト: hkuntal/MySociety
        public SyndicationFeedFormatter CreateFeed()
        {
            // Create a new Syndication Feed.
            SyndicationFeed feed = new SyndicationFeed("Feed Title", "A WCF Syndication Feed", null);
            List<SyndicationItem> items = new List<SyndicationItem>();

            // Create a new Syndication Item.
            SyndicationItem item = new SyndicationItem("An item", "Item content", null);
            items.Add(item);
            feed.Items = items;

            // Return ATOM or RSS based on query string
            // rss -> http://localhost:8733/Design_Time_Addresses/SyndicationServiceLibrary1/Feed1/
            // atom -> http://localhost:8733/Design_Time_Addresses/SyndicationServiceLibrary1/Feed1/?format=atom
            string query = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["format"];
            SyndicationFeedFormatter formatter = null;
            if (query == "atom")
            {
                formatter = new Atom10FeedFormatter(feed);
            }
            else
            {
                formatter = new Rss20FeedFormatter(feed);
            }

            return formatter;
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: DevrexLabs/GeekStream
        private static FeedItem CreateFeedItem(SyndicationItem syndicationItem, out string[] searchWords)
        {
            FeedItem newFeedItem = new FeedItem();

            try
            {
                var link = syndicationItem.Links.FirstOrDefault(l => l.RelationshipType == "alternate")
                           ?? syndicationItem.Links.FirstOrDefault(l => l.RelationshipType == "self")
                           ?? syndicationItem.Links.First();
                newFeedItem.Url = link.Uri.ToString();
            }
            catch (Exception ex)
            {
                throw new Exception("Syndication item has no links", ex);
            }

            newFeedItem.Published = syndicationItem.PublishDate;

            var builder = new SyndicationItemParser(syndicationItem);
            newFeedItem.Summary = builder.Summary;
            searchWords = builder.Keywords;

            newFeedItem.Title = syndicationItem.Title.Text;
            return newFeedItem;
        }
コード例 #15
0
    /// <summary>
    /// The add syndication item.
    /// </summary>
    /// <param name="currentList">
    /// The current list.
    /// </param>
    /// <param name="title">
    /// The title.
    /// </param>
    /// <param name="content">
    /// The content.
    /// </param>
    /// <param name="summary">
    /// The summary.
    /// </param>
    /// <param name="link">
    /// The alternate link.
    /// </param>
    /// <param name="id">
    /// The id.
    /// </param>
    /// <param name="posted">
    /// The posted.
    /// </param>
    public static void AddSyndicationItem(
      this List<SyndicationItem> currentList, string title, string content, string summary,string link, string id, DateTime posted, YafSyndicationFeed feed, List<SyndicationLink> mlinks)
    {
      var si = new SyndicationItem(
        YafContext.Current.Get<IBadWordReplace>().Replace(title),
        new TextSyndicationContent(YafContext.Current.Get<IBadWordReplace>().Replace(content),TextSyndicationContentKind.Html),
        // Alternate Link
        new Uri(link),
        id,
        new DateTimeOffset(posted)) {PublishDate = new DateTimeOffset(posted)};
      if (mlinks != null)
      {

        foreach (var syndicationLink in mlinks)
        {
          si.Links.Add(syndicationLink);
        }
      }
      si.Authors.Add(new SyndicationPerson(String.Empty, feed.Contributors[feed.Contributors.Count - 1].Name, String.Empty));
      si.SourceFeed = feed;
      if (summary.IsNotSet())
      {
        si.Summary = new TextSyndicationContent(YafContext.Current.Get<IBadWordReplace>().Replace(content),
          TextSyndicationContentKind.Html);
      }
      else
      {
        si.Summary = new TextSyndicationContent(YafContext.Current.Get<IBadWordReplace>().Replace(summary),
          TextSyndicationContentKind.Html);  
      }

      

      currentList.Add(si);
    }
コード例 #16
0
        private RssActionResult RSS(Func<V1FeedPackage, bool> exclude)
        {
            var nugetODataUrl = new Uri("http://packages.nuget.org/v1/FeedService.svc");
            var nugetOData = new FeedContext_x0060_1(nugetODataUrl);

            var packages = nugetOData.Packages.OrderByDescending(p => p.Published);
            var nugetFeed = new List<SyndicationItem>();

            foreach (var package in packages)
            {
                if (exclude(package)) continue;

                var syndicationItem = new SyndicationItem(
                    package.Title,
                    package.Description,
                    new Uri(package.ProjectUrl ?? package.GalleryDetailsUrl),
                    package.Id,
                    package.LastUpdated);
                nugetFeed.Add(syndicationItem);
            }

            return new RssActionResult
            {
                Feed = new SyndicationFeed(
                    "NuGet Feed",
                    "NuGet OData feed converted to RSS",
                    new Uri("http://www.nugetfeed.com/"),
                    "urn:uuid:f4df456c-6643-4c53-a6e5-f180ce6e030d",
                    nugetFeed.First().LastUpdatedTime,
                    nugetFeed)
            };
        }
コード例 #17
0
        public ActionResult ActivityFeed(string name, int id)
        {
            var polfeed = _polRep.LatestFeed(id, includeposts);
            List<SyndicationItem> items = new List<SyndicationItem>();
            var pol = _polRep.GetPoliticianById(id);
            var polLink = this.Request.Url.GetLeftPart(UriPartial.Authority) + pol.PolLink(this);

            SyndicationFeed feed =
                new SyndicationFeed(
                        String.Format("{0} Feed", pol.FullName()), "Activity Feed på Folkets Ting",
                        new Uri(Request.Url.ToString()),
                        Request.Url.AbsoluteUri,
                        polfeed.Last().date);

            foreach (var feeditem in polfeed)
            {
                var link = (this.Request.Url.GetLeftPart(UriPartial.Authority) + feeditem.ActionUrl);
                SyndicationItem item =
                    new SyndicationItem(feeditem.ActionText,
                                    feeditem.BodyText,
                                    new Uri(link),
                                    feeditem.ActionUrl + feeditem.ActionText,
                                    feeditem.date);
                items.Add(item);
            }
            feed.Items = items;

            return new RssActionResult() { Feed = feed };
        }
コード例 #18
0
        public SyndicationFeed CreateSyndicationFeed(string nickname, string feedType, string scheme, string host)
        {
            IList<Post> posts = _postRepository.GetBlogPosts(nickname);
            Blog blog = _blogRepository.GetBlog(nickname);
            
            string url = string.Format("{0}://{1}/{2}", scheme, host, nickname);
            var feed = new SyndicationFeed(blog.Title, blog.Description, new Uri(url), url, blog.LastUpdated);
            feed.Authors.Add(new SyndicationPerson {Name = blog.User.Name});
            
            feed.Links.Add(SyndicationLink.CreateSelfLink(new Uri(url + "/feed/" + feedType)));

            var items = new List<SyndicationItem>();
            foreach (Post post in posts)
            {
                var htmlurl = string.Format("{0}://{1}/{2}/{3}/{4}/{5}/{6}", scheme, host, nickname, post.Posted.Year,
                                    post.Posted.Month, post.Posted.Day, post.TitleLink);

                var item = new SyndicationItem();
                item.Title = new TextSyndicationContent(post.Title, TextSyndicationContentKind.Html);
                item.Content = new TextSyndicationContent(post.BlogPost, TextSyndicationContentKind.Html);
                item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(htmlurl), "text/html"));
                
                var editurl = string.Format("{0}://{1}/{2}/pub/atom/{3}", scheme, host, nickname, post.Id);
                item.Links.Add(SyndicationLink.CreateSelfLink(new Uri(editurl)));
                item.Links.Add(new SyndicationLink { RelationshipType = "edit", Uri = new Uri(editurl), MediaType = "application/atom+xml;type=entry" });

                item.PublishDate = post.Edited;
                item.Id = editurl;
                items.Add(item);                
            }
            feed.Items = items;
            return feed;
        }
コード例 #19
0
        /// <summary>
        /// Create the feed 
        /// </summary>
        /// <returns>The created feed</returns>
        public override SyndicationFeed ToFeed()
        {
            SyndicationFeed feed = new SyndicationFeed(Title, Title, new Uri(Uri), Id, DateTime.Parse(Updated.At));
            //feed.Authors.Add(new SyndicationPerson("*****@*****.**"));
            feed.Categories.Add(new SyndicationCategory(Title));
            feed.Description = new TextSyndicationContent(Title);

            List<SyndicationItem> items = new List<SyndicationItem>();
            if (commentList != null && commentList.comments != null)
            {
                for (int i = 0; i < commentList.comments.Count; i++)
                {
                    SyndicationItem item = new SyndicationItem(
                    "",
                    commentList.comments[i].text,
                    new Uri(commentList.comments[i].Uri),
                    commentList.comments[i].ID.ToString(),
                    DateTime.Parse(commentList.comments[i].Created.At));
                    items.Add(item);
                }

            }
            feed.Items = items;
            return feed;


        }
        /// <summary>
        /// Normalizes a SyndicationItem into a FeedItem.
        /// </summary>
        /// <param name="feed">The <see cref="SyndicationFeed"/> on which the item was retrieved.</param>
        /// <param name="item">A <see cref="SyndicationItem"/> to normalize into a <see cref="FeedItem"/>.</param>
        /// <returns>Returns a normalized <see cref="FeedItem"/>.</returns>
        public virtual FeedItem Normalize(SyndicationFeed feed, SyndicationItem item)
        {
            var alternatelink = item.Links.FirstOrDefault(l => l.RelationshipType == null || l.RelationshipType.Equals("alternate", StringComparison.OrdinalIgnoreCase));

            Uri itemuri = null;
            Uri parsed;
            if (alternatelink == null && !Uri.TryCreate(item.Id, UriKind.Absolute, out parsed))
            {
                itemuri = parsed;
            }
            else
            {
                itemuri = alternatelink.GetAbsoluteUri();
            }

            return new FeedItem
            {
                Id = string.IsNullOrEmpty(item.Id) ? null : item.Id.Trim(),
                Title = item.Title == null ? null : Normalize(item.Title.Text),
                Content = item.Content == null ? null : Normalize(((TextSyndicationContent)item.Content).Text),
                Summary = item.Summary == null ? null : Normalize(item.Summary.Text),
                PublishDate = item.PublishDate,
                LastUpdatedDate = item.LastUpdatedTime == DateTimeOffset.MinValue ? item.PublishDate : item.LastUpdatedTime,
                Uri = itemuri
            };
        }
コード例 #21
0
        public ActionResult NewsRssFeed()
        {
            var latestNews = Umbraco.TypedContentAtXPath("//ulgNewsItem").Where(x => x.IsVisible()).OrderByDescending(x => x.GetPropertyValue<DateTime>("articleDate")).Take(20);

            var lastUpdate = (from news in latestNews
                              select news.UpdateDate).Max();
            SyndicationFeed feed =
                     new SyndicationFeed("Local Government Starter Kit News RSS Feed Example",
                                         "Latest News for Local Government Starter Kit site",
                                         new Uri("http://www.uLocalGov.co.uk"),
                                         "uLocalCovNews",
                                         lastUpdate);

            List<SyndicationItem> items = new List<SyndicationItem>();
            foreach (var newsItem in latestNews)
            {
                string itemTitle = string.Format("{0}", newsItem.GetPropertyValue("title"));
                   Uri itemURI = new Uri(newsItem.UrlWithDomain());
                string itemContent = string.Format("<p>{0:dddd, MM yyyy} - {1}</p>", newsItem.GetPropertyValue<DateTime>("articleDate"), newsItem.GetPropertyValue("newsSummary"));
                SyndicationItem item =
                    new SyndicationItem(itemTitle,
                                        itemContent,
                                        itemURI,
                                        newsItem.Id.ToString(),
                                        newsItem.UpdateDate);

                items.Add(item);
            }
            feed.Items = items;
            return new RssActionResult(feed);
        }
コード例 #22
0
ファイル: Atom10Serializer.cs プロジェクト: nickchal/pash
		internal override void WriteXml(XmlWriter writer, SyndicationItem item)
		{
			writer.WriteStartElement(ItemName, ItemNamespace);
			writer.WriteElementString("id", item.Id);
			WriteXml(writer, item.Title, "title");
			WriteXml(writer, item.Summary, "summary");
			
			DateTime defDate = new DateTime(0);
			if (item.PublishDate != defDate)
				{
					string date = item.PublishDate.ToUniversalTime().ToString("s");
					writer.WriteElementString("published", date + "Z");
				}

			if (item.LastUpdatedTime != defDate)
				{
					string date = item.LastUpdatedTime.ToUniversalTime().ToString("s");
					writer.WriteElementString("updated", date + "Z");
				}

			WriteXml(writer, item.Content, "content");
			WriteXml(writer, item.Copyright, "rights");

			writer.WriteEndElement();
		}
コード例 #23
0
        private SyndicationItem FormatLogEntry(LogEntry entry, string repo)
        {
            var markdownParser = new Markdown(true);
            var item = new SyndicationItem();

            item.Id = entry.CommitHash;
            item.Title = new TextSyndicationContent(entry.Subject);
            item.Content = SyndicationContent.CreateHtmlContent(markdownParser.Transform(entry.Subject + "\n\n" + entry.Body));
            item.LastUpdatedTime = entry.AuthorDate;
            item.PublishDate = entry.CommitterDate;

            item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(Url.Action("ViewCommit", "Browse", new { repo, @object = entry.CommitHash }), UriKind.Relative)));

            item.Categories.Add(new SyndicationCategory("commit"));
            if (entry.Parents.Count > 1)
            {
                item.Categories.Add(new SyndicationCategory("merge"));
            }

            item.Authors.Add(new SyndicationPerson(entry.AuthorEmail, entry.Author, null));
            if (entry.Author != entry.Committer || entry.AuthorEmail != entry.CommitterEmail)
            {
                item.Contributors.Add(new SyndicationPerson(entry.CommitterEmail, entry.Committer, null));
            }

            return item;
        }
コード例 #24
0
        private SyndicationItem CreateSyndicationItem(IContent content)
        {
            var changeTrackable = content as IChangeTrackable;
            var changed = DateTime.Now;
            var changedby = string.Empty;

            if (changeTrackable != null)
            {
                changed = changeTrackable.Saved;
                changedby = changeTrackable.ChangedBy;
            }

            var item = new SyndicationItem
            {
                Title = new TextSyndicationContent(content.Name),
                Summary = new TextSyndicationContent(FeedDescriptionProvider.ItemDescripton(content)),
                PublishDate = changed,
            };

            foreach (var contentCategory in ContentCategoryLoader.GetContentCategories(content))
            {
                item.Categories.Add(new SyndicationCategory(contentCategory));
            }         

            var mimeType = GetMimeType(content);
            Uri url = GetItemUrl(content);

            item.Content = new UrlSyndicationContent(url, mimeType);
            item.AddPermalink(url);
            item.Authors.Add(new SyndicationPerson(string.Empty, changedby, string.Empty));

            return item;
        }
コード例 #25
0
        public void set_the_title()
        {
            var subject = new ItemSubject(){
                Title = "first",
                Title2 = "second"
            };

            var target = new SimpleValues<ItemSubject>(subject);

            var map1 = new FeedItem<ItemSubject>();
            map1.Title(x => x.Title);

            var map2 = new FeedItem<ItemSubject>();
            map2.Title(x => x.Title2);

            var item1 = new SyndicationItem();
            map1.As<IFeedItem<ItemSubject>>().ConfigureItem(item1, target);
            item1.Title.Text.ShouldEqual(subject.Title);


            var item2 = new SyndicationItem();
            map2.As<IFeedItem<ItemSubject>>().ConfigureItem(item2, target);
            item2.Title.Text.ShouldEqual(subject.Title2);

        }
コード例 #26
0
ファイル: PostFeed.cs プロジェクト: cdie/Piranha.vNext
		/// <summary>
		/// Executes the syndication result on the given context.
		/// </summary>
		/// <param name="context">The current context.</param>
		public virtual void Write(IStreamResponse response) {
			var writer = new XmlTextWriter(response.OutputStream, Encoding.UTF8);
			var ui = new Client.Helpers.UIHelper();

			// Write headers
			response.ContentType = ContentType;
			response.ContentEncoding = Encoding.UTF8;

			var feed = new SyndicationFeed() { 
				Title = new TextSyndicationContent(Config.Site.Title),
				LastUpdatedTime = Posts.First().Published.Value,
				Description = new TextSyndicationContent(Config.Site.Description),
			};
			feed.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(App.Env.AbsoluteUrl("~/"))));

			var items = new List<SyndicationItem>();
			foreach (var post in Posts) {
				var item = new SyndicationItem() { 
					Title = SyndicationContent.CreatePlaintextContent(post.Title),
					PublishDate = post.Published.Value,
					Summary = SyndicationContent.CreateHtmlContent(post.Body)
				};
				item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(App.Env.AbsoluteUrl("~/" + post.Type.Slug + "/" + post.Slug))));
				items.Add(item);
			}
			feed.Items = items;

			var formatter = GetFormatter(feed);
			formatter.WriteTo(writer);

			writer.Flush();
			writer.Close();
		}
コード例 #27
0
ファイル: Feed1.cs プロジェクト: yoan-durand/TP
        public SyndicationFeedFormatter CreateFeed()
        {
            // Create a new Syndication Feed.
            SyndicationFeed feed = new SyndicationFeed("Bug Track", "Flux rss du bug track", null);
            List<SyndicationItem> items = new List<SyndicationItem>();

            // Create a new Syndication Item.

            List<DBO.Bug> list = BusinessManagement.Bug.GetLastBug(10);

            foreach (DBO.Bug itemBug in list)
            {
                SyndicationItem item = new SyndicationItem(itemBug.ProjectName + " : " + itemBug.Title, itemBug.CreateDate + " \n " + itemBug.Details, null);
                items.Add(item);
            }

            feed.Items = items;

            // Return ATOM or RSS based on query string
            // rss -> http://localhost:8731/Design_Time_Addresses/SyndicationServiceBugTrack/Feed1/
            // atom -> http://localhost:8731/Design_Time_Addresses/SyndicationServiceBugTrack/Feed1/?format=atom
            string query = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["format"];
            SyndicationFeedFormatter formatter = null;
            if (query == "atom")
            {
                formatter = new Atom10FeedFormatter(feed);
            }
            else
            {
                formatter = new Rss20FeedFormatter(feed);
            }

            return formatter;
        }
コード例 #28
0
        public Atom10FeedFormatter GetFeed(int id)
        {
            SyndicationFeed feed = new SyndicationFeed("Atom Feed", "This is a test feed", new Uri("http://SomeURI"), "FeedOneID", new DateTimeOffset(DateTime.Now));
            feed.Authors.Add(new SyndicationPerson("*****@*****.**"));
            feed.Categories.Add(new SyndicationCategory("How To Sample Code"));
            feed.Description = new TextSyndicationContent("This is a sample that illistrates how to expose a feed using ATOM with WCF");

            SyndicationItem item1 = new SyndicationItem(
                "Item One",
                "This is the content for item one",
                new Uri("http://localhost/Content/One"),
                "ItemOneID",
                DateTime.Now);

            SyndicationItem item2 = new SyndicationItem(
                "Item Two",
                "This is the content for item two",
                new Uri("http://localhost/Content/Two"),
                "ItemTwoID",
                DateTime.Now);

            List<SyndicationItem> items = new List<SyndicationItem>();

            items.Add(item1);
            items.Add(item2);

            feed.Items = items;
            return new Atom10FeedFormatter(feed);
        }
コード例 #29
0
ファイル: FeedActionResult.cs プロジェクト: senfo/FrogBlogger
        /// <summary>
        /// Initializes a new instance of the FeedActionResult class
        /// </summary>
        /// <param name="blogName">Name of the blog</param>
        /// <param name="description">Feed description</param>
        /// <param name="format">Format of the feed</param>
        /// <param name="url">A URL Helper</param>
        /// <param name="posts">The posts to include in the feed</param>
        public FeedActionResult(string blogName, string description, FeedFormat format, UrlHelper url, IEnumerable<BlogPost> posts)
        {
            Guid blogPostId;
            string postRelative;
            SyndicationItem item;
            List<SyndicationItem> items = new List<SyndicationItem>();

            // Specify the type of feed
            Format = format;

            // Initialize the current feed
            Feed = new SyndicationFeed(blogName, description, new Uri(url.RouteUrl("Default"), UriKind.Relative));

            //load the posts as items
            foreach (BlogPost post in posts)
            {
                blogPostId = post.BlogPostId;
                postRelative = url.Action(
                    "Details", "Posts",
                    new
                    {
                        year = post.PostedDate.Value.Year,
                        month = post.PostedDate.Value.Month,
                        day = post.PostedDate.Value.Day,
                        id = blogPostId
                    });

                item = new SyndicationItem(post.Title, post.Post,
                    new Uri(postRelative, UriKind.Relative), post.BlogPostId.ToString(), post.PostedDate.Value);

                items.Add(item);
            }

            Feed.Items = items.OrderByDescending(x => x.LastUpdatedTime);
        }
コード例 #30
0
        public static SyndicationFeed ProcessFeedSource( string feedSource )
        {
            HtmlElement rootElement = HtmlElement.Create( feedSource );

            // identify the row container
            HtmlElement container = GetRowContainer( rootElement );

            // identify the rows and pass them into a list
            IList<HtmlElement> elementList = GetElementList( container );

            var items = new List<SyndicationItem>();

            //find all the headlines
            foreach (HtmlElement element in elementList)
            {
                //find the first link within the div
                HtmlAnchorElement link = (HtmlAnchorElement)element.ChildElements.Find( "a", 0 );

                string title = GetFeedItemTitle( link );
                string hRef = GetFeedItemLink( link );
                DateTime publishedTime = GetFeedItemPublishedTime();
                string summary = GetFeedItemSummary();
                DateTime lastUpdatedTime = GetFeedItemLastUpdatedTime();

                var syndicationItem = new SyndicationItem( title, string.Empty, new Uri( hRef ), hRef, lastUpdatedTime );
                syndicationItem.Summary = new TextSyndicationContent( summary, TextSyndicationContentKind.XHtml );
                syndicationItem.PublishDate = publishedTime;

                items.Add( syndicationItem );


            }

            return new SyndicationFeed( items );
        }
コード例 #31
0
        /// <summary>
        /// Turn a SimpleFeed object into a SyndicationFeed object
        /// </summary>
        private SyndicationFeed GetSyndicationFeed(SimpleFeed pFeed)
        {
            var feed = new SyndicationFeed();
            var items = new List<SyndicationItem>();

            feed.BaseUri = new Uri(pFeed.BaseUrl);
            if (!string.IsNullOrWhiteSpace(pFeed.Title))
                feed.Title = new TextSyndicationContent(pFeed.Title);
            if (!string.IsNullOrWhiteSpace(pFeed.Description))
                feed.Description = new TextSyndicationContent(pFeed.Description);
            if (!string.IsNullOrWhiteSpace(pFeed.Language))
                feed.Language = pFeed.Language;

            if (pFeed.Entries != null)
            {
                foreach (var entry in pFeed.Entries)
                {
                    var item = new SyndicationItem(entry.Title, entry.Body, entry.TitleLinkUri);
                    //Id, DatePublished, DateLastUpdated are required so that each new post won't make readers think that every entry is new
                    item.Id = entry.Id;
                    item.PublishDate = entry.DatePublished;
                    item.LastUpdatedTime = entry.DateLastUpdated;
                    item.BaseUri = entry.TitleLinkUri;
                    items.Add(item);
                }
            }

            feed.Items = items;
            return feed;
        }
コード例 #32
0
        /// <summary>
        /// Converts This IComposableMessage Into A Geo-RSS SyndicationItem
        /// </summary>
        /// <param name="myitem">Pointer to a Syndication Item to Populate</param>
        internal override void ToGeoRSS(System.ServiceModel.Syndication.SyndicationItem myitem)
        {
            // myitem.Title = new TextSyndicationContent("Field Observation - " + observationType.ToString() + " (EDXL-SitRep)");
            // TextSyndicationContent content = new TextSyndicationContent("Observation: " + this.observationText + "\nImmediate Needs: " + this.immediateNeeds);
            myitem.Title = new TextSyndicationContent("Casualty and Illness Summary By Period - " + " (EDXL-SitRep)");
            TextSyndicationContent content = new TextSyndicationContent("CasualtyandIllnessSummaryByPeriod: " + "\nImmediate Needs: ");

            myitem.Content = content;
        }
コード例 #33
0
        public override WrapperObject ConvertToWraperObject(System.ServiceModel.Syndication.SyndicationItem item)
        {
            var obj = base.ConvertToWraperObject(item);

            if (item.Summary != null)
            {
                obj.SetOrAddProperty(PublishingConstants.FieldSummary, item.Summary.Text.StripHtmlTags());
            }

            var contentText = item.ElementExtensions.Select(extension => extension.GetObject <XElement>())
                              .Where(e => e.Name.LocalName == "encoded" && e.Name.Namespace.ToString().Contains("content"))
                              .Select(e => e.Value).FirstOrDefault();

            obj.SetOrAddProperty(PublishingConstants.FieldContent, contentText);

            //vimeo feed contains custom elements for media thumbnail
            var mediaContent = item.ElementExtensions.Select(extension => extension.GetObject <XElement>())
                               .FirstOrDefault(e => e.Name.LocalName == "content");

            if (mediaContent != null)
            {
                var thumbnailElement = mediaContent.Elements().FirstOrDefault(e => e.Name.LocalName == "thumbnail");
                if (thumbnailElement != null)
                {
                    var thumbnailUrl = thumbnailElement.Attributes().First(a => a.Name.LocalName == "url").Value;
                    obj.SetOrAddProperty("ThumbnailUrl", thumbnailUrl);
                }
            }

            //youtube feed contains custom elements for media description & thumbnail
            var mediaGroup = item.ElementExtensions.Select(extension => extension.GetObject <XElement>())
                             .FirstOrDefault(e => e.Name.LocalName == "group");

            if (mediaGroup != null)
            {
                var thumbnailElement = mediaGroup.Elements().FirstOrDefault(e => e.Name.LocalName == "thumbnail");
                if (thumbnailElement != null)
                {
                    var thumbnailUrl = thumbnailElement.Attributes().First(a => a.Name.LocalName == "url").Value;
                    obj.SetOrAddProperty("ThumbnailUrl", thumbnailUrl);
                }

                var descriptionElement = mediaGroup.Elements().FirstOrDefault(e => e.Name.LocalName == "description");
                if (descriptionElement != null)
                {
                    var content = descriptionElement.Value;
                    obj.SetOrAddProperty(PublishingConstants.FieldContent, content);
                }
            }



            return(obj);
        }
コード例 #34
0
        /// <summary>
        /// Update the Atom entry specified by the id. If none exists, return null. Return the updated Atom entry. Return null if the entry does not exist.
        /// This method must be idempotent.
        /// </summary>
        /// <param name="collection">collection name</param>
        /// <param name="id">id of the entry</param>
        /// <param name="entry">Entry to put</param>
        /// <returns></returns>
        protected override SyndicationItem PutEntry(string collection, string id, System.ServiceModel.Syndication.SyndicationItem entry)
        {
            var headers = WebOperationContext.Current.IncomingRequest.Headers;

            var originalEntry = this.unitOfWork.Entries.GetById(id);

            if (originalEntry == null)
            {
                return(null);
            }

            var newEntry = entry.ConvertToModelEntry();

            try
            {
                originalEntry.Title             = newEntry.Title;
                originalEntry.Content           = newEntry.Content;
                originalEntry.StrippedDownTitle = BlogEntry.StripeDownTitle(newEntry.Title);
                originalEntry.LastUpdateDate    = newEntry.LastUpdateDate;

                originalEntry.Categories.Clear();
                foreach (var sCat in entry.Categories)
                {
                    // search if the category already exists.
                    var category = unitOfWork.Categories.GetById(BlogEntry.StripeDownTitle(sCat.Label));
                    if (category == null)
                    {   // create a new category
                        category = new Category()
                        {
                            Name = sCat.Label, Value = BlogEntry.StripeDownTitle(sCat.Label)
                        };
                    }

                    originalEntry.Categories.Add(category);
                }

                this.unitOfWork.Commit();

                return(originalEntry.ConvertToSyndicationItem(this.webOperationContext.BaseUri));
            }
            catch (Exception ex)
            {
                // TODO: add logging
                return(null);
            }
        }
 protected static bool TryParseAttribute(string name, string ns, string value, SyndicationItem item, string version)
 {
     return(default(bool));
 }
 protected static bool TryParseElement(System.Xml.XmlReader reader, SyndicationItem item, string version)
 {
     return(default(bool));
 }
 protected static void WriteElementExtensions(System.Xml.XmlWriter writer, SyndicationItem item, string version)
 {
 }
コード例 #38
0
 internal static void LoadElementExtensions(XmlBuffer buffer, XmlDictionaryWriter writer, SyndicationItem item)
 {
     if (item == null)
     {
         throw new ArgumentNullException(nameof(item));
     }
     CloseBuffer(buffer, writer);
     item.LoadElementExtensions(buffer);
 }
コード例 #39
0
 protected SyndicationItemFormatter()
 {
     _item = null;
 }
コード例 #40
0
 protected static SyndicationCategory CreateCategory(SyndicationItem item)
 {
     return(SyndicationFeedFormatter.CreateCategory(item));
 }
 protected internal virtual new void SetItem(SyndicationItem item)
 {
 }
 protected SyndicationItemFormatter(SyndicationItem itemToWrite)
 {
 }
 protected virtual new void WriteItem(System.Xml.XmlWriter writer, SyndicationItem item, Uri feedBaseUri)
 {
     Contract.Requires(item != null);
     Contract.Requires(writer != null);
 }
コード例 #44
0
        internal static void LoadElementExtensions(XmlBuffer buffer, XmlDictionaryWriter writer, SyndicationItem item)
        {
            Debug.Assert(item != null);

            CloseBuffer(buffer, writer);
            item.LoadElementExtensions(buffer);
        }
コード例 #45
0
ファイル: Rss20ItemFormatter.cs プロジェクト: naricc/runtime
 public Rss20ItemFormatter(SyndicationItem itemToWrite) : this(itemToWrite, true)
 {
 }
コード例 #46
0
 protected static bool TryParseElement(XmlReader reader, SyndicationItem item, string version)
 {
     return(SyndicationFeedFormatter.TryParseElement(reader, item, version));
 }
コード例 #47
0
 public Rss20ItemFormatter(SyndicationItem itemToWrite, bool serializeExtensionsAsAtom)
     : base(itemToWrite)
 {
     ext_atom_serialization = serializeExtensionsAsAtom;
 }
 protected static void LoadElementExtensions(System.Xml.XmlReader reader, SyndicationItem item, int maxExtensionSize)
 {
 }
コード例 #49
0
 public Atom10ItemFormatter(SyndicationItem feedToWrite)
     : base(feedToWrite)
 {
 }
 protected static SyndicationPerson CreatePerson(SyndicationItem item)
 {
     return(default(SyndicationPerson));
 }
コード例 #51
0
 internal static void LoadElementExtensions(XmlBuffer buffer, XmlDictionaryWriter writer, SyndicationItem item)
 {
     SyndicationFeedFormatter.LoadElementExtensions(buffer, writer, item);
 }
 protected static SyndicationLink CreateLink(SyndicationItem item)
 {
     return(default(SyndicationLink));
 }
コード例 #53
0
 protected static async Task WriteElementExtensionsAsync(XmlWriter writer, SyndicationItem item, string version)
 {
     await SyndicationFeedFormatter.WriteElementExtensionsAsync(writer, item, version);
 }
 protected static SyndicationCategory CreateCategory(SyndicationItem item)
 {
     return(default(SyndicationCategory));
 }
コード例 #55
0
 protected static bool TryParseContent(XmlReader reader, SyndicationItem item, string contentType, string version, out SyndicationContent content)
 {
     return(SyndicationFeedFormatter.TryParseContent(reader, item, contentType, version, out content));
 }
コード例 #56
0
 protected static bool TryParseAttribute(string name, string ns, string value, SyndicationItem item, string version)
 {
     return(SyndicationFeedFormatter.TryParseAttribute(name, ns, value, item, version));
 }
コード例 #57
0
 internal static protected bool TryParseContent(XmlReader reader, SyndicationItem item, string contentType, string version, out SyndicationContent content)
 {
     return(item.TryParseContent(reader, contentType, version, out content));
 }
コード例 #58
0
 internal static protected Task WriteAttributeExtensionsAsync(XmlWriter writer, SyndicationItem item, string version)
 {
     if (item == null)
     {
         throw new ArgumentNullException(nameof(item));
     }
     return(item.WriteAttributeExtensionsAsync(writer, version));
 }
コード例 #59
0
 internal static protected bool TryParseAttribute(string name, string ns, string value, SyndicationItem item, string version)
 {
     if (item == null)
     {
         throw new ArgumentNullException(nameof(item));
     }
     if (FeedUtils.IsXmlns(name, ns))
     {
         return(true);
     }
     return(item.TryParseAttribute(name, ns, value, version));
 }
コード例 #60
0
 protected static void LoadElementExtensions(XmlReader reader, SyndicationItem item, int maxExtensionSize)
 {
     SyndicationFeedFormatter.LoadElementExtensions(reader, item, maxExtensionSize);
 }