Some setup work

- renamed Index POST to IndexPOST and returning Index(model) on failure
- taking a dependence on the Comments module and flipping CommentsShown on the home page that's created in setup
- redirecting to ~/ on successful setup
- removing the remaining views (home) from Orchard.Web
- updating the slug constraint to cope with a null slug

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-02-08 15:20:40 -08:00
parent 4d070d1ca7
commit 8b00d2301c
6 changed files with 17 additions and 48 deletions

View File

@@ -42,6 +42,9 @@ namespace Orchard.Pages.Services {
public string LookupPublishedSlug(string slug) {
lock (_syncLock) {
if (slug == null)
return "";
string actual;
if (_currentlyPublishedSlugs.TryGetValue(slug, out actual))
return actual;

View File

@@ -1,5 +1,6 @@
using System;
using System.Web.Mvc;
using Orchard.Comments.Models;
using Orchard.ContentManagement;
using Orchard.Core.Common.Models;
using Orchard.Core.Settings.Models;
@@ -29,15 +30,15 @@ namespace Orchard.Setup.Controllers {
private Localizer T { get; set; }
public ActionResult Index() {
return View(new SetupViewModel { AdminUsername = "admin" });
public ActionResult Index(SetupViewModel model) {
return View(model ?? new SetupViewModel { AdminUsername = "admin" });
}
[HttpPost]
public ActionResult Index(SetupViewModel model) {
[HttpPost, ActionName("Index")]
public ActionResult IndexPOST(SetupViewModel model) {
try {
if (!ModelState.IsValid) {
return View(model);
return Index(model);
}
// initialize the database:
@@ -67,8 +68,9 @@ namespace Orchard.Setup.Controllers {
// create home page as a CMS page
var page = contentManager.Create("page");
page.As<BodyAspect>().Text = "Welcome to Orchard";
page.As<RoutableAspect>().Slug = "home";
page.As<RoutableAspect>().Slug = "";
page.As<RoutableAspect>().Title = model.SiteName;
page.As<HasComments>().CommentsShown = false;
contentManager.Publish(page);
var authenticationService = finiteEnvironment.Resolve<IAuthenticationService>();
@@ -78,11 +80,11 @@ namespace Orchard.Setup.Controllers {
_notifier.Information(T("Setup succeeded"));
// redirect to the welcome page.
return Redirect("~/home");
return Redirect("~/");
}
catch (Exception exception) {
_notifier.Error(T("Setup failed: " + exception.Message));
return RedirectToAction("Index");
return Index(model);
}
}
}

View File

@@ -83,6 +83,10 @@
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.Comments\Orchard.Comments.csproj">
<Project>{14C049FD-B35B-415A-A824-87F26B26E7FD}</Project>
<Name>Orchard.Comments</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="Module.txt" />

View File

@@ -92,8 +92,6 @@
<Content Include="Default.aspx" />
<Content Include="Global.asax" />
<Content Include="Web.config" />
<Content Include="Views\Home\Index.ascx" />
<Content Include="Views\Web.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Orchard\Orchard.csproj">

View File

@@ -1,4 +0,0 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<% Html.AddPageClassNames("home"); %>
<h1>Welcome to Orchard</h1>
<p>To learn more about Orchard visit <a href="http://orchardproject.net" title="Orchard Project">http://orchardproject.net</a>.</p>

View File

@@ -1,34 +0,0 @@
<?xml version="1.0"?>
<configuration>
<system.web>
<httpHandlers>
<add path="*" verb="*"
type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
<!--
Enabling request validation in view pages would cause validation to occur
after the input has already been processed by the controller. By default
MVC performs request validation before a controller processes the input.
To change this behavior apply the ValidateInputAttribute to a
controller or action.
-->
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
</handlers>
</system.webServer>
</configuration>