Eliminate IHomePageProvider. HomeController still exists as a fallback info

page (low priority -100)

--HG--
branch : autoroute
This commit is contained in:
randompete
2011-12-07 23:49:30 +00:00
parent f8b26a68d1
commit 3740d677db
7 changed files with 15 additions and 49 deletions

View File

@@ -4,49 +4,25 @@ using System.Web.Mvc;
using Orchard.Logging;
using Orchard.Services;
using Orchard.Themes;
using Orchard.Localization;
namespace Orchard.Core.HomePage.Controllers {
[HandleError]
public class HomeController : Controller {
private readonly IEnumerable<IHomePageProvider> _homePageProviders;
private readonly IOrchardServices _orchardServices;
public HomeController(IEnumerable<IHomePageProvider> homePageProviders, IOrchardServices orchardServices) {
_homePageProviders = homePageProviders;
_orchardServices = orchardServices;
public HomeController() {
Logger = NullLogger.Instance;
T = NullLocalizer.Instance;
}
public ILogger Logger { get; set; }
public Localizer T { get; set; }
[Themed]
public ActionResult Index() {
var homepage = _orchardServices.WorkContext.CurrentSite.HomePage;
if (String.IsNullOrEmpty(homepage))
return View();
var homePageParameters = homepage.Split(';');
if (homePageParameters.Length != 2)
return View();
var providerName = homePageParameters[0];
var item = Int32.Parse(homePageParameters[1]);
foreach (var provider in _homePageProviders) {
if (!string.Equals(provider.GetProviderName(), providerName))
continue;
var result = provider.GetHomePage(item);
if (result is ViewResultBase) {
var resultBase = result as ViewResultBase;
ViewData.Model = resultBase.ViewData.Model;
resultBase.ViewData = ViewData;
}
return result;
}
Logger.Error(T("No home page route exists").Text);
return View();
}
}
}

View File

@@ -4,6 +4,6 @@ Author: The Orchard Team
Website: http://orchardproject.net
Version: 1.3.0
OrchardVersion: 1.3.0
Description: The HomePage module enables the promotion of a content item or container to be the home page of the site.
FeatureDescription: Standard site home page that allows a specified content type or container to *be* the home page.
Description: The HomePage module provides a default home page if no home route is defined.
FeatureDescription: A fallback home page if you have none defined.
Category: Core

View File

@@ -13,7 +13,7 @@ namespace Orchard.Core.HomePage {
public IEnumerable<RouteDescriptor> GetRoutes() {
return new[] {
new RouteDescriptor {
Priority = 20,
Priority = -100,
Route = new Route(
"",
new RouteValueDictionary {

View File

@@ -0,0 +1,2 @@
<h1>Home Page</h1>
<p>You are seeing this page because you have no home page. Please log in and configure one in admin.</p>

View File

@@ -85,7 +85,6 @@
<Compile Include="Common\Drivers\BodyPartDriver.cs" />
<Compile Include="Common\Drivers\CommonPartDriver.cs" />
<Compile Include="Common\Drivers\TextFieldDriver.cs" />
<Compile Include="Containers\ContainersPathConstraint.cs" />
<Compile Include="Containers\Drivers\ContainerWidgetPartDriver.cs" />
<Compile Include="Containers\Drivers\CustomPropertiesDriver.cs" />
<Compile Include="Containers\Extensions\ContentQueryExtensions.cs" />
@@ -99,8 +98,6 @@
<Compile Include="Containers\Models\ContainerWidgetPart.cs" />
<Compile Include="Containers\Models\CustomPropertiesPart.cs" />
<Compile Include="Containers\Models\OrderByDirection.cs" />
<Compile Include="Containers\Routes.cs" />
<Compile Include="Containers\Services\ContainersPathConstraintUpdater.cs" />
<Compile Include="Containers\Settings\ContainerSettings.cs" />
<Compile Include="Containers\ViewModels\ContainableViewModel.cs" />
<Compile Include="Containers\ViewModels\ContainerWidgetViewModel.cs" />
@@ -135,7 +132,6 @@
<Compile Include="Navigation\Settings\AdminMenuPartTypeSettings.cs" />
<Compile Include="Routable\Events\ISlugEventHandler.cs" />
<Compile Include="Routable\ResourceManifest.cs" />
<Compile Include="Routable\Services\RoutableHomePageProvider.cs" />
<Compile Include="Contents\ViewModels\ListContentsViewModel.cs" />
<Compile Include="Contents\ViewModels\ListContentTypesViewModel.cs" />
<Compile Include="Reports\AdminMenu.cs" />
@@ -369,6 +365,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
<Folder Include="Containers\Services\" />
</ItemGroup>
<ItemGroup>
<Content Include="Contents\Views\Web.config" />
@@ -391,7 +388,6 @@
<Content Include="Contents\Views\Content.ControlWrapper.cshtml" />
<Content Include="Navigation\Placement.info" />
<Content Include="Routable\Views\Parts.RoutableTitle.cshtml" />
<Content Include="Routable\Views\Routable.HomePage.cshtml" />
<Content Include="Contents\Views\Content.Summary.cshtml" />
<Content Include="Contents\Views\Content.SaveButton.cshtml" />
<Content Include="Contents\Views\Content.PublishButton.cshtml" />
@@ -490,6 +486,9 @@
<ItemGroup>
<Content Include="Shapes\Views\ErrorPage.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="HomePage\Views\Home\Index.cshtml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -774,7 +774,6 @@
<Compile Include="Security\MembershipSettings.cs" />
<Compile Include="Security\StandardPermissions.cs" />
<Compile Include="Security\OrchardSecurityException.cs" />
<Compile Include="Services\IHomePageProvider.cs" />
<Compile Include="Tasks\Scheduling\IPublishingTaskManager.cs" />
<Compile Include="Tasks\Scheduling\IScheduledTask.cs" />
<Compile Include="Localization\Text.cs" />

View File

@@ -1,10 +0,0 @@
using System.Web.Mvc;
namespace Orchard.Services {
public interface IHomePageProvider : IDependency {
string GetProviderName();
string GetSettingValue(int itemId);
int GetHomePageId(string value);
ActionResult GetHomePage(int itemId);
}
}