diff --git a/config templates/web.config b/config templates/web.config index ef8006faae..c7504a6e81 100644 --- a/config templates/web.config +++ b/config templates/web.config @@ -253,6 +253,9 @@ + + + diff --git a/umbraco.MacroEngines.Juno/RazorCore/BaseContext.cs b/umbraco.MacroEngines.Juno/RazorCore/BaseContext.cs index fcccbece5a..8c1a2290c0 100644 --- a/umbraco.MacroEngines.Juno/RazorCore/BaseContext.cs +++ b/umbraco.MacroEngines.Juno/RazorCore/BaseContext.cs @@ -5,7 +5,8 @@ using umbraco.interfaces; namespace umbraco.MacroEngines { - public abstract class BaseContext : WebPage, IMacroContext { + public abstract class BaseContext : WebPage, IMacroContext + { private MacroModel _macro; private INode _node; @@ -22,7 +23,8 @@ namespace umbraco.MacroEngines public T Current { get { return CurrentModel; } } public new dynamic Model { get { return CurrentModel; } } - public virtual void SetMembers(MacroModel macro, INode node) { + public virtual void SetMembers(MacroModel macro, INode node) + { if (macro == null) throw new ArgumentNullException("macro"); if (node == null) @@ -33,22 +35,36 @@ namespace umbraco.MacroEngines _node = node; } - protected override void ConfigurePage(WebPageBase parentPage) { + protected override void ConfigurePage(WebPageBase parentPage) + { if (parentPage == null) return; //Inject SetMembers Into New Context - if (parentPage is IMacroContext) { + if (parentPage is IMacroContext) + { var macroContext = (IMacroContext)parentPage; SetMembers(macroContext.Macro, macroContext.Node); } } - public string GetParameter(string alias) { + public string GetParameter(string alias) + { return ParameterDictionary[alias]; } - public string GetDictionary(string key) { + public string GetDictionary(string key) + { return CultureDictionary[key]; } + + public IRazorLibrary Library + { + get + { + return new RazorLibraryImpl(_node); + } + } + + } } diff --git a/umbraco.MacroEngines.Juno/RazorCore/IRazorLibrary.cs b/umbraco.MacroEngines.Juno/RazorCore/IRazorLibrary.cs new file mode 100644 index 0000000000..04b74e6d3a --- /dev/null +++ b/umbraco.MacroEngines.Juno/RazorCore/IRazorLibrary.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using umbraco.interfaces; + +namespace umbraco.MacroEngines +{ + public interface IRazorLibrary + { + INode Node { get; } + } +} diff --git a/umbraco.MacroEngines.Juno/RazorCore/RazorLibraryImpl.cs b/umbraco.MacroEngines.Juno/RazorCore/RazorLibraryImpl.cs new file mode 100644 index 0000000000..402438f3dd --- /dev/null +++ b/umbraco.MacroEngines.Juno/RazorCore/RazorLibraryImpl.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using umbraco.interfaces; + +namespace umbraco.MacroEngines +{ + public class RazorLibraryImpl : IRazorLibrary + { + private readonly INode _node; + + public RazorLibraryImpl(INode node) + { + _node = node; + } + public INode Node + { + get + { + return _node; + } + } + } + +} diff --git a/umbraco.MacroEngines.Juno/RazorDynamicNode/DynamicNode.cs b/umbraco.MacroEngines.Juno/RazorDynamicNode/DynamicNode.cs index 58144c76cc..126067c1f2 100644 --- a/umbraco.MacroEngines.Juno/RazorDynamicNode/DynamicNode.cs +++ b/umbraco.MacroEngines.Juno/RazorDynamicNode/DynamicNode.cs @@ -16,6 +16,7 @@ using System.Xml; using System.Xml.Linq; + namespace umbraco.MacroEngines { public class DynamicNode : DynamicObject @@ -323,7 +324,25 @@ namespace umbraco.MacroEngines } return result; } - + private List GetAncestorOrSelfNodeTypeAlias(INode node) + { + List list = new List(); + if (node != null) + { + + //find the doctype node, so we can walk it's parent's tree- not the working.parent content tree + CMSNode working = ContentType.GetByAlias(node.NodeTypeAlias); + while (working != null) + { + if((working as ContentType) != null) + { + list.Add((working as ContentType).Alias); + } + working = working.Parent; + } + } + return list; + } public override bool TryGetMember(GetMemberBinder binder, out object result) { @@ -360,8 +379,13 @@ namespace umbraco.MacroEngines } //check if the alias is that of a child type + var typeChildren = n.ChildrenAsList - .Where(x => MakePluralName(x.NodeTypeAlias) == name || x.NodeTypeAlias == name); + .Where(x => + { + List ancestorAliases = GetAncestorOrSelfNodeTypeAlias(x); + return ancestorAliases.Any(alias => alias == name || MakePluralName(alias) == name); + }); if (typeChildren.Any()) { result = new DynamicNodeList(typeChildren); diff --git a/umbraco.MacroEngines.Juno/RazorDynamicNode/ExtensionMethods.cs b/umbraco.MacroEngines.Juno/RazorDynamicNode/ExtensionMethods.cs index 2fed8982d0..1067181dfc 100644 --- a/umbraco.MacroEngines.Juno/RazorDynamicNode/ExtensionMethods.cs +++ b/umbraco.MacroEngines.Juno/RazorDynamicNode/ExtensionMethods.cs @@ -6,7 +6,7 @@ using System.Web; namespace umbraco.MacroEngines { - public static class PrivateExtensionMethods + public static class ExtensionMethods { public static IEnumerable Map( this IEnumerable source, diff --git a/umbraco.MacroEngines.Juno/RazorDynamicNode/RazorLibraryCore.cs b/umbraco.MacroEngines.Juno/RazorDynamicNode/RazorLibraryCore.cs new file mode 100644 index 0000000000..7037987c21 --- /dev/null +++ b/umbraco.MacroEngines.Juno/RazorDynamicNode/RazorLibraryCore.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace umbraco.MacroEngines.Library +{ + public static class RazorLibraryCore + { + //public static string Helper1(this IRazorLibrary library, string defaultParam1 = "") + //{ + // return defaultParam1; + //} + } +} diff --git a/umbraco.MacroEngines.Juno/umbraco.MacroEngines.csproj b/umbraco.MacroEngines.Juno/umbraco.MacroEngines.csproj index 286cde54dc..242ce052ca 100644 --- a/umbraco.MacroEngines.Juno/umbraco.MacroEngines.csproj +++ b/umbraco.MacroEngines.Juno/umbraco.MacroEngines.csproj @@ -61,8 +61,11 @@ + + + diff --git a/umbraco/presentation/web.STANDARD.config b/umbraco/presentation/web.STANDARD.config index ae5a9b6280..9a046484db 100644 --- a/umbraco/presentation/web.STANDARD.config +++ b/umbraco/presentation/web.STANDARD.config @@ -258,12 +258,13 @@ - + +