diff --git a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs index 3a8b055374..7ce816644c 100644 --- a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs +++ b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs @@ -5,6 +5,7 @@ using Umbraco.Core; using Umbraco.Tests.Stubs; using Umbraco.Tests.TestHelpers; using Umbraco.Web; +using Umbraco.Web.Models; using Umbraco.Web.Mvc; using Umbraco.Web.Routing; using umbraco.BusinessLogic; diff --git a/src/Umbraco.Web/Mvc/RenderModel.cs b/src/Umbraco.Web/Models/RenderModel.cs similarity index 82% rename from src/Umbraco.Web/Mvc/RenderModel.cs rename to src/Umbraco.Web/Models/RenderModel.cs index 215a160a9e..aa06c747f3 100644 --- a/src/Umbraco.Web/Mvc/RenderModel.cs +++ b/src/Umbraco.Web/Models/RenderModel.cs @@ -1,10 +1,7 @@ using System.Globalization; -using System.Xml; using Umbraco.Core.Models; -using umbraco; -using umbraco.interfaces; -namespace Umbraco.Web.Mvc +namespace Umbraco.Web.Models { /// /// Represents the model for the current rendering page in Umbraco diff --git a/src/Umbraco.Web/Mvc/RenderModelBinder.cs b/src/Umbraco.Web/Mvc/RenderModelBinder.cs index f66a53ea15..f8b1df7520 100644 --- a/src/Umbraco.Web/Mvc/RenderModelBinder.cs +++ b/src/Umbraco.Web/Mvc/RenderModelBinder.cs @@ -1,4 +1,5 @@ using System.Web.Mvc; +using Umbraco.Web.Models; namespace Umbraco.Web.Mvc { diff --git a/src/Umbraco.Web/Mvc/RenderMvcController.cs b/src/Umbraco.Web/Mvc/RenderMvcController.cs index addbaf3a84..08469ef9ff 100644 --- a/src/Umbraco.Web/Mvc/RenderMvcController.cs +++ b/src/Umbraco.Web/Mvc/RenderMvcController.cs @@ -2,6 +2,7 @@ using System; using System.IO; using System.Web.Mvc; using Umbraco.Core.Logging; +using Umbraco.Web.Models; using Umbraco.Web.Routing; namespace Umbraco.Web.Mvc diff --git a/src/Umbraco.Web/Mvc/RenderRouteHandler.cs b/src/Umbraco.Web/Mvc/RenderRouteHandler.cs index ab2573d131..fc623fe905 100644 --- a/src/Umbraco.Web/Mvc/RenderRouteHandler.cs +++ b/src/Umbraco.Web/Mvc/RenderRouteHandler.cs @@ -7,6 +7,7 @@ using System.Web.Routing; using Umbraco.Core; using Umbraco.Core.Logging; using Umbraco.Core.Models; +using Umbraco.Web.Models; using Umbraco.Web.Routing; using umbraco.cms.businesslogic.template; diff --git a/src/Umbraco.Web/Mvc/RenderViewEngine.cs b/src/Umbraco.Web/Mvc/RenderViewEngine.cs index 4052505b9a..8236c6af56 100644 --- a/src/Umbraco.Web/Mvc/RenderViewEngine.cs +++ b/src/Umbraco.Web/Mvc/RenderViewEngine.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Web.Mvc; using Umbraco.Core; using Umbraco.Core.IO; +using Umbraco.Web.Models; namespace Umbraco.Web.Mvc { diff --git a/src/Umbraco.Web/Mvc/UmbracoTemplatePage.cs b/src/Umbraco.Web/Mvc/UmbracoTemplatePage.cs new file mode 100644 index 0000000000..1b390ca1e3 --- /dev/null +++ b/src/Umbraco.Web/Mvc/UmbracoTemplatePage.cs @@ -0,0 +1,37 @@ +using Umbraco.Core.Dictionary; +using Umbraco.Core.Dynamics; +using Umbraco.Core.Models; +using Umbraco.Web.Models; + +namespace Umbraco.Web.Mvc +{ + /// + /// The View that front-end templates inherit from + /// + public abstract class UmbracoTemplatePage : UmbracoViewPage + { + protected UmbracoTemplatePage() + { + + } + + protected override void InitializePage() + { + base.InitializePage(); + //set the model to the current node if it is not set, this is generally not the case + if (Model != null) + { + ////this.ViewData.Model = Model; + //var backingItem = new DynamicBackingItem(Model.CurrentNode); + var dynamicNode = new DynamicPublishedContent(Model.Content); + CurrentPage = dynamicNode.AsDynamic(); + } + } + + /// + /// Returns the a DynamicPublishedContent object + /// + public dynamic CurrentPage { get; private set; } + + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/Mvc/RenderViewPage.cs b/src/Umbraco.Web/Mvc/UmbracoViewPage.cs similarity index 58% rename from src/Umbraco.Web/Mvc/RenderViewPage.cs rename to src/Umbraco.Web/Mvc/UmbracoViewPage.cs index 8d3b450b75..0f707b9051 100644 --- a/src/Umbraco.Web/Mvc/RenderViewPage.cs +++ b/src/Umbraco.Web/Mvc/UmbracoViewPage.cs @@ -1,33 +1,22 @@ using System.Web.Mvc; using Umbraco.Core; -using Umbraco.Core.Dictionary; -using Umbraco.Core.Dynamics; -using Umbraco.Core.Models; -using Umbraco.Web.Models; using Umbraco.Web.Routing; namespace Umbraco.Web.Mvc { /// - /// The View that front-end templates inherit from + /// The View that umbraco front-end views inherit from /// - public abstract class RenderViewPage : WebViewPage + public abstract class UmbracoViewPage : WebViewPage { - protected RenderViewPage() + protected UmbracoViewPage() { } protected override void InitializePage() { - //set the model to the current node if it is not set, this is generally not the case - if (Model != null) - { - ////this.ViewData.Model = Model; - //var backingItem = new DynamicBackingItem(Model.CurrentNode); - var dynamicNode = new DynamicPublishedContent(Model.Content); - CurrentPage = dynamicNode.AsDynamic(); - } + base.InitializePage(); PublishedContentRequest = (PublishedContentRequest)ViewContext.RouteData.DataTokens.GetRequiredObject("umbraco-doc-request"); UmbracoContext = (UmbracoContext)ViewContext.RouteData.DataTokens.GetRequiredObject("umbraco-context"); ApplicationContext = UmbracoContext.Application; @@ -46,12 +35,7 @@ namespace Umbraco.Web.Mvc /// /// Returns the current PublishedContentRequest /// - internal PublishedContentRequest PublishedContentRequest { get; private set; } - - /// - /// Returns the a DynamicPublishedContent object - /// - public dynamic CurrentPage { get; private set; } + internal PublishedContentRequest PublishedContentRequest { get; private set; } private UmbracoHelper _helper; diff --git a/src/Umbraco.Web/PublishedContentExtensions.cs b/src/Umbraco.Web/PublishedContentExtensions.cs index 6680bbeedc..c7820e8766 100644 --- a/src/Umbraco.Web/PublishedContentExtensions.cs +++ b/src/Umbraco.Web/PublishedContentExtensions.cs @@ -23,6 +23,28 @@ namespace Umbraco.Web /// public static class PublishedContentExtensions { + /// + /// Gets the NiceUrl for the content item + /// + /// + /// + public static string NiceUrl(this IPublishedContent doc) + { + var umbHelper = new UmbracoHelper(UmbracoContext.Current); + return umbHelper.NiceUrl(doc.Id); + } + + /// + /// Gets the NiceUrlWithDomain for the content item + /// + /// + /// + public static string NiceUrlWithDomain(this IPublishedContent doc) + { + var umbHelper = new UmbracoHelper(UmbracoContext.Current); + return umbHelper.NiceUrlWithDomain(doc.Id); + } + /// /// Returns the current template Alias /// diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 389e13db63..9a42400d77 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -265,6 +265,7 @@ + @@ -360,12 +361,12 @@ - + - + diff --git a/src/Umbraco.Web/WebBootManager.cs b/src/Umbraco.Web/WebBootManager.cs index 704b35a477..0a49d7673d 100644 --- a/src/Umbraco.Web/WebBootManager.cs +++ b/src/Umbraco.Web/WebBootManager.cs @@ -10,6 +10,7 @@ using Umbraco.Core.Dynamics; using Umbraco.Core.PropertyEditors; using Umbraco.Web.Dictionary; using Umbraco.Web.Media.ThumbnailProviders; +using Umbraco.Web.Models; using Umbraco.Web.Mvc; using Umbraco.Web.PropertyEditors; using Umbraco.Web.Routing;