From f04db8c52c5537bf738905ca6159f0beb2a24b56 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Tue, 9 Oct 2012 20:17:27 +0500 Subject: [PATCH] Converted umbracoPage.master to have the correct codebehind structure. Added base2 as a default lib in umbracoPage. Converted EditView to use propery JS class so that we can now better support the editor for the new buttons (i.e. insert macro, etc...) --- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 7 + .../umbraco/masterpages/umbracoPage.Master | 5 +- .../umbraco/settings/views/EditView.aspx | 83 +++----- .../umbraco/settings/views/EditView.aspx.cs | 13 +- .../settings/views/EditView.aspx.designer.cs | 9 + .../umbraco_client/Editors/EditView.js | 91 ++++++++ src/Umbraco.Web/Mvc/RenderViewEngine.cs | 11 +- src/Umbraco.Web/Umbraco.Web.csproj | 11 +- .../umbraco/masterpages/umbracoPage.Master | 46 ---- .../umbraco/masterpages/umbracoPage.Master.cs | 201 ++++++++++++++++-- .../umbracoPage.Master.designer.cs | 177 --------------- 11 files changed, 337 insertions(+), 317 deletions(-) create mode 100644 src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/masterpages/umbracoPage.Master delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/masterpages/umbracoPage.Master.designer.cs diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index fa1c02c04b..3e3d4c6dd6 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -272,6 +272,12 @@ umbracoDialog.Master + + ASPXCodeBehind + + + umbracoPage.Master + ASPXCodeBehind @@ -570,6 +576,7 @@ + diff --git a/src/Umbraco.Web.UI/umbraco/masterpages/umbracoPage.Master b/src/Umbraco.Web.UI/umbraco/masterpages/umbracoPage.Master index a8f60b9bbb..d5b4f8353a 100644 --- a/src/Umbraco.Web.UI/umbraco/masterpages/umbracoPage.Master +++ b/src/Umbraco.Web.UI/umbraco/masterpages/umbracoPage.Master @@ -1,5 +1,5 @@ -<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="umbracoPage.master.cs" - Inherits="umbraco.presentation.masterpages.umbracoPage" %> +<%@ Master Language="C#" AutoEventWireup="True" CodeBehind="UmbracoPage.master.cs" + Inherits="Umbraco.Web.UI.Umbraco.Masterpages.UmbracoPage" %> <%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %> <%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> @@ -18,6 +18,7 @@ Priority="1" /> + + + @@ -86,11 +62,4 @@ - - - diff --git a/src/Umbraco.Web.UI/umbraco/settings/views/EditView.aspx.cs b/src/Umbraco.Web.UI/umbraco/settings/views/EditView.aspx.cs index 9f4844256e..261bfdd5f7 100644 --- a/src/Umbraco.Web.UI/umbraco/settings/views/EditView.aspx.cs +++ b/src/Umbraco.Web.UI/umbraco/settings/views/EditView.aspx.cs @@ -32,6 +32,7 @@ namespace Umbraco.Web.UI.Umbraco.Settings.Views protected global::umbraco.uicontrols.CodeArea editorSource; protected global::System.Web.UI.WebControls.Repeater rpt_codeTemplates; protected global::System.Web.UI.WebControls.Repeater rpt_macros; + protected MenuIconI SaveButton; public EditView() @@ -43,8 +44,6 @@ namespace Umbraco.Web.UI.Umbraco.Settings.Views { base.OnLoad(e); - MasterTemplate.Attributes.Add("onchange", "changeMasterPageFile()"); - if (!IsPostBack) { MasterTemplate.Items.Add(new ListItem(ui.Text("none"), "0")); @@ -91,11 +90,11 @@ namespace Umbraco.Web.UI.Umbraco.Settings.Views base.OnInit(e); Panel1.hasMenu = true; - MenuIconI save = Panel1.Menu.NewIcon(); - save.ImageURL = SystemDirectories.Umbraco + "/images/editor/save.gif"; - save.OnClickCommand = "doSubmit()"; - save.AltText = ui.Text("save"); - save.ID = "save"; + SaveButton = Panel1.Menu.NewIcon(); + SaveButton.ImageURL = SystemDirectories.Umbraco + "/images/editor/save.gif"; + //SaveButton.OnClickCommand = "doSubmit()"; + SaveButton.AltText = ui.Text("save"); + SaveButton.ID = "save"; Panel1.Text = ui.Text("edittemplate"); pp_name.Text = ui.Text("name", base.getUser()); diff --git a/src/Umbraco.Web.UI/umbraco/settings/views/EditView.aspx.designer.cs b/src/Umbraco.Web.UI/umbraco/settings/views/EditView.aspx.designer.cs index 86941bc42e..3764274310 100644 --- a/src/Umbraco.Web.UI/umbraco/settings/views/EditView.aspx.designer.cs +++ b/src/Umbraco.Web.UI/umbraco/settings/views/EditView.aspx.designer.cs @@ -11,5 +11,14 @@ namespace Umbraco.Web.UI.Umbraco.Settings.Views { public partial class EditView { + + /// + /// JsInclude1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude1; } } diff --git a/src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js b/src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js new file mode 100644 index 0000000000..48c32e5d8b --- /dev/null +++ b/src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js @@ -0,0 +1,91 @@ +Umbraco.Sys.registerNamespace("Umbraco.Editors"); + +(function ($) { + + + Umbraco.Editors.EditView = base2.Base.extend({ + //private methods/variables + _opts: null, + + // Constructor + constructor: function (opts) { + // Merge options with default + this._opts = $.extend({ + // Default options go here + }, opts); + }, + + //public methods/variables + + init: function () { + var self = this; + //bind to the change of the master template drop down + this._opts.masterPageDropDown.change(function () { + self.changeMasterPageFile(); + }); + //bind to the save event + this._opts.saveButton.click(function() { + self.doSubmit(); + }); + }, + + doSubmit: function () { + var codeVal = UmbEditor.GetCode(); + var self = this; + + umbraco.presentation.webservices.codeEditorSave.SaveTemplate( + this._opts.nameTxtBox.val(), + this._opts.aliasTxtBox.val(), + codeVal, + this._opts.templateId, + this._opts.masterPageDropDown.val(), + function (t) { self.submitSuccess(t); }, + function (t) { self.submitFailure(t); }); + }, + + submitSuccess: function (t) { + if (t != 'true') { + top.UmbSpeechBubble.ShowMessage('error', this._opts.msgs.templateErrorHeader, this._opts.msgs.templateErrorText); + } + else { + top.UmbSpeechBubble.ShowMessage('save', this._opts.msgs.templateSavedHeader, this._opts.msgs.templateSavedText); + } + }, + + submitFailure: function (t) { + top.UmbSpeechBubble.ShowMessage('error', this._opts.msgs.templateErrorHeader, this._opts.msgs.templateErrorText); + }, + + changeMasterPageFile: function ( ) { + //var editor = document.getElementById(this._opts.sourceEditorId); + var templateDropDown = this._opts.masterPageDropDown.get(0); + var templateCode = UmbEditor.GetCode(); + var newValue = templateDropDown.options[templateDropDown.selectedIndex].id; + + var layoutDefRegex = new RegExp("(@{[\\s\\S]*?Layout\\s*?=\\s*?)(\"[^\"]*?\"|null)(;[\\s\\S]*?})", "gi"); + + if (newValue != undefined && newValue != "") { + if (layoutDefRegex.test(templateCode)) { + // Declaration exists, so just update it + templateCode = templateCode.replace(layoutDefRegex, "$1\"" + newValue + "\"$3"); + } else { + // Declaration doesn't exist, so prepend to start of doc + //TODO: Maybe insert at the cursor position, rather than just at the top of the doc? + templateCode = "@{\n\tLayout = \"" + newValue + "\";\n}\n" + templateCode; + } + } else { + if (layoutDefRegex.test(templateCode)) { + // Declaration exists, so just update it + templateCode = templateCode.replace(layoutDefRegex, "$1null$3"); + } + } + + UmbEditor.SetCode(templateCode); + + return false; + } + }); + + + +})(jQuery); \ No newline at end of file diff --git a/src/Umbraco.Web/Mvc/RenderViewEngine.cs b/src/Umbraco.Web/Mvc/RenderViewEngine.cs index 2ebca40323..4052505b9a 100644 --- a/src/Umbraco.Web/Mvc/RenderViewEngine.cs +++ b/src/Umbraco.Web/Mvc/RenderViewEngine.cs @@ -34,13 +34,13 @@ namespace Umbraco.Web.Mvc AreaPartialViewLocationFormats = new string[] { }; AreaViewLocationFormats = new string[] { }; - EnsureFolderAndWebConfig(); + EnsureFoldersAndFiles(); } /// - /// Ensures that the correct web.config for razor exists in the /Views folder. + /// Ensures that the correct web.config for razor exists in the /Views folder, the partials folder exist and the ViewStartPage exists. /// - private void EnsureFolderAndWebConfig() + private void EnsureFoldersAndFiles() { var viewFolder = IOHelper.MapPath(Constants.ViewLocation); //ensure the web.config file is in the ~/Views folder @@ -52,6 +52,11 @@ namespace Umbraco.Web.Mvc writer.Write(Strings.web_config); } } + //auto create the partials folder + var partialsFolder = Path.Combine(viewFolder, "Partials"); + Directory.CreateDirectory(partialsFolder); + + //We could create a _ViewStart page if it isn't there as well, but we may not allow editing of this page in the back office. } public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache) diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 06831b3b47..cc17798375 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -327,6 +327,9 @@ ASPXCodeBehind + + ASPXCodeBehind + ASPXCodeBehind @@ -1374,13 +1377,6 @@ default.Master - - umbracoPage.Master - ASPXCodeBehind - - - umbracoPage.Master - EditMember.aspx ASPXCodeBehind @@ -1983,7 +1979,6 @@ Settings1.Designer.cs - diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/masterpages/umbracoPage.Master b/src/Umbraco.Web/umbraco.presentation/umbraco/masterpages/umbracoPage.Master deleted file mode 100644 index a8f60b9bbb..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/masterpages/umbracoPage.Master +++ /dev/null @@ -1,46 +0,0 @@ -<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="umbracoPage.master.cs" - Inherits="umbraco.presentation.masterpages.umbracoPage" %> - -<%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %> -<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> - - - - - - - - - - - - - - - - - - - - - -
- - - - -
- - - - diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/masterpages/umbracoPage.Master.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/masterpages/umbracoPage.Master.cs index 906c433220..0f400055d0 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/masterpages/umbracoPage.Master.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/masterpages/umbracoPage.Master.cs @@ -7,20 +7,21 @@ using System.Web.UI.WebControls; //This is only in case an upgrade goes wrong and the the /masterpages/ files are not copied over //which would result in an error. so we have kept the old namespaces intact with references to new ones using mp = umbraco.presentation.masterpages; -namespace umbraco.presentation.umbraco.masterpages { - public class umbracoPage : mp.umbracoPage { } - public class umbracoDialog : mp.umbracoDialog { } +namespace umbraco.presentation.umbraco.masterpages +{ + public class umbracoPage : mp.umbracoPage { } + public class umbracoDialog : mp.umbracoDialog { } } namespace umbraco.presentation.masterpages { - public delegate void MasterPageLoadHandler(object sender, System.EventArgs e); + public delegate void MasterPageLoadHandler(object sender, System.EventArgs e); public partial class umbracoPage : System.Web.UI.MasterPage { public new static event MasterPageLoadHandler Load; - public new static event MasterPageLoadHandler Init; + public new static event MasterPageLoadHandler Init; protected void Page_Load(object sender, EventArgs e) { @@ -28,19 +29,185 @@ namespace umbraco.presentation.masterpages FireOnLoad(e); } - protected override void OnInit(EventArgs e) { - base.OnInit(e); + protected override void OnInit(EventArgs e) + { + base.OnInit(e); - if (Init != null) { - Init(this, e); - } - } - + if (Init != null) + { + Init(this, e); + } + } - protected virtual void FireOnLoad(EventArgs e) { - if (Load != null) { - Load(this, e); - } - } + + protected virtual void FireOnLoad(EventArgs e) + { + if (Load != null) + { + Load(this, e); + } + } + + /// + /// ClientLoader control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.UmbracoClientDependencyLoader ClientLoader; + + /// + /// CssInclude1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.CssInclude CssInclude1; + + /// + /// CssInclude2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.CssInclude CssInclude2; + + /// + /// JsInclude1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude1; + + /// + /// JsInclude2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude2; + + /// + /// JsInclude8 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude8; + + /// + /// JsInclude9 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude9; + + /// + /// JsInclude4 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude4; + + /// + /// JsInclude5 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude5; + + /// + /// JsInclude6 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude6; + + /// + /// JsInclude7 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude7; + + /// + /// JsInclude3 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude3; + + /// + /// JsIncludeHotkeys control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsIncludeHotkeys; + + /// + /// head control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.ContentPlaceHolder head; + + /// + /// form1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// ScriptManager1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.ScriptManager ScriptManager1; + + /// + /// body control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.ContentPlaceHolder body; + + /// + /// footer control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.ContentPlaceHolder footer; } } diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/masterpages/umbracoPage.Master.designer.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/masterpages/umbracoPage.Master.designer.cs deleted file mode 100644 index 16d1820c83..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/masterpages/umbracoPage.Master.designer.cs +++ /dev/null @@ -1,177 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace umbraco.presentation.masterpages { - - - public partial class umbracoPage { - - /// - /// ClientLoader control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.UmbracoClientDependencyLoader ClientLoader; - - /// - /// CssInclude1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.CssInclude CssInclude1; - - /// - /// CssInclude2 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.CssInclude CssInclude2; - - /// - /// JsInclude1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsInclude1; - - /// - /// JsInclude2 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsInclude2; - - /// - /// JsInclude8 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsInclude8; - - /// - /// JsInclude9 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsInclude9; - - /// - /// JsInclude4 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsInclude4; - - /// - /// JsInclude5 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsInclude5; - - /// - /// JsInclude6 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsInclude6; - - /// - /// JsInclude7 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsInclude7; - - /// - /// JsInclude3 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsInclude3; - - /// - /// JsIncludeHotkeys control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsIncludeHotkeys; - - /// - /// head control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.ContentPlaceHolder head; - - /// - /// form1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.HtmlControls.HtmlForm form1; - - /// - /// ScriptManager1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.ScriptManager ScriptManager1; - - /// - /// body control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.ContentPlaceHolder body; - - /// - /// footer control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.ContentPlaceHolder footer; - } -}