diff --git a/src/Orchard.Tests/Environment/DefaultOrchardHostTests.cs b/src/Orchard.Tests/Environment/DefaultOrchardHostTests.cs index bd3d61ae7..dbd5eb57c 100644 --- a/src/Orchard.Tests/Environment/DefaultOrchardHostTests.cs +++ b/src/Orchard.Tests/Environment/DefaultOrchardHostTests.cs @@ -51,12 +51,16 @@ namespace Orchard.Tests.Environment { } public class StubShellSettingsLoader : IShellSettingsLoader { + private readonly List _shellSettings = new List + {new ShellSettings {Name = "testing"}}; + public IEnumerable LoadSettings() { - return new[] { new ShellSettings { Name = "testing" } }; + return _shellSettings.AsEnumerable(); } - public void SaveSettings(IShellSettings settings) { - + public bool SaveSettings(IShellSettings settings) { + _shellSettings.Add(settings); + return true; } } diff --git a/src/Orchard.Web/Modules/Orchard.Pages/Views/Admin/List.aspx b/src/Orchard.Web/Modules/Orchard.Pages/Views/Admin/List.aspx index ec85c41c4..3183414fe 100644 --- a/src/Orchard.Web/Modules/Orchard.Pages/Views/Admin/List.aspx +++ b/src/Orchard.Web/Modules/Orchard.Pages/Views/Admin/List.aspx @@ -73,7 +73,7 @@ foreach (var pageEntry in Model.PageEntries) <%=Html.Encode(pageEntry.Page.Title ?? T("(no title)").ToString())%> <% if (pageEntry.Page.HasPublished) { %> - <%=Html.ActionLink(pageEntry.Page.Slug ?? T("(no slug)").ToString(), "Item", new { controller = "Page", slug = pageEntry.Page.PublishedSlug })%> + <%=Html.ActionLink(!string.IsNullOrEmpty(pageEntry.Page.Slug) ? pageEntry.Page.Slug : T("(no slug)").ToString(), "Item", new { controller = "Page", slug = pageEntry.Page.PublishedSlug })%> <% } else {%> diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs b/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs index 8dd2b4e57..7976f7038 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs @@ -17,14 +17,17 @@ namespace Orchard.Setup.Controllers { private readonly INotifier _notifier; private readonly IDatabaseMigrationManager _databaseMigrationManager; private readonly IOrchardHost _orchardHost; + private readonly IShellSettingsLoader _shellSettingsLoader; public SetupController( INotifier notifier, IDatabaseMigrationManager databaseMigrationManager, - IOrchardHost orchardHost) { + IOrchardHost orchardHost, + IShellSettingsLoader shellSettingsLoader) { _notifier = notifier; _databaseMigrationManager = databaseMigrationManager; _orchardHost = orchardHost; + _shellSettingsLoader = shellSettingsLoader; T = NullLocalizer.Instance; } @@ -51,6 +54,12 @@ namespace Orchard.Setup.Controllers { // in theory this environment can be used to resolve any normal components by interface, and those // components will exist entirely in isolation - no crossover between the safemode container currently in effect var shellSettings = new ShellSettings { Name = "temp" }; + + if (!_shellSettingsLoader.SaveSettings(shellSettings)) { + _notifier.Error(T("Site settings could not be saved. (Name = \"{0}\")", shellSettings.Name)); + return Index(model); + } + using (var finiteEnvironment = _orchardHost.CreateStandaloneEnvironment(shellSettings)) { var contentManager = finiteEnvironment.Resolve(); // create superuser @@ -71,10 +80,13 @@ namespace Orchard.Setup.Controllers { page.As().Slug = ""; page.As().Title = model.SiteName; page.As().CommentsShown = false; + page.As().Owner = user; contentManager.Publish(page); var authenticationService = finiteEnvironment.Resolve(); authenticationService.SignIn(user, true); + + //_orchardHost.Reinitialize(); } _notifier.Information(T("Setup succeeded")); diff --git a/src/Orchard/Environment/Configuration/ShellSettingsLoader.cs b/src/Orchard/Environment/Configuration/ShellSettingsLoader.cs index b56422ab2..535a1f4e5 100644 --- a/src/Orchard/Environment/Configuration/ShellSettingsLoader.cs +++ b/src/Orchard/Environment/Configuration/ShellSettingsLoader.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Web.Hosting; @@ -8,7 +7,7 @@ using Yaml.Grammar; namespace Orchard.Environment.Configuration { public interface IShellSettingsLoader { IEnumerable LoadSettings(); - void SaveSettings(IShellSettings settings); + bool SaveSettings(IShellSettings settings); } public class ShellSettingsLoader : IShellSettingsLoader { @@ -17,8 +16,17 @@ namespace Orchard.Environment.Configuration { return LoadSettings().ToArray(); } - public void SaveSettings(IShellSettings settings) { - + public bool SaveSettings(IShellSettings settings) { + if (settings != null && !string.IsNullOrEmpty(settings.Name)) { + var sitesPath = HostingEnvironment.MapPath("~/App_Data/Sites"); + if (sitesPath != null) { + var filePath = Path.Combine(sitesPath, string.Format("{0}.txt", settings.Name)); + File.WriteAllText(filePath, ComposeSettings(settings)); + return true; + } + } + + return false; } static IEnumerable LoadSettings() { @@ -53,5 +61,9 @@ namespace Orchard.Environment.Configuration { DataItem value; return fields.TryGetValue(key, out value) ? value.ToString() : null; } + + static string ComposeSettings(IShellSettings shellSettings) { + return shellSettings == null ? "" : string.Format("Name: {0}", shellSettings.Name); + } } }