From 16a93f77ecf58de755b24e16bff53f036d509f59 Mon Sep 17 00:00:00 2001 From: Nathan Heskew Date: Wed, 10 Feb 2010 14:34:20 -0800 Subject: [PATCH 1/4] - Adding an ~/App_Data write access check up front in the setup process - Adding some notification style to the setup theme's css --HG-- branch : dev --- .../Controllers/SetupController.cs | 17 +++++++ .../Themes/SafeMode/Styles/site.css | 49 ++++++++++++++++++- 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs b/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs index 621cba3d0..1b7bedfc6 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Web.Mvc; using Orchard.Comments.Models; using Orchard.ContentManagement; @@ -36,6 +37,10 @@ namespace Orchard.Setup.Controllers { private Localizer T { get; set; } public ActionResult Index(SetupViewModel model) { + if(!CanWriteTo(Server.MapPath("~/App_Data"))) { + _notifier.Error(T("Hey, it looks like I can't write to the App_Data folder in the root of this application and that's where I need to save some of the information you're about to enter.\r\n\r\nPlease give me (the machine account this application is running under) write access to App_Data so I can get this app all set up for you.\r\n\r\nThanks!")); + } + return View(model ?? new SetupViewModel { AdminUsername = "admin" }); } @@ -112,5 +117,17 @@ namespace Orchard.Setup.Controllers { return Index(model); } } + + static bool CanWriteTo(string path) { + try { + var systemCheckPath = Path.Combine(path, "_systemcheck.txt"); + System.IO.File.WriteAllText(systemCheckPath, "Communicator check one two one two"); + System.IO.File.AppendAllText(systemCheckPath, "\r\nThis is Bones McCoy on a line to Sulu"); + System.IO.File.Delete(systemCheckPath); + return true; + } catch { + return false; + } + } } } diff --git a/src/Orchard.Web/Themes/SafeMode/Styles/site.css b/src/Orchard.Web/Themes/SafeMode/Styles/site.css index c49327828..e7e12636a 100644 --- a/src/Orchard.Web/Themes/SafeMode/Styles/site.css +++ b/src/Orchard.Web/Themes/SafeMode/Styles/site.css @@ -60,7 +60,7 @@ h5 {font-size: 105%;} #main { - margin:0 auto; + margin:0 auto 40px; width:600px; } @@ -148,4 +148,51 @@ button:focus, .button:focus { html.dyn fieldset.data div span { display:none; +} + + +/* Confirmations, Messages and the like +----------------------------------------------------------*/ +.message, .validation-summary-errors { + margin:10px 0 4px 0; + padding:4px; + white-space:pre-wrap; +} +span.message { + display:block; + margin:4px 0 4px 4px; +} +.message a { + font-weight:bold; +} + +.confirmation.message { + background:#e6f1c9; /* green */ + border:1px solid #cfe493; +} +.warning.message { + background:#fdf5bc; /* yellow */ + border:1px solid #ffea9b; +} +/* todo: (heskew) what else (other inputs) needs this? */ +.critical.message, .validation-summary-errors, +.input-validation-error.text-box, .input-validation-error.text { + border:1px solid #990808; +} +.critical.message, .validation-summary-errors { + background:#e68585; /* red */ + color:#fff; +} +.info.message { + background:#fff; /* orange :P */ + border:1px dashed #D2D6C6; +} +.debug.message { + background:#eee; + border:1px dashed #D2D6C6; + color:#7a7a7a; + margin:20px 0 14px 0; +} +.debug.message:before { + content:"DEBUG » "; } \ No newline at end of file From af3d696d64000d8374acb21be3fb6c3bd9446816 Mon Sep 17 00:00:00 2001 From: Nathan Heskew Date: Wed, 10 Feb 2010 15:09:43 -0800 Subject: [PATCH 2/4] Adding some more (debug) info to the "can't write to ~/App_Data" message --HG-- branch : dev --- .../Orchard.Setup/Controllers/SetupController.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs b/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs index 1b7bedfc6..d2d913f32 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs @@ -37,8 +37,12 @@ namespace Orchard.Setup.Controllers { private Localizer T { get; set; } public ActionResult Index(SetupViewModel model) { - if(!CanWriteTo(Server.MapPath("~/App_Data"))) { - _notifier.Error(T("Hey, it looks like I can't write to the App_Data folder in the root of this application and that's where I need to save some of the information you're about to enter.\r\n\r\nPlease give me (the machine account this application is running under) write access to App_Data so I can get this app all set up for you.\r\n\r\nThanks!")); + string message = ""; + if(!CanWriteTo(Server.MapPath("~/App_Data"), out message)) { + _notifier.Error( + T( + "Hey, it looks like I can't write to the App_Data folder in the root of this application and that's where I need to save some of the information you're about to enter.\r\n\r\nPlease give me (the machine account this application is running under) write access to App_Data so I can get this app all set up for you.\r\n\r\nThanks!\r\n\r\n----\r\n{0}", + message)); } return View(model ?? new SetupViewModel { AdminUsername = "admin" }); @@ -118,14 +122,18 @@ namespace Orchard.Setup.Controllers { } } - static bool CanWriteTo(string path) { + static bool CanWriteTo(string path, out string message) { try { var systemCheckPath = Path.Combine(path, "_systemcheck.txt"); + System.IO.File.WriteAllText(systemCheckPath, "Communicator check one two one two"); System.IO.File.AppendAllText(systemCheckPath, "\r\nThis is Bones McCoy on a line to Sulu"); System.IO.File.Delete(systemCheckPath); + + message = ""; return true; - } catch { + } catch (Exception ex) { + message = ex.Message.Replace("_systemcheck.txt", ""); return false; } } From 41ba3009e97c9cb88f00ba4097d4621bd51a6975 Mon Sep 17 00:00:00 2001 From: Erik Porter Date: Wed, 10 Feb 2010 15:29:26 -0800 Subject: [PATCH 3/4] Stubbed out some UI (not functional) --HG-- branch : dev --- .../Core/Navigation/Views/Admin/Index.ascx | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/Orchard.Web/Core/Navigation/Views/Admin/Index.ascx b/src/Orchard.Web/Core/Navigation/Views/Admin/Index.ascx index f4d02efe0..23bab71c7 100644 --- a/src/Orchard.Web/Core/Navigation/Views/Admin/Index.ascx +++ b/src/Orchard.Web/Core/Navigation/Views/Admin/Index.ascx @@ -1,3 +1,44 @@ <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> <%@ Import Namespace="Orchard.Core.Navigation.ViewModels"%> -

<%=Html.TitleForPage(T("Edit Main Menu").ToString())%>

+

<%=Html.TitleForPage(T("Edit Main Menu").ToString())%>

<% +using (Html.BeginFormAntiForgeryPost()) { %> + + + + + + + + + + + <%-- loop over menu items --%> + + + + + + + <%-- end loop --%> + + + + + + + +
TextPositionUrl
Delete Button
Update All Button
<% +} + +using (Html.BeginFormAntiForgeryPost()) { %> + + + + + + + + + +
Add Button
<% +} %> \ No newline at end of file From a9ef41d4e8990f98defeaa8838562e1723d9be4b Mon Sep 17 00:00:00 2001 From: Nathan Heskew Date: Wed, 10 Feb 2010 15:37:56 -0800 Subject: [PATCH 4/4] Some clean up on the setup UI around validation. --HG-- branch : dev --- .../Modules/Orchard.Setup/ViewModels/SetupViewModel.cs | 6 +++--- .../Modules/Orchard.Setup/Views/Setup/Index.ascx | 9 +++------ src/Orchard.Web/Themes/SafeMode/Styles/site.css | 9 +++++++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Setup/ViewModels/SetupViewModel.cs b/src/Orchard.Web/Modules/Orchard.Setup/ViewModels/SetupViewModel.cs index e44633f27..c0ee81b3f 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/ViewModels/SetupViewModel.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/ViewModels/SetupViewModel.cs @@ -4,11 +4,11 @@ using Orchard.Mvc.ViewModels; namespace Orchard.Setup.ViewModels { public class SetupViewModel : BaseViewModel { - [Required, StringLength(70)] + [Required(ErrorMessage = "Site name is required."), StringLength(70, ErrorMessage = "Site name can be no longer than 70 characters.")] public string SiteName { get; set; } - [Required, StringLengthMin(3), StringLength(25)] + [Required(ErrorMessage = "User name is required."), StringLengthMin(3, ErrorMessage = "User name must be longer than 3 characters."), StringLength(25, ErrorMessage = "User name can be no longer than 25 characters.")] public string AdminUsername { get; set; } - [Required, StringLengthMin(6), StringLength(50)] + [Required(ErrorMessage = "Password is required."), StringLengthMin(6, ErrorMessage = "Password must be longer than 6 characters."), StringLength(50, ErrorMessage = "Password can be no longer than 50 characters.")] public string AdminPassword { get; set; } [SqlDatabaseConnectionString] public string DatabaseConnectionString { get; set; } diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Views/Setup/Index.ascx b/src/Orchard.Web/Modules/Orchard.Setup/Views/Setup/Index.ascx index 77ac0ca28..24c8b0c16 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Views/Setup/Index.ascx +++ b/src/Orchard.Web/Modules/Orchard.Setup/Views/Setup/Index.ascx @@ -10,28 +10,25 @@ using (Html.BeginFormAntiForgeryPost()) { %>
<%=Html.EditorFor(svm => svm.SiteName) %> - <%=Html.ValidationMessage("SiteName", "*") %>
<%=Html.EditorFor(svm => svm.AdminUsername)%> - <%=Html.ValidationMessage("AdminUsername", "*")%>
<%=Html.PasswordFor(svm => svm.AdminPassword) %> - <%=Html.ValidationMessage("AdminPassword", "*") %>
-
+
"> <%=_Encoded("How would you like to store your data?") %> <%=Html.ValidationMessage("DatabaseOptions", "Unable to setup data storage") %>
- + <%=Html.RadioButtonFor(svm => svm.DatabaseOptions, true, new { id = "builtin" })%>
- + <%=Html.RadioButtonFor(svm => svm.DatabaseOptions, false, new { id = "sql" })%> diff --git a/src/Orchard.Web/Themes/SafeMode/Styles/site.css b/src/Orchard.Web/Themes/SafeMode/Styles/site.css index e7e12636a..981b2801d 100644 --- a/src/Orchard.Web/Themes/SafeMode/Styles/site.css +++ b/src/Orchard.Web/Themes/SafeMode/Styles/site.css @@ -146,7 +146,7 @@ button:focus, .button:focus { text-decoration:none; } -html.dyn fieldset.data div span { +html.dyn fieldset.data.builtin div span { display:none; } @@ -158,6 +158,10 @@ html.dyn fieldset.data div span { padding:4px; white-space:pre-wrap; } +form .message, form .validation-summary-errors { + margin:0 10px; + white-space:inherit; +} span.message { display:block; margin:4px 0 4px 4px; @@ -176,7 +180,8 @@ span.message { } /* todo: (heskew) what else (other inputs) needs this? */ .critical.message, .validation-summary-errors, -.input-validation-error.text-box, .input-validation-error.text { +.input-validation-error.text-box, .input-validation-error.text, +input[type="password"].input-validation-error { border:1px solid #990808; } .critical.message, .validation-summary-errors {