Beispiel #1
0
        public static string GetSyndicationFeed(this IEnumerable <Notification> notifications, string contentType)
        {
            var feed = new SyndicationFeed("System notification", "Publishes system notifications", new Uri("http://localhost"));

            feed.Authors.Add(new SyndicationPerson("*****@*****.**", "Testor Testorsson", "http://localhost"));
            feed.Links.Add(SyndicationLink.CreateSelfLink(new Uri(HttpContext.Current.Request.Url.AbsoluteUri), "application/atom+xml"));
            feed.Items = notifications.ASyndicationItems(feed);

            var stringWriter = new StringWriter();

            XmlWriter feedWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings
            {
                OmitXmlDeclaration = true
            });

            feed.Copyright = SyndicationContent.CreatePlaintextContent("Copyright hygia");
            feed.Language  = "en-us";

            if (contentType == ContentTypes.Atom)
            {
                feed.SaveAsAtom10(feedWriter);
            }
            else
            {
                feed.SaveAsRss20(feedWriter);
            }

            feedWriter.Close();

            return(stringWriter.ToString());
        }
Beispiel #2
0
        /// <summary>
        /// Gets the collection of <see cref="SyndicationItem"/>'s that represent the atom entries.
        /// </summary>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> signifying if the request is cancelled.</param>
        /// <returns>A collection of <see cref="SyndicationItem"/>'s.</returns>
        private async Task <List <SyndicationItem> > GetItems(CancellationToken cancellationToken)
        {
            List <SyndicationItem> items = new List <SyndicationItem>();

            foreach (var DBitem in db.absentdata)
            {
                var             DTvar1      = DBitem.AbsentDate1 ?? DateTime.Now;
                var             DTvar2      = DBitem.AbsentDate2 ?? DateTime.Now;
                var             DateString1 = DTvar1.ToString("MM.dd.yyyy");
                var             DateString2 = DTvar2.ToString("MM.dd.yyyy");
                SyndicationItem item        = new SyndicationItem()
                {
                    // id (Required) - Identifies the entry using a universally unique and permanent URI. Two entries
                    //                 in a feed can have the same value for id if they represent the same entry at
                    //                 different points in time.
                    Id = FeedId + DBitem.idAbsentData,
                    // title (Required) - Contains a human readable title for the entry. This value should not be blank.
                    Title = SyndicationContent.CreatePlaintextContent(CharAssembler(DBitem.PlayerID)),
                    // description (Recommended) - A summary of the entry.
                    Summary = SyndicationContent.CreatePlaintextContent(DBitem.AbsentText),
                    // updated (Optional) - Indicates the last time the entry was modified in a significant way. This
                    //                      value need not change after a typo is fixed, only after a substantial
                    //                      modification. Generally, different entries in a feed will have different
                    //                      updated timestamps.
                    Content = SyndicationContent.CreatePlaintextContent("отсутствие с " + DateString1 + " по " + DateString2),
                    // published (Optional) - Contains the time of the initial creation or first availability of the entry.
                };
                items.Add(item);
            }

            return(items);
        }
Beispiel #3
0
        public ActionResult RssFeed(long id)
        {
            NewsBusiness newsBusiness = new NewsBusiness();
            List <Common.SearchNewByGroupID_Result> model = new List <Common.SearchNewByGroupID_Result>();
            int totalRecord = 0;

            model = _newsBusiness.ListByNewsIdNewsGroup(id, ref totalRecord, 1, 10000);

            var items = new List <SyndicationItem>();

            foreach (SearchNewByGroupID_Result re in model)
            {
                var item = new SyndicationItem()
                {
                    Id          = re.Id.ToString(),
                    Title       = SyndicationContent.CreatePlaintextContent(re.Title),
                    Content     = SyndicationContent.CreateHtmlContent(re.Descriptions),
                    PublishDate = re.CreateDate
                };
                string url = Util.ReturnLinkFull(re.FriendlyUrl);
                item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(url)));//Nothing alternate about it. It is the MAIN link for the item.
                items.Add(item);
            }

            return(new RssFeed(title: "Greatness",
                               items: items,
                               contentType: "application/rss+xml",
                               description: String.Format("Sooper Dooper {0}", Guid.NewGuid())));
        }
        public SyndicationFeed BuildFeed(IEnumerable <JobResponse> jobs, Uri requestUri, string referrer, bool formatIsHtml)
        {
            var feed = new SyndicationFeed
            {
                Title = new TextSyndicationContent(_mandatorResponse.Name)
            };
            var items = new List <SyndicationItem>();

            foreach (var job in jobs)
            {
                var url = _urlBuilder.GetAbsolutJobUrl(job.Id, requestUri, referrer);

                var item = new SyndicationItem
                {
                    Title   = SyndicationContent.CreatePlaintextContent(job.Title),
                    Content = SyndicationContent.CreateHtmlContent(BuildContent(job, requestUri, referrer, formatIsHtml))
                };
                item.Authors.Add(new SyndicationPerson(job.UserEmail, job.UserFullName, null));
                item.Id = url;
                item.AddPermalink(new Uri(url));
                item.LastUpdatedTime = job.OnlineDateCorrected;
                items.Add(item);
            }

            feed.Items = items;
            return(feed);
        }
Beispiel #5
0
        /// <summary>
        /// Creates an RSS news feed for Issues By category
        /// </summary>
        /// <param name="feed">The feed.</param>
        private void CategoryFeed(ref SyndicationFeed feed)
        {
            var             objComps = new CategoryTree();
            List <Category> al       = objComps.GetCategoryTreeByProjectId(_projectId);

            var     feedItems = new List <SyndicationItem>();
            Project p         = ProjectManager.GetById(_projectId);

            foreach (Category c in al)
            {
                var item = new SyndicationItem();

                item.Title = SyndicationContent.CreatePlaintextContent(c.Name);
                item.Links.Add(
                    SyndicationLink.CreateAlternateLink(
                        new Uri(
                            GetFullyQualifiedUrl(string.Format("~/Issues/IssueList.aspx?pid={0}&c={1}", _projectId,
                                                               c.Id)))));
                item.Summary =
                    SyndicationContent.CreatePlaintextContent(
                        string.Format(GetLocalResourceObject("OpenIssues").ToString(), IssueManager.GetCountByProjectAndCategoryId(_projectId, c.Id)));
                item.PublishDate = DateTime.Now;
                // Add the item to the feed
                feedItems.Add(item);
            }
            feed.Title =
                SyndicationContent.CreatePlaintextContent(
                    string.Format(GetLocalResourceObject("IssuesByCategoryTitle").ToString(), p.Name));
            feed.Description =
                SyndicationContent.CreatePlaintextContent(
                    string.Format(GetLocalResourceObject("IssuesByCategoryDescription").ToString(), p.Name));
            feed.Items = feedItems;
        }
Beispiel #6
0
        public ActionResult Rss()
        {
            List <SyndicationItem> items1 = new List <SyndicationItem>();
            List <Models.MyBook>   items2 = ns.GetNewBooks();

            for (int i = 0; i < 9; i++)
            {
                string imgURL = "<img src=\"";
                imgURL += "http://localhost/Image/Sach/" + items2[i].AnhBia + "\"style=\"width:180px; height:230px; margin-top:9px;\"/><br>";
                SyndicationItem item = new SyndicationItem()
                {
                    Id    = items2[i].MaSach.ToString(),
                    Title = SyndicationContent.CreatePlaintextContent(String.Format("{0}", items2[i].TenSach)),

                    Content = SyndicationContent.CreateHtmlContent(String.Format("{0} Giá bán: {1} <br>", imgURL, items2[i].GiaBan.ToString())),
                };
                string mylink = "http://localhost/Product/Product/" + ns.Encode("id=" + items2[i].MaSach.ToString());
                item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(mylink)));//link to item
                items1.Add(item);
            }
            var feed = new SyndicationFeed("Usagi's Store", "Cửa hàng sách Usagi", new Uri("http://localhost"), items1)
            {
                Copyright = new TextSyndicationContent("© 2015 - Usagi's Store"),
                Language  = "vi-VN"
            };

            Response.ContentType = "text/xml";
            return(new FeedResult(new Rss20FeedFormatter(feed)));
        }
Beispiel #7
0
        public static async Task <SyndicationFeed> BuildSyndication(this IBlogService service, string baseAddress)
        {
            ClientUrlGenerator generator = new ClientUrlGenerator
            {
                BaseAddress = baseAddress
            };
            BlogOptions blogOptions = await service.GetOptions();

            SyndicationFeed   feed   = new SyndicationFeed(blogOptions.Name, blogOptions.Description, new Uri(baseAddress));
            SyndicationPerson author = new SyndicationPerson("", blogOptions.Onwer, baseAddress);

            feed.Authors.Add(author);
            Dictionary <string, SyndicationCategory> categoryMap = new Dictionary <string, SyndicationCategory>();

            {
                /*var cates = await BlogService.CategoryService.GetCategories(await BlogService.CategoryService.All());
                 * foreach (var p in cates)
                 * {
                 *  var cate = new SyndicationCategory(p.Name);
                 *  categoryMap.Add(p.Id, cate);
                 *  feed.Categories.Add(cate);
                 * }*/
            }
            {
                var posts = await service.PostService.GetPosts(await service.PostService.All());

                List <SyndicationItem> items = new List <SyndicationItem>();
                foreach (var p in posts)
                {
                    if (p is null)
                    {
                        continue;
                    }
                    var s = new SyndicationItem(p.Title,
                                                SyndicationContent.CreateHtmlContent(Markdown.ToHtml(p.Content.Raw, Pipeline)),
                                                new Uri(generator.Post(p.Id)), p.Id, p.ModificationTime);
                    s.Authors.Add(author);

                    string summary;
                    if (await service.PostService.Protector.IsProtected(p.Content))
                    {
                        summary = "Protected Post";
                    }
                    else
                    {
                        summary = Markdown.ToPlainText(p.Content.Raw, Pipeline);
                    }
                    s.Summary = SyndicationContent.CreatePlaintextContent(summary.Length <= 100 ? summary : summary.Substring(0, 100));
                    s.Categories.Add(new SyndicationCategory(p.Category.ToString()));

                    /*if (categoryMap.TryGetValue(p.CategoryId, out var cate))
                     *  s.Categories.Add(cate);*/
                    s.PublishDate = p.CreationTime;
                    items.Add(s);
                }
                feed.Items = items.AsEnumerable();
            }

            return(feed);
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            MemoryStream stream = new MemoryStream();

            //Simple feed with sample data
            SyndicationFeed feed = new SyndicationFeed("Custom JSON feed", "A Syndication extensibility sample", null);

            feed.LastUpdatedTime = DateTime.Now;
            feed.Items           = from s in new string[] { "hello", "world" }
            select new SyndicationItem()
            {
                Summary = SyndicationContent.CreatePlaintextContent(s)
            };

            //Write the feed out to a MemoryStream as JSON
            DataContractJsonSerializer writeSerializer = new DataContractJsonSerializer(typeof(JsonFeedFormatter));

            writeSerializer.WriteObject(stream, new JsonFeedFormatter(feed));

            stream.Position = 0;

            //Read in the feed using the DataContractJsonSerializer
            DataContractJsonSerializer readSerializer = new DataContractJsonSerializer(typeof(JsonFeedFormatter));
            JsonFeedFormatter          formatter      = readSerializer.ReadObject(stream) as JsonFeedFormatter;
            SyndicationFeed            feedRead       = formatter.Feed;


            //Dump the JSON stream to the console
            string output = Encoding.UTF8.GetString(stream.GetBuffer());

            Console.WriteLine(output);
            Console.ReadLine();
        }
Beispiel #9
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentEncoding = Encoding.UTF8;

            var portalContext  = PortalContext.Current;
            var serviceContext = PortalCrmConfigurationManager.CreateServiceContext();

            serviceContext.MergeOption = MergeOption.NoTracking;

            var newsRootPage = serviceContext.GetPageBySiteMarkerName(portalContext.Website, "News");

            if (newsRootPage == null)
            {
                context.Response.StatusCode  = 404;
                context.Response.ContentType = "text/plain";
                context.Response.Write("Not Found");

                return;
            }

            var feed = new SyndicationFeed(GetSyndicationItems(serviceContext, newsRootPage.ToEntityReference()))
            {
                Title       = SyndicationContent.CreatePlaintextContent(newsRootPage.GetAttributeValue <string>("adx_title") ?? newsRootPage.GetAttributeValue <string>("adx_name")),
                Description = SyndicationContent.CreateHtmlContent(newsRootPage.GetAttributeValue <string>("adx_summary") ?? string.Empty),
                BaseUri     = new Uri(context.Request.Url.GetLeftPart(UriPartial.Authority))
            };

            context.Response.ContentType = "application/atom+xml";

            using (var writer = new XmlTextWriter(context.Response.OutputStream, Encoding.UTF8))
            {
                feed.SaveAsAtom10(writer);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Creates the syndication items from issue count list.
        /// </summary>
        /// <param name="issueCountList">The issue count list.</param>
        /// <returns></returns>
        private IEnumerable <SyndicationItem> CreateSyndicationItemsFromIssueCountList(IEnumerable <IssueCount> issueCountList, string key)
        {
            var feedItems = new List <SyndicationItem>();

            foreach (var issueCount in issueCountList.Take(maxItemsInFeed))
            {
                // Atom items MUST have an author, so if there are no authors for this content item then go to next item in loop
                //if (outputAtom && t.TitleAuthors.Count == 0)
                //    continue;
                var item = new SyndicationItem {
                    Title = SyndicationContent.CreatePlaintextContent(issueCount.Name)
                };

                item.Links.Add(
                    SyndicationLink.CreateAlternateLink(
                        new Uri(
                            GetFullyQualifiedUrl(string.Format("~/Issues/IssueList.aspx?pid={0}&{1}={2}", _projectId, key,
                                                               issueCount.Id)))));
                item.Summary =
                    SyndicationContent.CreatePlaintextContent(
                        string.Format(GetLocalResourceObject("OpenIssues").ToString(), issueCount.Count));

                item.PublishDate = DateTime.Now;
                // Add the item to the feed
                feedItems.Add(item);
            }

            return(feedItems);
        }
Beispiel #11
0
        public SyndicationFeedFormatter GetProcesses(string format)
        {
            IEnumerable <Process> processes = new List <Process>(Process.GetProcesses());

            //SyndicationFeed also has convenience constructors
            //that take in common elements like Title and Content.
            SyndicationFeed f = new SyndicationFeed();


            f.LastUpdatedTime = DateTimeOffset.Now;
            f.Title           = SyndicationContent.CreatePlaintextContent("Currently running processes");
            f.Links.Add(SyndicationLink.CreateSelfLink(OperationContext.Current.IncomingMessageHeaders.To));

            f.Items = from p in processes
                      select new SyndicationItem()
            {
                LastUpdatedTime = DateTimeOffset.Now,
                Title           = SyndicationContent.CreatePlaintextContent(p.ProcessName),
                Summary         = SyndicationContent.CreateHtmlContent(String.Format("<b>{0}</b>", p.MainWindowTitle)),
                Content         = SyndicationContent.CreateXmlContent(new ProcessData(p))
            };


            // Choose a formatter according to the query string passed.
            if (format == "rss")
            {
                return(new Rss20FeedFormatter(f));
            }
            else
            {
                return(new Atom10FeedFormatter(f));
            }
        }
Beispiel #12
0
        private SyndicationFeed GetFeedPage0(string prev_url = null, string next_url = null)
        {
            var feed = new SyndicationFeed();

            if (prev_url != null)
            {
                feed.Links.Add(new SyndicationLink(new Uri(prev_url), "prev-archive", "prev link", "text/html", 1000));
            }

            if (next_url != null)
            {
                feed.Links.Add(new SyndicationLink(new Uri(next_url), "next-archive", "next link", "text/html", 1000));
            }
            List <SyndicationItem> items = new List <SyndicationItem>();

            SyndicationItem item1 = new SyndicationItem();

            item1.Title   = new TextSyndicationContent("Item 1");
            item1.Id      = "Id1";
            item1.Content = SyndicationContent.CreatePlaintextContent("This is the content for Item 1");
            items.Add(item1);

            SyndicationItem item2 = new SyndicationItem();

            item2.Title   = new TextSyndicationContent("Item 2");
            item2.Id      = "Id2";
            item2.Content = SyndicationContent.CreatePlaintextContent("This is the content for Item 2");
            items.Add(item2);

            feed.Items = items;
            return(feed);
        }
Beispiel #13
0
        private static SyndicationContent GenerateContent(Device device)
        {
            var content = string.Format("Driver:{0} , Vehicle:{1}/{2}/{3}, Speed:{4} km/h,Time: {5}", device.Driver, device.Make,
                                        device.Model, device.Reg, device.Speed, device.GpsTimeStamp);

            return(SyndicationContent.CreatePlaintextContent(content));
        }
Beispiel #14
0
        public virtual ActionResult CommentFeed()
        {
            var comments = Repository.Find(new GetCommentsQuery(), 0, 20);

            var baseUri = Request.GetOriginalUrl();
            var items   =
                from e in comments
                let itemUri = new Uri(baseUri, Url.Action("Page", "Wiki", new { page = e.Entry.Name }) + "#comment-" + e.Id)
                              select new SyndicationItem
            {
                Id              = itemUri.ToString(),
                Title           = SyndicationContent.CreatePlaintextContent(e.AuthorName + " on " + e.Entry.Title),
                Summary         = SyndicationContent.CreateHtmlContent(Renderer.RenderUntrusted(e.Body, Formats.Markdown, CreateHelper())),
                Content         = SyndicationContent.CreateHtmlContent(Renderer.RenderUntrusted(e.Body, Formats.Markdown, CreateHelper())),
                LastUpdatedTime = e.Posted,
                PublishDate     = e.Posted,
                Links           =
                {
                    new SyndicationLink(itemUri)
                },
                Authors =
                {
                    new SyndicationPerson {
                        Name = e.AuthorName, Uri = e.AuthorUrl
                    }
                },
            };

            return(FeedResult(items.ToList()));
        }
        public void CreatePlainContent_Invoke_ReturnsExpected(string content)
        {
            TextSyndicationContent syndicationContent = SyndicationContent.CreatePlaintextContent(content);

            Assert.Empty(syndicationContent.AttributeExtensions);
            Assert.Equal(content, syndicationContent.Text);
            Assert.Equal("text", syndicationContent.Type);
        }
Beispiel #16
0
        private static SyndicationContent GetSyndicationContent(string content, string contentType)
        {
            if (content.IsNullOrEmpty() || contentType.ToLowerInvariant() == PublicationContentTypes.Text)
            {
                return(SyndicationContent.CreatePlaintextContent(content ?? string.Empty));
            }

            return(SyndicationContent.CreateHtmlContent(content));
        }
Beispiel #17
0
        public override async Task Invoke(IOwinContext context)
        {
            PathString subPath;

            context.Request.Path.StartsWithSegments(options.Path, out subPath);
            if (!subPath.StartsWithSegments(new PathString("/rss")))
            {
                await Next.Invoke(context);

                return;
            }

            const int pageSize        = 15;
            var       errorLogEntries = await errorLog.GetErrorsAsync(0, pageSize);

            var syndicationFeed = new SyndicationFeed();

            var hostName = EnvironmentUtilities.GetMachineNameOrDefault("Unknown Host");

            syndicationFeed.Title       = new TextSyndicationContent($"Error log of {errorLog.ApplicationName} on {hostName}.");
            syndicationFeed.Description = new TextSyndicationContent("Log of recent errors");
            syndicationFeed.Language    = "en-us";

            var uriAsString = context.Request.Uri.ToString();
            var baseUri     = new Uri(uriAsString.Remove(uriAsString.LastIndexOf("/rss", StringComparison.InvariantCulture)));

            syndicationFeed.Links.Add(SyndicationLink.CreateAlternateLink(baseUri));

            var items = new List <SyndicationItem>();

            foreach (var errorLogEntry in errorLogEntries)
            {
                var item = new SyndicationItem
                {
                    Title   = SyndicationContent.CreatePlaintextContent(errorLogEntry.Error.Message),
                    Content =
                        SyndicationContent.CreatePlaintextContent(
                            $"An error of type {errorLogEntry.Error.TypeName} occurred. {errorLogEntry.Error.Message}"),
                    PublishDate = errorLogEntry.Error.Time
                };
                item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(baseUri, $"/detail?id={errorLogEntry.Id}")));

                items.Add(item);
            }

            syndicationFeed.Items = items;

            context.Response.ContentType = "application/rss+xml";
            context.Response.StatusCode  = 200;

            using (var writer = XmlWriter.Create(context.Response.Body, SettingsUtility.XmlWriterSettings))
            {
                var formatter = new Rss20FeedFormatter(syndicationFeed);
                formatter.WriteTo(writer);
            }
        }
Beispiel #18
0
        public SyndicationFeedFormatter CreateFeed()
        {
            // Create a new Syndication Feed.
            SyndicationFeed feed = new SyndicationFeed();

            feed.Generator       = "Pro C# 2008 Sample Feed Generator";
            feed.Language        = "en-us";
            feed.LastUpdatedTime = new DateTimeOffset(DateTime.Now);
            feed.Title           = SyndicationContent.CreatePlaintextContent("Formula1 results");
            feed.Categories.Add(new SyndicationCategory("Formula1"));

            feed.Authors.Add(new SyndicationPerson("*****@*****.**", "Christian Nagel", "http://www.christiannagel.com"));

            feed.Description = SyndicationContent.CreatePlaintextContent("Sample Formula 1");

            Formula1DataContext data = new Formula1DataContext();

            feed.Items = from racer in data.Racers
                         from raceResult in racer.RaceResults
                         where raceResult.Race.Date > new DateTime(2007, 1, 1) && raceResult.Position == 1
                         orderby raceResult.Race.Date
                         select new SyndicationItem()
            {
                Title   = SyndicationContent.CreatePlaintextContent(String.Format("G.P. {0}", raceResult.Race.Circuit.Country)),
                Content = SyndicationContent.CreateXhtmlContent(
                    new XElement("p",
                                 new XElement("h3", String.Format("{0}, {1}", raceResult.Race.Circuit.Country, raceResult.Race.Date.ToShortDateString())),
                                 new XElement("b", String.Format("Winner: {0} {1}", racer.Firstname, racer.Lastname))).ToString())
            };



            //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:8731/Design_Time_Addresses/SyndicationService/Feed1/
            // atom -> http://localhost:8731/Design_Time_Addresses/SyndicationService/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);
        }
        private SyndicationItem Item(int itemIndex, int version)
        {
            var item = new SyndicationItem();

            item.Id = ItemId(itemIndex);
            item.Links.Add(new SyndicationLink(new Uri(ItemUri(itemIndex)), "alternate", "link", null, 0));
            item.Title           = SyndicationContent.CreatePlaintextContent(ItemTitle(itemIndex, version).Content);
            item.Content         = SyndicationContent.CreatePlaintextContent(ItemContent(itemIndex, version));
            item.LastUpdatedTime = ItemUpdateTime(itemIndex, version).ToDateTimeOffset();

            return(item);
        }
Beispiel #20
0
        public static SyndicationFeed GetFeed(Node node)
        {
            var lastUpdatedTime = node.ModificationDate.ToUniversalTime();

            return(new SyndicationFeed
            {
                Title = SyndicationContent.CreatePlaintextContent(node.Name),
                Description = SyndicationContent.CreatePlaintextContent("{Feed desription}"),
                Copyright = SyndicationContent.CreatePlaintextContent("Sense/Net"),
                LastUpdatedTime = lastUpdatedTime,
                Items = GetItems(node as IFolder)
            });
        }
Beispiel #21
0
        /// <summary>
        /// Alls the issues feed.
        /// </summary>
        /// <param name="feed">The feed.</param>
        private void AllIssuesFeed(ref SyndicationFeed feed)
        {
            IEnumerable <SyndicationItem> feedItems = CreateSyndicationItemsFromIssueList(IssueManager.GetByProjectId(_projectId));
            Project p = ProjectManager.GetById(_projectId);

            feed.Title =
                SyndicationContent.CreatePlaintextContent(
                    string.Format(GetLocalResourceObject("AllIssuesTitle").ToString(), p.Name));
            feed.Description =
                SyndicationContent.CreatePlaintextContent(
                    string.Format(GetLocalResourceObject("AllIssuesDescription").ToString(), p.Name));
            feed.Items = feedItems;
        }
        private SyndicationFeed Feed()
        {
            var feed = new SyndicationFeed();

            feed.Title       = SyndicationContent.CreatePlaintextContent("Dynamic Test Feed");
            feed.Description = SyndicationContent.CreatePlaintextContent("Dynamic Test Feed description.");
            feed.Id          = "dynamic-test-feed";
            feed.Links.Add(new SyndicationLink(new Uri("http://dynamic-test-feed.com/atom"), "alternate", "link", null, 0));

            feed.Items = new List <SyndicationItem>();

            return(feed);
        }
        /// <summary>
        /// Gets the collection of <see cref="SyndicationItem"/>'s that represent the atom entries.
        /// </summary>
        /// <returns>A collection of <see cref="SyndicationItem"/>'s.</returns>
        private List <SyndicationItem> GetItems()
        {
            List <SyndicationItem> items = new List <SyndicationItem>();

            for (int i = 1; i < 4; ++i)
            {
                SyndicationItem item = new SyndicationItem()
                {
                    // id (Required) - Identifies the entry using a universally unique and permanent URI. Two entries in a feed can have the same value for id if they represent the same entry at different points in time.
                    Id = FeedId + i,
                    // title (Required) - Contains a human readable title for the entry. This value should not be blank.
                    Title = SyndicationContent.CreatePlaintextContent("Item " + i),
                    // description (Reccomended) - A summary of the entry.
                    Summary = SyndicationContent.CreatePlaintextContent("A summary of item " + i),
                    // updated (Optional) - Indicates the last time the entry was modified in a significant way. This value need not change after a typo is fixed, only after a substantial modification. Generally, different entries in a feed will have different updated timestamps.
                    LastUpdatedTime = DateTimeOffset.Now,
                    // published (Optional) - Contains the time of the initial creation or first availability of the entry.
                    PublishDate = DateTimeOffset.Now,
                    // rights (Optional) - Conveys information about rights, e.g. copyrights, held in and over the entry.
                    Copyright = new TextSyndicationContent(string.Format("© {0} - {0}", DateTime.Now.Year, Application.Name)),
                };

                // link (Reccomended) - Identifies a related Web page. An entry must contain an alternate link if there is no content element.
                item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(this.urlHelper.AbsoluteRouteUrl(HomeControllerRoute.GetIndex)), ContentType.Html));
                // AND/OR
                // Text content  (Optional) - Contains or links to the complete content of the entry. Content must be provided if there is no alternate link.
                // item.Content = SyndicationContent.CreatePlaintextContent("The actual plain text content of the entry");
                // HTML content (Optional) - Content can be plain text or HTML. Here is a HTML example.
                // item.Content = SyndicationContent.CreateHtmlContent("The actual HTML content of the entry");

                // author (Optional) - Names one author of the entry. An entry may have multiple authors. An entry must contain at least one author element unless there is an author element in the enclosing feed, or there is an author element in the enclosed source element.
                item.Authors.Add(this.GetPerson());

                // contributor (Optional) - Names one contributor to the entry. An entry may have multiple contributor elements.
                item.Contributors.Add(this.GetPerson());

                // category (Optional) - Specifies a category that the entry belongs to. A entry may have multiple category elements.
                item.Categories.Add(new SyndicationCategory("CategoryName"));

                // link - Add additional links to related images, audio or video like so.
                item.Links.Add(SyndicationLink.CreateMediaEnclosureLink(new Uri(this.urlHelper.AbsoluteContent("~/content/icons/atom-icon-48x48.png")), ContentType.Png, 0));

                // media:thumbnail - Add a Yahoo Media thumbnail for the entry. See http://www.rssboard.org/media-rss for more information.
                item.SetThumbnail(this.urlHelper.AbsoluteContent("~/content/icons/atom-icon-48x48.png"), 48, 48);

                items.Add(item);
            }

            return(items);
        }
        /// <summary>
        /// Gets the feed containing meta data about the feed and the feed entries.
        /// </summary>
        /// <returns>A <see cref="SyndicationFeed"/>.</returns>
        public SyndicationFeed GetFeed()
        {
            SyndicationFeed feed = new SyndicationFeed()
            {
                // id (Required) - The feed universally unique identifier.
                Id = FeedId,
                // title (Required) - Contains a human readable title for the feed. Often the same as the title of the associated website. This value should not be blank.
                Title = SyndicationContent.CreatePlaintextContent("ASP.NET MVC Boilerplate"),
                // items (Required) - The items to add to the feed.
                Items = this.GetItems(),
                // subtitle (Recommended) - Contains a human-readable description or subtitle for the feed.
                Description = SyndicationContent.CreatePlaintextContent("This is the ASP.NET MVC Boilerplate feed description."),
                // updated (Optional) - Indicates the last time the feed was modified in a significant way.
                LastUpdatedTime = DateTimeOffset.Now,
                // logo (Optional) - Identifies a larger image which provides visual identification for the feed. Images should be twice as wide as they are tall.
                ImageUrl = new Uri(this.urlHelper.AbsoluteContent("~/content/icons/atom-logo-96x48.png")),
                // rights (Optional) - Conveys information about rights, e.g. copyrights, held in and over the feed.
                Copyright = new TextSyndicationContent(string.Format("© {0} - {0}", DateTime.Now.Year, Application.Name)),
                // lang (Optional) - The language of the feed.
                Language = "en-GB",
                // generator (Optional) - Identifies the software used to generate the feed, for debugging and other purposes. Do not put in anything that identifies the technology you are using.
                // Generator = "Sample Code",
                // base (Buggy) - Add the full base URL to the site so that all other links can be relative. This is great, except some feed readers are buggy with it, INCLUDING FIREFOX!!! (See https://bugzilla.mozilla.org/show_bug.cgi?id=480600).
                // BaseUri = new Uri(this.urlHelper.AbsoluteRouteUrl(HomeControllerRoute.GetIndex))
            };

            // self link (Required) - The URL for the syndication feed.
            feed.Links.Add(SyndicationLink.CreateSelfLink(new Uri(this.urlHelper.AbsoluteRouteUrl(HomeControllerRoute.GetFeed)), ContentType.Atom));

            // alternate link (Recommended) - The URL for the web page showing the same data as the syndication feed.
            feed.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(this.urlHelper.AbsoluteRouteUrl(HomeControllerRoute.GetIndex)), ContentType.Html));

            // author (Recommended) - Names one author of the feed. A feed may have multiple author elements. A feed must contain at least one author element unless all of the entry elements contain at least one author element.
            feed.Authors.Add(this.GetPerson());

            // category (Optional) - Specifies a category that the feed belongs to. A feed may have multiple category elements.
            feed.Categories.Add(new SyndicationCategory("CategoryName"));

            // contributor (Optional) - Names one contributor to the feed. An feed may have multiple contributor elements.
            feed.Contributors.Add(this.GetPerson());

            // icon (Optional) - Identifies a small image which provides iconic visual identification for the feed. Icons should be square.
            feed.SetIcon(this.urlHelper.AbsoluteContent("~/content/icons/atom-icon-48x48.png"));

            // Add the Yahoo Media namespace (xmlns:media="http://search.yahoo.com/mrss/") to the Atom feed.
            // This gives us extra abilities, like the ability to give thumbnail images to entries. See http://www.rssboard.org/media-rss for more information.
            feed.AddYahooMediaNamespace();

            return(feed);
        }
Beispiel #25
0
        /// <summary>
        /// Queries the feed.
        /// </summary>
        /// <param name="feed">The feed.</param>
        private void QueryFeed(ref SyndicationFeed feed)
        {
            var issueList = IssueManager.PerformSavedQuery(_projectId, QueryId, null);
            var feedItems = CreateSyndicationItemsFromIssueList(issueList);
            var p         = ProjectManager.GetById(_projectId);

            feed.Title =
                SyndicationContent.CreatePlaintextContent(
                    string.Format(GetLocalResourceObject("SavedQueryTitle").ToString(), p.Name));
            feed.Description =
                SyndicationContent.CreatePlaintextContent(
                    string.Format(GetLocalResourceObject("SavedQueryDescription").ToString(), p.Name));
            feed.Items = feedItems;
        }
Beispiel #26
0
        /// <summary>
        /// Assignees the feed.
        /// </summary>
        /// <param name="feed">The feed.</param>
        private void AssigneeFeed(ref SyndicationFeed feed)
        {
            var al        = IssueManager.GetUserCountByProjectId(_projectId);
            var feedItems = CreateSyndicationItemsFromIssueCountList(al, "u");
            var p         = ProjectManager.GetById(_projectId);

            feed.Title =
                SyndicationContent.CreatePlaintextContent(
                    string.Format(GetLocalResourceObject("AssigneeTitle").ToString(), p.Name));
            feed.Description =
                SyndicationContent.CreatePlaintextContent(
                    string.Format(GetLocalResourceObject("AssigneeDescription").ToString(), p.Name));
            feed.Items = feedItems;
        }
Beispiel #27
0
        /// <summary>
        /// Createds the feed.
        /// </summary>
        /// <param name="feed">The feed.</param>
        private void CreatedFeed(ref SyndicationFeed feed)
        {
            var issueList = IssueManager.GetByCreatorUserName(_projectId, User.Identity.Name);
            var feedItems = CreateSyndicationItemsFromIssueList(issueList);
            var p         = ProjectManager.GetById(_projectId);

            feed.Title =
                SyndicationContent.CreatePlaintextContent(
                    string.Format(GetLocalResourceObject("CreatedIssuesTitle").ToString(), p.Name));
            feed.Description =
                SyndicationContent.CreatePlaintextContent(
                    string.Format(GetLocalResourceObject("CreatedIssuesDescription").ToString(), p.Name));
            feed.Items = feedItems;
        }
Beispiel #28
0
        private SyndicationItem TransformPost(PostEntry entry)
        {
            entry = RenderEntry(entry);
            SyndicationItem item = new SyndicationItem();

            item.Id      = entry.Name;
            item.Title   = SyndicationContent.CreatePlaintextContent(entry.Title);
            item.Content = SyndicationContent.CreateHtmlContent(Transformer.Transform(entry.Content));
            item.AddPermalink(new Uri("http://otakustay.com/" + entry.Name + "/"));
            item.PublishDate     = new DateTimeOffset(entry.PostDate);
            item.LastUpdatedTime = new DateTimeOffset(entry.UpdateDate);
            item.Authors.Add(Author.Clone());
            return(item);
        }
Beispiel #29
0
        public virtual ActionResult Feed()
        {
            var settings = Settings.GetSettings <FunnelWebSettings>();

            var entries = Repository.Find(new GetFullEntriesQuery(entryStatus: EntryStatus.PublicBlog), 0, 20);

            var baseUri = Request.GetOriginalUrl();

            var items =
                from e in entries
                let itemUri = new Uri(baseUri, Url.Action("Page", "Wiki", new { page = e.Name }))
                              let viaFeedUri = new Uri(baseUri, "/via-feed" + Url.Action("Page", "Wiki", new { page = e.Name }))
                                               orderby e.Published descending
                                               let content = SyndicationContent.CreateHtmlContent(BuildFeedItemBody(itemUri, viaFeedUri, e))
                                                             select new
            {
                Item = new SyndicationItem
                {
                    Id              = itemUri.ToString(),
                    Title           = SyndicationContent.CreatePlaintextContent(e.Title),
                    Summary         = content,
                    Content         = content,
                    LastUpdatedTime = TimeZoneInfo.ConvertTimeFromUtc(e.Revised, TimeZoneInfo.Local),
                    PublishDate     = e.Published,
                    Links           =
                    {
                        new SyndicationLink(itemUri)
                    },
                    Authors =
                    {
                        new SyndicationPerson {
                            Name = settings.Author
                        }
                    },
                },
                Keywords = e.TagsCommaSeparated.Split(',')
            };

            return(FeedResult(items.Select(i =>
            {
                var item = i.Item;
                foreach (var k in i.Keywords)
                {
                    item.Categories.Add(new SyndicationCategory(k.Trim()));
                }

                return item;
            }).ToList()));
        }
Beispiel #30
0
        public async Task <SyndicationFeed> GetFeed(CancellationToken cancellationToken)
        {
            SyndicationFeed feed = new SyndicationFeed()
            {
                // id (Required) - The feed universally unique identifier.
                Id = FeedId,
                // title (Required) - Contains a human readable title for the feed. Often the same as the title of the
                //                    associated website. This value should not be blank.
                Title = SyndicationContent.CreatePlaintextContent("Система кармы"),
                // items (Required) - The items to add to the feed.
                Items = await this.GetItems(cancellationToken),
            };

            return(feed);
        }