コード例 #1
0
 public void Subscribe(RootBuilder describe) {
     describe.Scope("Content",content => {
         // Root all items in layout
         content.Factory<RootShape, dynamic>((context) =>
         {
             var layout = _workContextAccessor.GetContext().Layout;
             var item = context.Get<Model, object>() as IContent;
             // Save the item there so we can use correct CSS class in layout
             layout.ContentItem = item;
             layout.Title = item.ContentItem.ContentManager.GetItemMetadata(item.ContentItem).DisplayText;
             return layout;
         }
         );
         // Prevent displaying anything in Content zone on layout
         content.Factory<ActionResultBuilder, Func<ControllerBase, object, ActionResult>>((context) => (c, o) => {
             // Return Null (empty) view
             return new ViewResult() {
                 MasterName = null,
                 ViewName = "Null",
                 ViewData = c.ViewData,
                 TempData = c.TempData
             };
         });
     });
 }
コード例 #2
0
        public void Subscribe(RootBuilder describe) {

            describe.Scope("Search.Fallback", compose => {

                // Chain include content list
                compose.Chain("ContentList");

                // We get the dud path from the url
                compose.Parameter<string>("path", path => {

                    path.Mutate<ContentList, ContentListQuery>((q, context) => {
                        string param = path.Get(context);
                        string endBit = param;
                        var pos = param.LastIndexOf('/');
                        if (pos >= 0) {
                            endBit = param.Substring(pos + 1);
                        }
                        endBit = endBit.Replace('-', ' ');
                        // TODO: Any other replaces to fix url special chars etc.?

                        q.Query = q.Query.Where<TitlePartRecord>(t => t.Title.Contains(endBit));
                    });
                });
            });

        }
コード例 #3
0
        public void Subscribe(RootBuilder describe) {
            describe.Global(global => {
                global.Factory<RootShapeBuilder, dynamic>(context => {
                    var model = context.Get<Model, object>();
                    var root = context.Get<RootShape, dynamic>();
                    if (model != null) {
                        var builder = context.Get<ModelBuilder, ModelShapeBuilder>();
                        _origami.Build(builder, root);
                    }
                    return root;
                });
                global.Factory<ActionResult>((context) => {
                    dynamic root = context.Get<RootShapeBuilder, object>();
                    var controller = context.Single<ControllerBase>();
                    dynamic display = context.Get<DisplayShape, object>();
                    return context.Get<ActionResultBuilder, Func<ControllerBase, object, ActionResult>>()(controller, display);
                });

                global.Factory<ActionResultBuilder, Func<ControllerBase, object, ActionResult>>((context) => (c, o) => {
                    return new ShapeResult(c, o);
                });

                global.Factory<ShapeMetadataFactory, ShapeMetadata>((context) => new ShapeMetadata() {
                    DisplayType = "Detail",
                });
                global.Factory<DisplayShape, dynamic>((context) => context.Get<RootShape, dynamic>());
                global.Factory<ModelBuilder, ModelShapeBuilder>((context) => _origami.Builder(context.Get<Model, object>()).WithDisplayType(context.Get<ShapeMetadataFactory, ShapeMetadata>().DisplayType).WithMode("Display"));
            });
            describe.Scope("Ajax", ajax => {
                ajax.Factory<ActionResultBuilder, Func<ControllerBase, object, ActionResult>>((context2) => (c, o) => {
                    return new ShapePartialResult(c, o);
                });
            });
        }
コード例 #4
0
 public void Subscribe(RootBuilder describe) {
     describe.Scope("Content", mix => {
         mix.Factory<RootShape, dynamic>((context) => _origami.ContentShape(context.Get<Model, object>() as IContent, context.Get<ShapeMetadataFactory, ShapeMetadata>().DisplayType));
         mix.Factory<ModelBuilder, ModelShapeBuilder>((context) => _origami.ContentBuilder(context.Get<Model, object>() as IContent).WithDisplayType(context.Get<ShapeMetadataFactory, ShapeMetadata>().DisplayType));
         mix.Parameter<int>("contentId", (mix2) => {
             mix2.Factory<Model, object>((ctx) => _contentManager.Get(mix2.Get(ctx), VersionOptions.Published));
         });
     });
 }
コード例 #5
0
        public void Subscribe(RootBuilder describe) {
            describe.Scope("ContentList", mix => {
                mix.Factory<RootShape,dynamic>((context) => Shape.ContentList(ListItems:((ContentListViewModel)context.Get<Model,object>()).Rendered));
                mix.Factory<ContentList,ShapeMetadata>((context) => new ShapeMetadata() {
                    DisplayType = "Summary",
                });
                mix.Factory<ContentList,ParadigmsContext>((context) => new ParadigmsContext());
                mix.Factory<ContentList,ContentListQuery>((context) => new ContentListQuery() { Query = _contentManager.Query() });
                mix.Factory<ContentList,IEnumerable<IContent>>((context) => {
                    var query = context.Get<ContentList, ContentListQuery>();
                    var pager = context.Get<ContentList,PagerData>();
                    if (pager!=null) 
                        return query.Query.Slice(pager.PageSize*(pager.Page-1),pager.PageSize);
                    return query.Query.List();
                });
                mix.Factory<ContentModelBuilder, Func<IContent, ModelShapeBuilder>>((context) => (c) => Builder(c, context));
                // TODO: Could support prefix here
                mix.Factory<ContentShapeBuilder, Func<IContent, object>>((context) => (s) => _origami.ContentShape(s, context.Get<ContentList, ShapeMetadata>().DisplayType));
                mix.Factory<Model,object>((context) => {
                    var source = context.Get<ContentList,IEnumerable<IContent>>();
                    var builder = context.Get<ContentModelBuilder, Func<IContent,ModelShapeBuilder>>();
                    return new ContentListViewModel() {
                        Rendered = source.Select(s => {
                            var root = context.Get<ContentShapeBuilder, Func<IContent, object>>()(s);
                            _origami.Build(builder(s), root);
                            return root;
                        }).ToList()
                    };
                });
                // TODO: Get page size from settings
                mix.Factory<ContentList,PagerData>((context) => {
                    var pager = new PagerData() {
                        Page = 1,
                        PageSize = 10
                    };
                    return pager;
                });
                mix.Parameter<int>("PageSize", (pageSize) => {
                    pageSize.Mutate<ContentList, PagerData>((pager, context) => { pager.PageSize = pageSize.Get(context); });
                });
                mix.Parameter<int>("Page", (page) => {
                    page.Mutate<ContentList, PagerData>((pager, context) => { pager.Page = page.Get(context); });
                });
                mix.Parameter<string>("ContentType", (ct) => {
                    ct.Mutate<ContentList, ContentListQuery>((q,context) => q.Query = q.Query.ForType(ct.Get(context)));
                });
                mix.Parameter<string>("ContentTypes", (ct) => {
                    ct.Mutate<ContentList, ContentListQuery>((q, context) => q.Query = q.Query.ForType(ct.Get(context).Split(new[]{','},StringSplitOptions.RemoveEmptyEntries)));
                });
                // Calculate total pages at end
                mix.Mutate<ContentList, PagerData>((pager, context) => {
                    var query = context.Get<ContentList, ContentListQuery>();
                    pager.TotalPages = query.Query.Count() / pager.PageSize; // TODO: Check calculation
                });

            });
        }
コード例 #6
0
        public void Subscribe(RootBuilder describe) {

            describe.Scope("Content.Edit", compose => {
                compose.Chain("Content");


            });

        }
コード例 #7
0
        public void Subscribe(RootBuilder describe) {
            describe.Scope("Search.Ajax", compose => {
                // Following mutate should be in LensCompositionProvider?
                compose.Mutate<ContentList, ParadigmsContext>((p, context) => p.Add("Lens"));
                compose.Parameter<String>("context", param => {
                    // Context comes from a data attribute on the lens element
                    param.Mutate<ContentList, ParadigmsContext>((p,context) => {
                                switch (param.Get(context)) {
                                    case "Socket":
                                        p.Add("LensSocket");
                                        break;
                                    case "Search":
                                        p.Add("LensSearch");
                                        break;
                                }
                            });
                    });
                compose.Parameter<string>("contentTypes", param => {
                    param.Mutate<ContentListQuery, ContentListQuery>((q,context) => {
                        var types = param.Get(context).Split(',');
                        q.Query = q.Query.ForType(types);
                    });
                });
            });
            /*
            describe.Scope("Mechanics.Connector", compose => {
                compose.Chain("Content.Edit");
                compose.Chain("Ajax");
                compose.Factory<Model, object>((context) => {
                    var model = new ConnectorDisplayContext(
                });
                compose.Factory<Model, SocketsPart>((context) => context.Get<Model,IContent>().As<SocketsPart>());
                compose.Factory<RootShape, dynamic>((context) => {
                    var content = context.Get<Model,IContent>();
                    var socket = content.As<SocketsPart>();

                    return Shape.Connector_Edit(
                        ContentItem: c.SocketContext.Left.ContentItem,
                        RightContentItem: c.Right.Content,
                        ConnectorType: c.Descriptor.Name,
                        RightContentType: c.Right.ContentType,
                        LeftContentType: c.SocketContext.Left.ContentType);
                compose.Parameter<string>("socketName", leftId => {

                });
                compose.Parameter<int>("newRightId", rightId => {
                    compose.Factory<Model,IConnector>
                    var socket = context.Get<Model,SocketsPart>();

                });
            });*/
        }
コード例 #8
0
        public void Subscribe(RootBuilder describe) {
            describe.Scope("Plumbing.Drill", drill => {
                drill.Chain("Content");
                drill
                .Parameter<int>("drillId", param => {
                    param.Factory<DrillContent>((context) => {
                        var c = _contentManager.Get<ConnectorPart>(param.Get(context));
                        if (c == null) return null;
                        return new DrillContent() {
                            Connector = c,
                            Left = c.LeftContent,
                            Right = c.RightContent
                        };
                    });

                    param.Factory<Model, object>((context) => {
                        return context.Get<DrillContent>().Left;
                    });
                    param.Factory<DrillContent, DrillFilterData>((context) => {
                        var content = context.Get<DrillContent>();
                        if (content == null) return null;
                        var drillPart = content.Connector.As<DrillRoutePart>();
                        if (drillPart == null) return null;
                        return new DrillFilterData() {
                            Id = content.Connector.Id,
                            // TODO: DisplayType is kinda redundant here; need to handle in Placement?
                            DisplayType = "Detail",
                            DrillType = content.Connector.ContentItem.TypeDefinition.Name
                        };
                    });
                    param.Factory<DrillContent, ModelShapeBuilder>(msb => {
                        return _origami.Builder(msb.Get<DrillContent>().Right).WithDisplayType(msb.Get<ShapeMetadataFactory, ShapeMetadata>().DisplayType).WithMode("Display").WithParadigms(new[]{"DrillDetail"});});

/*                    param.Mutate<ModelBuilder, ModelShapeBuilder>((msb, context) => {
                        // Push drill data into model builder context
                        msb.Context.CustomContext[typeof(DrillFilterData)] = context.Get<DrillContent, DrillFilterData>();
                        msb.WithParadigms(new[] { "DrillDetail" });
                    });*/
                    param.Mutate<RootShapeBuilder, dynamic>((root, context) => {
                        var model = context.Get<DrillContent>().Right;
                        if (model != null) {
                            var builder = context.Get<DrillContent, ModelShapeBuilder>();
                            _origami.Build(builder, root);
                        }
                    });
                });
            });
        }
コード例 #9
0
        public void Subscribe(RootBuilder describe) {
            describe.Scope("Search.Ajax", compose => {

                // Chain include content list
                compose.Chain("Ajax");
                compose.Chain("ContentList");

                // Hijack with our own bits
                compose.Parameter<string>("query", query => {
                    query.Mutate<ContentList, ContentListQuery>((q,context) => {
                        q.Query = q.Query.Where<TitlePartRecord>(t => t.Title.StartsWith(query.Get(context)));
                    });
                });
                compose.Mutate<ContentList, ParadigmsContext>((p,context) => {
                    p.Add("LensResult");
                });
                compose.Mutate<ContentList, ShapeMetadata>((metadata,context) => {
                });
            });
        }