コード例 #1
0
ファイル: TagFeedQuery.cs プロジェクト: kyletowb/InfusionDocs
        public FeedQueryMatch Match(FeedContext context) {
            var tagName = context.ValueProvider.GetValue("tag");
            if (tagName == null)
                return null;

            return new FeedQueryMatch { FeedQuery = this, Priority = -5 };
        }
コード例 #2
0
        public void Populate(FeedContext context) {
            var containerIdValue = context.ValueProvider.GetValue("containerid");
            if (containerIdValue == null)
                return;

            var containerId = (int)containerIdValue.ConvertTo(typeof(int));
            var container = _contentManager.Get(containerId);

            if (container == null) {
                return;
            }

            if (container.ContentType != "Blog") {
                return;
            }

            var blog = container.As<BlogPart>();

            if (context.Format == "rss") {
                context.Response.Element.SetElementValue("description", blog.Description);
            }
            else {
                context.Builder.AddProperty(context, null, "description", blog.Description);
            }
        }
コード例 #3
0
ファイル: FeedController.cs プロジェクト: RasterImage/Orchard
        public ActionResult Index(string format) {
            var context = new FeedContext(ValueProvider, format);

            var bestFormatterMatch = _feedFormatProviders
                .Select(provider => provider.Match(context))
                .Where(match => match != null && match.FeedBuilder != null)
                .OrderByDescending(match => match.Priority)
                .FirstOrDefault();

            if (bestFormatterMatch == null || bestFormatterMatch.FeedBuilder == null)
                return HttpNotFound();

            context.Builder = bestFormatterMatch.FeedBuilder;

            var bestQueryMatch = _feedQueryProviders
                .Select(provider => provider.Match(context))
                .Where(match => match != null && match.FeedQuery != null)
                .OrderByDescending(match => match.Priority)
                .FirstOrDefault();

            if (bestQueryMatch == null || bestQueryMatch.FeedQuery == null)
                return HttpNotFound();

            return context.Builder.Process(context, () => {
                bestQueryMatch.FeedQuery.Execute(context);
                _feedItemBuilder.Populate(context);
                foreach (var contextualizer in context.Response.Contextualizers) {
                    if (ControllerContext != null &&
                        ControllerContext.RequestContext != null) {
                        contextualizer(ControllerContext.RequestContext);
                    }
                }
            });
        }
コード例 #4
0
        public FeedQueryMatch Match(FeedContext context) {
            var containerIdValue = context.ValueProvider.GetValue("containerid");
            if (containerIdValue == null)
                return null;

            return new FeedQueryMatch { FeedQuery = this, Priority = -5 };
        }
コード例 #5
0
 public FeedQueryMatch Match(FeedContext context)
 {
     if (context.ValueProvider.GetValue("commentedoncontainer") != null) {
         return new FeedQueryMatch { Priority = -1, FeedQuery = this };
     }
     return null;
 }
コード例 #6
0
        public void Execute(FeedContext context)
        {
            var termParthId = context.ValueProvider.GetValue("term");
            if (termParthId == null) return;

            var limitValue = context.ValueProvider.GetValue("limit");
            var limit = 20;
            if (limitValue != null) limit = (int)limitValue.ConvertTo(typeof(int));

            var containerId = (int)termParthId.ConvertTo(typeof(int));
            var container = _contentManager.Get<TermPart>(containerId);

            if (container == null)
            {
                return;
            }

            var inspector = new ItemInspector(container, _contentManager.GetItemMetadata(container));
            if (context.Format == "rss")
            {
                var link = new XElement("link");
                context.Response.Element.SetElementValue("title", inspector.Title);
                context.Response.Element.Add(link);
                context.Response.Element.SetElementValue("description", inspector.Description);

                context.Response.Contextualize(
                    requestContext =>
                        {
                            var urlHelper = new UrlHelper(requestContext);
                            var uriBuilder =
                                new UriBuilder(urlHelper.RequestContext.HttpContext.Request.ToRootUrlString())
                                    { Path = urlHelper.RouteUrl(inspector.Link) };
                            link.Add(uriBuilder.Uri.OriginalString);
                        });
            }
            else
            {
                context.Builder.AddProperty(context, null, "title", inspector.Title);
                context.Builder.AddProperty(context, null, "description", inspector.Description);
                context.Response.Contextualize(
                    requestContext =>
                        {
                            var urlHelper = new UrlHelper(requestContext);
                            context.Builder.AddProperty(context, null, "link", urlHelper.RouteUrl(inspector.Link));
                        });
            }

            var items = _taxonomyService.GetContentItems(container, 0, limit);

            foreach (var item in items)
            {
                // call item.ContentItem to force a cast to ContentItem, and 
                // thus use CorePartsFeedItemBuilder
                context.Builder.AddItem(context, item.ContentItem);
            }
        }
コード例 #7
0
        public void Populate(FeedContext context) {
            foreach (var feedItem in context.Response.Items.OfType<FeedItem<ContentItem>>()) {

                var inspector = new ItemInspector(
                    feedItem.Item,
                    _contentManager.GetItemMetadata(feedItem.Item), 
                    _htmlFilters);


                // TODO: author


                // add to known formats
                if (context.Format == "rss") {
                    var link = new XElement("link");
                    var guid = new XElement("guid", new XAttribute("isPermaLink", "true"));

                    context.Response.Contextualize(requestContext => {
                                                        var urlHelper = new UrlHelper(requestContext, _routes);
                                                        var uriBuilder = new UriBuilder(urlHelper.RequestContext.HttpContext.Request.ToRootUrlString()) { Path = urlHelper.RouteUrl(inspector.Link) };
                                                        link.Add(uriBuilder.Uri.OriginalString);
                                                        guid.Add(uriBuilder.Uri.OriginalString);
                                                   });

                    feedItem.Element.SetElementValue("title", inspector.Title);
                    feedItem.Element.Add(link);
                    feedItem.Element.SetElementValue("description", inspector.Description);

                    if ( inspector.PublishedUtc != null ) {
                        // RFC833 
                        // The "R" or "r" standard format specifier represents a custom date and time format string that is defined by 
                        // the DateTimeFormatInfo.RFC1123Pattern property. The pattern reflects a defined standard, and the property  
                        // is read-only. Therefore, it is always the same, regardless of the culture used or the format provider supplied.  
                        // The custom format string is "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'". When this standard format specifier is used,  
                        // the formatting or parsing operation always uses the invariant culture. 
                        feedItem.Element.SetElementValue("pubDate", inspector.PublishedUtc.Value.ToString("r"));
                    }

                    feedItem.Element.Add(guid);
                }
                else {
                    var feedItem1 = feedItem;
                    context.Response.Contextualize(requestContext => {
                                                       var urlHelper = new UrlHelper(requestContext, _routes);
                                                       context.Builder.AddProperty(context, feedItem1, "link", urlHelper.RouteUrl(inspector.Link));
                                                   });
                    context.Builder.AddProperty(context, feedItem, "title", inspector.Title);
                    context.Builder.AddProperty(context, feedItem, "description", inspector.Description);

                    if (inspector.PublishedUtc != null)
                        context.Builder.AddProperty(context, feedItem, "published-date", Convert.ToString(inspector.PublishedUtc)); // format? cvt to generic T?
                }
            }
        }
コード例 #8
0
ファイル: TagFeedQuery.cs プロジェクト: Higea/Orchard
        public void Execute(FeedContext context) {
            var tagIdValue = context.ValueProvider.GetValue("tag");
            if (tagIdValue == null)
                return;

            var limitValue = context.ValueProvider.GetValue("limit");
            var limit = 20;
            if (limitValue != null) { 
                Int32.TryParse(Convert.ToString(limitValue), out limit);
            }
            
            limit = Math.Min(limit, 100);

            var tagName = (string)tagIdValue.ConvertTo(typeof(string));
            var tag = _tagService.GetTagByName(tagName);

            if (tag == null) {
                return;
            }

            var displayRouteValues = new RouteValueDictionary {
                {"area", "Orchard.Tags"},
                {"controller", "Home"},
                {"action", "Search"},
                {"tagName", tag.TagName}
            };

            if (context.Format == "rss") {
                var link = new XElement("link");
                context.Response.Element.SetElementValue("title", tag.TagName);
                context.Response.Element.Add(link);
                context.Response.Element.SetElementValue("description", T("Content tagged with {0}", tag.TagName).ToString());

                context.Response.Contextualize(requestContext => {
                    var urlHelper = new UrlHelper(requestContext);
                    var uriBuilder = new UriBuilder(urlHelper.MakeAbsolute("/")) { Path = urlHelper.RouteUrl(displayRouteValues) };
                    link.Add(uriBuilder.Uri.OriginalString);
                });
            }
            else {
                context.Builder.AddProperty(context, null, "title", tag.TagName);
                context.Builder.AddProperty(context, null, "description", T("Content tagged with {0}", tag.TagName).ToString());
                context.Response.Contextualize(requestContext => {
                    var urlHelper = new UrlHelper(requestContext);
                    context.Builder.AddProperty(context, null, "link", urlHelper.MakeAbsolute(urlHelper.RouteUrl(displayRouteValues)));
                });
            }

            var items = _tagService.GetTaggedContentItems(tag.Id, 0, limit);

            foreach (var item in items) {
                context.Builder.AddItem(context, item.ContentItem);
            }
        }
コード例 #9
0
        public void Execute(FeedContext context)
        {
            var containerIdValue = context.ValueProvider.GetValue("containerid");
            if (containerIdValue == null)
                return;

            var limitValue = context.ValueProvider.GetValue("limit");
            var limit = 20;
            if (limitValue != null) {
                Int32.TryParse(Convert.ToString(limitValue), out limit);
            }

            limit = Math.Min(limit, 100);

            var containerId = (int)containerIdValue.ConvertTo(typeof(int));
            var container = _contentManager.Get(containerId);

            if (container == null) {
                return;
            }

            var inspector = new ItemInspector(container, _contentManager.GetItemMetadata(container), _htmlFilters);
            if (context.Format == "rss") {
                var link = new XElement("link");
                context.Response.Element.SetElementValue("title", inspector.Title);
                context.Response.Element.Add(link);
                context.Response.Element.SetElementValue("description", inspector.Description);

                context.Response.Contextualize(requestContext => {
                    var urlHelper = new UrlHelper(requestContext);
                    var uriBuilder = new UriBuilder(urlHelper.MakeAbsolute("/")) { Path = urlHelper.RouteUrl(inspector.Link) };
                    link.Add(uriBuilder.Uri.OriginalString);
                });
            }
            else {
                context.Builder.AddProperty(context, null, "title", inspector.Title);
                context.Builder.AddProperty(context, null, "description", inspector.Description);
                context.Response.Contextualize(requestContext => {
                    var urlHelper = new UrlHelper(requestContext);
                    context.Builder.AddProperty(context, null, "link",urlHelper.MakeAbsolute(urlHelper.RouteUrl(inspector.Link)));
                });
            }

            var items = _contentManager.Query()
                .Where<CommonPartRecord>(x => x.Container == container.Record)
                .OrderByDescending(x => x.CreatedUtc)
                .Slice(0, limit);

            foreach (var item in items) {
                context.Builder.AddItem(context, item);
            }
        }
コード例 #10
0
        public void Execute(FeedContext context)
        {
            var calendarId = context.ValueProvider.GetValue("calendar");
            if (calendarId == null)
                return;

            var containerId = (int)calendarId.ConvertTo(typeof(int));
            var container = _contentManager.Get<CalendarPart>(containerId);

            if (container == null)
            {
                return;
            }

            var inspector = new ItemInspector(container, _contentManager.GetItemMetadata(container));
            if (context.Format == "rss")
            {
                var link = new XElement("link");
                context.Response.Element.SetElementValue("title", inspector.Title);
                context.Response.Element.Add(link);
                context.Response.Element.SetElementValue("description", inspector.Description);

                context.Response.Contextualize(requestContext =>
                {
                    var urlHelper = new UrlHelper(requestContext);
                    var uriBuilder = new UriBuilder(urlHelper.MakeAbsolute("/"))
                    {
                        Path = urlHelper.RouteUrl(inspector.Link) ?? "/"
                    };
                    link.Add(uriBuilder.Uri.OriginalString);
                });
            }
            else
            {
                context.Builder.AddProperty(context, null, "title", inspector.Title);
                context.Builder.AddProperty(context, null, "description", inspector.Description);
                context.Response.Contextualize(requestContext =>
                {
                    var urlHelper = new UrlHelper(requestContext);
                    context.Builder.AddProperty(context, null, "link", urlHelper.RouteUrl(inspector.Link));
                });
            }

            var items = _calendarService.GetEvents(container.As<IdentityPart>().Identifier);

            foreach (var item in items)
            {
                // call item.ContentItem to force a cast to ContentItem, and 
                // thus use CorePartsFeedItemBuilder
                context.Builder.AddItem(context, item.ContentItem);
            }
        }
コード例 #11
0
ファイル: TagFeedQuery.cs プロジェクト: Higea/Orchard
        public FeedQueryMatch Match(FeedContext context) {
            var tagIdValue = context.ValueProvider.GetValue("tag");
            if (tagIdValue == null)
                return null;

            var tagName = (string)tagIdValue.ConvertTo(typeof(string));
            var tag = _tagService.GetTagByName(tagName);
            
            if (tag == null) {
                return null;
            }
            
            return new FeedQueryMatch { FeedQuery = this, Priority = -5 };
        }
コード例 #12
0
ファイル: ContainerFeedQuery.cs プロジェクト: anycall/Orchard
        public FeedQueryMatch Match(FeedContext context) {
            var containerIdValue = context.ValueProvider.GetValue("containerid");
            if (containerIdValue == null)
                return null;

            var containerId = (int)containerIdValue.ConvertTo(typeof(int));
            var container = _contentManager.Get(containerId);
            
            if (container == null) {
                return null;
            }
            
            return new FeedQueryMatch { FeedQuery = this, Priority = -5 };
        }
コード例 #13
0
 public void Populate(FeedContext context) {
     foreach (var feedItem in context.Response.Items.OfType<FeedItem<ContentItem>>()) {
         // add to known formats
         if (context.Format == "rss") {
             
             // adding tags to the rss item
             var tagsPart = feedItem.Item.As<TagsPart>();
             if (tagsPart != null) {
                 tagsPart.CurrentTags.ToList().ForEach(x => 
                     feedItem.Element.Add(new XElement("category", x)));
             }
         }
     }
 }
コード例 #14
0
ファイル: QueryFeedQuery.cs プロジェクト: kanujhun/orchard
        public void Execute(FeedContext context) {
            var projectionId = context.ValueProvider.GetValue("projection");
            if (projectionId == null)
                return;

            var limitValue = context.ValueProvider.GetValue("limit");
            var limit = 20;
            if (limitValue != null) {
                Int32.TryParse(Convert.ToString(limitValue), out limit);
            }

            var containerId = (int)projectionId.ConvertTo(typeof(int));
            var container = _contentManager.Get<ProjectionPart>(containerId);

            if (container == null) {
                return;
            }

            var inspector = new ItemInspector(container, _contentManager.GetItemMetadata(container), _htmlFilters);
            if (context.Format == "rss") {
                var link = new XElement("link");
                context.Response.Element.SetElementValue("title", inspector.Title);
                context.Response.Element.Add(link);
                context.Response.Element.SetElementValue("description", inspector.Description);

                context.Response.Contextualize(requestContext => {
                    var urlHelper = new UrlHelper(requestContext);
                    var uriBuilder = new UriBuilder(urlHelper.RequestContext.HttpContext.Request.ToRootUrlString()) { Path = urlHelper.RouteUrl(inspector.Link) };
                    link.Add(uriBuilder.Uri.OriginalString);
                });
            }
            else {
                context.Builder.AddProperty(context, null, "title", inspector.Title);
                context.Builder.AddProperty(context, null, "description", inspector.Description);
                context.Response.Contextualize(requestContext => {
                    var urlHelper = new UrlHelper(requestContext);
                    context.Builder.AddProperty(context, null, "link", urlHelper.RouteUrl(inspector.Link));
                });
            }

            var items = _projectionManager.GetContentItems(container.Record.QueryPartRecord.Id, 0, limit).ToList();

            foreach (var item in items) {
                context.Builder.AddItem(context, item);
            }
        }
コード例 #15
0
        public void Execute(FeedContext context) {
            var commentedOnContainer = (int)context.ValueProvider.GetValue("commentedoncontainer").ConvertTo(typeof(int));

            var limit = 20;
            var limitValue = context.ValueProvider.GetValue("limit");
            if (limitValue != null)
                limit = (int)limitValue.ConvertTo(typeof(int));

            var comments = _contentManager
                .Query<Comment, CommentRecord>()
                .Where(x => x.CommentedOnContainer == commentedOnContainer && x.Status == CommentStatus.Approved)
                .OrderByDescending(x => x.CommentDateUtc)
                .Slice(0, limit);

            foreach (var comment in comments) {
                context.Builder.AddItem(context, comment);
            }
        }
コード例 #16
0
        public void Populate(FeedContext context) {
            foreach (var feedItem in context.Response.Items.OfType<FeedItem<ContentItem>>()) {

                var inspector = new ItemInspector(
                    feedItem.Item,
                    _contentManager.GetItemMetadata(feedItem.Item));


                // TODO: author


                // add to known formats
                if (context.Format == "rss") {
                    var link = new XElement("link");
                    var guid = new XElement("guid", new XAttribute("isPermaLink", "true"));

                    context.Response.Contextualize(requestContext => {
                                                       var urlHelper = new UrlHelper(requestContext, _routes);
                                                       link.Add(urlHelper.RouteUrl(inspector.Link));
                                                       guid.Add(urlHelper.RouteUrl(inspector.Link));
                                                   });

                    feedItem.Element.SetElementValue("title", inspector.Title);
                    feedItem.Element.Add(link);
                    feedItem.Element.SetElementValue("description", inspector.Description);
                    if (inspector.PublishedUtc != null)
                        feedItem.Element.SetElementValue("pubDate", inspector.PublishedUtc);//TODO: format
                    feedItem.Element.Add(guid);
                }
                else {
                    var feedItem1 = feedItem;
                    context.Response.Contextualize(requestContext => {
                                                       var urlHelper = new UrlHelper(requestContext, _routes);
                                                       context.Builder.AddProperty(context, feedItem1, "link", urlHelper.RouteUrl(inspector.Link));
                                                   });
                    context.Builder.AddProperty(context, feedItem, "title", inspector.Title);
                    context.Builder.AddProperty(context, feedItem, "description", inspector.Description);

                    if (inspector.PublishedUtc != null)
                        context.Builder.AddProperty(context, feedItem, "published-date", Convert.ToString(inspector.PublishedUtc)); // format? cvt to generic T?
                }
            }
        }
コード例 #17
0
        public void Execute(FeedContext context) {
            var containerIdValue = context.ValueProvider.GetValue("containerid");
            if (containerIdValue == null)
                return;

            var limitValue = context.ValueProvider.GetValue("limit");
            var limit = 20;
            if (limitValue != null)
                limit = (int)limitValue.ConvertTo(typeof(int));

            var containerId = (int)containerIdValue.ConvertTo(typeof(int));
            var container = _contentManager.Get(containerId);

            var inspector = new ItemInspector(container, _contentManager.GetItemMetadata(container));
            if (context.Format == "rss") {
                var link = new XElement("link");
                context.Response.Element.SetElementValue("title", inspector.Title);
                context.Response.Element.Add(link);
                context.Response.Element.SetElementValue("description", inspector.Description);

                context.Response.Contextualize(requestContext => {
                    var urlHelper = new UrlHelper(requestContext);
                    link.Add(urlHelper.RouteUrl(inspector.Link));
                });
            }
            else {
                context.Builder.AddProperty(context, null, "title", inspector.Title);
                context.Builder.AddProperty(context, null, "description", inspector.Description);
                context.Response.Contextualize(requestContext => {
                    var urlHelper = new UrlHelper(requestContext);
                    context.Builder.AddProperty(context, null, "link", urlHelper.RouteUrl(inspector.Link));
                });
            }

            var items = _contentManager.Query()
                .Where<CommonRecord>(x => x.Container == container.Record)
                .OrderByDescending(x => x.PublishedUtc)
                .Slice(0, limit);

            foreach (var item in items) {
                context.Builder.AddItem(context, item);
            }
        }
コード例 #18
0
        public void Execute(FeedContext context) {
            var commentedOn = (int)context.ValueProvider.GetValue("commentedon").ConvertTo(typeof(int));

            var limit = 20;
            var limitValue = context.ValueProvider.GetValue("limit");
            if (limitValue != null) {
                Int32.TryParse(Convert.ToString(limitValue), out limit);
            }

            var comments = _contentManager
                .Query<CommentPart, CommentPartRecord>()
                .Where(x => x.CommentsPartRecord.Id == commentedOn && x.Status == CommentStatus.Approved)
                .OrderByDescending(x => x.CommentDateUtc)
                .Slice(0, limit);

            foreach (var comment in comments) {
                context.Builder.AddItem(context, comment);
            }
        }
コード例 #19
0
        public void Populate(FeedContext context) {
            foreach (var feedItem in context.Response.Items.OfType<FeedItem<CommentPart>>()) {
                var comment = feedItem.Item;
                var commentedOn = _contentManager.Get(feedItem.Item.Record.CommentedOn);
                var commentedOnInspector = new ItemInspector(
                    commentedOn,
                    _contentManager.GetItemMetadata(commentedOn)
                );

                var title = T("Comment on {0} by {1}", commentedOnInspector.Title, comment.Record.Author);

                
                // add to known formats
                if (context.Format == "rss") {
                    var link = new XElement("link");
                    var guid = new XElement("guid", new XAttribute("isPermaLink", "false"));
                    context.Response.Contextualize(requestContext => {
                        var urlHelper = new UrlHelper(requestContext);
                        link.Add(urlHelper.RouteUrl(commentedOnInspector.Link) + "#comment-" + comment.Record.Id);
                        guid.Add("urn:comment:" + comment.Record.Id);
                    });

                    feedItem.Element.SetElementValue("title", title);
                    feedItem.Element.Add(link);
                    feedItem.Element.SetElementValue("description", comment.Record.CommentText);
                    feedItem.Element.SetElementValue("pubDate", comment.Record.CommentDateUtc);//TODO: format
                    feedItem.Element.Add(guid);
                }
                else {
                    var feedItem1 = feedItem;
                    context.Response.Contextualize(requestContext => {
                        var urlHelper = new UrlHelper(requestContext);
                        context.Builder.AddProperty(context, feedItem1, "link", urlHelper.RouteUrl(commentedOnInspector.Link));
                    });
                    context.Builder.AddProperty(context, feedItem, "title", title.ToString());
                    context.Builder.AddProperty(context, feedItem, "description", comment.Record.CommentText);

                    context.Builder.AddProperty(context, feedItem, "published-date", Convert.ToString(comment.Record.CommentDateUtc)); // format? cvt to generic T?
                }
            }
        }
コード例 #20
0
ファイル: TagFeedQuery.cs プロジェクト: kyletowb/InfusionDocs
        public void Execute(FeedContext context) {
            var tagValue = context.ValueProvider.GetValue("tag");
            if (tagValue == null) return;

            var tagName = (string)tagValue.ConvertTo(typeof (string));
            var tag = _tagService.GetTagByName(tagName);
            if (tag == null) return;

            var limitValue = context.ValueProvider.GetValue("limit");
            var limit = 20;
            if (limitValue != null) {
                limit = (int) limitValue.ConvertTo(typeof (int));
            }

            var site = _services.WorkContext.CurrentSite;

            if (context.Format == "rss") {
                var link = new XElement("link");
                context.Response.Element.SetElementValue("title", GetTitle(tagName, site));
                context.Response.Element.Add(link);
                context.Response.Element.SetElementValue("description", GetDescription(tagName, site));

                context.Response.Contextualize(requestContext => link.Add(GetTagUrl(tagName, requestContext)));
            }
            else {
                context.Builder.AddProperty(context, null, "title", GetTitle(tagName, site));
                context.Builder.AddProperty(context, null, "description", GetDescription(tagName, site));
                context.Response.Contextualize(requestContext => context.Builder.AddProperty(context, null, "link", GetTagUrl(tagName, requestContext)));
            }

            var items = _tagService.GetTaggedContentItems(tag.Id, 0, limit);

            foreach (var item in items) {
                context.Builder.AddItem(context, item.ContentItem);
            }
        }
コード例 #21
0
 public FeedQueryMatch Match(FeedContext context) {
     if (context.ValueProvider.ContainsPrefix("commentscopeid")) {
         return new FeedQueryMatch { Priority = -1, FeedQuery = this };
     }
     return null;
 }
コード例 #22
0
        public void Populate(FeedContext context) {
            foreach (var feedItem in context.Response.Items.OfType<FeedItem<ContentItem>>()) {
                var rssPart = feedItem.Item.As<RssPart>();
                if (rssPart == null) {
                    continue;
                }

                var settings = rssPart.TypePartDefinition.Settings.GetModel<RssPartSettings>();

                // add to known formats
                if (context.Format == "rss") {

                    if (!String.IsNullOrWhiteSpace(settings.Title)) {
                        var title = feedItem.Element.Element("title");

                        if (settings.Title == "-") {
                            if (title != null) {
                                title.Remove();
                            }
                        }
                        else {
                            if (title == null) {
                                feedItem.Element.Add(title = new XElement("title"));
                            }

                            FeedItem<ContentItem> item = feedItem;
                            context.Response.Contextualize(requestContext => {
                                title.Value = _tokenizer.Replace(settings.Title, new { Content = item.Item, Text = title.Value });
                            });
                        }
                    }

                    if (!String.IsNullOrWhiteSpace(settings.Author)) {
                        var author = feedItem.Element.Element("author");

                        if (settings.Author == "-") {
                            if (author != null) {
                                author.Remove();
                            }
                        }
                        else {
                            if (author == null) {
                                feedItem.Element.Add(author = new XElement("author"));
                            }

                            FeedItem<ContentItem> item = feedItem;
                            context.Response.Contextualize(requestContext => {
                                author.Value = _tokenizer.Replace(settings.Title, new { Content = item.Item, Text = author.Value });
                            });
                        }
                    }

                    if (!String.IsNullOrWhiteSpace(settings.Description)) {
                        var description = feedItem.Element.Element("description");

                        if (settings.Description == "-") {
                            if (description != null) {
                                description.Remove();
                            }
                        }
                        else {
                            if (description == null) {
                                feedItem.Element.Add(description = new XElement("description"));
                            }

                            FeedItem<ContentItem> item = feedItem;
                            context.Response.Contextualize(requestContext => {
                                description.Value = _tokenizer.Replace(settings.Description, new { Content = item.Item, Text = description.Value });
                            });
                        }
                    }

                    if (!String.IsNullOrWhiteSpace(settings.Enclosure)) {
                        var enclosure = feedItem.Element.Element("enclosure");

                        if (settings.Enclosure == "-") {
                            if (enclosure != null) {
                                enclosure.Remove();
                            }
                        }
                        else {
                            if (enclosure == null) {
                                feedItem.Element.Add(enclosure = new XElement("enclosure"));
                            }

                            FeedItem<ContentItem> item = feedItem;
                            context.Response.Contextualize(requestContext => {
                                enclosure.Value = _tokenizer.Replace(settings.Enclosure, new { Content = item.Item, Text = enclosure.Value });
                            });
                        }
                    }


                    if (!String.IsNullOrWhiteSpace(settings.Link)) {
                        var link = feedItem.Element.Element("link");

                        if (settings.Link == "-") {
                            if (link != null) {
                                link.Remove();
                            }
                        }
                        else {
                            if (link == null) {
                                feedItem.Element.Add(link = new XElement("link"));
                            }

                            FeedItem<ContentItem> item = feedItem;
                            context.Response.Contextualize(requestContext => {
                                link.Value = _tokenizer.Replace(settings.Link, new { Content = item.Item, Text = link.Value });
                            });
                        }
                    }

                    if (!String.IsNullOrWhiteSpace(settings.PubDate)) {
                        var pubDate = feedItem.Element.Element("pubDate");

                        if (settings.PubDate == "-") {
                            if (pubDate != null) {
                                pubDate.Remove();
                            }
                        }
                        else {
                            if (pubDate == null) {
                                feedItem.Element.Add(pubDate = new XElement("pubDate"));
                            }

                            FeedItem<ContentItem> item = feedItem;
                            context.Response.Contextualize(requestContext => {
                                pubDate.Value = _tokenizer.Replace(settings.PubDate, new { Content = item.Item, Text = pubDate.Value });
                            });
                        }
                    }

                    if (!String.IsNullOrWhiteSpace(settings.Source)) {
                        var source = feedItem.Element.Element("source");

                        if (settings.Source == "-") {
                            if (source != null) {
                                source.Remove();
                            }
                        }
                        else {
                            if (source == null) {
                                feedItem.Element.Add(source = new XElement("source"));
                            }

                            FeedItem<ContentItem> item = feedItem;
                            context.Response.Contextualize(requestContext => {
                                source.Value = _tokenizer.Replace(settings.Source, new { Content = item.Item, Text = source.Value });
                            });
                        }
                    }

                    if (!String.IsNullOrWhiteSpace(settings.Category)) {
                        var categories = feedItem.Element.Elements("category").ToArray();

                        var currentValue = String.Join(",", categories.Select(x => x.Value).ToArray());

                        if (settings.Category == "-") {
                            foreach (var category in categories) {
                                category.Remove();
                            }
                        }
                        else {
                            foreach (var category in categories) {
                                category.Remove();
                            }

                            FeedItem<ContentItem> item = feedItem;
                            context.Response.Contextualize(requestContext => {

                                var newValue = _tokenizer.Replace(settings.Category, new { Content = item.Item, Text = currentValue });

                                foreach (var value in newValue.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) {
                                    feedItem.Element.Add(new XElement("category", value));
                                }
                            });
                        }
                    }
                }
            }
        }
コード例 #23
0
 public void Execute(FeedContext context) {
     var scopeContainerId = (int)context.ValueProvider.GetValue("commentscopeid").ConvertTo(typeof (int));
     _commonRepository.Fetch(x => x.Container.Id == scopeContainerId).Select(x => x.Id);
     var comments = _commentRepository.Fetch(x=>x.)
     context.FeedFormatter.AddItem(context, new Comment());
 }
コード例 #24
0
 public FeedQueryMatch Match(FeedContext context) {
     return new FeedQueryMatch { FeedQuery = this, Priority = 10 };
 }
コード例 #25
0
 public void Execute(FeedContext context) {
     foreach (var item in _items) {
         context.Builder.AddItem(context, item);
     }
 }
コード例 #26
0
 public void Populate(FeedContext context) {
 }